mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-14 13:58:21 +00:00
feat(packages): extract build logic to @lucide/shared, still wip
This commit is contained in:
@@ -17,14 +17,15 @@
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"prebuild": "pnpm clean && pnpm copy:license && pnpm build:icons",
|
||||
"prebuild": "pnpm clean && pnpm copy:license && pnpm copy:utils && pnpm build:icons",
|
||||
"build": "pnpm prebuild && pnpm build:ng",
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE",
|
||||
"copy:utils": "mkdir -p ./src/utils && cp -f ../../packages/shared/src/build/buildLucideIconNode.ts ./src/utils/ && cp -f ../../packages/shared/src/build/types.ts ./src/utils/",
|
||||
"clean": "rm -rf dist && rm -rf ./src/icons/*.ts",
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mts --renderUniqueKey --iconFileExtension=.ts --exportFileName=lucide-angular.ts --useDefaultExports=0",
|
||||
"build:ng": "ng build --configuration production",
|
||||
"test": "pnpm build:icons && ng test --no-watch",
|
||||
"test:watch": "ng test",
|
||||
"test": "pnpm copy:utils && pnpm build:icons && ng test --no-watch",
|
||||
"test:watch": "pnpm copy:utils && ng test",
|
||||
"lint": "npx eslint 'src/**/*.{js,jsx,ts,tsx,html,css,scss}' --quiet --fix",
|
||||
"e2e": "ng e2e",
|
||||
"version": "pnpm version --git-tag-version=false"
|
||||
|
||||
@@ -12,6 +12,7 @@ import { LUCIDE_CONFIG } from './lucide-config';
|
||||
import { LucideIconData, Nullable } from './types';
|
||||
import defaultAttributes from './default-attributes';
|
||||
import { lucideIconTemplate } from './lucide-icon-template';
|
||||
import buildLucideIconNode from './utils/buildLucideIconNode';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -82,18 +83,27 @@ export abstract class LucideIconBase {
|
||||
const icon = this.icon();
|
||||
if (icon) {
|
||||
const absoluteStrokeWidth = this.absoluteStrokeWidth();
|
||||
const { name, node, aliases = [] } = icon;
|
||||
const classes = [name, ...aliases].map((item) => `lucide-${item}`);
|
||||
const [, iconAttributes, iconNode] = buildLucideIconNode(icon as any, {
|
||||
absoluteStrokeWidth,
|
||||
hasA11yProp: this.title() != null,
|
||||
});
|
||||
|
||||
const classes =
|
||||
typeof iconAttributes['class'] === 'string'
|
||||
? iconAttributes['class']
|
||||
.split(' ')
|
||||
.filter((cssClass) => cssClass && cssClass !== 'lucide')
|
||||
: [];
|
||||
|
||||
for (const cssClass of classes) {
|
||||
this.renderer.addClass(this.elRef.nativeElement, cssClass);
|
||||
}
|
||||
|
||||
const contentRef = this.contentRef();
|
||||
const refChild = contentRef.nativeElement;
|
||||
const elements = node.map(([name, attrs]) => {
|
||||
const elements = (iconNode ?? []).map(([name, attrs]) => {
|
||||
const element = this.renderer.createElement(name, 'http://www.w3.org/2000/svg');
|
||||
if (absoluteStrokeWidth) {
|
||||
this.renderer.setAttribute(element, 'vector-effect', 'non-scaling-stroke');
|
||||
}
|
||||
|
||||
Object.entries(attrs).forEach(([name, value]) =>
|
||||
this.renderer.setAttribute(
|
||||
element,
|
||||
|
||||
Reference in New Issue
Block a user