-
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.
Merge pull request #24 from SunbirdAI/github-actions
GitHub actions
- Loading branch information
Showing
2 changed files
with
68 additions
and
65 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
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 |
---|---|---|
@@ -1,72 +1,75 @@ | ||
import {PhraseList, PhraseListItem, SamplePhrasesAccordion} from "./SamplePhrases.styles"; | ||
import {Accordion, AccordionSummary, AccordionDetails} from '@mui/material'; | ||
import {Tabs, Tab} from "@mui/material"; | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
import {useState} from "react"; | ||
import {samplePhraseDict} from "../../constants"; | ||
import { | ||
PhraseList, | ||
PhraseListItem, | ||
SamplePhrasesAccordion, | ||
} from "./SamplePhrases.styles"; | ||
import { Accordion, AccordionSummary, AccordionDetails } from "@mui/material"; | ||
import { Tabs, Tab } from "@mui/material"; | ||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; | ||
import { useState } from "react"; | ||
import { samplePhraseDict } from "../../constants"; | ||
|
||
const WordList = ({ sentences, setSamplePhrase }) => { | ||
const onClick = (index) => { | ||
setSamplePhrase(sentences[index]); | ||
}; | ||
|
||
const WordList = ({sentences, setSamplePhrase}) => { | ||
|
||
const onClick = (index) => { | ||
setSamplePhrase(sentences[index]); | ||
}; | ||
|
||
return ( | ||
<PhraseList> | ||
{sentences.map((sentence, index) => ( | ||
<PhraseListItem key={index} onClick={() => onClick(index)}> | ||
{sentence} | ||
</PhraseListItem> | ||
))} | ||
</PhraseList> | ||
); | ||
return ( | ||
<PhraseList> | ||
{sentences.map((sentence, index) => ( | ||
<PhraseListItem key={index} onClick={() => onClick(index)}> | ||
{sentence} | ||
</PhraseListItem> | ||
))} | ||
</PhraseList> | ||
); | ||
}; | ||
|
||
|
||
const TabPanel = ({value, index, sentences, setSamplePhrase}) => ( | ||
<div> | ||
{ | ||
value === index && ( | ||
<WordList sentences={sentences} setSamplePhrase={setSamplePhrase}/> | ||
) | ||
} | ||
</div> | ||
const TabPanel = ({ value, index, sentences, setSamplePhrase }) => ( | ||
<div> | ||
{value === index && ( | ||
<WordList sentences={sentences} setSamplePhrase={setSamplePhrase} /> | ||
)} | ||
</div> | ||
); | ||
|
||
const SamplePhrases = ({sourceLanguage, setSamplePhrase}) => { | ||
|
||
const [tab, setTab] = useState(0); | ||
const SamplePhrases = ({ sourceLanguage, setSamplePhrase }) => { | ||
const [tab, setTab] = useState(0); | ||
|
||
const handleChange = (event, newTab) => { | ||
setTab(newTab); | ||
} | ||
const handleChange = (event, newTab) => { | ||
setTab(newTab); | ||
}; | ||
|
||
return ( | ||
<SamplePhrasesAccordion> | ||
<Accordion> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon/>} | ||
> | ||
<h2 className="font-bold text-xl">Sample Phrases</h2> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Tabs value={tab} onChange={handleChange} variant="scrollable" scrollButtons="auto"> | ||
{samplePhraseDict[sourceLanguage].map((section, index) => <Tab key={index} label={section[0]}/>)} | ||
</Tabs> | ||
{samplePhraseDict[sourceLanguage].map((section, index) => | ||
<TabPanel | ||
value={tab} | ||
key={index} | ||
index={index} | ||
sentences={section[1]} | ||
setSamplePhrase={setSamplePhrase} | ||
/> | ||
)} | ||
</AccordionDetails> | ||
</Accordion> | ||
</SamplePhrasesAccordion> | ||
) | ||
return ( | ||
<SamplePhrasesAccordion> | ||
<Accordion> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<h2 className="font-bold text-xl">Sample Phrases</h2> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Tabs | ||
value={tab} | ||
onChange={handleChange} | ||
variant="scrollable" | ||
scrollButtons="auto" | ||
> | ||
{samplePhraseDict[sourceLanguage].map((section, index) => ( | ||
<Tab key={index} label={section[0]} /> | ||
))} | ||
</Tabs> | ||
{samplePhraseDict[sourceLanguage].map((section, index) => ( | ||
<TabPanel | ||
value={tab} | ||
key={index} | ||
index={index} | ||
sentences={section[1]} | ||
setSamplePhrase={setSamplePhrase} | ||
/> | ||
))} | ||
</AccordionDetails> | ||
</Accordion> | ||
</SamplePhrasesAccordion> | ||
); | ||
}; | ||
|
||
export default SamplePhrases; |