-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(picker): correct implementation of "disabled", expand stories and…
… documentation (#4040) * fix(picker): correct implementation of "disabled", expand stories and documentation * ci: update golden images cache
- Loading branch information
Westbrook Johnson
authored
Feb 13, 2024
1 parent
5022b4a
commit 84c2fef
Showing
7 changed files
with
195 additions
and
58 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
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
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
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,66 @@ | ||
/* | ||
Copyright 2024 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
export const argTypes = { | ||
size: { | ||
name: 'size', | ||
type: { name: 'string', required: false }, | ||
description: 'The size at which to display accordion items.', | ||
table: { | ||
defaultValue: { summary: 'm' }, | ||
}, | ||
control: { | ||
labels: { | ||
s: 'Small', | ||
m: 'Medium', | ||
l: 'Large', | ||
xl: 'Extra large', | ||
}, | ||
type: 'select', | ||
}, | ||
}, | ||
quiet: { | ||
name: 'quiet', | ||
type: { name: 'boolean', required: false }, | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
disabled: { | ||
name: 'disabled', | ||
type: { name: 'boolean', required: false }, | ||
description: | ||
'Disable this control. It will not receive focus or events.', | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
invalid: { | ||
name: 'invalid', | ||
type: { name: 'boolean', required: false }, | ||
table: { | ||
type: { summary: 'boolean' }, | ||
defaultValue: { summary: false }, | ||
}, | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}; |
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
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,53 @@ | ||
/* | ||
Copyright 2024 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { html, type TemplateResult } from '@spectrum-web-components/base'; | ||
import type { Picker } from '@spectrum-web-components/picker'; | ||
import '@spectrum-web-components/field-label/sp-field-label.js'; | ||
import '@spectrum-web-components/picker/sp-picker.js'; | ||
import '@spectrum-web-components/menu/sp-menu-item.js'; | ||
|
||
import { spreadProps } from '../../../test/lit-helpers.js'; | ||
|
||
export interface StoryArgs { | ||
disabled?: boolean; | ||
invalid?: boolean; | ||
open?: boolean; | ||
quiet?: boolean; | ||
showText?: boolean; | ||
onChange?: (val: string) => void; | ||
[prop: string]: unknown; | ||
} | ||
|
||
export const handleChange = | ||
({ onChange }: StoryArgs) => | ||
(event: Event): void => { | ||
const picker = event.target as Picker; | ||
if (onChange) onChange(picker.value); | ||
}; | ||
|
||
export const Template = (args: StoryArgs): TemplateResult => html` | ||
<sp-field-label for="picker-1">Where do you live?</sp-field-label> | ||
<sp-picker | ||
id="picker-1" | ||
@change=${handleChange(args)} | ||
label="Choose your neighborhood" | ||
${spreadProps(args)} | ||
> | ||
<sp-menu-item value="option-1">Carol Gardens</sp-menu-item> | ||
<sp-menu-item value="option-2">Cobble Hill</sp-menu-item> | ||
<sp-menu-item value="option-3">Ft. Greene</sp-menu-item> | ||
<sp-menu-item value="option-4">Park Slope</sp-menu-item> | ||
<sp-menu-item disabled value="option-5">Prospect Park</sp-menu-item> | ||
<sp-menu-item value="option-6">Red Hook</sp-menu-item> | ||
</sp-picker> | ||
`; |
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