Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storybook): updated 2 component stories to v7 #11362

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/carbon-web-components/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const stories = glob.sync(
'../src/**/file-uploader.stories.ts',
'../src/**/overflow-menu.mdx',
'../src/**/overflow-menu.stories.ts',
'../src/**/search.mdx',
'../src/**/search.stories.ts',
'../src/**/select.mdx',
'../src/**/select.stories.ts',
'../src/**/progress-indicator.mdx',
'../src/**/progress-indicator.stories.ts',
'../src/**/skeleton-placeholder.mdx',
Expand Down
152 changes: 0 additions & 152 deletions packages/carbon-web-components/src/components/search/search-story.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Props, Description } from '@storybook/addon-docs/blocks';
import { ArgsTable, Meta, Markdown } from '@storybook/addon-docs/blocks';
import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn';
import * as SearchStories from './search.stories';

<Meta of={SearchStories} />

# Search

Expand All @@ -24,8 +27,8 @@ Here's a quick example to get you started.
import '@carbon/web-components/es/components/search/index.js';
```

<Description markdown={`${cdnJs({ components: ['search'] })}`} />
<Description markdown={`${cdnCss()}`} />
<Markdown>{`${cdnJs({ components: ['search'] })}`}</Markdown>
<Markdown>{`${cdnCss()}`}</Markdown>

### HTML

Expand All @@ -47,4 +50,4 @@ Note: For `boolean` attributes, `true` means simply setting the attribute (e.g.
`<cds-search light>`) and `false` means not setting the attribute (e.g.
`<cds-search>` without `light` attribute).

<Props of="cds-search" />
<ArgsTable of="cds-search" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import { html } from 'lit';
import { ifDefined } from 'lit/directives/if-defined.js';
import { INPUT_SIZE } from '../text-input/text-input';
import './search-skeleton';
import storyDocs from './search.mdx';
import '../layer';
import '../../../.storybook/templates/with-layer';
import './index';

const sizes = {
[`Small size (${INPUT_SIZE.SMALL})`]: INPUT_SIZE.SMALL,
[`Medium size (${INPUT_SIZE.MEDIUM})`]: INPUT_SIZE.MEDIUM,
[`Large size (${INPUT_SIZE.LARGE})`]: INPUT_SIZE.LARGE,
};

const args = {
autoComplete: 'off',
closeButtonLabelText: 'Clear search input',
disabled: false,
labelText: 'Search',
placeholder: 'Placeholder text',
playgroundWidth: 300,
role: 'searchbox',
size: null,
type: 'text',
value: 'Default value',
};

const argTypes = {
autoComplete: {
control: 'text',
description:
'Specify an optional value for the <code>autocomplete</code> property on the underlying <code>&lt;input&gt;</code>, defaults to "off".',
},
closeButtonLabelText: {
control: 'text',
description:
'Specify a label to be read by screen readers on the "close" button.',
},
disabled: {
control: 'boolean',
description:
'Specify whether the <code>&lt;input&gt;</code> should be disabled.',
},
labelText: {
control: 'text',
description: 'Provide the label text for the Search icon.',
},
placeholder: {
control: 'text',
description:
'Provide an optional placeholder text for the Search. Note: if the label and placeholder differ, VoiceOver on Mac will read both.',
},
playgroundWidth: {
control: { type: 'range', min: 300, max: 800, step: 50 },
description: 'Playground width',
},
role: {
control: 'text',
description:
'Specify the role for the underlying <code>&lt;input&gt;</code>, defaults to <code>searchbox</code>.',
},
size: {
control: 'select',
description: 'Specify the size of the Search.',
options: sizes,
},
type: {
control: 'text',
description:
'Optional prop to specify the type of the <code>&lt;input&gt;</code>.',
},
value: {
control: 'text',
description: 'Specify the value of the <code>&lt;input&gt;</code>.',
},
};

export const Default = {
render: () => {
return html`
<cds-search
size="lg"
close-button-label-text="Clear search input"
label-text="Search"
placeholder="Find your items"
type="text"></cds-search>
`;
},
};

export const Disabled = {
render: () => {
return html`
<cds-search
size="lg"
disabled
close-button-label-text="Clear search input"
label-text="Search"
placeholder="Find your items"
type="text"></cds-search>
`;
},
};

export const Expandable = {
render: () => {
return html`
<cds-search
size="lg"
expandable
close-button-assistive-text="Clear search input"
label-text="Search"
placeholder="Find your items"
type="text"></cds-search>
`;
},
};

export const ExpandableWithLayer = {
render: () => {
return html`
<sb-template-layers>
<cds-search size="lg" expandable placeholder="Layer two"></cds-search>
</sb-template-layers>
`;
},
};

export const WithLayer = {
render: () => {
return html`
<sb-template-layers>
<cds-search size="lg" placeholder="Find your items"></cds-search>
</sb-template-layers>
`;
},
};

export const Playground = {
args,
argTypes,
render: (args) => {
const {
autoComplete,
closeButtonLabelText,
colorScheme,
disabled,
labelText,
placeholder,
playgroundWidth,
size,
role,
type,
value,
onInput,
} = args ?? {};

const mainDiv = document.querySelector('#main-content');

if (mainDiv) {
(mainDiv as HTMLElement).style.width = `${playgroundWidth}px`;
}

return html`
<cds-search
autocomplete="${autoComplete}"
close-button-assistive-text="${ifDefined(closeButtonLabelText)}"
color-scheme="${ifDefined(colorScheme)}"
?disabled="${disabled}"
label-text="${ifDefined(labelText)}"
placeholder="${ifDefined(placeholder)}"
size="${ifDefined(size)}"
type="${ifDefined(type)}"
role=${role}
value="${ifDefined(value)}"
@cds-search-input="${onInput}">
</cds-search>
`;
},
};

const meta = {
title: 'Components/Search',
parameters: {
docs: {
page: storyDocs,
},
},
};

export default meta;
Loading
Loading