Skip to content

Commit 6453703

Browse files
committed
feat(many): extract raw svgs for cross-package use
extracted raw svgs into a new ui-icons-svg package and added as a dependency in ui-icons feat(ui-scripts,ui-icons,ui-icons-svg): added parchment assets added parchment icons, vectors and graphics retooled script bundling to support parchment asset categories extended demo app to conditionally render all icons by org extended demo app to conditionally render parchment icons by type refactor(ui-icons-svg): icons cleanup cleaned up now unused directory refactor(ui-scripts): typescript fix fix(github actions): pin chromaui/action to v11 ci(github actions): removed debugging change refactor(ui-scripts): rebase and add suffix Handled a complex rebase and added a ParchIcon suffix to Parchment Icons refactor(ui-scripts): pivot to prefix parchment icons will now prefix icons - no longer used as a suffix
1 parent 84f11c1 commit 6453703

1,504 files changed

Lines changed: 11180 additions & 27 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/__docs__/src/Icons/IconsGallery.tsx

Lines changed: 117 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
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'
2633
import type { ChangeEvent } from 'react'
2734

2835
import { Heading } from '@instructure/ui-heading'
@@ -36,13 +43,26 @@ import {
3643
} from '@instructure/ui-a11y-content'
3744
import { Modal } from '@instructure/ui-modal'
3845
import { 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'
4053
import { XInstUIIcon } from '@instructure/ui-icons'
4154
import { 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

4361
type 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(
156199
IconTile.displayName = 'IconTile'
157200

158201
const 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={{

packages/ui-icons-svg/README.md

Lines changed: 37 additions & 0 deletions

packages/ui-icons-svg/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@instructure/ui-icons-svg",
3+
"version": "11.7.2",
4+
"description": "Raw SVG source files for the Instructure UI icon set.",
5+
"author": "Instructure, Inc. Engineering and Product Design",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/instructure/instructure-ui.git"
9+
},
10+
"homepage": "https://instructure.github.io/instructure-ui/",
11+
"bugs": "https://github.com/instructure/instructure-ui/issues",
12+
"license": "MIT",
13+
"publishConfig": {
14+
"access": "public"
15+
},
16+
"files": [
17+
"svg"
18+
],
19+
"exports": {
20+
"./*": "./svg/*",
21+
"./package.json": "./package.json"
22+
}
23+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)