Skip to content

Commit c7dec77

Browse files
committed
feat: remove modifiers from the API [SWC-1264]
1 parent 857bd63 commit c7dec77

File tree

200 files changed

+3766
-5999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+3766
-5999
lines changed

.changeset/weak-colts-divide.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"@spectrum-css/assetlist": major
66
"@spectrum-css/avatar": major
77
"@spectrum-css/badge": major
8+
"@spectrum-css/breadcrumb": major
9+
"@spectrum-css/divider": major
810
"@spectrum-css/miller": major
9-
"@spectrum-css/well": major
1011
"@spectrum-css/page": major
12+
"@spectrum-css/well": major
1113
---
1214

1315
This update removes `--mod-*` custom property hooks per SWC-1264, see also the RFC for extensible styling. In addition, this update cleans up any component-level custom properties that did not rely on the CSS cascade to define the styles; this was done to reduce the number of custom properties that are defined at the component level and trim down the size of the CSS we are shipping to consumers.

.storybook/blocks/ColorPalette.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const ColorItem = ({ title, color, size = 60, values = [], noCheckerboard
5252
<SwatchSet
5353
className="swatch-set"
5454
key={`${color}-${value}`}
55-
style={{ "--mod-swatch-size": `${size}px` }}
55+
style={{ "--spectrum-swatch-size": `${size}px` }}
5656
>
5757
<Body className="swatch-label" size="s">
5858
{value}

.storybook/blocks/PropertiesTable.jsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import React, { useContext } from 'react';
44
import { Table } from "./Layouts.jsx";
55
import { ThemeContainer } from "./ThemeContainer.jsx";
66
import { Body, Code, LinkableHeading } from "./Typography.jsx";
7-
import styles from "@spectrum-css/bundle/dist/index.module.css";
87

98
/**
109
* Displays the modifiable custom properties for a component based on the metadata provided in the story.
1110
* The story metadata object is imported from the "metadata.json" file in the component's directory.
1211
*
13-
* If the metadata object does not contain a "modifiers" array, this component will not render.
12+
* If the metadata object does not contain a "component" array, this component will not render.
1413
*
1514
* Usage of this doc block within MDX template(s):
1615
* <PropertiesTable />
@@ -23,26 +22,28 @@ export const PropertiesTable = () => {
2322
const metadata = storyMeta?.csfFile?.meta?.parameters?.metadata ?? {};
2423

2524
if (!packageJson?.name) return;
26-
if (!metadata?.modifiers || !metadata?.modifiers.length) return;
25+
if (!metadata?.component || !metadata?.component.length) return;
2726

2827
return (
2928
<ThemeContainer color="light" display="contents">
30-
<LinkableHeading id="modifiable-properties" size="m">
31-
<a aria-hidden="true" href="#modifiable-properties" tabIndex="-1" target="_self" onClick={() => {
32-
context.channel.emit(NAVIGATE_URL, "#modifiable-properties");
33-
}}></a>
34-
Modifiable custom properties
29+
<LinkableHeading id="custom-properties" size="m">
30+
<a
31+
aria-hidden="true"
32+
href="#custom-properties"
33+
tabIndex="-1"
34+
target="_self"
35+
onClick={() => {
36+
context.channel.emit(NAVIGATE_URL, "#custom-properties");
37+
}}
38+
></a>
39+
Custom properties
3540
</LinkableHeading>
36-
<Body>
37-
These are empty CSS custom property hooks available in this component
38-
that enable one-off customizations specific to a product implementation.
39-
</Body>
4041
<Table
4142
headers={["Property"]}
42-
rows={metadata?.modifiers.map((propertyName) => [
43+
rows={metadata?.component.map((propertyName) => [
4344
<Code backgroundColor={"transparent"} size="s">
4445
{propertyName}
45-
</Code>
46+
</Code>,
4647
])}
4748
/>
4849
</ThemeContainer>

.storybook/foundations/drop-shadow/index.css

Lines changed: 27 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,106 +10,77 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212

13-
/* stylelint-disable spectrum-tools/no-unknown-custom-properties */
14-
1513
.spectrum-Foundations-Example-DropShadow-swatch {
16-
block-size: 150px;
17-
inline-size: 150px;
18-
background-color: var(--spectrum-gray-25);
19-
border-radius: var(--spectrum-corner-radius-large-default);
20-
border: transparent;
14+
block-size: 150px;
15+
inline-size: 150px;
16+
background-color: var(--spectrum-gray-25);
17+
border-radius: var(--spectrum-corner-radius-large-default);
18+
border: transparent;
2119
}
2220

2321
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch {
24-
background-color: var(--spectrum-gray-75); /* matches dark mode design spec rgb(34, 34, 34) */
22+
background-color: var(--spectrum-gray-75); /* matches dark mode design spec rgb(34, 34, 34) */
2523
}
2624

2725
.spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-box-shadow {
28-
box-shadow:
29-
var(--spectrum-drop-shadow-emphasized-default-x)
30-
var(--spectrum-drop-shadow-emphasized-default-y)
31-
var(--spectrum-drop-shadow-emphasized-default-blur)
32-
var(--mod-drop-shadow-emphasized-default-color, var(--spectrum-drop-shadow-emphasized-default-color));
26+
box-shadow: var(--spectrum-drop-shadow-emphasized-default-x) var(--spectrum-drop-shadow-emphasized-default-y) var(--spectrum-drop-shadow-emphasized-default-blur) var(--spectrum-drop-shadow-emphasized-default-color);
3327
}
3428

3529
.spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-drop-shadow {
36-
filter: drop-shadow(
37-
var(--spectrum-drop-shadow-emphasized-default-x)
38-
var(--spectrum-drop-shadow-emphasized-default-y)
39-
calc(var(--spectrum-drop-shadow-emphasized-default-blur) / 2) /* adjust blur by half of box-shadow */
40-
var(--mod-drop-shadow-emphasized-default-color, var(--spectrum-drop-shadow-emphasized-default-color))
41-
);
30+
filter: drop-shadow(var(--spectrum-drop-shadow-emphasized-default-x) var(--spectrum-drop-shadow-emphasized-default-y) calc(var(--spectrum-drop-shadow-emphasized-default-blur) / 2) /* adjust blur by half of box-shadow */ var(--spectrum-drop-shadow-emphasized-default-color));
4231
}
4332

4433
.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-box-shadow,
4534
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-box-shadow,
4635
.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-drop-shadow,
4736
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-drop-shadow {
48-
/* adjustment because color tokens do not work properly on foundations pages */
49-
--mod-drop-shadow-emphasized-default-color: var(--spectrum-drop-shadow-color-100);
37+
/* adjustment because color tokens do not work properly on foundations pages */
38+
--spectrum-drop-shadow-emphasized-default-color: var(--spectrum-drop-shadow-color-100);
5039
}
5140

5241
.spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-box-shadow {
53-
box-shadow:
54-
var(--spectrum-drop-shadow-emphasized-hover-x)
55-
var(--spectrum-drop-shadow-emphasized-hover-y)
56-
var(--spectrum-drop-shadow-emphasized-hover-blur)
57-
var(--mod-drop-shadow-emphasized-hover-color, var(--spectrum-drop-shadow-emphasized-hover-color));
42+
box-shadow: var(--spectrum-drop-shadow-emphasized-hover-x) var(--spectrum-drop-shadow-emphasized-hover-y) var(--spectrum-drop-shadow-emphasized-hover-blur) var(--spectrum-drop-shadow-emphasized-hover-color);
5843
}
5944

6045
.spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-drop-shadow {
61-
filter: drop-shadow(
62-
var(--spectrum-drop-shadow-emphasized-hover-x)
63-
var(--spectrum-drop-shadow-emphasized-hover-y)
64-
calc(var(--spectrum-drop-shadow-emphasized-hover-blur) / 2) /* adjust blur by half of box-shadow */
65-
var(--mod-drop-shadow-emphasized-hover-color, var(--spectrum-drop-shadow-emphasized-hover-color))
66-
);
46+
filter: drop-shadow(var(--spectrum-drop-shadow-emphasized-hover-x) var(--spectrum-drop-shadow-emphasized-hover-y) calc(var(--spectrum-drop-shadow-emphasized-hover-blur) / 2) /* adjust blur by half of box-shadow */ var(--spectrum-drop-shadow-emphasized-hover-color));
6747
}
6848

6949
.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-drop-shadow,
7050
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-drop-shadow,
7151
.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-box-shadow,
7252
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-box-shadow {
73-
/* adjustment because color tokens do not work properly on foundations pages */
74-
--mod-drop-shadow-emphasized-hover-color: var(--spectrum-drop-shadow-color-200);
53+
/* adjustment because color tokens do not work properly on foundations pages */
54+
--spectrum-drop-shadow-emphasized-hover-color: var(--spectrum-drop-shadow-color-200);
7555
}
7656

7757
.spectrum-Foundations-Example-DropShadow-swatch--elevated-box-shadow {
78-
box-shadow:
79-
var(--spectrum-drop-shadow-elevated-x)
80-
var(--spectrum-drop-shadow-elevated-y)
81-
var(--spectrum-drop-shadow-elevated-blur)
82-
var(--mod-drop-shadow-elevated-color, var(--spectrum-drop-shadow-elevated-color));
58+
box-shadow: var(--spectrum-drop-shadow-elevated-x) var(--spectrum-drop-shadow-elevated-y) var(--spectrum-drop-shadow-elevated-blur) var(--spectrum-drop-shadow-elevated-color);
8359
}
8460

8561
.spectrum-Foundations-Example-DropShadow-swatch--elevated-drop-shadow {
86-
filter: drop-shadow(
87-
var(--spectrum-drop-shadow-elevated-x)
88-
var(--spectrum-drop-shadow-elevated-y)
89-
calc(var(--spectrum-drop-shadow-elevated-blur) / 2) /* adjust blur by half of box-shadow */
90-
var(--mod-drop-shadow-elevated-color, var(--spectrum-drop-shadow-elevated-color))
91-
);
62+
filter: drop-shadow(var(--spectrum-drop-shadow-elevated-x) var(--spectrum-drop-shadow-elevated-y) calc(var(--spectrum-drop-shadow-elevated-blur) / 2) /* adjust blur by half of box-shadow */ var(--spectrum-drop-shadow-elevated-color));
9263
}
9364

9465
.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--elevated-drop-shadow,
9566
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--elevated-drop-shadow,
9667
.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--elevated-box-shadow,
9768
.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--elevated-box-shadow {
98-
/* adjustment because color tokens do not work properly on foundations pages */
99-
--mod-drop-shadow-elevated-color: var(--spectrum-drop-shadow-color-200);
69+
/* adjustment because color tokens do not work properly on foundations pages */
70+
--spectrum-drop-shadow-elevated-color: var(--spectrum-drop-shadow-color-200);
10071
}
10172

10273
.spectrum-Foundations-Example-swatch-container {
103-
background-color: var(--spectrum-gray-25);
104-
block-size: 200px;
105-
inline-size: 300px;
106-
display: flex;
107-
align-items: center;
108-
justify-content: center;
74+
background-color: var(--spectrum-gray-25);
75+
block-size: 200px;
76+
inline-size: 300px;
77+
display: flex;
78+
align-items: center;
79+
justify-content: center;
10980
}
11081

11182
.spectrum-Foundations-Example-variant-container {
112-
background-color: var(--spectrum-gray-25);
113-
display: flex;
114-
flex-direction: row;
83+
background-color: var(--spectrum-gray-25);
84+
display: flex;
85+
flex-direction: row;
11586
}

.storybook/guides/releasing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Meta, Title } from "@storybook/blocks";
88

99
This project versions components independently, meaning each component has its own version number, updated independently of other components. We follow [semantic versioning](https://semver.org/) and as such, each release is versioned according to the following rules:
1010

11-
- **Major**: Breaking changes such as API changes, the removal of features, or changes to `--mod` custom properties
11+
- **Major**: Breaking changes such as API changes or the removal of features
1212
- **Minor**: New features or enhancements
1313
- **Patch**: Bug fixes or minor improvements
1414

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<h1 align="center">Spectrum CSS</h1>
88
<h3 align="center">A CSS-implementation of the Spectrum design language</h3>
99

10-
<img src=".storybook/assets/images/spectrum-css_illustration_desktop.png">
10+
<img src=".storybook/assets/images/spectrum-css_illustration_desktop.png" alt="Spectrum CSS illustration" />
1111

1212
## Features
1313

@@ -16,7 +16,7 @@
1616
- 🧪 **Rigorously tested**: These individually-versioned components have been vetted to be accessible and inclusive of global audiences.
1717
- 📱 **Multi-platform support**: We support [evergreen browsers](https://github.com/adobe/spectrum-css?tab=readme-ov-file#browser-support) for scalability and flexibility.
1818

19-
&nbsp;&nbsp;&nbsp;&nbsp; [<img src="https://img.shields.io/badge/Get%20started-F0F0F0?style=for-the-badge&logo=adobe&logoColor=%23FF0000"/>](https://opensource.adobe.com/spectrum-css/get-started.html) &nbsp; [<img src="https://img.shields.io/badge/Storybook-F0F0F0?style=for-the-badge&logo=storybook&logoColor=%23FF4785"/>](https://opensource.adobe.com/spectrum-css/)
19+
&nbsp;&nbsp;&nbsp;&nbsp; [<img src="https://img.shields.io/badge/Get%20started-F0F0F0?style=for-the-badge&logo=adobe&logoColor=%23FF0000" alt="Get started" />](https://opensource.adobe.com/spectrum-css/get-started.html) &nbsp; [<img src="https://img.shields.io/badge/Storybook-F0F0F0?style=for-the-badge&logo=storybook&logoColor=%23FF4785" alt="Storybook" />](https://opensource.adobe.com/spectrum-css/)
2020

2121
## Using Spectrum CSS
2222

@@ -44,13 +44,13 @@ yarn add -DW @spectrum-css/tokens @spectrum-css/typography @spectrum-css/page @s
4444

4545
Installed components will be available in the `node_modules/@spectrum-css/` folder of your project.
4646

47-
All components in this library have a peer dependency on [`@spectrum-css/tokens`](tokens), which is a local package that serves up the [Spectrum design tokens](https://github.com/adobe/spectrum-tokens) as CSS custom properties (via [Style dictionary](https://amzn.github.io/style-dictionary/#/)). These custom properties are leveraged in all components to create a cohesive visual language and to allow for easy theming. If you choose not to use the provided `@spectrum-css/tokens` package, you must define your own custom properties or your components will render with a significant number of missing styles. When overriding certain styles is necessary, modifying styles is supported through the use of component-specific `--mod` prefixed properties. [More on this below](https://github.com/adobe/spectrum-css?tab=readme-ov-file#modifying-components).
47+
All components in this library have a peer dependency on [`@spectrum-css/tokens`](tokens), which is a local package that serves up the [Spectrum design tokens](https://github.com/adobe/spectrum-tokens) as CSS custom properties (via [Style dictionary](https://amzn.github.io/style-dictionary/#/)). These custom properties are leveraged in all components to create a cohesive visual language and to allow for easy theming. If you choose not to use the provided `@spectrum-css/tokens` package, you must define your own custom properties or your components will render with a significant number of missing styles.
4848

4949
### Using components in your project
5050

5151
Spectrum CSS components have build output that is designed to be used in a variety of ways:
5252

53-
- `index.css` - _Preferred and most commonly used to incorporate Spectrum CSS into a project_. This file includes the component's styles and variable definitions. In this version, token-driven CSS properties<sup>[1](#token-footnote)</sup> are mapped to empty `--mod` prefixed variables (for customization) with a fallback to variables prefixed with `--spectrum` (sourced from the design tokens).
53+
- `index.css` - _Preferred and most commonly used to incorporate Spectrum CSS into a project_. This file includes the component's styles and variable definitions. In this version, component-specific custom properties<sup>[1](#token-footnote)</sup> are mapped to variables sourced from the design tokens.
5454

5555
<sup><a name="token-footnote">1</a></sup>: Token-driven CSS properties are properties whose values are mapped to a value in the `@spectrum-css/tokens` package. These values represent design-language and are meant to be used across platforms. In contrast, properties specific to web-based implementations will not have a token value assigned, so not all CSS properties will use custom properties.
5656

@@ -104,10 +104,6 @@ Put together, we would define the context for our application in the following w
104104

105105
Because CSS custom properties honor the cascading nature of CSS, you can infinitely nest different contexts. For example, you could have a `.spectrum--dark` context inside of a `.spectrum--light` context, and components will honor the innermost context.
106106

107-
### Modifying components
108-
109-
You can override variables and modify Spectrum CSS' look and feel by re-defining the custom properties in context. Look for the **Custom Property API** section in each component to determine which custom properties you can override. See [Action Button for a complete example](https://opensource.adobe.com/spectrum-css/actionbutton.html#custompropertiesapi).
110-
111107
### Importing UI icons
112108

113109
Some components require certain "UI icons" to render. These icons are released within the [`@spectrum-css/ui-icons`](https://www.npmjs.com/package/@spectrum-css/ui-icons) package and are used by components like `@spectrum-css/icon` and `@spectrum-css/actionbutton`.

components/accordion/dist/metadata.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
".spectrum-Accordion:lang(ko)",
3838
".spectrum-Accordion:lang(zh)"
3939
],
40-
"modifiers": [],
4140
"component": [
4241
"--spectrum-accordion-animation-duration",
4342
"--spectrum-accordion-background-color-default",

components/actionbar/dist/metadata.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
".spectrum-ActionBar--sticky",
1616
".spectrum-ActionBar.is-open"
1717
],
18-
"modifiers": [],
1918
"component": [
2019
"--spectrum-action-bar-border-color",
2120
"--spectrum-action-bar-bottom-to-content-area",

0 commit comments

Comments
 (0)