2222 * SOFTWARE.
2323 */
2424
25- import { useState , memo , useCallback , useMemo , useRef } from 'react'
25+ import {
26+ useState ,
27+ memo ,
28+ useCallback ,
29+ useMemo ,
30+ useRef ,
31+ type SyntheticEvent
32+ } from 'react'
2633import type { ChangeEvent } from 'react'
2734
2835import { Heading } from '@instructure/ui-heading'
@@ -36,13 +43,26 @@ import {
3643} from '@instructure/ui-a11y-content'
3744import { Modal } from '@instructure/ui-modal'
3845import { SourceCodeEditor } from '@instructure/ui-source-code-editor'
39- import { LucideIcons , CustomIcons } from '@instructure/ui-icons'
46+ import {
47+ LucideIcons ,
48+ CustomIcons ,
49+ ParchmentGraphics ,
50+ ParchmentIcons ,
51+ ParchmentVectors
52+ } from '@instructure/ui-icons'
4053import { XInstUIIcon } from '@instructure/ui-icons'
4154import { Flex } from '@instructure/ui-flex'
55+ import { SimpleSelect } from '@instructure/ui-simple-select'
56+
57+ type OrgType = 'Instructure' | 'Parchment'
58+
59+ type IconCategory = 'Icons' | 'Graphics' | 'Vectors'
4260
4361type IconInfo = {
4462 name : string
4563 component : React . ComponentType < any >
64+ org : OrgType
65+ iconCategory ?: IconCategory
4666 importPath : string
4767}
4868
@@ -56,11 +76,34 @@ const allIcons: IconInfo[] = [
5676 ...Object . entries ( LucideIcons ) . map ( ( [ name , component ] ) => ( {
5777 name,
5878 component : component as React . ComponentType < any > ,
79+ org : 'Instructure' as OrgType ,
5980 importPath : '@instructure/ui-icons'
6081 } ) ) ,
6182 ...Object . entries ( CustomIcons ) . map ( ( [ name , component ] ) => ( {
6283 name,
6384 component : component as React . ComponentType < any > ,
85+ org : 'Instructure' as OrgType ,
86+ importPath : '@instructure/ui-icons'
87+ } ) ) ,
88+ ...Object . entries ( ParchmentGraphics ) . map ( ( [ name , component ] ) => ( {
89+ name,
90+ component : component as React . ComponentType < any > ,
91+ org : 'Parchment' as OrgType ,
92+ iconCategory : 'Graphics' ,
93+ importPath : '@instructure/ui-icons'
94+ } ) ) ,
95+ ...Object . entries ( ParchmentIcons ) . map ( ( [ name , component ] ) => ( {
96+ name,
97+ component : component as React . ComponentType < any > ,
98+ org : 'Parchment' as OrgType ,
99+ iconCategory : 'Icons' ,
100+ importPath : '@instructure/ui-icons'
101+ } ) ) ,
102+ ...Object . entries ( ParchmentVectors ) . map ( ( [ name , component ] ) => ( {
103+ name,
104+ component : component as React . ComponentType < any > ,
105+ org : 'Parchment' as OrgType ,
106+ iconCategory : 'Vectors' ,
64107 importPath : '@instructure/ui-icons'
65108 } ) )
66109]
@@ -156,7 +199,12 @@ const IconTile = memo(
156199IconTile . displayName = 'IconTile'
157200
158201const IconsGallery = ( ) => {
202+ const orgs = [ 'Instructure' , 'Parchment' ] as OrgType [ ]
159203 const [ searchQuery , setSearchQuery ] = useState < string > ( '' )
204+ const [ selectedOrg , setSelectedOrg ] = useState < OrgType > ( 'Instructure' )
205+ const [ selectedCategory , setSelectedCategory ] = useState <
206+ IconCategory | undefined
207+ > ( undefined )
160208 const [ selectedIcon , setSelectedIcon ] = useState < IconInfo | null > ( null )
161209 const [ rtl , setRtl ] = useState < boolean > ( false )
162210 const searchTimeoutId = useRef < ReturnType < typeof setTimeout > | null > ( null )
@@ -178,6 +226,26 @@ const IconsGallery = () => {
178226 } , 500 )
179227 }
180228
229+ const handleOrgChange = useCallback (
230+ ( _e : SyntheticEvent , { value } : { value ?: string | number } ) => {
231+ setSelectedOrg ( value as OrgType )
232+
233+ if ( value === 'Parchment' ) {
234+ setSelectedCategory ( 'Icons' )
235+ } else {
236+ setSelectedCategory ( undefined )
237+ }
238+ } ,
239+ [ ]
240+ )
241+
242+ const handleCategoryChange = useCallback (
243+ ( _e : SyntheticEvent , { value } : { value ?: string | number } ) => {
244+ setSelectedCategory ( value as IconCategory )
245+ } ,
246+ [ ]
247+ )
248+
181249 const handleBidirectionToggle = useCallback ( ( e : ChangeEvent < any > ) => {
182250 setRtl ( e . target . checked )
183251 } , [ ] )
@@ -191,10 +259,18 @@ const IconsGallery = () => {
191259 } , [ ] )
192260
193261 const filteredIcons = useMemo ( ( ) => {
194- if ( ! searchQuery ) return allIcons
195- const query = searchQuery . toLowerCase ( )
196- return allIcons . filter ( ( icon ) => icon . name . toLowerCase ( ) . includes ( query ) )
197- } , [ searchQuery ] )
262+ const iconsByOrgAndCategory = allIcons
263+ . filter ( ( icon ) => icon . org === selectedOrg )
264+ . filter (
265+ ( icon ) => ! selectedCategory || icon . iconCategory === selectedCategory
266+ )
267+
268+ return searchQuery
269+ ? iconsByOrgAndCategory . filter ( ( icon ) =>
270+ icon . name . toLowerCase ( ) . includes ( searchQuery . toLowerCase ( ) )
271+ )
272+ : iconsByOrgAndCategory
273+ } , [ searchQuery , selectedCategory , selectedOrg ] )
198274
199275 return (
200276 < div >
@@ -208,6 +284,17 @@ const IconsGallery = () => {
208284 onChange = { handleSearchChange }
209285 renderLabel = { < ScreenReaderContent > Icon Name</ ScreenReaderContent > }
210286 />
287+ < SimpleSelect
288+ name = "org-select"
289+ renderLabel = { < ScreenReaderContent > Icon Format</ ScreenReaderContent > }
290+ onChange = { handleOrgChange }
291+ >
292+ { orgs . map ( ( org ) => (
293+ < SimpleSelect . Option value = { org } id = { org } key = { org } >
294+ { `${ org } Icons` }
295+ </ SimpleSelect . Option >
296+ ) ) }
297+ </ SimpleSelect >
211298 < Checkbox
212299 label = {
213300 < AccessibleContent alt = "Render icons with right-to-left text direction" >
@@ -219,6 +306,30 @@ const IconsGallery = () => {
219306 onChange = { handleBidirectionToggle }
220307 />
221308 </ FormFieldGroup >
309+ { selectedOrg === 'Parchment' && (
310+ < >
311+ < br />
312+ < SimpleSelect
313+ name = "category-select"
314+ renderLabel = {
315+ < ScreenReaderContent >
316+ Icon Category (only for Parchment)
317+ </ ScreenReaderContent >
318+ }
319+ onChange = { handleCategoryChange }
320+ >
321+ { [ 'Icons' , 'Graphics' , 'Vectors' ] . map ( ( category ) => (
322+ < SimpleSelect . Option
323+ value = { category }
324+ id = { category }
325+ key = { category }
326+ >
327+ { category }
328+ </ SimpleSelect . Option >
329+ ) ) }
330+ </ SimpleSelect >
331+ </ >
332+ ) }
222333
223334 < div
224335 css = { {
0 commit comments