Skip to content

Commit

Permalink
adjust new vocabs pop up for situation where there are no more vocabs…
Browse files Browse the repository at this point in the history
… in backlog
  • Loading branch information
nora-kauczor committed Nov 10, 2024
1 parent cac8d50 commit 19cd69f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
1 change: 1 addition & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ function App() {
vocabs={vocabs}
finishedReviewing={vocabsToReview.length <
1}
allVocabsActivated={getInactiveVocabs().length < 1}
setUseForm={setUseForm}
language={language}
setLanguage={setLanguage}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NewVocabsPopUp/NewVocabsPopUp.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#new-vocabs-popup {
width: 70%;
max-width: 400px;
height: 60%;
height: auto;
max-height: 600px;
display: flex;
flex-direction: column;
Expand Down
43 changes: 23 additions & 20 deletions frontend/src/components/NewVocabsPopUp/NewVocabsPopUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Props = {
setUseForm: React.Dispatch<React.SetStateAction<boolean>>
userId: string | undefined
activateVocab: (id: string) => void
allVocabsActivated: boolean
}

export default function NewVocabsPopUp(props: Readonly<Props>) {
Expand Down Expand Up @@ -72,26 +73,28 @@ export default function NewVocabsPopUp(props: Readonly<Props>) {
>Enter new
vocab
</button>
<button className={"new-vocabs-button"}
onClick={() => navigate("/backlog")}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') navigate(
"/backlog");
}}
aria-label={"Pick from backlog"}
>Pick
from backlog
</button>
<button className={"new-vocabs-button"}
onClick={activateAndGoToDisplayPageWithRandomVocab}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key ===
' ') activateAndGoToDisplayPageWithRandomVocab();
}}
aria-label={"Get random vocabulary"}
>Get random
vocab
</button>
{!props.allVocabsActivated &&
<button className={"new-vocabs-button"}
onClick={() => navigate("/backlog")}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') navigate(
"/backlog");
}}
aria-label={"Pick from backlog"}
>Pick
from backlog
</button>}
{!props.allVocabsActivated &&
<button className={"new-vocabs-button"}
onClick={activateAndGoToDisplayPageWithRandomVocab}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key ===
' ') activateAndGoToDisplayPageWithRandomVocab();
}}
aria-label={"Get random vocabulary"}
>Get random
vocab
</button>}
</div>
</div>)
}
7 changes: 5 additions & 2 deletions frontend/src/pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import PickLanguagePopUp

type Props = {
finishedReviewing: boolean
allVocabsActivated: boolean
setUseForm: React.Dispatch<React.SetStateAction<boolean>>
language?: string
vocabs: Vocab[]
Expand All @@ -30,7 +31,8 @@ export default function HomePage(props: Readonly<Props>) {
all of it. <br/><br/>To start learning
(more) words click below. </p>}
{!props.finishedReviewing && props.language &&
<p className={"homepage-text"}>Nice to see you! <br/><br/>Click below
<p className={"homepage-text"}>Nice to see you! <br/><br/>Click
below
to
get
started with your daily vocab
Expand Down Expand Up @@ -58,7 +60,8 @@ export default function HomePage(props: Readonly<Props>) {
vocabs={props.vocabs}
setUseForm={props.setUseForm}
setDisplayNewVocabsPopUp={props.setDisplayNewVocabsPopUp}
activateVocab={props.activateVocab}/>}
activateVocab={props.activateVocab}
allVocabsActivated={props.allVocabsActivated}/>}
{!props.language && <div className={"overlay"}/>}
{!props.language &&
<PickLanguagePopUp setLanguage={props.setLanguage}/>}
Expand Down

0 comments on commit 19cd69f

Please sign in to comment.