@@ -26,14 +26,10 @@ import React, { forwardRef } from 'react'
2626import type { LucideIcon } from 'lucide-react'
2727import { useStyle , useTheme } from '@instructure/emotion'
2828import { px } from '@instructure/ui-utils'
29+ import type { Theme } from '@instructure/ui-themes'
2930
3031import generateStyle from './styles'
31- import generateComponentTheme from './theme'
32- import type {
33- LucideIconWrapperProps ,
34- InstUIIconProps ,
35- LucideIconTheme
36- } from './props'
32+ import type { LucideIconWrapperProps , InstUIIconProps } from './props'
3733
3834/**
3935 * Wraps a Lucide icon component with InstUI theming and RTL support.
@@ -121,9 +117,9 @@ export function wrapLucideIcon(Icon: LucideIcon): LucideIcon {
121117 ...rest
122118 } = props
123119
124- // Get theme to convert semantic sizes to pixels
125- const theme = useTheme ( )
126- const componentTheme = generateComponentTheme ( theme as any )
120+ // Get theme to access Icon component theme properties
121+ const theme = useTheme ( ) as Theme
122+ const iconTheme = themeOverride || theme ?. newTheme ?. components ?. Icon
127123
128124 // Determine if using InstUI semantic size or Lucide numeric size
129125 const isSemanticSize = typeof instUISize === 'string'
@@ -133,12 +129,14 @@ export function wrapLucideIcon(Icon: LucideIcon): LucideIcon {
133129 // Lucide doesn't inherit fontSize, so we need explicit pixel values
134130 let numericSize : number | undefined
135131 if ( isSemanticSize ) {
132+ // Map InstUI semantic sizes to Icon theme size properties
133+ // We map InstUI sizes to Icon theme sizes based on relative scale
136134 const sizeMap = {
137- 'x-small' : componentTheme . sizeXSmall ,
138- small : componentTheme . sizeSmall ,
139- medium : componentTheme . sizeMedium ,
140- large : componentTheme . sizeLarge ,
141- 'x-large' : componentTheme . sizeXLarge
135+ 'x-small' : iconTheme ?. sizeSm || '1rem' , // sizeSm (16px)
136+ small : iconTheme ?. sizeMd || '1.25rem' , // sizeMd (20px)
137+ medium : iconTheme ?. sizeLg || '1.5rem' , // sizeLg (24px)
138+ large : iconTheme ?. sizeXl || '2rem' , // sizeXl (32px)
139+ 'x-large' : iconTheme ?. size2xl || '2.25rem' // size2xl (36px)
142140 }
143141 const themeSizeValue = sizeMap [ instUISize as keyof typeof sizeMap ]
144142 // Use InstUI's px utility to convert rem/em to pixels
@@ -169,7 +167,6 @@ export function wrapLucideIcon(Icon: LucideIcon): LucideIcon {
169167 // Using useStyle hook for functional component theming
170168 const styles = useStyle ( {
171169 generateStyle,
172- generateComponentTheme,
173170 params : {
174171 size : semanticSize ,
175172 color : colorValue ,
@@ -178,7 +175,7 @@ export function wrapLucideIcon(Icon: LucideIcon): LucideIcon {
178175 inline,
179176 themeOverride
180177 } ,
181- componentId : 'LucideIcon ' ,
178+ componentId : 'Icon ' ,
182179 displayName : `LucideIcon(${ Icon . displayName || Icon . name } )`
183180 } )
184181
@@ -240,6 +237,5 @@ export function wrapLucideIcon(Icon: LucideIcon): LucideIcon {
240237 return WrappedIcon as LucideIcon
241238}
242239
243- export type { LucideIconWrapperProps , InstUIIconProps , LucideIconTheme }
244- export { default as generateComponentTheme } from './theme'
240+ export type { LucideIconWrapperProps , InstUIIconProps }
245241export { default as generateStyle } from './styles'
0 commit comments