mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-12-02 16:49:06 +00:00
Allow string values for size and strokeWidth in icon contexts
The global icon context types declare `size` and `strokeWidth` as `number`,
while the component props they supply defaults for accept `number | string`.
The context value is passed through to the component untouched, so a CSS
length that works on a single icon is rejected when set as a default:
setLucideProps({ size: '1em' }); // Type 'string' is not assignable to 'number'
<Moon size="1em" /> // same value, same code path, no error
This commit is contained in:
@@ -2,9 +2,9 @@ import { createContext, h, type ComponentChildren } from 'preact';
|
||||
import { useContext, useMemo } from 'preact/hooks';
|
||||
|
||||
const LucideContext = createContext<{
|
||||
size?: number;
|
||||
size?: number | string;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
strokeWidth?: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
@@ -22,9 +22,9 @@ const LucideContext = createContext<{
|
||||
|
||||
interface LucideProviderProps {
|
||||
children: ComponentChildren;
|
||||
size?: number;
|
||||
size?: number | string;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
strokeWidth?: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
|
||||
@@ -4,9 +4,9 @@ import { createContext, createElement, type ReactNode, useContext, useMemo } fro
|
||||
import { LucideProps } from './types';
|
||||
|
||||
type LucideConfig = {
|
||||
size: number;
|
||||
size: number | string;
|
||||
color: string;
|
||||
strokeWidth: number;
|
||||
strokeWidth: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createContext, splitProps, type JSXElement } from 'solid-js';
|
||||
|
||||
export const LucideContext = createContext<{
|
||||
size?: number;
|
||||
size?: number | string;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
strokeWidth?: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
@@ -21,9 +21,9 @@ export const LucideContext = createContext<{
|
||||
|
||||
interface LucideProviderProps {
|
||||
children: JSXElement;
|
||||
size?: number;
|
||||
size?: number | string;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
strokeWidth?: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
|
||||
@@ -4,8 +4,8 @@ const LucideContext = Symbol('lucide-context');
|
||||
|
||||
export interface LucideGlobalContext {
|
||||
color?: string;
|
||||
size?: number;
|
||||
strokeWidth?: number;
|
||||
size?: number | string;
|
||||
strokeWidth?: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
|
||||
@@ -3,9 +3,9 @@ import { provide, inject } from 'vue';
|
||||
export const LUCIDE_CONTEXT = Symbol('lucide-icons');
|
||||
|
||||
interface LucideIconsContext {
|
||||
size?: number;
|
||||
size?: number | string;
|
||||
color?: string;
|
||||
strokeWidth?: number;
|
||||
strokeWidth?: number | string;
|
||||
/**
|
||||
* @deprecated Use `nonScalingStroke` instead.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user