diff --git a/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size m.snap.png b/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size m.snap.png index 06468823c7..f161a95401 100644 Binary files a/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size m.snap.png and b/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size m.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size s.snap.png b/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size s.snap.png index 34fe8217ed..ce85b8e94c 100644 Binary files a/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size s.snap.png and b/cypress/snapshots/web/components/Radiobox/Radiobox.component-test.tsx/plasma-web Radiobox -- default size s.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core RadioGroup -- simple.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core RadioGroup -- simple.snap.png index 2ab930c02a..92df67468e 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core RadioGroup -- simple.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core RadioGroup -- simple.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- __label.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- __label.snap.png index 6ca38266ee..34519a2a54 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- __label.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- __label.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _checked.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _checked.snap.png index 2886cb91f4..e2ae8f0a08 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _checked.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _checked.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _disabled.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _disabled.snap.png index 3820946ad2..ad64f97201 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _disabled.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _disabled.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _focused.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _focused.snap.png index 962c33cf15..cbf1f1d8ac 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _focused.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- _focused.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- squeezes.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- squeezes.snap.png index 5e27d5ccaf..a9ec71c297 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- squeezes.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- squeezes.snap.png differ diff --git a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- with focus.snap.png b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- with focus.snap.png index cc2cb9a249..3a9d1d0569 100644 Binary files a/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- with focus.snap.png and b/cypress/snapshots/web/components/Radiobox/RadioboxBase.component-test.tsx/plasma-core Radiobox -- with focus.snap.png differ diff --git a/packages/plasma-web/api/plasma-web.api.md b/packages/plasma-web/api/plasma-web.api.md index 897de26340..105a31b426 100644 --- a/packages/plasma-web/api/plasma-web.api.md +++ b/packages/plasma-web/api/plasma-web.api.md @@ -177,9 +177,7 @@ import { PriceProps } from '@salutejs/plasma-hope'; import { Progress } from '@salutejs/plasma-hope'; import { ProgressProps } from '@salutejs/plasma-hope'; import { PropsType } from '@salutejs/plasma-new-hope/types/engines/types'; -import { Radiobox } from '@salutejs/plasma-hope'; -import { RadioboxProps } from '@salutejs/plasma-hope'; -import { RadioGroup } from '@salutejs/plasma-hope'; +import { RadioGroup } from '@salutejs/plasma-new-hope/styled-components'; import { radiuses } from '@salutejs/plasma-core'; import { Ratio } from '@salutejs/plasma-hope'; import { default as React_2 } from 'react'; @@ -647,9 +645,27 @@ export { Progress } export { ProgressProps } -export { Radiobox } +// @public +export const Radiobox: FunctionComponent & Filter, "size"> & BaseboxProps & RefAttributes>; -export { RadioboxProps } +// Warning: (ae-forgotten-export) The symbol "RadioboxComponent" needs to be exported by the entry point index.d.ts +// +// @public (undocumented) +export type RadioboxProps = typeof RadioboxComponent; export { RadioGroup } diff --git a/packages/plasma-web/src/components/Radiobox/Radiobox.config.ts b/packages/plasma-web/src/components/Radiobox/Radiobox.config.ts new file mode 100644 index 0000000000..f6ead7782e --- /dev/null +++ b/packages/plasma-web/src/components/Radiobox/Radiobox.config.ts @@ -0,0 +1,77 @@ +import { css } from '@salutejs/plasma-new-hope/styled-components'; + +export const config = { + defaults: { + view: 'accent', + size: 'm', + focused: 'true', + }, + variations: { + /** + * Размер контрола. + */ + size: { + s: css` + --plasma-radiobox-trigger-width: 1rem; + --plasma-radiobox-trigger-height: 1rem; + --plasma-radiobox-trigger-border-radius 1.125rem; + --plasma-radiobox-ellipse-size 0.5rem; + --plasma-radiobox-content-top-offset: 0.1rem; + --plasma-radiobox-content-left-offset 0.5rem; + --plasma-radiobox-label-font-family: var(--plasma-typo-footnote1-font-family); + --plasma-radiobox-label-font-size: var(--plasma-typo-footnote1-font-size); + --plasma-radiobox-label-font-style: var(--plasma-typo-footnote1-font-style); + --plasma-radiobox-label-font-weight: var(--plasma-typo-footnote1-font-weight); + --plasma-radiobox-label-letter-spacing: var(--plasma-typo-footnote1-letter-spacing); + --plasma-radiobox-label-line-height: var(--plasma-typo-footnote1-line-height); + --plasma-radiobox-description-font-family: var(--plasma-typo-caption-font-family); + --plasma-radiobox-description-font-size: var(--plasma-typo-caption-font-size); + --plasma-radiobox-description-font-style: var(--plasma-typo-caption-font-style); + --plasma-radiobox-description-font-weight: var(--plasma-typo-caption-font-weight); + --plasma-radiobox-description-letter-spacing: var(--plasma-typo-caption-letter-spacing); + --plasma-radiobox-description-line-height: var(--plasma-typo-caption-line-height); + `, + m: css` + --plasma-radiobox-trigger-width: 1.375rem; + --plasma-radiobox-trigger-height: 1.375rem; + --plasma-radiobox-trigger-border-radius 1.125rem; + --plasma-radiobox-ellipse-size 0.625rem; + --plasma-radiobox-content-top-offset: 0.25rem; + --plasma-radiobox-content-left-offset 0.6875rem; + --plasma-radiobox-label-font-family: var(--plasma-typo-body1-font-family); + --plasma-radiobox-label-font-size: var(--plasma-typo-body1-font-size); + --plasma-radiobox-label-font-style: var(--plasma-typo-body1-font-style); + --plasma-radiobox-label-font-weight: var(--plasma-typo-body1-font-weight); + --plasma-radiobox-label-letter-spacing: var(--plasma-typo-body1-letter-spacing); + --plasma-radiobox-label-line-height: var(--plasma-typo-body1-line-height); + --plasma-radiobox-description-font-family: var(--plasma-typo-footnote1-font-family); + --plasma-radiobox-description-font-size: var(--plasma-typo-footnote1-font-size); + --plasma-radiobox-description-font-style: var(--plasma-typo-footnote1-font-style); + --plasma-radiobox-description-font-weight: var(--plasma-typo-footnote1-font-weight); + --plasma-radiobox-description-letter-spacing: var(--plasma-typo-footnote1-letter-spacing); + --plasma-radiobox-description-line-height: var(--plasma-typo-footnote1-line-height); + `, + }, + /** + * Вид контрола. + */ + view: { + accent: css` + --plasma-radiobox-view: var(--plasma-colors-accent); + --plasma-radiobox-ellipse-color: var(--plasma-colors-white); + --plasma-radiobox-description-color: var(--plasma-colors-secondary); + --plasma-radiobox-trigger-border-color: var(--plasma-colors-secondary); + `, + }, + disabled: { + true: css` + --plasma-radiobox-disabled-opacity: 0.4; + `, + }, + focused: { + true: css` + --plasma-radiobox-focus-color: var(--plasma-colors-accent); + `, + }, + }, +}; diff --git a/packages/plasma-web/src/components/Radiobox/Radiobox.props.tsx b/packages/plasma-web/src/components/Radiobox/Radiobox.props.tsx deleted file mode 100644 index c59076a4f6..0000000000 --- a/packages/plasma-web/src/components/Radiobox/Radiobox.props.tsx +++ /dev/null @@ -1,18 +0,0 @@ -export const sizes = { - m: { - width: '1.375rem', - height: '1.375rem', - outLineRadius: '1.125rem', - ellipseSize: '0.625rem', - contentTopOffset: '0.25rem', - contentLeftOffset: '0.6875rem', - }, - s: { - width: '1rem', - height: '1rem', - outLineRadius: '1.125rem', - ellipseSize: '0.5rem', - contentTopOffset: '0.1rem', - contentLeftOffset: '0.5rem', - }, -}; diff --git a/packages/plasma-web/src/components/Radiobox/Radiobox.stories.tsx b/packages/plasma-web/src/components/Radiobox/Radiobox.stories.tsx index e9e1d0717f..87fe3bd6f4 100644 --- a/packages/plasma-web/src/components/Radiobox/Radiobox.stories.tsx +++ b/packages/plasma-web/src/components/Radiobox/Radiobox.stories.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Story, Meta } from '@storybook/react'; +import { ComponentStory, Meta } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { SSRProvider } from '../SSRProvider'; @@ -46,7 +46,7 @@ const items = [ { name: 'language', value: 'elixir', label: 'Elixir', disabled: true }, ]; -export const Live = () => { +export const Live = (props) => { const [value, setValue] = React.useState('c'); return ( @@ -74,6 +74,7 @@ export const Live = () => { }} onFocus={onFocus} onBlur={onBlur} + {...props} /> ))} @@ -83,7 +84,23 @@ export const Live = () => { ); }; -export const Default: Story = ({ name, label, description, disabled, singleLine, size }) => { +Live.argTypes = { + size: { + options: sizes, + control: { + type: 'inline-radio', + }, + }, +}; + +Live.args = { + size: 'm', + view: 'accent', + singleLine: false, + focused: true, +}; + +export const Default: ComponentStory = ({ name, label, description, disabled, singleLine, size }) => { const value = 0; const [checked, setChecked] = React.useState(true); diff --git a/packages/plasma-web/src/components/Radiobox/Radiobox.ts b/packages/plasma-web/src/components/Radiobox/Radiobox.ts new file mode 100644 index 0000000000..2224934fdd --- /dev/null +++ b/packages/plasma-web/src/components/Radiobox/Radiobox.ts @@ -0,0 +1,15 @@ +import { radioboxConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components'; + +import { config } from './Radiobox.config'; + +const mergedConfig = mergeConfig(radioboxConfig, config); +const RadioboxComponent = component(mergedConfig); + +export type RadioboxProps = typeof RadioboxComponent; + +/** + * Переключатель, или *радиокнопка*. + */ +export const Radiobox = RadioboxComponent; + +export { RadioGroup } from '@salutejs/plasma-new-hope/styled-components'; diff --git a/packages/plasma-web/src/components/Radiobox/index.ts b/packages/plasma-web/src/components/Radiobox/index.ts index b233ecce20..43ce06a8f4 100644 --- a/packages/plasma-web/src/components/Radiobox/index.ts +++ b/packages/plasma-web/src/components/Radiobox/index.ts @@ -1,2 +1,2 @@ -export { Radiobox, RadioGroup } from '@salutejs/plasma-hope'; -export type { RadioboxProps } from '@salutejs/plasma-hope'; +export { Radiobox, RadioGroup } from './Radiobox'; +export type { RadioboxProps } from './Radiobox';