diff --git a/components/picker/CHANGELOG.md b/components/picker/CHANGELOG.md index 52c9d82f9bd..eb124fdaf9c 100644 --- a/components/picker/CHANGELOG.md +++ b/components/picker/CHANGELOG.md @@ -383,11 +383,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline \*refactor(picker)!: remove focus-ring([e37b430](https://github.com/adobe/spectrum-css/commit/e37b430)) - ### - 🛑 BREAKING CHANGES +### 🛑 BREAKING CHANGES - * - Remove focus-ring pseudo class in favor of focus-visible +#### Remove `focus-ring` class + +We've migrated away from the `focus-ring` class in favor of the native `:focus-visible` pseudo-class due to changes in browser support. @@ -1379,6 +1379,52 @@ Co-authored-by: castastrophe - correct icononly Picker width ([b165e11](https://github.com/adobe/spectrum-css/commit/b165e11)) - updated icon sizes for picker examples ([ad054f6](https://github.com/adobe/spectrum-css/commit/ad054f6)) +### Migration guide + +#### Component renamed + +Dropdown is now known as Picker. Replace all `.spectrum-Dropdown*` classnames with `.spectrum-Picker*`. + +#### Markup change + +The outer `
` is now gone and `.spectrum-FieldButton` is no longer used. Instead, the outer tag is now ` `; }; +/** + * Picker template including adjacent popover and help text. + */ export const Template = ({ rootClass = "spectrum-Picker", size = "m", label, labelPosition = "top", - placeholder, - helpText, + placeholder = "", + currentValue = "", + helpText = "", isQuiet = false, isKeyboardFocused = false, + showWorkflowIcon = false, isOpen = false, isInvalid = false, isLoading = false, isDisabled = false, isReadOnly = false, + isHovered = false, + isActive = false, withSwitch = false, fieldLabelStyle = {}, customClasses = [], customStyles = {}, - content = [], + popoverContent = [], id = getRandomId("picker"), } = {}, context = {}) => { const { updateArgs } = context; - let iconName = "ChevronDown200"; - switch (size) { - case "s": - iconName = "ChevronDown75"; - break; - case "m": - iconName = "ChevronDown100"; - break; - case "xl": - iconName = "ChevronDown300"; - break; - default: - iconName = "ChevronDown200"; - } - return html` ${when(label, () => FieldLabel({ @@ -117,7 +136,7 @@ export const Template = ({ label, isDisabled, customStyles: fieldLabelStyle, - alignment: labelPosition, + alignment: labelPosition === "side" ? "left" : undefined, }, context) )} ${Popover({ @@ -129,27 +148,26 @@ export const Template = ({ rootClass, size, placeholder, + currentValue, isQuiet, + showWorkflowIcon, isKeyboardFocused, isOpen, isInvalid, isLoading, isDisabled, isReadOnly, + isHovered, + isActive, customClasses, - customStyles: { - "display": labelPosition == "left" ? "inline-block" : undefined, - ...customStyles, - }, - content, - iconName, + customStyles, labelPosition, id, onclick: function() { updateArgs({ isOpen: !isOpen }); }, }, context), - content, + content: popoverContent, }, context)} ${when(helpText, () => HelpText({ @@ -158,12 +176,65 @@ export const Template = ({ hideIcon: true, }, context) )} - ${when(withSwitch, () => Switch({ - size, - label: "Toggle switch", - customStyles: { - "padding-inline-start": "15px" - } - }, context))} + ${when(withSwitch, () => + Switch({ + size, + label: "Toggle switch", + customStyles: { + "padding-inline-start": "15px" + } + }, context) + )} `; }; + +/** + * Template showing both closed and open versions of the Picker. + */ +export const ClosedAndOpenTemplate = (args, context) => Container({ + withBorder: false, + content: html`${[false, true].map((isOpen) => + Container({ + withBorder: false, + direction: "column", + heading: isOpen ? "Open" : "Closed", + containerStyles: { + rowGap: "8px", + }, + // Make sure container flex layout does not misalign sibling elements such as field label in Template() + wrapperStyles: { + display: "block", + }, + content: Template({ + ...args, + isOpen, + }, context), + }) + )}`, +}); + +/** + * Template for the Disabled docs story. + */ +export const DisabledTemplate = (args, context) => Container({ + withBorder: false, + content: html`${[false, true].map((isInvalid) => + Container({ + withBorder: false, + direction: "column", + heading: isInvalid ? "Invalid" : "Default", + containerStyles: { + rowGap: "8px", + overflow: "hidden", + }, + // Make sure container flex layout does not misalign sibling elements such as field label in Template() + wrapperStyles: { + display: "block", + }, + content: Template({ + ...args, + isInvalid, + }, context), + }) + )}`, +}); \ No newline at end of file diff --git a/components/tabs/stories/template.js b/components/tabs/stories/template.js index 17c6a3e2585..2e5c4ee6d45 100644 --- a/components/tabs/stories/template.js +++ b/components/tabs/stories/template.js @@ -124,7 +124,7 @@ export const Template = ({ customPopoverStyles: { insetBlockStart: "24px", }, - content: [ + popoverContent: [ () => Menu({ selectionMode: "none", size,