Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(icons): add deprecationReason and alias deprecation feature #1960

Merged
merged 21 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f8995ac
feat(icons): add deprecationReason and alias deprecation feature
Mar 8, 2024
b9ea801
chore(tools): run prettier. again.
Mar 8, 2024
e98b58d
Merge branch 'main' into feat/icon-alias-deprecation-reasons
Mar 8, 2024
1fedcfe
Merge branch 'main' into feat/icon-alias-deprecation-reasons
Mar 8, 2024
79989d4
Merge branch 'main' into feat/icon-alias-deprecation-reasons
Mar 8, 2024
d51aa9b
fix(scripts): overall alias as object support
Mar 8, 2024
3032134
fix(icon.schema.json): add dependentRequired on deprecated properties
Mar 8, 2024
ef86b03
fix(icon.schema.json): remove unicode for now
Mar 8, 2024
90903ce
fix(icon.schema.json): use const true for deprecated
Mar 8, 2024
d939863
fix(build): convert deprecation reason to enum
Mar 9, 2024
855861a
fix(build): fix linting of icon.schema.json
Mar 9, 2024
8a9136b
fix(build): renamed gracePeriod => toBeRemovedInVersion
Mar 9, 2024
bab4eb1
fix(build): fix aliases map in related icons generation
Mar 11, 2024
353faf4
fix(build): deprecate aliases using numbers
Mar 11, 2024
5a025ad
feat(icon-schema): separate deprecation reason enumerations, extract …
May 13, 2024
1aab12d
fix(icon-schema): fix linting
May 13, 2024
3640c35
Update tools/build-icons/utils/deprecationReasonTemplate.mjs
karsa-mistmere May 13, 2024
3d073e1
Merge branch 'main' into feat/icon-alias-deprecation-reasons
jguddas May 17, 2024
d693064
Merge branch 'main' into feat/icon-alias-deprecation-reasons
May 22, 2024
589e141
fix(icons): add deprecation reason to some more icons
May 22, 2024
2a3d796
fix(docs): fix linting issue
May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions icon.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,32 @@
"aliases": {
"type": "array",
"items": {
"type": "string"
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"deprecated": {
"const": true
},
"deprecationReason": {
"$ref": "#/$defs/deprecationReasons"
},
"gracePeriod": {
karsa-mistmere marked this conversation as resolved.
Show resolved Hide resolved
"$ref": "#/$defs/versionNumber",
"description": "The version this icon will be removed in."
}
},
"dependentRequired": {
"deprecated": ["deprecationReason", "gracePeriod"]
}
}
]
},
"uniqueItems": true
},
Expand Down Expand Up @@ -49,8 +74,27 @@
"uniqueItems": true
},
"deprecated": {
"type": "boolean",
"default": false
"const": true
},
"deprecationReason": {
"$ref": "#/$defs/deprecationReasons"
},
"gracePeriod": {
"$ref": "#/$defs/versionNumber",
"description": "The version this icon will be removed in."
}
},
"dependentRequired": {
"deprecated": ["deprecationReason", "gracePeriod"]
},
"$defs": {
"deprecationReasons": {
"type": "string",
"enum": ["icon.brand", "alias.typo"]
},
"versionNumber": {
"type": "string",
"pattern": "v[0-9]+(\\.[0-9]+)+"
}
},
"description": "A JSON Schema for icons defined by Lucide Icons."
Expand Down
7 changes: 6 additions & 1 deletion icons/between-horizontal-end.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"account"
],
"aliases": [
"between-horizonal-end"
{
"name": "between-horizonal-end",
"deprecated": true,
"deprecationReason": "alias.typo",
"gracePeriod": "v1.0"
}
]
}
7 changes: 6 additions & 1 deletion icons/between-horizontal-start.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"account"
],
"aliases": [
"between-horizonal-start"
{
"name": "between-horizonal-start",
"deprecated": true,
"deprecationReason": "alias.typo",
"gracePeriod": "v1.0"
}
]
}
2 changes: 2 additions & 0 deletions icons/chrome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"ericfennis"
Expand Down
2 changes: 2 additions & 0 deletions icons/codepen.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"ericfennis"
Expand Down
2 changes: 2 additions & 0 deletions icons/codesandbox.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/dribbble.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"ahtohbi4"
],
Expand Down
2 changes: 2 additions & 0 deletions icons/facebook.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/figma.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/framer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/github.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/gitlab.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/instagram.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/pocket.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
7 changes: 6 additions & 1 deletion icons/send-horizontal.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"connectivity"
],
"aliases": [
"send-horizonal"
{
"name": "send-horizonal",
"deprecated": true,
"deprecationReason": "alias.typo",
"gracePeriod": "v1.0"
}
]
}
2 changes: 2 additions & 0 deletions icons/slack.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"ashygee",
Expand Down
2 changes: 2 additions & 0 deletions icons/trello.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"bdbch",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/twitch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"ahtohbi4",
"johnletey"
Expand Down
2 changes: 2 additions & 0 deletions icons/twitter.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
2 changes: 2 additions & 0 deletions icons/youtube.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"deprecationReason": "icon.brand",
"gracePeriod": "v1.0",
"contributors": [
"colebemis",
"csandman",
Expand Down
4 changes: 2 additions & 2 deletions packages/lucide-angular/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

export default ({ componentName, iconName, children, getSvg, deprecated }) => {
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
const svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

Expand All @@ -17,7 +17,7 @@ import { LucideIconData } from './types';
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {FunctionalComponent} Vue component
* ${deprecated ? '@deprecated' : ''}
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
*/
const ${componentName}: LucideIconData = ${JSON.stringify(children)}; //eslint-disable-line no-shadow-restricted-names

Expand Down
4 changes: 2 additions & 2 deletions packages/lucide-preact/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

export default ({ componentName, iconName, children, getSvg, deprecated }) => {
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
const svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

Expand All @@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {JSX.Element} JSX Element
* ${deprecated ? '@deprecated' : ''}
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
*/
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});

Expand Down
4 changes: 2 additions & 2 deletions packages/lucide-react-native/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

export default ({ componentName, iconName, children, getSvg, deprecated }) => {
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
const svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

Expand All @@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {JSX.Element} JSX Element
* ${deprecated ? '@deprecated' : ''}
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
*/
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});

Expand Down
1 change: 0 additions & 1 deletion packages/lucide-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"copy:license": "cp ../../LICENSE ./LICENSE",
"clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.ts && rm -f dynamicIconImports.*",
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --renderUniqueKey --withAliases --withDynamicImports --separateAliasesFile --aliasesFileExtension=.ts --iconFileExtension=.ts --exportFileName=index.ts",
"build:types": "node ./scripts/buildTypes.mjs",
"build:bundles": "rollup -c ./rollup.config.mjs",
"typecheck": "tsc",
"typecheck:watch": "tsc -w",
Expand Down
4 changes: 2 additions & 2 deletions packages/lucide-react/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

export default ({ componentName, iconName, children, getSvg, deprecated }) => {
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
const svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

Expand All @@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {JSX.Element} JSX Element
* ${deprecated ? '@deprecated' : ''}
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
*/
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});

Expand Down
4 changes: 3 additions & 1 deletion packages/lucide-react/scripts/getAliasesEntryNames.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export default async function getAliasesEntryNames() {

const aliases = iconWithAliases.flatMap(({ aliases }) => aliases);

return aliases.map((alias) => path.join('src/icons', `${alias}.ts`));
return aliases
.map((alias) => (typeof alias === 'string' ? alias : alias.name))
.map((alias) => path.join('src/icons', `${alias}.ts`));
}
4 changes: 2 additions & 2 deletions packages/lucide-solid/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

export default ({ componentName, iconName, children, getSvg, deprecated }) => {
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
const svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

Expand All @@ -20,7 +20,7 @@ const iconNode: IconNode = ${JSON.stringify(children)};
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {JSX.Element} JSX Element
* ${deprecated ? '@deprecated' : ''}
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
*/
const ${componentName} = (props: LucideProps) => (
<Icon {...props} name="${componentName}" iconNode={iconNode} />
Expand Down
4 changes: 2 additions & 2 deletions packages/lucide-static/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

export default ({ componentName, iconName, children, getSvg, deprecated }) => {
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
let svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

Expand All @@ -21,7 +21,7 @@ export default ({ componentName, iconName, children, getSvg, deprecated }) => {
* @see https://lucide.dev/guide/packages/lucide-static - Documentation
*
* @returns {String}
* ${deprecated ? '@deprecated' : ''}
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
*/
const ${componentName}: string = \`\
${svgContents}\
Expand Down
Loading
Loading