From 0c01a66627bbc46b459bda7680c6dcb9ea9c1b66 Mon Sep 17 00:00:00 2001 From: Rajdeep Chandra Date: Fri, 15 Mar 2024 17:42:41 +0530 Subject: [PATCH] fix(theme): deprecate lightest and darkest color stops (#4179) * chore: deprecation warning for color lightest and darkest * chore: updated deprecationNotice to include package name instead of component --------- Co-authored-by: Rajdeep Chandra Co-authored-by: Rajdeep Chandra --- packages/banner/package.json | 2 +- packages/quick-actions/package.json | 2 +- packages/split-button/package.json | 2 +- .../_includes/partials/deprecation.njk | 3 +-- .../scripts/copy-component-docs.js | 22 +++++++++---------- tools/theme/package.json | 1 + tools/theme/src/Theme.ts | 8 +++++++ 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/packages/banner/package.json b/packages/banner/package.json index 708493fd3f..12d5f62026 100644 --- a/packages/banner/package.json +++ b/packages/banner/package.json @@ -64,7 +64,7 @@ }, "types": "./src/index.d.ts", "customElements": "custom-elements.json", - "deprecationNotice": "Banner is deprecated and it will be removed in the future release.", + "deprecationNotice": "@spectrum-web-components/banner is deprecated and it will be removed in the future release.", "sideEffects": [ "./sp-*.js", "./**/*.dev.js" diff --git a/packages/quick-actions/package.json b/packages/quick-actions/package.json index c5f64d6233..6eea1fdf5c 100644 --- a/packages/quick-actions/package.json +++ b/packages/quick-actions/package.json @@ -64,7 +64,7 @@ }, "types": "./src/index.d.ts", "customElements": "custom-elements.json", - "deprecationNotice": "Quick Actions is deprecated. Use an Action bar to allow users to perform actions on either a single or multiple items at the same time, instead.", + "deprecationNotice": "@spectrum-web-components/quick-actions is deprecated. Use an Action bar to allow users to perform actions on either a single or multiple items at the same time, instead.", "sideEffects": [ "./sp-*.js", "./**/*.dev.js" diff --git a/packages/split-button/package.json b/packages/split-button/package.json index b1ef92c3ea..341e9db612 100644 --- a/packages/split-button/package.json +++ b/packages/split-button/package.json @@ -76,7 +76,7 @@ }, "types": "./src/index.d.ts", "customElements": "custom-elements.json", - "deprecationNotice": "Split Button is deprecated. Use a button group to show any additional actions related to the most critical action. Reference Spectrum documentation for more information.", + "deprecationNotice": "@spectrum-web-components/split-button is deprecated. Use a button group to show any additional actions related to the most critical action. Refer Spectrum documentation for more information.", "sideEffects": [ "./sp-*.js", "./**/*.dev.js", diff --git a/projects/documentation/content/_includes/partials/deprecation.njk b/projects/documentation/content/_includes/partials/deprecation.njk index 8edaef392c..8a01055463 100644 --- a/projects/documentation/content/_includes/partials/deprecation.njk +++ b/projects/documentation/content/_includes/partials/deprecation.njk @@ -3,11 +3,10 @@ >
- Deprecated component + Deprecation Warning
- This component has been deprecated.

{{ deprecationNotice | safe }}
diff --git a/projects/documentation/scripts/copy-component-docs.js b/projects/documentation/scripts/copy-component-docs.js index 94fc9cf3a5..714cae69d9 100644 --- a/projects/documentation/scripts/copy-component-docs.js +++ b/projects/documentation/scripts/copy-component-docs.js @@ -58,12 +58,14 @@ const findDeclaration = (customElements, test) => { }; const findDeprecationNotice = async function (filePath) { - const hasDeprecation = fs.existsSync(filePath); - if (hasDeprecation) { - const packageJSON = await import(filePath, { - assert: { type: 'json' }, - }).then((packageDefault) => packageDefault.default); - return packageJSON.deprecationNotice; + for await (const mdPath of globby.stream(filePath)) { + const hasDeprecation = fs.existsSync(mdPath); + if (hasDeprecation) { + const packageJSON = await import(mdPath, { + assert: { type: 'json' }, + }).then((packageDefault) => packageDefault.default); + return packageJSON.deprecationNotice; + } } }; @@ -184,12 +186,7 @@ export async function processREADME(mdPath) { ) ); const deprecationNotice = await findDeprecationNotice( - path.resolve( - __dirname, - '../../../packages', - packageName, - 'package.json' - ) + `${projectDir}/(packages|tools)/${packageName}/package.json` ); const hasTemplate = fs.existsSync( path.resolve( @@ -211,6 +208,7 @@ export async function processREADME(mdPath) { hasDemoControls: ${hasArgs}, hasDemoTemplate: ${hasTemplate}, deprecationNotice: ${JSON.stringify(deprecationNotice)}, + isComponent: ${isComponent}, ${hasArgs ? 'demoControls: Object.values(argTypes),' : ''} }; `; diff --git a/tools/theme/package.json b/tools/theme/package.json index b9728ba2ab..948bd11c93 100644 --- a/tools/theme/package.json +++ b/tools/theme/package.json @@ -138,6 +138,7 @@ }, "types": "./src/index.d.ts", "customElements": "custom-elements.json", + "deprecationNotice": "Color Lightest and Darkest are deprecated and will be removed in a future release", "sideEffects": [ "./sp-*.js", "./**/*.dev.js", diff --git a/tools/theme/src/Theme.ts b/tools/theme/src/Theme.ts index f3d773b0d3..1afebaa1c9 100644 --- a/tools/theme/src/Theme.ts +++ b/tools/theme/src/Theme.ts @@ -342,6 +342,14 @@ export class Theme extends HTMLElement implements ThemeKindProvider { } ); } + if (['lightest', 'darkest'].includes(this.color)) { + window.__swc.warn( + this, + `Color lightest and darkest are deprecated and will be removed in a future release`, + 'https://opensource.adobe.com/spectrum-web-components/tools/themes/#deprecation', + { level: 'deprecation' } + ); + } } return [...styles]; }