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

Build d.ts for use in typescript #277

Merged
merged 38 commits into from
Apr 5, 2021
Merged

Build d.ts for use in typescript #277

merged 38 commits into from
Apr 5, 2021

Conversation

SMAH1
Copy link
Contributor

@SMAH1 SMAH1 commented Mar 31, 2021

How to use

in html file:

  <div id="ico"></div>
  <i icon-lucide="menu"></i>
  <i icon-lucide="circle"></i>

in ts file:

import { createIcons, createElement, Menu, ArrowRight, Circle, icons } from 'lucide';
...
const svg = createElement(ArrowRight);
svg.setAttribute('color', 'red');

const elm = document.getElementById('ico');
elm?.appendChild(svg);

createIcons({
  icons: { Menu, Circle },
  attrs: {
    fill: 'green',
    stroke: 'blue',
    'stroke-width': 5
  },
  nameAttr: 'icon-lucide'
});

and for use all icons:

...
icons: icons,
...

I test it in Angular App and without app (typescript + webpack)

@vercel
Copy link

vercel bot commented Mar 31, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/lucide/lucide/ECoAj4NgQAR1XvXTZK1umDQwbGx5
✅ Preview: Canceled

[Deployment for 9ca395c canceled]

@ericfennis
Copy link
Member

@SMAH1 Thank you very much, very nice work!
I will test it, I will let you know if I found some issues.

Copy link
Member

@ericfennis ericfennis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of days ago I tried to fix this issue as well.
I came with this solution.

The attrs object you can pass in the createIcon function is also able to use other attributes then the attributes we commonly use in our icons. See comment at the createIconsOptions type.

The icons data is for this package is a bit different then we use for the framework packages.
We use: [tag, attrs, children] for the icons, in framework packages: [iconName, children], I tried to make it the same but for createElement we use an recursive function to render the svgs, so it was not possible to use the [iconName, children] format.

I'm curious what think of the additions what I made.

packages/lucide/scripts/buildTypes.js Show resolved Hide resolved
packages/lucide/scripts/buildTypes.js Outdated Show resolved Hide resolved
packages/lucide/scripts/buildTypes.js Outdated Show resolved Hide resolved
packages/lucide/scripts/buildTypes.js Outdated Show resolved Hide resolved
packages/lucide/scripts/buildTypes.js Outdated Show resolved Hide resolved
packages/lucide/scripts/buildTypes.js Outdated Show resolved Hide resolved
packages/lucide/scripts/buildTypes.js Outdated Show resolved Hide resolved
@SMAH1
Copy link
Contributor Author

SMAH1 commented Apr 3, 2021

And change export type Icons = { [key: string]: IconData } to export type Icons = { [key: string]: IconNode }.
I test it. it work but I think we need two items IconData and IconNode for show correct structure of icon data.
for example:

Activity = ['svg', defaultAttributes, [['polyline', {
    points: '22 12 18 12 15 21 9 3 6 12 2 12'
  }]]];

define three sections: 1) string, 2) defaultAttributes, 3) Array of data that is not same three sections

@ericfennis
Copy link
Member

@SMAH1 Nice work. Can you maybe remove the code for the angular-package. I makes it easier to review the code.

@ericfennis ericfennis merged commit c7fc71a into lucide-icons:master Apr 5, 2021
@SMAH1
Copy link
Contributor Author

SMAH1 commented Apr 12, 2021

I test release 0.15.1. It is fine.

realguse pushed a commit to realguse/lucide that referenced this pull request Dec 25, 2024
* Add lucide-angular

* Build d.ts for use in typescript

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

Co-authored-by: Eric Fennis <[email protected]>

* Update packages/lucide/scripts/buildTypes.js

* Update package.json

* Update package.json

* Delete .gitignore

* Delete angular.json

* Delete package.json

* Delete README.md

* Delete default-attributes.ts

* Delete icons-index.ts

* Delete package.json

* Delete karma.conf.js

* Delete lucide.ts

* Delete ng-package.json

* Delete package.json

* Delete lib-index.ts

* Delete icons.provider.ts

* Delete lucide-angular.component.spec.ts

* Delete lucide-angular.component.ts

* Delete lucide-angular.module.ts

* Delete test.ts

* Delete tsconfig.lib.json

* Delete tsconfig.lib.prod.json

* Delete tsconfig.spec.json

* Delete tslint.json

* Delete buildIconsIndex.js

* Delete exportTemplate.js

* Delete tsconfig.json

* Delete tslint.json

* Update buildTypes.js

Pretty code

Co-authored-by: Eric Fennis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants