-
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.
feat: add select dictionary variant feature
- Loading branch information
Showing
6 changed files
with
94 additions
and
2 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ui' |
72 changes: 72 additions & 0 deletions
72
src/features/dictionary/SelectDictionaryVariant/ui/SelectDictionaryList.tsx
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,72 @@ | ||
import { useStore } from '@nanostores/preact' | ||
|
||
import { NoSelectedLanguages } from '@features/language/SelectLanguages' | ||
|
||
import { DictionaryCard, dictionaryStore } from '@entities/dictionary' | ||
import { languageStore } from '@entities/language' | ||
|
||
import { Tab, TabPanel, Tabs, TabsList, a11yProps } from '@shared/ui/Tabs' | ||
|
||
import { SelectDictionaryVariant } from './SelectDictionaryVariant' | ||
import styles from './styles.module.scss' | ||
|
||
export const SelectDictionaryList = () => { | ||
const dictionaries = useStore(dictionaryStore.$dictionaries) | ||
const languages = useStore(languageStore.$languages) | ||
|
||
return ( | ||
<> | ||
{languages.length ? ( | ||
<> | ||
<Tabs> | ||
<TabsList arrows={true}> | ||
{languages.map((language) => ( | ||
<Tab | ||
value={language.value} | ||
{...a11yProps('language_navigation', language.value)} | ||
> | ||
{language.label} | ||
</Tab> | ||
))} | ||
</TabsList> | ||
{languages.map((language) => { | ||
return ( | ||
<TabPanel | ||
{...a11yProps('language_navigation', language.value)} | ||
value={language.value} | ||
> | ||
<ul className={styles.dictionaries}> | ||
{dictionaries[language.value].dictionaries.map( | ||
(dictionary) => { | ||
if ('variants' in dictionary) { | ||
return ( | ||
<li> | ||
<SelectDictionaryVariant | ||
key={dictionary.id} | ||
dictionary={dictionary} | ||
/> | ||
</li> | ||
) | ||
} else { | ||
return ( | ||
<DictionaryCard | ||
key={dictionary.id} | ||
url={dictionary.url} | ||
name={dictionary.name} | ||
/> | ||
) | ||
} | ||
}, | ||
)} | ||
</ul> | ||
</TabPanel> | ||
) | ||
})} | ||
</Tabs> | ||
</> | ||
) : ( | ||
<NoSelectedLanguages /> | ||
)} | ||
</> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { SelectDictionaryList } from './SelectDictionaryList' |
6 changes: 6 additions & 0 deletions
6
src/features/dictionary/SelectDictionaryVariant/ui/styles.module.scss
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