diff --git a/src/app/context/language.tsx b/src/app/context/language.tsx index 02c07f5..1ad8ec9 100644 --- a/src/app/context/language.tsx +++ b/src/app/context/language.tsx @@ -6,6 +6,11 @@ interface LanguageContextProviderProps children: ReactNode; } +interface Navigator { + // Properties + readonly language: string; +} + interface LanguageContextValue { language: string; @@ -17,13 +22,20 @@ const LanguageContext = createContext(undefine export const LanguageContextProvider = ({ children }: LanguageContextProviderProps) => { const detectLanguage = ():string => { //function used to execute useEffect before useState - if (navigator.language.includes('es')) - { - return 'Spanish'; - } - else + if (typeof navigator !== "undefined") { + // browser code + if ((navigator as Navigator).language.includes('es')) + { + return 'Spanish'; + } + else + { + return 'English'; + } + } + else { - return 'English'; + return ''; } }; @@ -35,8 +47,6 @@ export const LanguageContextProvider = ({ children }: LanguageContextProviderPro const [language, setLanguage] = useState(startLanguage); - console.log(navigator.language) - return ( {children} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index d38c0ee..03e733d 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -23,4 +23,4 @@ export default function RootLayout({ ) -} +} \ No newline at end of file diff --git a/src/components/CrtSwitch.tsx b/src/components/CrtSwitch.tsx index 1f13419..1fb1c37 100644 --- a/src/components/CrtSwitch.tsx +++ b/src/components/CrtSwitch.tsx @@ -36,11 +36,12 @@ const CrtSwtich: React.FC = ({ changeState }) => {
- +
); }; diff --git a/src/components/LanguageSwitch.tsx b/src/components/LanguageSwitch.tsx index ab1a405..813ceac 100644 --- a/src/components/LanguageSwitch.tsx +++ b/src/components/LanguageSwitch.tsx @@ -1,9 +1,8 @@ -import React, {useState, useEffect, useRef} from 'react'; import styles from '../css/switch.module.css' import { vt323 } from '../fonts/fonts'; import { useLanguageContext } from '../app/context/language'; -const Typewriter = () => { +const LanguageSwitch = () => { const {language, setLanguage} = useLanguageContext(); let l1:string @@ -28,7 +27,6 @@ const Typewriter = () => { const changeState = (language:string) => { setLanguage(language); }; - console.log(language) //TODO delete this line return (
@@ -37,24 +35,25 @@ const Typewriter = () => { className={styles.checkbox} type="radio" name='language' + id="english" checked={language=='English'} - onClick={() => changeState('English')} + onChange={() => changeState('English')} /> - +
changeState('Spanish')} + onChange={() => changeState('Spanish')} /> - +
) }; -export default Typewriter; +export default LanguageSwitch; \ No newline at end of file diff --git a/src/components/Terminal.tsx b/src/components/Terminal.tsx index fd024ae..39919e0 100644 --- a/src/components/Terminal.tsx +++ b/src/components/Terminal.tsx @@ -289,6 +289,7 @@ const Terminal = () => { ref={inputRef} style={vt323.style} type="text" + id='prompt' value={input} onChange={e=>setInput(e.target.value)} onKeyDown={e=>{ diff --git a/src/css/globals.css b/src/css/globals.css index 124f8fd..aefe273 100644 --- a/src/css/globals.css +++ b/src/css/globals.css @@ -2,6 +2,7 @@ :root { --foreground-rgb: 255, 255, 255; --background-start-rgb: 0, 0, 0; + background-color: black; /*TODO*/ --background-end-rgb: 0, 0, 0; --primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0)); diff --git a/src/css/switch.module.css b/src/css/switch.module.css index 88ca63a..08edadb 100644 --- a/src/css/switch.module.css +++ b/src/css/switch.module.css @@ -56,7 +56,6 @@ { width: 50%; font-size: 2vh; - justify-content: space-between; } .languageSwitchContainer { diff --git a/src/css/terminal.module.css b/src/css/terminal.module.css index 7ec6156..8e180e6 100644 --- a/src/css/terminal.module.css +++ b/src/css/terminal.module.css @@ -29,7 +29,7 @@ .history { - padding: 15px; + padding: 15px 15px 0px 15px; /* white-space: pre-wrap; word-wrap: break-word; */ width: 100%;