diff --git a/packages/input-option/src/InputOption/InputOption.stories.tsx b/packages/input-option/src/InputOption/InputOption.stories.tsx index b5d28a2324..64e962a0aa 100644 --- a/packages/input-option/src/InputOption/InputOption.stories.tsx +++ b/packages/input-option/src/InputOption/InputOption.stories.tsx @@ -5,7 +5,7 @@ import { storybookExcludedControlParams, StoryMetaType, } from '@lg-tools/storybook-utils'; -import { Decorator, StoryFn, StoryObj } from '@storybook/react'; +import { StoryFn, StoryObj } from '@storybook/react'; import Icon, { glyphs } from '@leafygreen-ui/icon'; @@ -16,7 +16,7 @@ import { import { InputOption, type InputOptionProps } from '.'; -const meta: StoryMetaType = { +export default { title: 'Components/InputOption', component: InputOption, parameters: { @@ -68,9 +68,7 @@ const meta: StoryMetaType = { }, as: storybookArgTypes.as, }, -}; - -export default meta; +} satisfies StoryMetaType; export const LiveExample: StoryFn< InputOptionProps & InputOptionContentProps @@ -99,57 +97,10 @@ export const Generated = { parameters: { generate: { combineArgs: { - selected: [false, true], - disabled: [false, true], - }, - }, - }, -} satisfies StoryObj; - -const _withContentDecorator: Decorator = ( - Instance, - ctx, -) => { - return ( - - - {ctx.args.children} - - - ); -}; - -export const WithContent = { - render: () => <>, - parameters: { - generate: { - args: { - showWedge: true, - }, - combineArgs: { - description: [undefined, 'Description'], - preserveIconSpace: [false, true], - leftGlyph: [undefined, ], - rightGlyph: [undefined, ], highlighted: [false, true], + checked: [false, true], disabled: [false, true], }, - excludeCombinations: [ - { - leftGlyph: undefined, - rightGlyph: , - }, - { - preserveIconSpace: false, - leftGlyph: , - }, - ], - decorator: _withContentDecorator, }, }, -} satisfies StoryObj; +} satisfies StoryObj; diff --git a/packages/input-option/src/InputOption/InputOption.style.ts b/packages/input-option/src/InputOption/InputOption.style.ts index 17ff138440..9c38ae4966 100644 --- a/packages/input-option/src/InputOption/InputOption.style.ts +++ b/packages/input-option/src/InputOption/InputOption.style.ts @@ -28,7 +28,7 @@ export const getInputOptionStyles = ({ checked, isInteractive, }: InputOptionStyleArgs) => { - const ixnState = highlighted || checked ? State.Focus : State.Default; + const ixnState = highlighted ? State.Focus : State.Default; return css` position: relative; list-style: none; @@ -66,8 +66,6 @@ export const getInputOptionStyles = ({ background-color: ${color[theme].background.primary.hover}; .${leftGlyphClassName} { - -export const inputOptionClassName = createUniqueClassName('') color: ${color[theme].icon.primary.hover}; } } @@ -77,6 +75,11 @@ export const inputOptionClassName = createUniqueClassName('') outline: none; border: unset; } + + ${checked && + css` + font-weight: 600; + `} `} `; }; @@ -90,7 +93,6 @@ export const getInputOptionWedge = ({ theme, disabled, highlighted, - checked, }: InputOptionStyleArgs) => css` // Left wedge &:before { @@ -108,7 +110,7 @@ export const getInputOptionWedge = ({ transition: ${transitionDuration.default}ms ease-in-out; transition-property: transform, background-color; - ${(highlighted || checked) && + ${highlighted && css` transform: scaleY(1) translateY(-50%); background-color: ${color[theme].icon.primary.focus}; diff --git a/packages/input-option/src/InputOptionContent/InputOptionContent.stories.tsx b/packages/input-option/src/InputOptionContent/InputOptionContent.stories.tsx new file mode 100644 index 0000000000..6c2ebdf835 --- /dev/null +++ b/packages/input-option/src/InputOptionContent/InputOptionContent.stories.tsx @@ -0,0 +1,139 @@ +/* eslint-disable react/jsx-key */ +import React from 'react'; +import { + InstanceDecorator, + storybookArgTypes, + storybookExcludedControlParams, + StoryMetaType, +} from '@lg-tools/storybook-utils'; +import { StoryObj } from '@storybook/react'; + +import Icon, { glyphs } from '@leafygreen-ui/icon'; + +import { InputOption } from '../InputOption'; + +import { InputOptionContent } from '.'; + +const _withInputOptionDecorator: InstanceDecorator< + typeof InputOption & typeof InputOptionContent +> = (Instance, ctx) => { + const { + args: { darkMode, highlighted, checked, disabled }, + } = ctx || { args: {} }; + return ( + + + + ); +}; + +export default { + title: 'Components/InputOption/Content', + component: InputOptionContent, + parameters: { + default: 'Basic', + controls: { + exclude: [...storybookExcludedControlParams], + }, + generate: { + storyNames: ['Basic', 'Highlighted', 'Checked', 'Disabled'], + combineArgs: { + darkMode: [false, true], + description: [undefined, 'Description'], + preserveIconSpace: [false, true], + leftGlyph: [undefined, ], + rightGlyph: [undefined, ], + }, + excludeCombinations: [ + { + leftGlyph: undefined, + rightGlyph: , + }, + { + preserveIconSpace: false, + leftGlyph: , + }, + ], + decorator: _withInputOptionDecorator, + }, + }, + args: { + children: 'Some text', + showWedge: true, + }, + argTypes: { + disabled: { + control: 'boolean', + }, + highlighted: { + control: 'boolean', + }, + checked: { + control: 'boolean', + }, + showWedge: { + control: 'boolean', + }, + leftGlyph: { + options: Object.keys(glyphs), + control: { type: 'select' }, + }, + rightGlyph: { + options: Object.keys(glyphs), + control: { type: 'select' }, + }, + description: { + control: { type: 'text' }, + }, + as: storybookArgTypes.as, + }, +} satisfies StoryMetaType; + +export const Basic = { + render: () => <>, +} satisfies StoryObj; + +export const Highlighted = { + render: () => <>, + parameters: { + generate: { + args: { + description: 'Description', + rightGlyph: , + highlighted: true, + }, + }, + }, +} satisfies StoryObj; + +export const Checked = { + render: () => <>, + parameters: { + generate: { + args: { + description: 'Description', + rightGlyph: , + checked: true, + }, + combineArgs: { + highlighted: [false, true], + }, + }, + }, +} satisfies StoryObj; + +export const Disabled = { + render: () => <>, + parameters: { + generate: { + args: { + disabled: true, + }, + }, + }, +} satisfies StoryObj; diff --git a/packages/input-option/src/InputOptionContent/InputOptionContent.styles.ts b/packages/input-option/src/InputOptionContent/InputOptionContent.styles.ts index 940a9f31b3..f769ea2216 100644 --- a/packages/input-option/src/InputOptionContent/InputOptionContent.styles.ts +++ b/packages/input-option/src/InputOptionContent/InputOptionContent.styles.ts @@ -50,10 +50,9 @@ export const getLeftGlyphStyles = ({ theme, disabled, highlighted, - selected, }: InputOptionStyleArgs) => { const variant = disabled ? Variant.Disabled : Variant.Primary; - const ixnState = highlighted || selected ? State.Focus : State.Default; + const ixnState = highlighted ? State.Focus : State.Default; return css` grid-area: left-glyph;