From 0601524411535546ae0a7d8891e9c2e3275c3ac6 Mon Sep 17 00:00:00 2001 From: anatolykopyl Date: Fri, 20 May 2022 00:42:22 +0300 Subject: [PATCH] Language selector --- src/components/Controls.module.css | 24 ++++++---- src/components/Controls.tsx | 53 ++++++++++++---------- src/components/LanguageSelector.module.css | 4 ++ src/components/LanguageSelector.tsx | 25 ++++++++++ src/localization/en.json | 1 + src/localization/ru.json | 1 + 6 files changed, 74 insertions(+), 34 deletions(-) create mode 100644 src/components/LanguageSelector.module.css create mode 100644 src/components/LanguageSelector.tsx diff --git a/src/components/Controls.module.css b/src/components/Controls.module.css index 75bb31f..55adba7 100644 --- a/src/components/Controls.module.css +++ b/src/components/Controls.module.css @@ -7,7 +7,13 @@ padding: 18px; border-radius: 12px; width: 64px; - height: 200px; +} + +.chapters { + position: relative; + height: calc(64px * 3); + width: 100%; + margin-bottom: 32px; } .controlsWrapper, .gooWrapper { @@ -16,8 +22,6 @@ left: 0; width: 100%; height: 100%; - padding: 18px; - box-sizing: border-box; } .gooWrapper { @@ -27,7 +31,7 @@ .control, .blob { position: absolute; left: 50%; - transform: translate(-50%, -50%); + transform: translateX(-50%); cursor: pointer; } @@ -35,7 +39,7 @@ display: flex; justify-content: center; align-items: center; - width: calc(100% - 36px); + width: 100%; height: auto; padding: 18px; box-sizing: border-box; @@ -47,9 +51,9 @@ .blob { background: var(--clr-bg); - border-radius: 16px; + border-radius: 20px; aspect-ratio: 1/1; - transition: all .5s; + transition: width .6s, height .6s; width: 0; height: 0; } @@ -60,13 +64,13 @@ } .control:nth-child(1), .blob:nth-child(1) { - top: 60px; + } .control:nth-child(2), .blob:nth-child(2) { - top: 120px; + top: 70px; } .control:nth-child(3), .blob:nth-child(3) { - top: 180px; + top: calc(70px * 2); } diff --git a/src/components/Controls.tsx b/src/components/Controls.tsx index 6a48363..65e4da1 100644 --- a/src/components/Controls.tsx +++ b/src/components/Controls.tsx @@ -3,6 +3,7 @@ import { createEffect } from 'solid-js'; import { useStore } from '../store/index'; import styles from './Controls.module.css'; +import LanguageSelector from './LanguageSelector'; import homeIcon from '../assets/icons/home.svg' import gridIcon from '../assets/icons/grid.svg' @@ -10,7 +11,7 @@ export default () => { const [store] = useStore(); const [selected, setSelected] = createSignal('home'); const [blobby, setBlobby] = createSignal(['home']); - const controls = [ + const chapters = [ { name: 'home', icon: homeIcon }, { name: 'projects', icon: gridIcon }, { name: 'whatever', icon: homeIcon }, @@ -36,30 +37,34 @@ export default () => { return ( <>
-
- {(control) => -
- }
-
-
- {(control) => -
{ - selectChapter(control.name) - }} - class={styles.control} - > - -
- }
+
+
+ {(chapter) => +
+ }
+
+
+ {(chapter) => +
{ + selectChapter(chapter.name) + }} + class={styles.control} + > + +
+ }
+
+ +
diff --git a/src/components/LanguageSelector.module.css b/src/components/LanguageSelector.module.css new file mode 100644 index 0000000..f478a9b --- /dev/null +++ b/src/components/LanguageSelector.module.css @@ -0,0 +1,4 @@ +.LanguageSelector { + cursor: pointer; + user-select: none; +} diff --git a/src/components/LanguageSelector.tsx b/src/components/LanguageSelector.tsx new file mode 100644 index 0000000..a01abf4 --- /dev/null +++ b/src/components/LanguageSelector.tsx @@ -0,0 +1,25 @@ +import { useI18n } from "@solid-primitives/i18n"; + +import styles from './LanguageSelector.module.css'; + +export default () => { + const [t, { locale }] = useI18n(); + + return ( +
{ + switch (locale()) { + case 'ru': + locale('en') + break; + case 'en': + locale('ru') + break; + } + }} + class={styles.LanguageSelector} + > + {t('lang')} +
+ ) +} diff --git a/src/localization/en.json b/src/localization/en.json index ec26b8b..4d4e5f6 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -1,4 +1,5 @@ { + "lang": "en", "my_name": "Anatoly Kopyl", "tagline": "Professional fullstack developer with standards" } diff --git a/src/localization/ru.json b/src/localization/ru.json index d6eb94b..b8799bb 100644 --- a/src/localization/ru.json +++ b/src/localization/ru.json @@ -1,4 +1,5 @@ { + "lang": "ru", "my_name": "Анатолий Копыл", "tagline": "Профессиональный fullstack разработчик со стандартами" }