Skip to content

Commit

Permalink
SelectControl: Add story for prefix slot (#65730)
Browse files Browse the repository at this point in the history
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent cd701e9 commit 5e47d48
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/components/src/select-control/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useState } from '@wordpress/element';
* Internal dependencies
*/
import SelectControl from '../';
import { InputControlPrefixWrapper } from '../../input-control/input-prefix-wrapper';

const meta: Meta< typeof SelectControl > = {
title: 'Components/SelectControl',
Expand Down Expand Up @@ -64,6 +65,7 @@ const SelectControlWithState: StoryFn< typeof SelectControl > = ( props ) => {
export const Default = SelectControlWithState.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
label: 'Label',
options: [
{ value: '', label: 'Select an Option', disabled: true },
{ value: 'a', label: 'Option A' },
Expand All @@ -76,7 +78,6 @@ export const WithLabelAndHelpText = SelectControlWithState.bind( {} );
WithLabelAndHelpText.args = {
...Default.args,
help: 'Help text to explain the select control.',
label: 'Value',
};

/**
Expand All @@ -86,6 +87,7 @@ WithLabelAndHelpText.args = {
export const WithCustomChildren = SelectControlWithState.bind( {} );
WithCustomChildren.args = {
__nextHasNoMarginBottom: true,
label: 'Label',
children: (
<>
<option value="option-1">Option 1</option>
Expand All @@ -104,8 +106,19 @@ WithCustomChildren.args = {
),
};

/**
* By default, the prefix is aligned with the edge of the input border, with no padding.
* If you want to apply standard padding in accordance with the size variant, wrap the element in the `<InputControlPrefixWrapper>` component.
*/
export const WithPrefix = SelectControlWithState.bind( {} );
WithPrefix.args = {
...Default.args,
prefix: <InputControlPrefixWrapper>Prefix:</InputControlPrefixWrapper>,
};

export const Minimal = SelectControlWithState.bind( {} );
Minimal.args = {
...Default.args,
variant: 'minimal',
hideLabelFromVision: true,
};

0 comments on commit 5e47d48

Please sign in to comment.