Skip to content

Commit

Permalink
Added language component
Browse files Browse the repository at this point in the history
  • Loading branch information
theendie committed Dec 5, 2023
1 parent aa2d850 commit d10262d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
31 changes: 31 additions & 0 deletions app/components/Lang/Lang.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import styles from './page.module.css';

function Lang(props) {
return (
<div className={styles.language}>
<label>
<select name="selectedLang" onChange={e => props.onSelectLanguage(e.target.value)}>
<option value="pt-br">Portuguese</option>
<option value="en">English</option>
</select>
</label>
</div>
);
}

export default {
component: Lang
};

/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/api/csf
* to learn how to use render functions.
*/
export const Desktop = {
render: () => <Lang onSelectLanguage={(value)=>{console.log(value);}}/>
};

export const Mobile = {
render: () => <Lang onSelectLanguage={(value)=>{console.log(value);}}/>
};
6 changes: 6 additions & 0 deletions app/components/Lang/page.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.language {
position: absolute;
top: 1rem;
right: 1rem;
color: red;
}
26 changes: 24 additions & 2 deletions app/page.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import Presentation from './components/Presentation/Presentation.stories'
'use client'

import Page from './components/Page/Page.stories'
import Lang from './components/Lang/Lang.stories'
import language from './language.json'
import { useEffect, useState } from "react";

export default function Home() {

const [language, setLanguage] = useState('pt-br');

// useEffect(() => {
// // Atualiza o título do documento usando a API do browser
// document.title = `Você clicou ${count} vezes`;
// });

const handleLanguage = (langValue) => {
setLanguage(langValue);
}

return (
<main>
<Page.component>
<Presentation.component primary />
AQUI: {language}
<Lang.component onSelectLanguage={handleLanguage} />
{/* <Menu /> */}
{/* <Content> */}
{/* <Post></Post> */}
{/* <Post></Post> */}
{/* </Content> */}
</Page.component>
</main>
)
Expand Down

0 comments on commit d10262d

Please sign in to comment.