Git Product home page Git Product logo

softclub's Introduction

- please note that my clone is not 100% exact as original website, for reusability and simplicity purposes. Header scrolling animation also might not work as I am using new css features, that are experimental for now

In this project I expect to use:

  1. React-router-dom - for client-side routing and SPA
  2. Vite - React new generation bundler
  3. i18next - for localization
  4. Google materials - for icons (check CDN links in html root file)
  5. React Hooks I have used
  6. Issues in production of this application

1. React-router-dom

I have used following router's hooks:

  1. useNavigate(): - App component

2. Vite

For me it seems somewhat like a Gulp
This is what I have understand for now:

  • It reads scss

3. i18next

:
  1. install it: npm install react-i18next i18next --save
  2. create languages folder
  3. create i18n file (for config) and write following:
   // Languages import
      import global_en from "./english/english.json"
      import global_ru from "./russian/russian.json"
      import global_tj from "./tajik/tajik.jso
   // i18next
      import { initReactI18next } from "react-i18next"
      import i18n from "i18nex
   // i18n initalization
      i18n.use(initReactI18next).init({
         lng: localStorage.getItem("language") || "english"
         debug: true,
             resources: {
                english: {
                   translation: global_en,
                },
                russian: {
                   translation: global_ru,
                },
                tajik: {
                   translation: global_tj,
                },
             },
      })
      export default i18n;
  1. wrap main.tsx with I18nextProvider (and i18n config file as its prop).
  2. in header.tsx or app.tsx, where language-switcher lies add these:
   // i18next hook
   import { useTranslation } from "react-i18next";
   ...
   // handle languages
      const { i18n } = useTranslation()
      const locLang = localStorage.getItem("language") || i18n.language
      const [lang, setlang] = useState(locLang)

      const changeLang = (language: string) => {
         setlang(language)
         localStorage.setItem("language", language)
         i18n.changeLanguage(language)
      }
   ...
   // switcher
   <select
       className="header__switchers__languages"
       value={lang}
       onChange={(e) => changeLang(e.target.value)}
     >
       <option value="english">EN</option>
       <option value="russian">RU</option>
       <option value="tajik">TJ</option>
     </select>
   ...
   <NavLink to="/news">{t("header.news")}</NavLink>
   ...

4. Google materials

:
  1. Add CDN in HTML head tag (here I have for outlined, sharp and rounded icons):
<!--Google icons CDN outlined-->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
    <!--Google icons CDN sharp-->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
    <!--Google icons CDN rounded-->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
    <title>softclub</title>
  1. Search for desired icon on official website and paste icon in your html. Google material icons are usually as span html tags.

5. React Hooks I have used

:
  1. useState - used to store values (instead of variables, for it won't work in React DOM)
  2. useEffect -
    1. used to add and remove classes (just like element.classList.add or element.classList.remove in vanilla) in Header.tsx.
    2. to run a function based on dependecy change in App.tsx
  3. useLocation - is like window.location that we have in vanilla (for now I do not see any difference, although it is recommended to use useLocation)
  4. useRef - used to select rendered html elements

Issues in production of this application</3>:

  1. Header box-shadow animation (scroll) is not working , therefore I have commented that part of my code

softclub's People

Contributors

islom2202 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.