From 6be20422494e3806fba3d1c5ad5c3e98bd6e67e5 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 1 Jun 2022 19:34:43 +0200 Subject: chore: replace the Ackee select by a toggle component --- .../organisms/forms/settings-form.module.scss | 54 ++++++++++++---------- .../organisms/forms/settings-form.stories.tsx | 2 +- .../organisms/forms/settings-form.test.tsx | 11 ++--- src/components/organisms/forms/settings-form.tsx | 23 +++++---- .../organisms/modals/settings-modal.module.scss | 12 +---- src/components/organisms/modals/settings-modal.tsx | 7 +-- 6 files changed, 51 insertions(+), 58 deletions(-) (limited to 'src/components/organisms') diff --git a/src/components/organisms/forms/settings-form.module.scss b/src/components/organisms/forms/settings-form.module.scss index 6174304..647f1b5 100644 --- a/src/components/organisms/forms/settings-form.module.scss +++ b/src/components/organisms/forms/settings-form.module.scss @@ -8,7 +8,8 @@ @include mix.media("screen") { @include mix.dimensions(null, "2xs", "height") { - gap: var(--spacing-md); + column-gap: var(--spacing-lg); + row-gap: var(--spacing-xs); font-size: var(--font-size-sm); } } @@ -16,28 +17,31 @@ .label { @include mix.media("screen") { @include mix.dimensions(null, "2xs", "height") { + margin: 0 auto; + float: none; font-size: var(--font-size-sm); - - &:not(.label--select) { - float: none; - margin: 0 auto; - } } - } - &.label--select { - @include mix.media("screen") { - @include mix.dimensions("2xs", null, "height") { - margin: 0 auto 0 0; - } + @include mix.dimensions(null, "2xs") { + //font-size: var(--font-size-sm); } } } .tooltip { + top: unset; + bottom: calc(100% + var(--spacing-2xs)); + font-size: var(--font-size-sm); + transform-origin: bottom center; + @include mix.media("screen") { - @include mix.dimensions(null, "2xs") { - font-size: var(--font-size-sm); + @include mix.dimensions(null, "2xs", "height") { + width: 250%; + transform-origin: bottom left; + } + + @include mix.dimensions("sm") { + font-size: var(--font-size-md); } } } @@ -50,28 +54,28 @@ @include mix.dimensions(null, "2xs", "height") { display: flex; flex-flow: column wrap; - width: fit-content; - - &:last-of-type { - flex: 0 0 100%; - margin: 0; - } + max-width: fit-content; + margin: 0; } } } -.setting { - &--select { - flex: 0 0 100%; +.group { + margin-left: auto; + + @include mix.media("screen") { + @include mix.dimensions(null, "2xs", "height") { + margin: auto; + } } } -.group { +.fieldset__body { margin-left: auto; @include mix.media("screen") { @include mix.dimensions(null, "2xs", "height") { - margin: auto; + margin: 0 auto; } } } diff --git a/src/components/organisms/forms/settings-form.stories.tsx b/src/components/organisms/forms/settings-form.stories.tsx index ceb08c7..de9f769 100644 --- a/src/components/organisms/forms/settings-form.stories.tsx +++ b/src/components/organisms/forms/settings-form.stories.tsx @@ -1,4 +1,4 @@ -import { storageKey as ackeeStorageKey } from '@components/molecules/forms/ackee-select.fixture'; +import { storageKey as ackeeStorageKey } from '@components/molecules/forms/ackee-toggle.fixture'; import { storageKey as motionStorageKey } from '@components/molecules/forms/motion-toggle.fixture'; import { ComponentMeta, ComponentStory } from '@storybook/react'; import SettingsForm from './settings-form'; diff --git a/src/components/organisms/forms/settings-form.test.tsx b/src/components/organisms/forms/settings-form.test.tsx index 90a2751..584261d 100644 --- a/src/components/organisms/forms/settings-form.test.tsx +++ b/src/components/organisms/forms/settings-form.test.tsx @@ -1,9 +1,8 @@ +import { storageKey as ackeeStorageKey } from '@components/molecules/forms/ackee-toggle.fixture'; +import { storageKey as motionStorageKey } from '@components/molecules/forms/motion-toggle.fixture'; import { render, screen } from '@test-utils'; import SettingsForm from './settings-form'; -const ackeeStorageKey = 'ackee-tracking'; -const motionStorageKey = 'reduce-motion'; - describe('SettingsForm', () => { it('renders a form', () => { render( @@ -17,7 +16,7 @@ describe('SettingsForm', () => { ).toBeInTheDocument(); }); - it('renders a theme toggle setting', () => { + it('renders a theme setting', () => { render( { ).toBeInTheDocument(); }); - it('renders a code blocks toggle setting', () => { + it('renders a code blocks setting', () => { render( { /> ); expect( - screen.getByRole('combobox', { name: /^Tracking:/i }) + screen.getByRole('radiogroup', { name: /^Tracking:/i }) ).toBeInTheDocument(); }); }); diff --git a/src/components/organisms/forms/settings-form.tsx b/src/components/organisms/forms/settings-form.tsx index 9dc0e90..5d915a8 100644 --- a/src/components/organisms/forms/settings-form.tsx +++ b/src/components/organisms/forms/settings-form.tsx @@ -1,7 +1,7 @@ import Form from '@components/atoms/forms/form'; -import AckeeSelect, { - type AckeeSelectProps, -} from '@components/molecules/forms/ackee-select'; +import AckeeToggle, { + type AckeeToggleProps, +} from '@components/molecules/forms/ackee-toggle'; import MotionToggle, { type MotionToggleProps, } from '@components/molecules/forms/motion-toggle'; @@ -11,11 +11,11 @@ import { FC } from 'react'; import { useIntl } from 'react-intl'; import styles from './settings-form.module.scss'; -export type SettingsFormProps = Pick & { +export type SettingsFormProps = Pick & { /** * The local storage key for Ackee settings. */ - ackeeStorageKey: AckeeSelectProps['storageKey']; + ackeeStorageKey: AckeeToggleProps['storageKey']; /** * The local storage key for Reduce motion settings. */ @@ -42,24 +42,29 @@ const SettingsForm: FC = ({ onSubmit={() => null} > - ); diff --git a/src/components/organisms/modals/settings-modal.module.scss b/src/components/organisms/modals/settings-modal.module.scss index a6a2077..70b786d 100644 --- a/src/components/organisms/modals/settings-modal.module.scss +++ b/src/components/organisms/modals/settings-modal.module.scss @@ -1,11 +1 @@ -@use "@styles/abstracts/mixins" as mix; - -.label { - margin-right: auto; - - @include mix.media("screen") { - @include mix.dimensions(null, "2xs", "height") { - font-size: var(--font-size-sm); - } - } -} +// TODO diff --git a/src/components/organisms/modals/settings-modal.tsx b/src/components/organisms/modals/settings-modal.tsx index 5d14836..34f5619 100644 --- a/src/components/organisms/modals/settings-modal.tsx +++ b/src/components/organisms/modals/settings-modal.tsx @@ -37,12 +37,7 @@ const SettingsModal: FC = ({ }); return ( - + ); -- cgit v1.2.3