You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(downstate): docs + implementation for example components (#2520)
* feat(downstate): docs + implementation for example components
* docs: update mdx
* docs: reorg, stories live within foundations
* docs: decorator for down state dimension tokens
* docs: fix mdx hierarchy console error
* fix: small iconOnly button gets min perspective
* docs: use markdown, update language
* fix: disabled, readonly checkbox doesnt have down state
* chore(button,checkbox): update package versions
"Buttons allow users to perform an action or to navigate to another page. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.",
Down state is a Spectrum 2 feature that creates the illusion of components being pressed-in when active. This functionality is already included in Spectrum 2 components that require down state in this project. It is implemented with a CSS transform. The implementation depends on the size of the interactable element, as shown in the examples below.
10
+
11
+
## Examples
12
+
13
+
### Minimum perspective
14
+
15
+
For elements that have a width of 24px or less, the minimum perspective token is used to apply the down state. One example of a component that uses this token is the checkbox:
16
+
17
+
<Storyof={Checkbox.CheckboxDownState} />
18
+
19
+
In this case, we use the minimum perspective token:
For elements that have a width of greater than 24px, we need to use the component's width and height to apply the down state. One example of a component that uses this logic is the button:
30
+
31
+
<Storyof={Button.ButtonDownState} />
32
+
33
+
In this case, we use a max formula to calculate the perspective based on component width and height (this helps us account for components that may be very wide):
*Note that in this case, users are required to develop an implementation to determine the width and height of the component. Assign these values to the `--spectrum-downstate-width` and `--spectrum-downstate-height` custom properties in a `style` attribute on the HTML element to expose them for use in the CSS.*
"Buttons allow users to perform an action or to navigate to another page. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.",
description: "How the buttons align in the preview (Storybook only).",
102
104
type: {name: "string"},
103
-
table: {
105
+
table: {
104
106
type: {summary: "string"},
105
107
category: "Advanced"
106
108
},
@@ -349,4 +351,4 @@ Wrapping.args = {
349
351
showIconOnlyButton: false,
350
352
variant: "accent",
351
353
label: "An example of text overflow behavior within the button component. When the button text is too long for the horizontal space available, it wraps to form another line.",
0 commit comments