-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(downstate,checkbox,button): downstate docs and implementation wi…
…thin example components
- Loading branch information
Showing
12 changed files
with
103 additions
and
121 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
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 |
---|---|---|
@@ -1,23 +1,82 @@ | ||
name: Down state | ||
SpectrumSiteSlug: https://spectrum.adobe.com/page/down-state/ | ||
description: | | ||
Down state is a Spectrum 2 (S2) feature that creates the illusion of components being pressed-in when active. There are two different ways to implement down state depending on the component. | ||
Down state is a Spectrum 2 (S2) feature that creates the illusion of components being pressed-in when active. This functionality is already included in S2 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: | ||
If the component is interactable at it's root level: | ||
- Add the `.spectrum-DownState` class to the root of the element that receives interactions. | ||
- Components with a width of 24px or less require the addition of the `.spectrum-DownState--min-perpsective` class next to the `.spectrum-DownState` class. | ||
- Develop an implementation to determine the width and height of the component. Assign this to the `--spectrum-downstate-width` and `--spectrum-downstate-height` custom properties in a `style` attribute on the HTML element. | ||
- If the interactable element has a width of 24px or less, we use the minimum perspective token: `transform: perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down));` | ||
- If the interactable element has a width that is greater than 24px, we use the max formula: `transform: perspective(max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down))) translateZ(var(--spectrum-component-size-difference-down));` | ||
- 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. | ||
If the component has an interactable element nested within it, this will require CSS changes: | ||
- Use the `%spectrum-DownState` or `%spectrum-DownState--min-perspective` placeholder on the interactable element when the root of the component is in an `:active` state. | ||
- Components with a width of 24px or less require the `%spectrum-DownState--min-perspective` placeholder instead. | ||
- Note that this functionality is included in S2 components that require down state in this project. This can be seen in the [checkbox component](/checkbox.html). | ||
examples: | ||
- id: downstate | ||
name: Down state - utility class | ||
- id: downstate-min | ||
name: Checkbox - less than 24px wide | ||
markup: | | ||
<div class="spectrum-Examples"> | ||
<button class="spectrum-DownState spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM" style="--spectrum-downstate-width: 72px; --spectrum-downstate-height: 32px;"> | ||
<div class="spectrum-Examples-item"> | ||
<h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">Default</h4> | ||
<label class="spectrum-Checkbox spectrum-Checkbox--sizeM"> | ||
<input type="checkbox" class="spectrum-Checkbox-input" id="checkbox-0"> | ||
<span class="spectrum-Checkbox-box"> | ||
<svg class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-css-icon-Checkmark100" /> | ||
</svg> | ||
<svg class="spectrum-Icon spectrum-UIIcon-Dash100 spectrum-Checkbox-partialCheckmark" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-css-icon-Dash100" /> | ||
</svg> | ||
</span> | ||
<span class="spectrum-Checkbox-label">Checkbox</span> | ||
</label> | ||
<br> | ||
<label class="spectrum-Checkbox spectrum-Checkbox--sizeM"> | ||
<input type="checkbox" class="spectrum-Checkbox-input" id="checkbox-1" checked> | ||
<span class="spectrum-Checkbox-box"> | ||
<svg class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-css-icon-Checkmark100" /> | ||
</svg> | ||
<svg class="spectrum-Icon spectrum-UIIcon-Dash100 spectrum-Checkbox-partialCheckmark" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-css-icon-Dash100" /> | ||
</svg> | ||
</span> | ||
<span class="spectrum-Checkbox-label">Checkbox</span> | ||
</label> | ||
<br> | ||
<label class="spectrum-Checkbox spectrum-Checkbox--sizeM is-indeterminate"> | ||
<input type="checkbox" class="spectrum-Checkbox-input" id="checkbox-2"> | ||
<span class="spectrum-Checkbox-box"> | ||
<svg class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-css-icon-Checkmark100" /> | ||
</svg> | ||
<svg class="spectrum-Icon spectrum-UIIcon-Dash100 spectrum-Checkbox-partialCheckmark" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-css-icon-Dash100" /> | ||
</svg> | ||
</span> | ||
<span class="spectrum-Checkbox-label">Checkbox</span> | ||
</label> | ||
</div> | ||
</div> | ||
- id: downstate | ||
name: Button - greater than 24px wide | ||
markup: | | ||
<div class="spectrum-Examples-item"> | ||
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM" style="--spectrum-downstate-width: 72px; --spectrum-downstate-height: 32px;"> | ||
<span class="spectrum-Button-label">Edit</span> | ||
</button> | ||
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM" style="--spectrum-downstate-width: 78px; --spectrum-downstate-height: 32px;"> | ||
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-icon-18-Edit" /> | ||
</svg> | ||
<span class="spectrum-Button-label">Edit</span> | ||
</button> | ||
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM spectrum-Button--iconOnly" aria-label="Edit" style="--spectrum-downstate-width: 34px; --spectrum-downstate-height: 34px;"> | ||
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true"> | ||
<use xlink:href="#spectrum-icon-18-Edit" /> | ||
</svg> | ||
</button> | ||
</div> |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.