-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): updated 2 component stories to v7 (#11362)
* chore(search): update search stories to sb v7 * chore(select): update select stories to sb v7 * chore(select): trim back select imports * fix(select): use optional chaining on a @query property inside getter * chore(select): fix case on readOnly --------- Co-authored-by: kennylam <[email protected]>
- Loading branch information
Showing
8 changed files
with
481 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 0 additions & 152 deletions
152
packages/carbon-web-components/src/components/search/search-story.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 201 additions & 0 deletions
201
packages/carbon-web-components/src/components/search/search.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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><input></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><input></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><input></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><input></code>.', | ||
}, | ||
value: { | ||
control: 'text', | ||
description: 'Specify the value of the <code><input></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; |
Oops, something went wrong.