-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
468 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client" | ||
import { createContext, useContext, useState, ReactNode } from "react"; | ||
|
||
interface LanguageContextProviderProps | ||
{ | ||
children: ReactNode; | ||
} | ||
|
||
interface LanguageContextValue | ||
{ | ||
language: string; | ||
setLanguage: (language: string) => void; | ||
} | ||
|
||
const LanguageContext = createContext<LanguageContextValue | undefined>(undefined); | ||
|
||
export const LanguageContextProvider = ({ children }: LanguageContextProviderProps) => { | ||
const [language, setLanguage] = useState('Spanish'); | ||
|
||
console.log(navigator.language) | ||
|
||
return ( | ||
<LanguageContext.Provider value={{ language, setLanguage }}> | ||
{children} | ||
</LanguageContext.Provider> | ||
); | ||
}; | ||
|
||
export const useLanguageContext = (): LanguageContextValue => { | ||
const context = useContext(LanguageContext); | ||
if (!context) | ||
{ | ||
throw new Error("useLanguageContext must be used within a LanguageContextProvider"); | ||
} | ||
return context; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useState } from 'react'; | ||
import styles from '../css/switch.module.css'; | ||
import { vt323 } from '../fonts/fonts'; | ||
import { useLanguageContext } from '../app/context/language'; | ||
|
||
interface CrtProps { | ||
changeState: (newValue: boolean) => void; | ||
} | ||
|
||
const CrtSwtich: React.FC<CrtProps> = ({ changeState }) => { | ||
const [crt, setCrt] = useState(false); | ||
const {language, setLanguage} = useLanguageContext(); | ||
|
||
const handleChange = () => { | ||
const newValue:boolean = !crt; | ||
setCrt(newValue); | ||
changeState(newValue); | ||
}; | ||
|
||
let label:string; | ||
|
||
if(language == 'English') | ||
{ | ||
label = 'CRT EFFECT' | ||
} | ||
else if(language == 'Spanish') | ||
{ | ||
label = 'EFECTO CRT' | ||
} | ||
else | ||
{ | ||
label = '' | ||
} | ||
|
||
return ( | ||
<section className={styles.container}> | ||
<input | ||
className={styles.checkbox} | ||
type="checkbox" | ||
checked={crt} | ||
onChange={handleChange} | ||
/> | ||
<label style={vt323.style} htmlFor="">{label}</label> | ||
</section> | ||
); | ||
}; | ||
|
||
export default CrtSwtich; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
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 {language, setLanguage} = useLanguageContext(); | ||
|
||
let l1:string | ||
let l2:string | ||
|
||
if(language == 'English') | ||
{ | ||
l1 = 'ENGLISH' | ||
l2 = 'SPANISH' | ||
} | ||
else if(language == 'Spanish') | ||
{ | ||
l1 = 'INGLÉS' | ||
l2 = 'ESPAÑOL' | ||
} | ||
else | ||
{ | ||
l1 = '' | ||
l2 = '' | ||
} | ||
|
||
const changeState = (language:string) => { | ||
setLanguage(language); | ||
}; | ||
console.log(language) //TODO delete this line | ||
|
||
return ( | ||
<section className={styles.languageSwitchContainer}> | ||
<section className={styles.section}> | ||
<input | ||
className={styles.checkbox} | ||
type="radio" | ||
name='language' | ||
onClick={() => changeState('English')} | ||
/> | ||
<label style={vt323.style} htmlFor="">{l1}</label> | ||
</section> | ||
<section className={styles.section}> | ||
<input | ||
className={styles.checkbox} | ||
type="radio" | ||
id='language' | ||
name='language' | ||
onClick={() => changeState('Spanish')} | ||
/> | ||
<label style={vt323.style} htmlFor="language" id='label'>{l2}</label> | ||
</section> | ||
</section> | ||
) | ||
}; | ||
|
||
export default Typewriter; |
Oops, something went wrong.