From cbd2e4b6bcdbea1ff1e2be6e11e5bf680181acac Mon Sep 17 00:00:00 2001 From: totocalcio Date: Sun, 19 May 2024 13:41:36 +0900 Subject: [PATCH 1/9] add LocalSwitch component --- .../components/common/LocaleSwitch.stories.ts | 17 ++ .../ui/components/common/LocaleSwitch.vue | 146 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 packages/ui/components/common/LocaleSwitch.stories.ts create mode 100644 packages/ui/components/common/LocaleSwitch.vue diff --git a/packages/ui/components/common/LocaleSwitch.stories.ts b/packages/ui/components/common/LocaleSwitch.stories.ts new file mode 100644 index 00000000..0fd0de8d --- /dev/null +++ b/packages/ui/components/common/LocaleSwitch.stories.ts @@ -0,0 +1,17 @@ +import { StoryFn } from '@storybook/vue3' +import LocaleSwitch from './LocaleSwitch.vue' + +export default { + title: 'common/LocaleSwitch', + component: LocaleSwitch, +} + +const Template: StoryFn = () => ({ + components: { LocaleSwitch }, + setup() { + return { } + }, + template: '', +}) + +export const Default = Template.bind({}) diff --git a/packages/ui/components/common/LocaleSwitch.vue b/packages/ui/components/common/LocaleSwitch.vue new file mode 100644 index 00000000..2ffd54b6 --- /dev/null +++ b/packages/ui/components/common/LocaleSwitch.vue @@ -0,0 +1,146 @@ + + + + + From f13d944c36ed33347a14b4030a38dd29c0000646 Mon Sep 17 00:00:00 2001 From: totocalcio Date: Sun, 19 May 2024 17:59:35 +0900 Subject: [PATCH 2/9] use useRouter --- .../ui/components/common/LocaleSwitch.vue | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/packages/ui/components/common/LocaleSwitch.vue b/packages/ui/components/common/LocaleSwitch.vue index 2ffd54b6..7cff5b49 100644 --- a/packages/ui/components/common/LocaleSwitch.vue +++ b/packages/ui/components/common/LocaleSwitch.vue @@ -1,25 +1,51 @@ From 789e27213833baf4eda4149512cbb2d43c879392 Mon Sep 17 00:00:00 2001 From: totocalcio Date: Sun, 19 May 2024 18:49:40 +0900 Subject: [PATCH 3/9] setting vue-router for Storybook --- packages/ui/.storybook/preview.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/ui/.storybook/preview.js b/packages/ui/.storybook/preview.js index e360110d..227bc347 100644 --- a/packages/ui/.storybook/preview.js +++ b/packages/ui/.storybook/preview.js @@ -1,6 +1,7 @@ import { setup } from '@storybook/vue3' import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport' import { createI18n } from 'vue-i18n' +import { createRouter, createMemoryHistory } from 'vue-router' import './global.css' @@ -33,14 +34,29 @@ const i18n = createI18n({ // end dummy sponsor: { start_date: 'April 8', - end_date: '25,', + end_date: '25,', }, }, }, }) +const routes = [ + { + path: '/', + name: 'ja', + }, + { + path: '/en', + name: 'en', + }, +] + +// 画面遷移は発生しないが、StorybookではURLを直接使えないため、createMemoryHistoryで生成 +const router = createRouter({ history: createMemoryHistory(), routes }) + setup((app) => { app.use(i18n) + app.use(router) }) export const parameters = { From 070ad8c00012430d6d5ff5c43701d525ea1f8e82 Mon Sep 17 00:00:00 2001 From: totocalcio Date: Sun, 19 May 2024 19:06:09 +0900 Subject: [PATCH 4/9] fix locate switch for footer --- apps/web/app/components/FooterPageSection.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/app/components/FooterPageSection.vue b/apps/web/app/components/FooterPageSection.vue index a6c6ecf2..bf86e544 100644 --- a/apps/web/app/components/FooterPageSection.vue +++ b/apps/web/app/components/FooterPageSection.vue @@ -39,11 +39,11 @@ const snsLinkList: LinkList[] = [ const internalLinkList: LinkList[] = [ { href: '/privacy', - text: t('privacy.title'), + text: 'privacy.title', }, { href: '/code-of-conduct', - text: t('code_of_conduct.title'), + text: 'code_of_conduct.title', }, ] const vueFesLinkList: LinkList[] = [ @@ -86,14 +86,14 @@ const vueFesLinkList: LinkList[] = [ From 2e7ca26f4baa9793bc9bf15f72cf2e087f17bd38 Mon Sep 17 00:00:00 2001 From: totocalcio Date: Sun, 19 May 2024 19:58:37 +0900 Subject: [PATCH 5/9] delete unnecessary style --- packages/ui/components/common/LocaleSwitch.vue | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/ui/components/common/LocaleSwitch.vue b/packages/ui/components/common/LocaleSwitch.vue index 7cff5b49..91e355e6 100644 --- a/packages/ui/components/common/LocaleSwitch.vue +++ b/packages/ui/components/common/LocaleSwitch.vue @@ -125,13 +125,6 @@ watch( font-weight: bold; } -/* din-2014 の `j` のグリフがずれているため微調整 */ -.locale-switch-button-language-ja, -.locale-switch-button-circle-ja { - box-sizing: border-box; - padding-left: 0.125rem; -} - .locale-switch-button-circle { position: absolute; display: flex; From 1295e12051bc9b72f3d86fd9e25570188b1dc971 Mon Sep 17 00:00:00 2001 From: totocalcio Date: Mon, 20 May 2024 00:26:47 +0900 Subject: [PATCH 6/9] delete space --- packages/ui/components/common/LocaleSwitch.stories.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/components/common/LocaleSwitch.stories.ts b/packages/ui/components/common/LocaleSwitch.stories.ts index 0fd0de8d..a0a680b1 100644 --- a/packages/ui/components/common/LocaleSwitch.stories.ts +++ b/packages/ui/components/common/LocaleSwitch.stories.ts @@ -9,7 +9,7 @@ export default { const Template: StoryFn = () => ({ components: { LocaleSwitch }, setup() { - return { } + return {} }, template: '', }) From 67060f52591ad8b4459e1def4b075b0ec05fc7b9 Mon Sep 17 00:00:00 2001 From: totocalcio Date: Mon, 20 May 2024 00:38:18 +0900 Subject: [PATCH 7/9] delete unnecessary className --- packages/ui/components/common/LocaleSwitch.vue | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/ui/components/common/LocaleSwitch.vue b/packages/ui/components/common/LocaleSwitch.vue index 91e355e6..011b5012 100644 --- a/packages/ui/components/common/LocaleSwitch.vue +++ b/packages/ui/components/common/LocaleSwitch.vue @@ -60,15 +60,12 @@ watch( > {{ LANGUAGES.JAPANESE }} - + {{ isChecked ? LANGUAGES.ENGLISH : LANGUAGES.JAPANESE }} Date: Wed, 22 May 2024 00:24:46 +0900 Subject: [PATCH 8/9] fix path matching words --- packages/ui/components/common/LocaleSwitch.vue | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/ui/components/common/LocaleSwitch.vue b/packages/ui/components/common/LocaleSwitch.vue index 011b5012..ba0421f1 100644 --- a/packages/ui/components/common/LocaleSwitch.vue +++ b/packages/ui/components/common/LocaleSwitch.vue @@ -18,17 +18,12 @@ const getPath = () => { return router.currentRoute.value.path.replace(`/${LANGUAGES.ENGLISH}`, '') } const setSwitchStatus = () => { - isChecked.value = router.currentRoute.value.path.includes(LANGUAGES.ENGLISH) + isChecked.value = router.currentRoute.value.path.includes(`/${LANGUAGES.ENGLISH}/`) } const toggleStatus = () => { isChecked.value = !isChecked.value const path = getPath() - // トレイリングスラッシュ対策 - if (path === '') { - router.push('/') - return - } router.push(path) } onMounted(() => { From 2a9e4629587224c73d1869ac3151ff005b723f9f Mon Sep 17 00:00:00 2001 From: totocalcio Date: Wed, 22 May 2024 00:39:23 +0900 Subject: [PATCH 9/9] fix custom property scope --- packages/ui/components/common/LocaleSwitch.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/ui/components/common/LocaleSwitch.vue b/packages/ui/components/common/LocaleSwitch.vue index ba0421f1..abd509f2 100644 --- a/packages/ui/components/common/LocaleSwitch.vue +++ b/packages/ui/components/common/LocaleSwitch.vue @@ -75,11 +75,9 @@ watch(