-
-
Notifications
You must be signed in to change notification settings - Fork 533
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(lucide-svelte) : Set defaults props with Svelte Context API #1903
feat(lucide-svelte) : Set defaults props with Svelte Context API #1903
Conversation
Added named exports for easy context key management
@ericfennis why are you confused? |
Also see https://github.com/haruaki07/phosphor-svelte#context. Phosphor Icons has a similar feature. |
@lolcabanon yeah I understand the problem. But I need to think about this. We want to keep APIs similar with the other packages we have. So maybe we need to consider this for the other packages as well.. |
I have used I see 3 possibilities (there are probably more) :
|
lucide-svelte
) : Set defaults props with Svelte Context APIThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to merge this into the next
branch. This will be used in the future version of @lucide/svelte
What is the purpose of this pull request?
Description
I added the use of Svelte Context API to set default icons props. This allows to set default values in any part of the app.
The first commit uses
string
context keys. The last one exportsSymbol
context keys. I tend to prefer the last one, but I am open to suggestions on naming and architecture.WARNING :
I have not run the
build
orpackage
commands yet on this pull request. I just threw this up directly on GitHub, but I have tested the code directly in mynode_modules
and can attest it works as expected.I will do everything in order if you have any interest, including documentation for the
lucide-svelte
package. 😉Example :
Why ?
The global styling with CSS is not overridable (at least in Svelte!).
This means that setting a global CSS rule will overwrite the SVG attributes and ignore them.
Also, not being able to set default props values is not really DRY :
Before Submitting