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

Implement deprecated block comment #1765

Merged
merged 14 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions icon.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
},
"minItems": 1,
"uniqueItems": true
},
"deprecated": {
"type": "boolean",
"default": false
}
},
"description": "A JSON Schema for icons defined by Lucide Icons."
Expand Down
3 changes: 2 additions & 1 deletion icons/chrome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"ericfennis"
Expand All @@ -11,4 +12,4 @@
"categories": [
"brands"
]
}
}
3 changes: 2 additions & 1 deletion icons/codepen.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"ericfennis"
Expand All @@ -11,4 +12,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/codesandbox.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -12,4 +13,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/dribbble.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"ahtohbi4",
"karsa-mistmere"
Expand All @@ -13,4 +14,4 @@
"social",
"design"
]
}
}
3 changes: 2 additions & 1 deletion icons/facebook.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -14,4 +15,4 @@
"social",
"brands"
]
}
}
3 changes: 2 additions & 1 deletion icons/figma.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -15,4 +16,4 @@
"brands",
"design"
]
}
}
3 changes: 2 additions & 1 deletion icons/framer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -15,4 +16,4 @@
"brands",
"design"
]
}
}
3 changes: 2 additions & 1 deletion icons/github.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -14,4 +15,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/gitlab.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -14,4 +15,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/instagram.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -15,4 +16,4 @@
"social",
"photography"
]
}
}
3 changes: 2 additions & 1 deletion icons/pocket.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -13,4 +14,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/slack.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"ashygee",
Expand All @@ -17,4 +18,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/trello.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"bdbch",
"csandman",
Expand All @@ -15,4 +16,4 @@
"brands",
"development"
]
}
}
3 changes: 2 additions & 1 deletion icons/twitch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"ahtohbi4",
"johnletey"
Expand All @@ -14,4 +15,4 @@
"account",
"gaming"
]
}
}
3 changes: 2 additions & 1 deletion icons/twitter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -15,4 +16,4 @@
"social",
"account"
]
}
}
3 changes: 2 additions & 1 deletion icons/youtube.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "../icon.schema.json",
"deprecated": true,
"contributors": [
"colebemis",
"csandman",
Expand All @@ -20,4 +21,4 @@
"text",
"brands"
]
}
}
26 changes: 22 additions & 4 deletions packages/lucide-angular/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
export default ({ componentName, children }) => `
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

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

return `\
import { LucideIconData } from './types';

/* eslint-disable no-shadow-restricted-names */
const ${componentName}: LucideIconData = ${JSON.stringify(children)};
/**
* @component @name ${componentName}
* @description Lucide SVG icon component, renders SVG Element with children.
*
* @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName}
* @see https://lucide.dev/guide/packages/lucide-vue-next - Documentation
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {FunctionalComponent} Vue component
* ${deprecated ? '@deprecated' : ''}
*/
const ${componentName}: LucideIconData = ${JSON.stringify(children)}; //eslint-disable-line no-shadow-restricted-names

export default ${componentName};
`;
`
};
21 changes: 20 additions & 1 deletion packages/lucide-preact/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
export default ({ componentName, children }) => `
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

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

return `
import createLucideIcon from '../createLucideIcon';

/**
* @component @name ${componentName}
* @description Lucide SVG icon component, renders SVG Element with children.
*
* @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName}
* @see https://lucide.dev/guide/packages/lucide-preact - Documentation
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {JSX.Element} JSX Element
* ${deprecated ? '@deprecated' : ''}
*/
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});

export default ${componentName};
`;
};
21 changes: 20 additions & 1 deletion packages/lucide-react-native/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
export default ({ componentName, children }) => `
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

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

return `
import createLucideIcon from '../createLucideIcon';

/**
* @component @name ${componentName}
* @description Lucide SVG icon component, renders SVG Element with children.
*
* @preview ![img](data:image/svg+xml;base64,${svgBase64}) - https://lucide.dev/icons/${iconName}
* @see https://lucide.dev/guide/packages/lucide-react-native - Documentation
*
* @param {Object} props - Lucide icons props and any valid SVG attribute
* @returns {JSX.Element} JSX Element
* ${deprecated ? '@deprecated' : ''}
*/
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});

export default ${componentName};
`;
};
19 changes: 6 additions & 13 deletions packages/lucide-react/scripts/exportTemplate.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
export default ({ componentName, iconName, children, getSvg }) => {
const svgContents = getSvg();

const svgBase64 = Buffer.from(
svgContents
.replace('\n', '')
.replace(
'stroke="currentColor"',
'stroke="#000" style="background-color: #fff; border-radius: 2px"',
),
).toString('base64');
/* eslint-disable import/no-extraneous-dependencies */
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';

// declarationFileContent += `\
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
const svgContents = getSvg();
const svgBase64 = base64SVG(svgContents);

return `
import createLucideIcon from '../createLucideIcon';
Expand All @@ -24,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' : ''}
*/
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});

Expand Down
4 changes: 2 additions & 2 deletions packages/lucide-react/scripts/getAliasesEntryNames.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'path';
// eslint-disable-next-line import/no-extraneous-dependencies
import getAliases from '@lucide/build-icons/utils/getAliases.mjs';
import getIconMetaData from '@lucide/build-icons/utils/getIconMetaData.mjs';

const ICONS_DIR = path.resolve(process.cwd(), '../../icons');

export default async function getAliasesEntryNames() {
const metaJsonFiles = await getAliases(ICONS_DIR);
const metaJsonFiles = await getIconMetaData(ICONS_DIR);

const iconWithAliases = Object.values(metaJsonFiles).filter(({ aliases }) => aliases != null);

Expand Down
6 changes: 4 additions & 2 deletions packages/lucide-react/src/createLucideIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export const toKebabCase = (string: string) =>

const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => {
const Component = forwardRef<SVGSVGElement, LucideProps>(
({ color = 'currentColor', size = 24, strokeWidth = 2, absoluteStrokeWidth, className = '', children, ...rest }, ref) =>
createElement(
({ color = 'currentColor', size = 24, strokeWidth = 2, absoluteStrokeWidth, className = '', children, ...rest }, ref) =>{

return createElement(
'svg',
{
ref,
Expand All @@ -53,6 +54,7 @@ const createLucideIcon = (iconName: string, iconNode: IconNode): LucideIcon => {
...(Array.isArray(children) ? children : [children]),
]
)
}
);

Component.displayName = `${iconName}`;
Expand Down
Loading