From f66f1dd5f74b7439c07d474f9690d90d7b8735cd Mon Sep 17 00:00:00 2001 From: ares Date: Tue, 31 Dec 2024 15:35:04 +0800 Subject: [PATCH] support to select language --- package.json | 5 +- src/components/Header.js | 151 +++++++++++++++++---------------------- 2 files changed, 68 insertions(+), 88 deletions(-) diff --git a/package.json b/package.json index 8d50a22..65d9e1c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "my-app", + "name": "123btc.org", "version": "0.1.0", "private": true, "dependencies": { @@ -22,7 +22,8 @@ "devDependencies": { "@babel/core": "^7.16.0", "@babel/preset-env": "^7.16.0", - "@babel/preset-react": "^7.16.0" + "@babel/preset-react": "^7.16.0", + "react-refresh": "^0.16.0" }, "homepage": ".", "scripts": { diff --git a/src/components/Header.js b/src/components/Header.js index 080a64a..0389777 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -7,7 +7,6 @@ import { // Menu, // MenuItem, } from '@material-ui/core'; -import { Language } from '@material-ui/icons'; import MenuIcon from '@material-ui/icons/Menu'; import NavBar from './NavBar'; @@ -20,12 +19,7 @@ import Box from './Box'; // const ETH123URL = 'https://eth123.org/'; -const Header = ({ - language, - onChangeLanguage, - tagList, -}) => { - +const Header = ({ language, onChangeLanguage, tagList }) => { const [visible, setVisible] = useState(false); // const [anchorEl, setAnchorEl] = React.useState(null); @@ -36,13 +30,13 @@ const Header = ({ }, en: { ethTitle: 'A Portal to Ethereum Ecosystem', - btcTitle: 'A Portal to Bitcoin Ecosystem' - } - } + btcTitle: 'A Portal to Bitcoin Ecosystem', + }, + }; const t = (key) => { return translations[language][key]; - } + }; // const handleClick = (event) => { // setAnchorEl(event.currentTarget); @@ -55,63 +49,59 @@ const Header = ({ // render language change btn const renderLanguageBtn = () => { return ( - - ) - } + + + + ); + }; // web header const webHeader = () => { return ( - + - - - + display='flex' + flexDirection='row' + alignItems='center' + justifyContent='space-between' + py={2} + > + + + - + {t('btcTitle')} @@ -134,41 +124,35 @@ const Header = ({ */} - - {renderLanguageBtn()} - + {renderLanguageBtn()} - ) - } + ); + }; // wap header const wapHeader = () => { return ( - + + display='flex' + flexDirection='row' + alignItems='center' + justifyContent='space-between' + height={30} + > { setVisible(true); - }}> + }} + > - + {/* */} - + {renderLanguageBtn()} @@ -208,14 +189,12 @@ const Header = ({ */} - ) - } + ); + }; return ( - - {webHeader()} - + {webHeader()} {wapHeader()} - ) -} + ); +}; export default Header;