Skip to content

Commit

Permalink
fix(pagination): deprecate legacy features to align with foundations
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe committed Dec 4, 2024
1 parent 24419a9 commit cdb180d
Show file tree
Hide file tree
Showing 97 changed files with 6,520 additions and 8,774 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ jobs:
files_yaml: |
styles:
- components/*/index.css
- components/*/themes/spectrum.css
- components/*/themes/express.css
- components/*/themes/*.css
eslint:
- components/*/stories/*.js
plugins:
Expand Down
22 changes: 3 additions & 19 deletions .storybook/decorators/context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeDecorator, useEffect } from "@storybook/preview-api";
import { fetchContainers, toggleStyles } from "./helpers.js";

import legacyTokens from "@spectrum-css/tokens-legacy/dist/index.css?inline";
import tokens from "@spectrum-css/tokens/dist/index.css?inline";

/**
Expand Down Expand Up @@ -48,8 +47,6 @@ export const withContextWrapper = makeDecorator({
const isTesting = testingPreview;
const isDocs = viewMode === "docs";
const isRaw = Boolean(context === "raw");
const isModern = Boolean(context === "spectrum");
const isExpress = Boolean(context === "express");

// Start by attaching the appropriate tokens to the container
toggleStyles(document.body, "tokens", tokens, !isRaw);
Expand All @@ -60,7 +57,7 @@ export const withContextWrapper = makeDecorator({
}

// Start by attaching the appropriate tokens to the container
toggleStyles(document.body, "tokens", isModern ? tokens : legacyTokens, !isRaw);
toggleStyles(document.body, "tokens", tokens, !isRaw);

for (const container of fetchContainers(id, isDocs, isTesting)) {
// Reset the context to the original values
Expand All @@ -85,19 +82,6 @@ export const withContextWrapper = makeDecorator({
// Every container gets the spectrum class
container.classList.toggle("spectrum", !isRaw);

// S1 and S1 Express get the legacy class
container.classList.toggle("spectrum--legacy", !isModern && !isRaw);

// Express only gets the express class
container.classList.toggle("spectrum--express", isExpress && !isRaw);

// Darkest is deprecated in Spectrum 2
if (isModern && color === "darkest") {
/* eslint-disable no-console -- notify that darkest was deprecated in S2 */
console.warn("The 'darkest' color is deprecated in Spectrum 2. Please use 'dark' instead.");
color = "dark";
}

// Let the static color override the color if it's set
if (hasStaticElement && staticColorSettings[staticKey]?.color) {
color = staticColorSettings[staticKey].color;
Expand All @@ -109,7 +93,7 @@ export const withContextWrapper = makeDecorator({
color = "light";
}

for (let c of ["light", "dark", "darkest"]) {
for (let c of ["light", "dark"]) {
container.classList.toggle(`spectrum--${c}`, c === color && !isRaw);
}

Expand All @@ -124,7 +108,7 @@ export const withContextWrapper = makeDecorator({
}
}

}, [context, viewMode, original, staticColor, color, scale, rootClass, tokens, legacyTokens, staticColorSettings, testingPreview]);
}, [context, viewMode, original, staticColor, color, scale, rootClass, tokens, staticColorSettings, testingPreview]);

return StoryFn(data);
},
Expand Down
422 changes: 264 additions & 158 deletions .storybook/guides/develop.mdx

Large diffs are not rendered by default.

35 changes: 13 additions & 22 deletions .storybook/modes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,22 @@
*/

const modes = {
"Light | LTR": {
color: "light",
textDirection: "ltr",
},
"Dark | RTL": {
color: "dark",
textDirection: "rtl",
},
"S1 | Light | LTR": {
context: "legacy",
color: "light",
textDirection: "ltr",
},
"Express | Light | LTR": {
context: "express",
color: "light",
textDirection: "ltr",
},
Light: {
color: "light",
},
Dark: {
color: "dark",
},
RTL: {
textDirection: "rtl",
},
};

export default modes;

export const disableDefaultModes = {
...Object.keys(modes).reduce((acc, key) => {
acc[key] = { disable: true };
return acc;
}, {}),
...Object.keys(modes).reduce((acc, key) => {
acc[key] = { disable: true };
return acc;
}, {}),
};
1 change: 0 additions & 1 deletion .storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@spectrum-css/button": "workspace:^",
"@spectrum-css/table": "workspace:^",
"@spectrum-css/tokens": "workspace:^",
"@spectrum-css/tokens-legacy": "npm:@spectrum-css/tokens@^14.6.0",
"@spectrum-css/typography": "workspace:^",
"@spectrum-css/ui-icons": "workspace:^",
"@spectrum-css/underlay": "workspace:^"
Expand Down
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const parameters = {
// Set an empty object to avoid the "undefined" value in the ComponentDetails doc block
packageJson: {},
// A list of published npm tags that should not appear in the ComponentDetails doc block
ignoredTags: ["beta", "next"],
ignoredTags: ["beta"],
};

export default {
Expand Down
3 changes: 0 additions & 3 deletions .storybook/types/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export default {
toolbar: {
items: [
{ value: "spectrum", title: "Spectrum 2", right: "default" },
{ value: "legacy", title: "Spectrum 1", right: "legacy" },
{ value: "express", title: "Express", right: "legacy" },
{ value: "raw", title: "Token-free", right: "raw" },
],
dynamicTitle: true,
Expand All @@ -30,7 +28,6 @@ export default {
items: [
{ value: "light", title: "Light", right: "default" },
{ value: "dark", title: "Dark" },
{ value: "darkest", title: "Darkest", right: "deprecated" },
],
dynamicTitle: true,
},
Expand Down
Loading

0 comments on commit cdb180d

Please sign in to comment.