@leafygreen-ui/icon 11.6.0 → 11.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +60 -12
- package/dist/Clock.js +2 -0
- package/dist/Clock.js.map +1 -0
- package/dist/ClockWithArrow.js +2 -0
- package/dist/ClockWithArrow.js.map +1 -0
- package/dist/Key.js +2 -0
- package/dist/Key.js.map +1 -0
- package/dist/Note.js +2 -0
- package/dist/Note.js.map +1 -0
- package/dist/Redo.js +2 -0
- package/dist/Redo.js.map +1 -0
- package/dist/ReplicaSet.js +2 -0
- package/dist/ReplicaSet.js.map +1 -0
- package/dist/Serverless.js +2 -0
- package/dist/Serverless.js.map +1 -0
- package/dist/ShardedCluster.js +2 -0
- package/dist/ShardedCluster.js.map +1 -0
- package/dist/Table.js.map +1 -1
- package/dist/Undo.js +2 -0
- package/dist/Undo.js.map +1 -0
- package/dist/createGlyphComponent.d.ts +7 -0
- package/dist/createGlyphComponent.d.ts.map +1 -1
- package/dist/createIconComponent.d.ts +5 -0
- package/dist/createIconComponent.d.ts.map +1 -1
- package/dist/esm/Clock.js +2 -0
- package/dist/esm/Clock.js.map +1 -0
- package/dist/esm/ClockWithArrow.js +2 -0
- package/dist/esm/ClockWithArrow.js.map +1 -0
- package/dist/esm/Key.js +2 -0
- package/dist/esm/Key.js.map +1 -0
- package/dist/esm/Note.js +2 -0
- package/dist/esm/Note.js.map +1 -0
- package/dist/esm/Redo.js +2 -0
- package/dist/esm/Redo.js.map +1 -0
- package/dist/esm/ReplicaSet.js +2 -0
- package/dist/esm/ReplicaSet.js.map +1 -0
- package/dist/esm/Serverless.js +2 -0
- package/dist/esm/Serverless.js.map +1 -0
- package/dist/esm/ShardedCluster.js +2 -0
- package/dist/esm/ShardedCluster.js.map +1 -0
- package/dist/esm/Table.js.map +1 -1
- package/dist/esm/Undo.js +2 -0
- package/dist/esm/Undo.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/generated/Clock.d.ts +23 -0
- package/dist/generated/Clock.d.ts.map +1 -0
- package/dist/generated/ClockWithArrow.d.ts +23 -0
- package/dist/generated/ClockWithArrow.d.ts.map +1 -0
- package/dist/generated/Key.d.ts +23 -0
- package/dist/generated/Key.d.ts.map +1 -0
- package/dist/generated/Note.d.ts +23 -0
- package/dist/generated/Note.d.ts.map +1 -0
- package/dist/generated/Redo.d.ts +23 -0
- package/dist/generated/Redo.d.ts.map +1 -0
- package/dist/generated/ReplicaSet.d.ts +23 -0
- package/dist/generated/ReplicaSet.d.ts.map +1 -0
- package/dist/generated/Serverless.d.ts +23 -0
- package/dist/generated/Serverless.d.ts.map +1 -0
- package/dist/generated/ShardedCluster.d.ts +23 -0
- package/dist/generated/ShardedCluster.d.ts.map +1 -0
- package/dist/generated/Table.d.ts +1 -1
- package/dist/generated/Undo.d.ts +23 -0
- package/dist/generated/Undo.d.ts.map +1 -0
- package/dist/glyphs/index.d.ts +1 -1
- package/dist/glyphs/index.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/LGGlyph.d.ts +7 -0
- package/dist/types/LGGlyph.d.ts.map +1 -0
- package/dist/types/SVGR.d.ts +7 -0
- package/dist/types/SVGR.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/Icon.spec.tsx +68 -20
- package/src/Icon.story.tsx +2 -1
- package/src/createGlyphComponent.tsx +7 -0
- package/src/createIconComponent.tsx +5 -0
- package/src/generated/Clock.tsx +68 -0
- package/src/generated/ClockWithArrow.tsx +70 -0
- package/src/generated/Key.tsx +68 -0
- package/src/generated/Note.tsx +76 -0
- package/src/generated/Redo.tsx +66 -0
- package/src/generated/ReplicaSet.tsx +68 -0
- package/src/generated/Serverless.tsx +66 -0
- package/src/generated/ShardedCluster.tsx +68 -0
- package/src/generated/Table.tsx +1 -1
- package/src/generated/Undo.tsx +66 -0
- package/src/glyphs/Clock.svg +3 -0
- package/src/glyphs/ClockWithArrow.svg +4 -0
- package/src/glyphs/Key.svg +3 -0
- package/src/glyphs/Note.svg +5 -0
- package/src/glyphs/Redo.svg +3 -0
- package/src/glyphs/ReplicaSet.svg +3 -0
- package/src/glyphs/Serverless.svg +3 -0
- package/src/glyphs/ShardedCluster.svg +3 -0
- package/src/glyphs/Table.svg +1 -1
- package/src/glyphs/Undo.svg +3 -0
- package/src/glyphs/index.ts +20 -2
- package/src/index.ts +3 -1
- package/src/types/LGGlyph.ts +8 -0
- package/src/types/SVGR.ts +8 -0
- package/src/types/index.ts +2 -0
- package/src/{svg.d.ts → types/svg.d.ts} +0 -0
- package/{typings → src/types}/svgr.d.ts +0 -0
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +431 -217
- package/dist/types.d.ts +0 -15
- package/dist/types.d.ts.map +0 -1
- package/src/types.ts +0 -17
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/glyphCommon.ts","../src/createIconComponent.tsx","../src/createGlyphComponent.tsx","../src/glyphs/index.ts","../src/index.ts","../src/isComponentGlyph.ts"],"sourcesContent":["export const Size = {\n Small: 'small',\n Default: 'default',\n Large: 'large',\n XLarge: 'xlarge',\n} as const;\n\nexport type Size = typeof Size[keyof typeof Size];\n\nexport const sizeMap: Record<Size, number> = {\n small: 14,\n default: 16,\n large: 20,\n xlarge: 24,\n} as const;\n\ninterface AccessibleFunctionParams {\n 'aria-labelledby'?: string;\n 'aria-label'?: string;\n title?: string | null;\n}\n\ntype AccessibleFunctionReturnType =\n | AccessibleFunctionParams\n | { 'aria-hidden': true; alt: '' };\n\nexport function generateAccessibleProps(\n role: 'img' | 'presentation',\n glyphName: string,\n {\n ['aria-label']: ariaLabel,\n ['aria-labelledby']: ariaLabelledby,\n title,\n }: AccessibleFunctionParams,\n): AccessibleFunctionReturnType {\n switch (role) {\n case 'img':\n if (!ariaLabel && !ariaLabelledby && !title) {\n return { 'aria-label': getGlyphLabel(glyphName) };\n }\n\n return {\n ['aria-labelledby']: ariaLabelledby,\n ['aria-label']: ariaLabel,\n title,\n };\n\n case 'presentation':\n return { 'aria-hidden': true, alt: '' };\n }\n}\n\nexport function getGlyphLabel(name: string) {\n return `${name.replace(/([a-z])([A-Z])/g, '$1 $2')} Icon`;\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { LGGlyph } from './types';\nimport { Size } from './glyphCommon';\n\n// We omit size here because we map string values for size to numbers in this component.\nexport interface IconProps extends Omit<LGGlyph.ComponentProps, 'size'> {\n glyph: string;\n size?: Size | number;\n}\n\ntype GlyphObject = Record<string, LGGlyph.Component>;\n\nexport default function createIconComponent<\n G extends GlyphObject = GlyphObject\n>(glyphs: G) {\n const Icon = ({ glyph, ...rest }: IconProps) => {\n const SVGComponent = glyphs[glyph];\n\n return <SVGComponent {...rest} />;\n };\n\n Icon.displayName = 'Icon';\n\n Icon.propTypes = {\n glyph: PropTypes.oneOf(Object.keys(glyphs)).isRequired,\n size: PropTypes.oneOfType([\n PropTypes.oneOf(Object.values(Size)),\n PropTypes.number,\n ]),\n } as any;\n\n return Icon;\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SVGR, LGGlyph } from './types';\nimport { css, cx } from '@leafygreen-ui/emotion';\nimport { generateAccessibleProps, sizeMap, Size } from './glyphCommon';\n\nexport default function createGlyphComponent(\n glyphName: string,\n Glyph: SVGR.Component,\n): LGGlyph.Component {\n function GlyphComponent({\n className,\n size = Size.Default,\n fill,\n title,\n 'aria-labelledby': ariaLabelledby,\n 'aria-label': ariaLabel,\n role = 'img',\n ...rest\n }: LGGlyph.ComponentProps) {\n const fillStyle = css`\n color: ${fill};\n `;\n\n const renderedSize = typeof size === 'number' ? size : sizeMap[size];\n\n if (!(role === 'img' || role === 'presentation')) {\n console.warn(\n \"Please provide a valid role to this component. Valid options are 'img' and 'presentation'. If you'd like the Icon to be accessible to screen readers please use 'img', otherwise set the role to 'presentation'.\",\n );\n }\n\n return (\n <Glyph\n className={cx(\n {\n [fillStyle]: fill != null,\n },\n className,\n )}\n height={renderedSize}\n width={renderedSize}\n role={role}\n {...generateAccessibleProps(role, glyphName, {\n title,\n ['aria-label']: ariaLabel,\n ['aria-labelledby']: ariaLabelledby,\n })}\n {...rest}\n />\n );\n }\n\n GlyphComponent.displayName = glyphName;\n\n GlyphComponent.isGlyph = true;\n\n GlyphComponent.propTypes = {\n fill: PropTypes.string,\n size: PropTypes.oneOfType([\n PropTypes.oneOf(Object.values(Size)),\n PropTypes.number,\n ]),\n className: PropTypes.string,\n };\n\n return GlyphComponent;\n}\n","import createGlyphComponent from '../createGlyphComponent';\nimport { LGGlyph } from '../types';\n\n// Glyphs\nimport ActivityFeed from './ActivityFeed.svg';\nimport AddFile from './AddFile.svg';\nimport Apps from './Apps.svg';\nimport Array from './Array.svg';\nimport ArrowDown from './ArrowDown.svg';\nimport ArrowLeft from './ArrowLeft.svg';\nimport ArrowRight from './ArrowRight.svg';\nimport ArrowUp from './ArrowUp.svg';\nimport Beaker from './Beaker.svg';\nimport Bell from './Bell.svg';\nimport Building from './Building.svg';\nimport Bulb from './Bulb.svg';\nimport Calendar from './Calendar.svg';\nimport CaretDown from './CaretDown.svg';\nimport CaretLeft from './CaretLeft.svg';\nimport CaretRight from './CaretRight.svg';\nimport CaretUp from './CaretUp.svg';\nimport Charts from './Charts.svg';\nimport Checkmark from './Checkmark.svg';\nimport CheckmarkWithCircle from './CheckmarkWithCircle.svg';\nimport ChevronUp from './ChevronUp.svg';\nimport ChevronDown from './ChevronDown.svg';\nimport ChevronRight from './ChevronRight.svg';\nimport ChevronLeft from './ChevronLeft.svg';\nimport Clone from './Clone.svg';\nimport Cloud from './Cloud.svg';\nimport Code from './Code.svg';\nimport Connect from './Connect.svg';\nimport Copy from './Copy.svg';\nimport CreditCard from './CreditCard.svg';\nimport CurlyBraces from './CurlyBraces.svg';\nimport Database from './Database.svg';\nimport Diagram from './Diagram.svg';\nimport Disconnect from './Disconnect.svg';\nimport Download from './Download.svg';\nimport Edit from './Edit.svg';\nimport Ellipsis from './Ellipsis.svg';\nimport Export from './Export.svg';\nimport Favorite from './Favorite.svg';\nimport File from './File.svg';\nimport Filter from './Filter.svg';\nimport FullScreenEnter from './FullScreenEnter.svg';\nimport FullScreenExit from './FullScreenExit.svg';\nimport Folder from './Folder.svg';\nimport GlobeAmericas from './GlobeAmericas.svg';\nimport GovernmentBuilding from './GovernmentBuilding.svg';\nimport Home from './Home.svg';\nimport ImportantWithCircle from './ImportantWithCircle.svg';\nimport InfoWithCircle from './InfoWithCircle.svg';\nimport InviteUser from './InviteUser.svg';\nimport Laptop from './Laptop.svg';\nimport Lock from './Lock.svg';\nimport MagnifyingGlass from './MagnifyingGlass.svg';\nimport Megaphone from './Megaphone.svg';\nimport Menu from './Menu.svg';\nimport Minus from './Minus.svg';\nimport NotAllowed from './NotAllowed.svg';\nimport OpenNewTab from './OpenNewTab.svg';\nimport Pause from './Pause.svg';\nimport Person from './Person.svg';\nimport PersonGroup from './PersonGroup.svg';\nimport PersonWithLock from './PersonWithLock.svg';\nimport Play from './Play.svg';\nimport Plus from './Plus.svg';\nimport PlusWithCircle from './PlusWithCircle.svg';\nimport QuestionMarkWithCircle from './QuestionMarkWithCircle.svg';\nimport Refresh from './Refresh.svg';\nimport Save from './Save.svg';\nimport Settings from './Settings.svg';\nimport Shell from './Shell.svg';\nimport SortAscending from './SortAscending.svg';\nimport SortDescending from './SortDescending.svg';\nimport Stitch from './Stitch.svg';\nimport Support from './Support.svg';\nimport Table from './Table.svg';\nimport TimeSeries from './TimeSeries.svg';\nimport Trash from './Trash.svg';\nimport University from './University.svg';\nimport Unlock from './Unlock.svg';\nimport Unsorted from './Unsorted.svg';\nimport UpDownCarets from './UpDownCarets.svg';\nimport Upload from './Upload.svg';\nimport VerticalEllipsis from './VerticalEllipsis.svg';\nimport Visibility from './Visibility.svg';\nimport VisibilityOff from './VisibilityOff.svg';\nimport Warning from './Warning.svg';\nimport X from './X.svg';\nimport XWithCircle from './XWithCircle.svg';\n\nconst glyphs = {\n ActivityFeed,\n AddFile,\n Apps,\n Array,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n Beaker,\n Bell,\n Building,\n Bulb,\n Calendar,\n CaretDown,\n CaretLeft,\n CaretRight,\n CaretUp,\n Charts,\n Checkmark,\n CheckmarkWithCircle,\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n ChevronUp,\n Clone,\n Cloud,\n Code,\n Connect,\n Copy,\n CreditCard,\n CurlyBraces,\n Database,\n Diagram,\n Disconnect,\n Download,\n Edit,\n Ellipsis,\n Export,\n Favorite,\n File,\n Filter,\n FullScreenEnter,\n FullScreenExit,\n Folder,\n GlobeAmericas,\n GovernmentBuilding,\n Home,\n ImportantWithCircle,\n InfoWithCircle,\n InviteUser,\n Laptop,\n Lock,\n MagnifyingGlass,\n Megaphone,\n Menu,\n Minus,\n NotAllowed,\n OpenNewTab,\n Pause,\n Person,\n PersonGroup,\n PersonWithLock,\n Play,\n Plus,\n PlusWithCircle,\n QuestionMarkWithCircle,\n Refresh,\n Save,\n Settings,\n Shell,\n SortAscending,\n SortDescending,\n Stitch,\n Support,\n Table,\n TimeSeries,\n Trash,\n University,\n Unlock,\n Unsorted,\n UpDownCarets,\n Upload,\n VerticalEllipsis,\n Visibility,\n VisibilityOff,\n Warning,\n X,\n XWithCircle,\n} as const;\n\ntype GlyphName = keyof typeof glyphs;\n\nconst glyphKeys = Object.keys(glyphs) as Array<GlyphName>;\n\nconst processedGlyphs = glyphKeys.reduce((acc, name) => {\n acc[name] = createGlyphComponent(name, glyphs[name]);\n\n return acc;\n}, {} as Record<GlyphName, LGGlyph.Component>);\n\nexport default processedGlyphs;\n","import createIconComponent from './createIconComponent';\nimport glyphs from './glyphs';\n\nexport { default as createIconComponent } from './createIconComponent';\nexport { default as glyphs } from './glyphs';\nexport { Size } from './glyphCommon';\nexport { isComponentGlyph } from './isComponentGlyph';\nexport default createIconComponent(glyphs);\n","import { LGGlyph } from './types';\n\n/** Helper type to check if element is a LeafyGreen UI Glyph */\nexport function isComponentGlyph(\n child: React.ReactNode,\n): child is React.ReactElement<LGGlyph.ComponentProps> {\n return (\n child != null &&\n typeof child === 'object' &&\n 'type' in child &&\n (child.type as any).isGlyph === true\n );\n}\n"],"names":["Size","Small","Default","Large","XLarge","sizeMap","small","default","large","xlarge","_templateObject","_excluded","createIconComponent","glyphs","Icon","_ref","glyph","rest","_objectWithoutProperties","SVGComponent","___EmotionJSX","displayName","propTypes","PropTypes","oneOf","Object","keys","isRequired","size","oneOfType","values","number","createGlyphComponent","glyphName","Glyph","GlyphComponent","_generateAccessiblePr","className","_ref$size","fill","title","ariaLabelledby","ariaLabel","_ref$role","role","fillStyle","css","renderedSize","console","warn","_extends","cx","_defineProperty","height","width","_ref2","name","aria-label","concat","replace","aria-hidden","alt","generateAccessibleProps","isGlyph","string","ActivityFeed","AddFile","Apps","Array","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Beaker","Bell","Building","Bulb","Calendar","CaretDown","CaretLeft","CaretRight","CaretUp","Charts","Checkmark","CheckmarkWithCircle","ChevronDown","ChevronLeft","ChevronRight","ChevronUp","Clone","Cloud","Code","Connect","Copy","CreditCard","CurlyBraces","Database","Diagram","Disconnect","Download","Edit","Ellipsis","Export","Favorite","File","Filter","FullScreenEnter","FullScreenExit","Folder","GlobeAmericas","GovernmentBuilding","Home","ImportantWithCircle","InfoWithCircle","InviteUser","Laptop","Lock","MagnifyingGlass","Megaphone","Menu","Minus","NotAllowed","OpenNewTab","Pause","Person","PersonGroup","PersonWithLock","Play","Plus","PlusWithCircle","QuestionMarkWithCircle","Refresh","Save","Settings","Shell","SortAscending","SortDescending","Stitch","Support","Table","TimeSeries","Trash","University","Unlock","Unsorted","UpDownCarets","Upload","VerticalEllipsis","Visibility","VisibilityOff","Warning","X","XWithCircle","processedGlyphs","reduce","acc","child","_typeof","type"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/glyphCommon.ts","../src/createIconComponent.tsx","../src/createGlyphComponent.tsx","../src/glyphs/index.ts","../src/index.ts","../src/isComponentGlyph.ts"],"sourcesContent":["export const Size = {\n Small: 'small',\n Default: 'default',\n Large: 'large',\n XLarge: 'xlarge',\n} as const;\n\nexport type Size = typeof Size[keyof typeof Size];\n\nexport const sizeMap: Record<Size, number> = {\n small: 14,\n default: 16,\n large: 20,\n xlarge: 24,\n} as const;\n\ninterface AccessibleFunctionParams {\n 'aria-labelledby'?: string;\n 'aria-label'?: string;\n title?: string | null;\n}\n\ntype AccessibleFunctionReturnType =\n | AccessibleFunctionParams\n | { 'aria-hidden': true; alt: '' };\n\nexport function generateAccessibleProps(\n role: 'img' | 'presentation',\n glyphName: string,\n {\n ['aria-label']: ariaLabel,\n ['aria-labelledby']: ariaLabelledby,\n title,\n }: AccessibleFunctionParams,\n): AccessibleFunctionReturnType {\n switch (role) {\n case 'img':\n if (!ariaLabel && !ariaLabelledby && !title) {\n return { 'aria-label': getGlyphLabel(glyphName) };\n }\n\n return {\n ['aria-labelledby']: ariaLabelledby,\n ['aria-label']: ariaLabel,\n title,\n };\n\n case 'presentation':\n return { 'aria-hidden': true, alt: '' };\n }\n}\n\nexport function getGlyphLabel(name: string) {\n return `${name.replace(/([a-z])([A-Z])/g, '$1 $2')} Icon`;\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { LGGlyph } from './types';\nimport { Size } from './glyphCommon';\n\n// We omit size here because we map string values for size to numbers in this component.\nexport interface IconProps extends Omit<LGGlyph.ComponentProps, 'size'> {\n glyph: string;\n size?: Size | number;\n}\n\ntype GlyphObject = Record<string, LGGlyph.Component>;\n\n/**\n * Returns a single component with a `glyph` prop to select the glyph\n * @param glyphs The set of glyphs\n * @returns Icon component\n */\nexport default function createIconComponent<\n G extends GlyphObject = GlyphObject\n>(glyphs: G) {\n const Icon = ({ glyph, ...rest }: IconProps) => {\n const SVGComponent = glyphs[glyph];\n\n return <SVGComponent {...rest} />;\n };\n\n Icon.displayName = 'Icon';\n\n Icon.propTypes = {\n glyph: PropTypes.oneOf(Object.keys(glyphs)).isRequired,\n size: PropTypes.oneOfType([\n PropTypes.oneOf(Object.values(Size)),\n PropTypes.number,\n ]),\n } as any;\n\n return Icon;\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { SVGR, LGGlyph } from './types';\nimport { css, cx } from '@leafygreen-ui/emotion';\nimport { generateAccessibleProps, sizeMap, Size } from './glyphCommon';\n\n/**\n * Returns a single glyph component.\n * Process custom glyphs to ensure consistent behavior between custom and built-in icons\n * @param glyphName: string - the display name of the icon\n * @param Glyph: SVGR.Component - the SVG icon component\n * @returns LGGlyph.Component\n */\nexport default function createGlyphComponent(\n glyphName: string,\n Glyph: SVGR.Component,\n): LGGlyph.Component {\n function GlyphComponent({\n className,\n size = Size.Default,\n fill,\n title,\n 'aria-labelledby': ariaLabelledby,\n 'aria-label': ariaLabel,\n role = 'img',\n ...rest\n }: LGGlyph.ComponentProps) {\n const fillStyle = css`\n color: ${fill};\n `;\n\n const renderedSize = typeof size === 'number' ? size : sizeMap[size];\n\n if (!(role === 'img' || role === 'presentation')) {\n console.warn(\n \"Please provide a valid role to this component. Valid options are 'img' and 'presentation'. If you'd like the Icon to be accessible to screen readers please use 'img', otherwise set the role to 'presentation'.\",\n );\n }\n\n return (\n <Glyph\n className={cx(\n {\n [fillStyle]: fill != null,\n },\n className,\n )}\n height={renderedSize}\n width={renderedSize}\n role={role}\n {...generateAccessibleProps(role, glyphName, {\n title,\n ['aria-label']: ariaLabel,\n ['aria-labelledby']: ariaLabelledby,\n })}\n {...rest}\n />\n );\n }\n\n GlyphComponent.displayName = glyphName;\n\n GlyphComponent.isGlyph = true;\n\n GlyphComponent.propTypes = {\n fill: PropTypes.string,\n size: PropTypes.oneOfType([\n PropTypes.oneOf(Object.values(Size)),\n PropTypes.number,\n ]),\n className: PropTypes.string,\n };\n\n return GlyphComponent;\n}\n","import createGlyphComponent from '../createGlyphComponent';\nimport { LGGlyph } from '../types';\n\n// Glyphs\nimport ActivityFeed from './ActivityFeed.svg';\nimport AddFile from './AddFile.svg';\nimport Apps from './Apps.svg';\nimport Array from './Array.svg';\nimport ArrowDown from './ArrowDown.svg';\nimport ArrowLeft from './ArrowLeft.svg';\nimport ArrowRight from './ArrowRight.svg';\nimport ArrowUp from './ArrowUp.svg';\nimport Beaker from './Beaker.svg';\nimport Bell from './Bell.svg';\nimport Building from './Building.svg';\nimport Bulb from './Bulb.svg';\nimport Calendar from './Calendar.svg';\nimport CaretDown from './CaretDown.svg';\nimport CaretLeft from './CaretLeft.svg';\nimport CaretRight from './CaretRight.svg';\nimport CaretUp from './CaretUp.svg';\nimport Charts from './Charts.svg';\nimport Checkmark from './Checkmark.svg';\nimport CheckmarkWithCircle from './CheckmarkWithCircle.svg';\nimport ChevronDown from './ChevronDown.svg';\nimport ChevronLeft from './ChevronLeft.svg';\nimport ChevronRight from './ChevronRight.svg';\nimport ChevronUp from './ChevronUp.svg';\nimport Clock from './Clock.svg';\nimport ClockWithArrow from './ClockWithArrow.svg';\nimport Clone from './Clone.svg';\nimport Cloud from './Cloud.svg';\nimport Code from './Code.svg';\nimport Connect from './Connect.svg';\nimport Copy from './Copy.svg';\nimport CreditCard from './CreditCard.svg';\nimport CurlyBraces from './CurlyBraces.svg';\nimport Database from './Database.svg';\nimport Diagram from './Diagram.svg';\nimport Disconnect from './Disconnect.svg';\nimport Download from './Download.svg';\nimport Edit from './Edit.svg';\nimport Ellipsis from './Ellipsis.svg';\nimport Export from './Export.svg';\nimport Favorite from './Favorite.svg';\nimport File from './File.svg';\nimport Filter from './Filter.svg';\nimport FullScreenEnter from './FullScreenEnter.svg';\nimport FullScreenExit from './FullScreenExit.svg';\nimport Folder from './Folder.svg';\nimport GlobeAmericas from './GlobeAmericas.svg';\nimport GovernmentBuilding from './GovernmentBuilding.svg';\nimport Home from './Home.svg';\nimport ImportantWithCircle from './ImportantWithCircle.svg';\nimport InfoWithCircle from './InfoWithCircle.svg';\nimport InviteUser from './InviteUser.svg';\nimport Key from './Key.svg';\nimport Laptop from './Laptop.svg';\nimport Lock from './Lock.svg';\nimport MagnifyingGlass from './MagnifyingGlass.svg';\nimport Megaphone from './Megaphone.svg';\nimport Menu from './Menu.svg';\nimport Minus from './Minus.svg';\nimport NotAllowed from './NotAllowed.svg';\nimport Note from './Note.svg';\nimport OpenNewTab from './OpenNewTab.svg';\nimport Pause from './Pause.svg';\nimport Person from './Person.svg';\nimport PersonGroup from './PersonGroup.svg';\nimport PersonWithLock from './PersonWithLock.svg';\nimport Play from './Play.svg';\nimport Plus from './Plus.svg';\nimport PlusWithCircle from './PlusWithCircle.svg';\nimport QuestionMarkWithCircle from './QuestionMarkWithCircle.svg';\nimport Redo from './Redo.svg';\nimport Refresh from './Refresh.svg';\nimport ReplicaSet from './ReplicaSet.svg';\nimport Save from './Save.svg';\nimport Serverless from './Serverless.svg';\nimport ShardedCluster from './ShardedCluster.svg';\nimport Settings from './Settings.svg';\nimport Shell from './Shell.svg';\nimport SortAscending from './SortAscending.svg';\nimport SortDescending from './SortDescending.svg';\nimport Stitch from './Stitch.svg';\nimport Support from './Support.svg';\nimport Table from './Table.svg';\nimport TimeSeries from './TimeSeries.svg';\nimport Trash from './Trash.svg';\nimport Undo from './Undo.svg';\nimport University from './University.svg';\nimport Unlock from './Unlock.svg';\nimport Unsorted from './Unsorted.svg';\nimport UpDownCarets from './UpDownCarets.svg';\nimport Upload from './Upload.svg';\nimport VerticalEllipsis from './VerticalEllipsis.svg';\nimport Visibility from './Visibility.svg';\nimport VisibilityOff from './VisibilityOff.svg';\nimport Warning from './Warning.svg';\nimport X from './X.svg';\nimport XWithCircle from './XWithCircle.svg';\n\nconst glyphs = {\n ActivityFeed,\n AddFile,\n Apps,\n Array,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n Beaker,\n Bell,\n Building,\n Bulb,\n Calendar,\n CaretDown,\n CaretLeft,\n CaretRight,\n CaretUp,\n Charts,\n Checkmark,\n CheckmarkWithCircle,\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n ChevronUp,\n Clock,\n ClockWithArrow,\n Clone,\n Cloud,\n Code,\n Connect,\n Copy,\n CreditCard,\n CurlyBraces,\n Database,\n Diagram,\n Disconnect,\n Download,\n Edit,\n Ellipsis,\n Export,\n Favorite,\n File,\n Filter,\n FullScreenEnter,\n FullScreenExit,\n Folder,\n GlobeAmericas,\n GovernmentBuilding,\n Home,\n ImportantWithCircle,\n InfoWithCircle,\n InviteUser,\n Key,\n Laptop,\n Lock,\n MagnifyingGlass,\n Megaphone,\n Menu,\n Minus,\n NotAllowed,\n Note,\n OpenNewTab,\n Pause,\n Person,\n PersonGroup,\n PersonWithLock,\n Play,\n Plus,\n PlusWithCircle,\n QuestionMarkWithCircle,\n Redo,\n Refresh,\n ReplicaSet,\n Save,\n Serverless,\n ShardedCluster,\n Settings,\n Shell,\n SortAscending,\n SortDescending,\n Stitch,\n Support,\n Table,\n TimeSeries,\n Trash,\n Undo,\n University,\n Unlock,\n Unsorted,\n UpDownCarets,\n Upload,\n VerticalEllipsis,\n Visibility,\n VisibilityOff,\n Warning,\n X,\n XWithCircle,\n} as const;\n\ntype GlyphName = keyof typeof glyphs;\n\nconst glyphKeys = Object.keys(glyphs) as Array<GlyphName>;\n\nconst processedGlyphs = glyphKeys.reduce((acc, name) => {\n acc[name] = createGlyphComponent(name, glyphs[name]);\n\n return acc;\n}, {} as Record<GlyphName, LGGlyph.Component>);\n\nexport default processedGlyphs;\n","import createIconComponent from './createIconComponent';\nimport glyphs from './glyphs';\n\nexport { LGGlyph } from './types';\nexport { Size } from './glyphCommon';\nexport { default as createIconComponent } from './createIconComponent';\nexport { default as createGlyphComponent } from './createGlyphComponent';\nexport { default as glyphs } from './glyphs';\nexport { isComponentGlyph } from './isComponentGlyph';\nexport default createIconComponent(glyphs);\n","import { LGGlyph } from './types';\n\n/** Helper type to check if element is a LeafyGreen UI Glyph */\nexport function isComponentGlyph(\n child: React.ReactNode,\n): child is React.ReactElement<LGGlyph.ComponentProps> {\n return (\n child != null &&\n typeof child === 'object' &&\n 'type' in child &&\n (child.type as any).isGlyph === true\n );\n}\n"],"names":["Size","Small","Default","Large","XLarge","sizeMap","small","default","large","xlarge","_templateObject","_excluded","createIconComponent","glyphs","Icon","_ref","glyph","rest","_objectWithoutProperties","SVGComponent","___EmotionJSX","displayName","propTypes","PropTypes","oneOf","Object","keys","isRequired","size","oneOfType","values","number","createGlyphComponent","glyphName","Glyph","GlyphComponent","_generateAccessiblePr","className","_ref$size","fill","title","ariaLabelledby","ariaLabel","_ref$role","role","fillStyle","css","renderedSize","console","warn","_extends","cx","_defineProperty","height","width","_ref2","name","aria-label","concat","replace","aria-hidden","alt","generateAccessibleProps","isGlyph","string","ActivityFeed","AddFile","Apps","Array","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Beaker","Bell","Building","Bulb","Calendar","CaretDown","CaretLeft","CaretRight","CaretUp","Charts","Checkmark","CheckmarkWithCircle","ChevronDown","ChevronLeft","ChevronRight","ChevronUp","Clock","ClockWithArrow","Clone","Cloud","Code","Connect","Copy","CreditCard","CurlyBraces","Database","Diagram","Disconnect","Download","Edit","Ellipsis","Export","Favorite","File","Filter","FullScreenEnter","FullScreenExit","Folder","GlobeAmericas","GovernmentBuilding","Home","ImportantWithCircle","InfoWithCircle","InviteUser","Key","Laptop","Lock","MagnifyingGlass","Megaphone","Menu","Minus","NotAllowed","Note","OpenNewTab","Pause","Person","PersonGroup","PersonWithLock","Play","Plus","PlusWithCircle","QuestionMarkWithCircle","Redo","Refresh","ReplicaSet","Save","Serverless","ShardedCluster","Settings","Shell","SortAscending","SortDescending","Stitch","Support","Table","TimeSeries","Trash","Undo","University","Unlock","Unsorted","UpDownCarets","Upload","VerticalEllipsis","Visibility","VisibilityOff","Warning","X","XWithCircle","processedGlyphs","reduce","acc","child","_typeof","type"],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import * as SVGR from './SVGR';
|
|
3
|
+
export interface ComponentProps extends SVGR.ComponentProps {
|
|
4
|
+
size?: number | 'small' | 'default' | 'large' | 'xlarge';
|
|
5
|
+
}
|
|
6
|
+
export declare type Component = ComponentType<ComponentProps>;
|
|
7
|
+
//# sourceMappingURL=LGGlyph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LGGlyph.d.ts","sourceRoot":"","sources":["../../src/types/LGGlyph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,cAAc;IACzD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC1D;AAED,oBAAY,SAAS,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentType, SVGProps } from 'react';
|
|
2
|
+
export interface ComponentProps extends SVGProps<SVGSVGElement> {
|
|
3
|
+
title?: string | null;
|
|
4
|
+
role?: 'presentation' | 'img';
|
|
5
|
+
}
|
|
6
|
+
export declare type Component = ComponentType<ComponentProps>;
|
|
7
|
+
//# sourceMappingURL=SVGR.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SVGR.d.ts","sourceRoot":"","sources":["../../src/types/SVGR.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,MAAM,WAAW,cAAe,SAAQ,QAAQ,CAAC,aAAa,CAAC;IAC7D,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,cAAc,GAAG,KAAK,CAAC;CAC/B;AAED,oBAAY,SAAS,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafygreen-ui/icon",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.8.0",
|
|
4
4
|
"description": "LeafyGreen UI Kit Icons",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"xml2json": "^0.11.2"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@leafygreen-ui/lib": "^9.0
|
|
27
|
+
"@leafygreen-ui/lib": "^9.2.0"
|
|
28
28
|
},
|
|
29
29
|
"gitHead": "dd71a2d404218ccec2e657df9c0263dc1c15b9e0"
|
|
30
30
|
}
|
package/src/Icon.spec.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { SVGR } from './types';
|
|
|
10
10
|
import { createIconComponent, glyphs } from '.';
|
|
11
11
|
import createGlyphComponent from './createGlyphComponent';
|
|
12
12
|
import EditIcon from '@leafygreen-ui/icon/dist/Edit';
|
|
13
|
+
import { Size } from './glyphCommon';
|
|
13
14
|
|
|
14
15
|
function getBaseName(filePath: string): string {
|
|
15
16
|
return path.basename(filePath, path.extname(filePath));
|
|
@@ -85,58 +86,105 @@ describe('packages/Icon/glyphs/', () => {
|
|
|
85
86
|
});
|
|
86
87
|
});
|
|
87
88
|
|
|
88
|
-
const
|
|
89
|
+
const MyGlyph: SVGR.Component = props => (
|
|
90
|
+
<svg data-testid="my-glyph" {...props}></svg>
|
|
91
|
+
);
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
const MyGlyph: SVGR.Component = () => <div>{text}</div>;
|
|
92
|
-
|
|
93
|
-
describe('packages/Icon/createGlyphComponent createGlyphComponent()', () => {
|
|
93
|
+
describe('packages/Icon/createGlyphComponent', () => {
|
|
94
94
|
const GlyphComponent = createGlyphComponent('MyGlyph', MyGlyph);
|
|
95
95
|
|
|
96
|
-
test('
|
|
96
|
+
test('returns a function', () => {
|
|
97
97
|
expect(typeof GlyphComponent).toBe('function');
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
test('
|
|
100
|
+
test('returned function has correct display name', () => {
|
|
101
101
|
expect(GlyphComponent.displayName).toBe('MyGlyph');
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
test('returned function renders the glyph specified', () => {
|
|
105
|
+
const { getByTestId } = render(<GlyphComponent />);
|
|
106
|
+
const glyph = getByTestId('my-glyph');
|
|
106
107
|
|
|
107
|
-
test('The function returned by createGlyphComponent renders the glyph specified', () => {
|
|
108
108
|
if (!typeIs.element(glyph)) {
|
|
109
109
|
throw new Error('Glyph was not rendered');
|
|
110
110
|
}
|
|
111
|
+
expect(glyph.nodeName.toLowerCase()).toBe('svg');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('returned funcion passes through props', () => {
|
|
115
|
+
test('`size` prop as number', () => {
|
|
116
|
+
const { getByTestId } = render(<GlyphComponent size={20} />);
|
|
117
|
+
const glyph = getByTestId('my-glyph');
|
|
118
|
+
expect(glyph).toHaveAttribute('height', '20');
|
|
119
|
+
expect(glyph).toHaveAttribute('width', '20');
|
|
120
|
+
});
|
|
111
121
|
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
test('`size` prop as Size', () => {
|
|
123
|
+
const { getByTestId } = render(<GlyphComponent size={Size.Large} />);
|
|
124
|
+
const glyph = getByTestId('my-glyph');
|
|
125
|
+
expect(glyph).toHaveAttribute('height', '20');
|
|
126
|
+
expect(glyph).toHaveAttribute('width', '20');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('`role`', () => {
|
|
130
|
+
const { getByTestId } = render(<GlyphComponent role="presentation" />);
|
|
131
|
+
const glyph = getByTestId('my-glyph');
|
|
132
|
+
expect(glyph).toHaveAttribute('role', 'presentation');
|
|
133
|
+
});
|
|
114
134
|
});
|
|
115
135
|
});
|
|
116
136
|
|
|
117
|
-
const customGlyphs = {
|
|
137
|
+
const customGlyphs = {
|
|
138
|
+
MyGlyph: createGlyphComponent('MyGlyph', MyGlyph),
|
|
139
|
+
};
|
|
118
140
|
|
|
119
141
|
describe('packages/Icon/createIconComponent', () => {
|
|
120
142
|
const IconComponent = createIconComponent(customGlyphs);
|
|
121
143
|
|
|
122
|
-
test('
|
|
144
|
+
test('returns a function', () => {
|
|
123
145
|
expect(typeof IconComponent).toBe('function');
|
|
124
146
|
});
|
|
125
147
|
|
|
126
|
-
test('
|
|
148
|
+
test('returned function has the displayName: "Icon"', () => {
|
|
127
149
|
expect(IconComponent.displayName).toBe('Icon');
|
|
128
150
|
});
|
|
129
151
|
|
|
130
|
-
|
|
131
|
-
|
|
152
|
+
test('returned funciton renders the glyph specified', () => {
|
|
153
|
+
const { getByTestId } = render(<IconComponent glyph="MyGlyph" />);
|
|
154
|
+
const glyph = getByTestId('my-glyph');
|
|
132
155
|
|
|
133
|
-
test('The function returned by createIconComponent renders the glyph specified', () => {
|
|
134
156
|
if (!typeIs.element(glyph)) {
|
|
135
157
|
throw new Error('Glyph was not rendered');
|
|
136
158
|
}
|
|
159
|
+
expect(glyph.nodeName.toLowerCase()).toBe('svg');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe('returned funcion passes through props', () => {
|
|
163
|
+
test('`size` prop as number', () => {
|
|
164
|
+
const { getByTestId } = render(
|
|
165
|
+
<IconComponent glyph="MyGlyph" size={20} />,
|
|
166
|
+
);
|
|
167
|
+
const glyph = getByTestId('my-glyph');
|
|
168
|
+
expect(glyph).toHaveAttribute('height', '20');
|
|
169
|
+
expect(glyph).toHaveAttribute('width', '20');
|
|
170
|
+
});
|
|
137
171
|
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
test('`size` prop as Size', () => {
|
|
173
|
+
const { getByTestId } = render(
|
|
174
|
+
<IconComponent glyph="MyGlyph" size={Size.Large} />,
|
|
175
|
+
);
|
|
176
|
+
const glyph = getByTestId('my-glyph');
|
|
177
|
+
expect(glyph).toHaveAttribute('height', '20');
|
|
178
|
+
expect(glyph).toHaveAttribute('width', '20');
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('`role`', () => {
|
|
182
|
+
const { getByTestId } = render(
|
|
183
|
+
<IconComponent glyph="MyGlyph" role="presentation" />,
|
|
184
|
+
);
|
|
185
|
+
const glyph = getByTestId('my-glyph');
|
|
186
|
+
expect(glyph).toHaveAttribute('role', 'presentation');
|
|
187
|
+
});
|
|
140
188
|
});
|
|
141
189
|
});
|
|
142
190
|
|
package/src/Icon.story.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import Icon, { glyphs, Size } from '.';
|
|
|
3
3
|
import { css } from '@leafygreen-ui/emotion';
|
|
4
4
|
import { storiesOf } from '@storybook/react';
|
|
5
5
|
import { color, select } from '@storybook/addon-knobs';
|
|
6
|
+
import { uiColors } from '@leafygreen-ui/palette';
|
|
6
7
|
|
|
7
8
|
const containerStyle = css`
|
|
8
9
|
width: 150px;
|
|
@@ -20,7 +21,7 @@ const containerStyle = css`
|
|
|
20
21
|
|
|
21
22
|
const textStyle = css`
|
|
22
23
|
font-size: 12px;
|
|
23
|
-
color:
|
|
24
|
+
color: ${uiColors.gray.base};
|
|
24
25
|
margin-top: 0.5rem;
|
|
25
26
|
`;
|
|
26
27
|
|
|
@@ -4,6 +4,13 @@ import { SVGR, LGGlyph } from './types';
|
|
|
4
4
|
import { css, cx } from '@leafygreen-ui/emotion';
|
|
5
5
|
import { generateAccessibleProps, sizeMap, Size } from './glyphCommon';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Returns a single glyph component.
|
|
9
|
+
* Process custom glyphs to ensure consistent behavior between custom and built-in icons
|
|
10
|
+
* @param glyphName: string - the display name of the icon
|
|
11
|
+
* @param Glyph: SVGR.Component - the SVG icon component
|
|
12
|
+
* @returns LGGlyph.Component
|
|
13
|
+
*/
|
|
7
14
|
export default function createGlyphComponent(
|
|
8
15
|
glyphName: string,
|
|
9
16
|
Glyph: SVGR.Component,
|
|
@@ -11,6 +11,11 @@ export interface IconProps extends Omit<LGGlyph.ComponentProps, 'size'> {
|
|
|
11
11
|
|
|
12
12
|
type GlyphObject = Record<string, LGGlyph.Component>;
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Returns a single component with a `glyph` prop to select the glyph
|
|
16
|
+
* @param glyphs The set of glyphs
|
|
17
|
+
* @returns Icon component
|
|
18
|
+
*/
|
|
14
19
|
export default function createIconComponent<
|
|
15
20
|
G extends GlyphObject = GlyphObject
|
|
16
21
|
>(glyphs: G) {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a generated file. Do not modify it manually.
|
|
3
|
+
*
|
|
4
|
+
* @script ./node_modules/.bin/ts-node packages/icon/scripts/build.ts
|
|
5
|
+
* @checksum 867509eef46d330604af7224e7ceb53b
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { css, cx } from '@leafygreen-ui/emotion';
|
|
10
|
+
import { generateAccessibleProps, sizeMap } from '../glyphCommon';
|
|
11
|
+
import { LGGlyph } from '../types';
|
|
12
|
+
export interface ClockProps extends LGGlyph.ComponentProps {}
|
|
13
|
+
|
|
14
|
+
const Clock = ({
|
|
15
|
+
className,
|
|
16
|
+
size = 16,
|
|
17
|
+
title,
|
|
18
|
+
['aria-label']: ariaLabel,
|
|
19
|
+
['aria-labelledby']: ariaLabelledby,
|
|
20
|
+
fill,
|
|
21
|
+
role = 'img',
|
|
22
|
+
...props
|
|
23
|
+
}: ClockProps) => {
|
|
24
|
+
const fillStyle = css`
|
|
25
|
+
color: ${fill};
|
|
26
|
+
`;
|
|
27
|
+
const noFlexShrink = css`
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
`;
|
|
30
|
+
const accessibleProps = generateAccessibleProps(role, 'Clock', {
|
|
31
|
+
title,
|
|
32
|
+
['aria-label']: ariaLabel,
|
|
33
|
+
['aria-labelledby']: ariaLabelledby,
|
|
34
|
+
});
|
|
35
|
+
return (
|
|
36
|
+
<svg
|
|
37
|
+
className={cx(
|
|
38
|
+
{
|
|
39
|
+
[fillStyle]: fill != null,
|
|
40
|
+
},
|
|
41
|
+
noFlexShrink,
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
height={typeof size === 'number' ? size : sizeMap[size]}
|
|
45
|
+
width={typeof size === 'number' ? size : sizeMap[size]}
|
|
46
|
+
role={role}
|
|
47
|
+
{...accessibleProps}
|
|
48
|
+
{...props}
|
|
49
|
+
viewBox="0 0 16 16"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
fillRule="evenodd"
|
|
53
|
+
clipRule="evenodd"
|
|
54
|
+
d="M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14ZM7.25 4.75C7.25 4.33579 7.58579 4 8 4C8.41421 4 8.75 4.33579 8.75 4.75V7.90966L10.4939 9.43556C10.8056 9.70832 10.8372 10.1821 10.5644 10.4939C10.2917 10.8056 9.81786 10.8372 9.50613 10.5644L7.51059 8.81833C7.5014 8.8104 7.4924 8.80226 7.48361 8.79391C7.41388 8.7278 7.35953 8.65117 7.32087 8.56867C7.27541 8.47195 7.25 8.36394 7.25 8.25V4.75Z"
|
|
55
|
+
fill={'currentColor'}
|
|
56
|
+
/>
|
|
57
|
+
</svg>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
Clock.displayName = 'Clock';
|
|
62
|
+
Clock.isGlyph = true;
|
|
63
|
+
Clock.propTypes = {
|
|
64
|
+
fill: PropTypes.string,
|
|
65
|
+
size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
66
|
+
className: PropTypes.string,
|
|
67
|
+
};
|
|
68
|
+
export default Clock;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a generated file. Do not modify it manually.
|
|
3
|
+
*
|
|
4
|
+
* @script ./node_modules/.bin/ts-node packages/icon/scripts/build.ts
|
|
5
|
+
* @checksum 5cebdb544bb818697100aa36feb9bd15
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { css, cx } from '@leafygreen-ui/emotion';
|
|
10
|
+
import { generateAccessibleProps, sizeMap } from '../glyphCommon';
|
|
11
|
+
import { LGGlyph } from '../types';
|
|
12
|
+
export interface ClockWithArrowProps extends LGGlyph.ComponentProps {}
|
|
13
|
+
|
|
14
|
+
const ClockWithArrow = ({
|
|
15
|
+
className,
|
|
16
|
+
size = 16,
|
|
17
|
+
title,
|
|
18
|
+
['aria-label']: ariaLabel,
|
|
19
|
+
['aria-labelledby']: ariaLabelledby,
|
|
20
|
+
fill,
|
|
21
|
+
role = 'img',
|
|
22
|
+
...props
|
|
23
|
+
}: ClockWithArrowProps) => {
|
|
24
|
+
const fillStyle = css`
|
|
25
|
+
color: ${fill};
|
|
26
|
+
`;
|
|
27
|
+
const noFlexShrink = css`
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
`;
|
|
30
|
+
const accessibleProps = generateAccessibleProps(role, 'ClockWithArrow', {
|
|
31
|
+
title,
|
|
32
|
+
['aria-label']: ariaLabel,
|
|
33
|
+
['aria-labelledby']: ariaLabelledby,
|
|
34
|
+
});
|
|
35
|
+
return (
|
|
36
|
+
<svg
|
|
37
|
+
className={cx(
|
|
38
|
+
{
|
|
39
|
+
[fillStyle]: fill != null,
|
|
40
|
+
},
|
|
41
|
+
noFlexShrink,
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
height={typeof size === 'number' ? size : sizeMap[size]}
|
|
45
|
+
width={typeof size === 'number' ? size : sizeMap[size]}
|
|
46
|
+
role={role}
|
|
47
|
+
{...accessibleProps}
|
|
48
|
+
{...props}
|
|
49
|
+
viewBox="0 0 16 16"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
d="M13 8C13 10.7614 10.7614 13 8 13C7.16895 13 6.38526 12.7973 5.69568 12.4385C5.34783 12.2576 4.90944 12.3087 4.65841 12.6099L4.32712 13.0075C4.05174 13.3379 4.1087 13.8355 4.48034 14.0521C5.51438 14.6548 6.71687 15 8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C6.05606 1 4.2972 1.7924 3.02879 3.07181L1.96954 2.14618C1.56206 1.7901 0.931193 2.13127 1.00611 2.66721L1.4606 5.9185C1.50083 6.20624 1.7463 6.4287 2.03684 6.43H5.31972C5.86086 6.43241 6.1144 5.76821 5.70691 5.41212L4.53896 4.3915C5.4373 3.52965 6.65679 3 8 3C10.7614 3 13 5.23858 13 8Z"
|
|
53
|
+
fill={'currentColor'}
|
|
54
|
+
/>
|
|
55
|
+
<path
|
|
56
|
+
d="M7.25 5.25C7.25 4.83579 7.58579 4.5 8 4.5C8.41421 4.5 8.75 4.83579 8.75 5.25V7.91793L10.4294 9.44169C10.7412 9.71445 10.7728 10.1883 10.5 10.5C10.2272 10.8117 9.75342 10.8433 9.44169 10.5706L7.50697 8.81519C7.49904 8.80826 7.49125 8.80117 7.48361 8.79391C7.41388 8.72781 7.35954 8.65118 7.32088 8.56868C7.27541 8.47196 7.25 8.36395 7.25 8.25V5.25Z"
|
|
57
|
+
fill={'currentColor'}
|
|
58
|
+
/>
|
|
59
|
+
</svg>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
ClockWithArrow.displayName = 'ClockWithArrow';
|
|
64
|
+
ClockWithArrow.isGlyph = true;
|
|
65
|
+
ClockWithArrow.propTypes = {
|
|
66
|
+
fill: PropTypes.string,
|
|
67
|
+
size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
68
|
+
className: PropTypes.string,
|
|
69
|
+
};
|
|
70
|
+
export default ClockWithArrow;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a generated file. Do not modify it manually.
|
|
3
|
+
*
|
|
4
|
+
* @script ./node_modules/.bin/ts-node packages/icon/scripts/build.ts
|
|
5
|
+
* @checksum 472b9840b2d10f0876a3c95cb82ae7c1
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { css, cx } from '@leafygreen-ui/emotion';
|
|
10
|
+
import { generateAccessibleProps, sizeMap } from '../glyphCommon';
|
|
11
|
+
import { LGGlyph } from '../types';
|
|
12
|
+
export interface KeyProps extends LGGlyph.ComponentProps {}
|
|
13
|
+
|
|
14
|
+
const Key = ({
|
|
15
|
+
className,
|
|
16
|
+
size = 16,
|
|
17
|
+
title,
|
|
18
|
+
['aria-label']: ariaLabel,
|
|
19
|
+
['aria-labelledby']: ariaLabelledby,
|
|
20
|
+
fill,
|
|
21
|
+
role = 'img',
|
|
22
|
+
...props
|
|
23
|
+
}: KeyProps) => {
|
|
24
|
+
const fillStyle = css`
|
|
25
|
+
color: ${fill};
|
|
26
|
+
`;
|
|
27
|
+
const noFlexShrink = css`
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
`;
|
|
30
|
+
const accessibleProps = generateAccessibleProps(role, 'Key', {
|
|
31
|
+
title,
|
|
32
|
+
['aria-label']: ariaLabel,
|
|
33
|
+
['aria-labelledby']: ariaLabelledby,
|
|
34
|
+
});
|
|
35
|
+
return (
|
|
36
|
+
<svg
|
|
37
|
+
className={cx(
|
|
38
|
+
{
|
|
39
|
+
[fillStyle]: fill != null,
|
|
40
|
+
},
|
|
41
|
+
noFlexShrink,
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
height={typeof size === 'number' ? size : sizeMap[size]}
|
|
45
|
+
width={typeof size === 'number' ? size : sizeMap[size]}
|
|
46
|
+
role={role}
|
|
47
|
+
{...accessibleProps}
|
|
48
|
+
{...props}
|
|
49
|
+
viewBox="0 0 16 16"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
fillRule="evenodd"
|
|
53
|
+
clipRule="evenodd"
|
|
54
|
+
d="M6 10C6.55427 10 7.08222 9.88726 7.56215 9.68347L8.87868 11L8.43934 11.4393C7.85355 12.0251 7.85355 12.9749 8.43934 13.5607C9.02513 14.1464 9.97487 14.1464 10.5607 13.5607L11 13.1213L11.4393 13.5607C12.0251 14.1464 12.9749 14.1464 13.5607 13.5607C14.1464 12.9749 14.1464 12.0251 13.5607 11.4393L9.68347 7.56215C9.88726 7.08222 10 6.55427 10 6C10 3.79086 8.20914 2 6 2C3.79086 2 2 3.79086 2 6C2 8.20914 3.79086 10 6 10ZM5.25 6.5C5.94036 6.5 6.5 5.94036 6.5 5.25C6.5 4.55964 5.94036 4 5.25 4C4.55964 4 4 4.55964 4 5.25C4 5.94036 4.55964 6.5 5.25 6.5Z"
|
|
55
|
+
fill={'currentColor'}
|
|
56
|
+
/>
|
|
57
|
+
</svg>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
Key.displayName = 'Key';
|
|
62
|
+
Key.isGlyph = true;
|
|
63
|
+
Key.propTypes = {
|
|
64
|
+
fill: PropTypes.string,
|
|
65
|
+
size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
66
|
+
className: PropTypes.string,
|
|
67
|
+
};
|
|
68
|
+
export default Key;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a generated file. Do not modify it manually.
|
|
3
|
+
*
|
|
4
|
+
* @script ./node_modules/.bin/ts-node packages/icon/scripts/build.ts
|
|
5
|
+
* @checksum 8138c0459c5346416e419e5fc40eab64
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { css, cx } from '@leafygreen-ui/emotion';
|
|
10
|
+
import { generateAccessibleProps, sizeMap } from '../glyphCommon';
|
|
11
|
+
import { LGGlyph } from '../types';
|
|
12
|
+
export interface NoteProps extends LGGlyph.ComponentProps {}
|
|
13
|
+
|
|
14
|
+
const Note = ({
|
|
15
|
+
className,
|
|
16
|
+
size = 16,
|
|
17
|
+
title,
|
|
18
|
+
['aria-label']: ariaLabel,
|
|
19
|
+
['aria-labelledby']: ariaLabelledby,
|
|
20
|
+
fill,
|
|
21
|
+
role = 'img',
|
|
22
|
+
...props
|
|
23
|
+
}: NoteProps) => {
|
|
24
|
+
const fillStyle = css`
|
|
25
|
+
color: ${fill};
|
|
26
|
+
`;
|
|
27
|
+
const noFlexShrink = css`
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
`;
|
|
30
|
+
const accessibleProps = generateAccessibleProps(role, 'Note', {
|
|
31
|
+
title,
|
|
32
|
+
['aria-label']: ariaLabel,
|
|
33
|
+
['aria-labelledby']: ariaLabelledby,
|
|
34
|
+
});
|
|
35
|
+
return (
|
|
36
|
+
<svg
|
|
37
|
+
className={cx(
|
|
38
|
+
{
|
|
39
|
+
[fillStyle]: fill != null,
|
|
40
|
+
},
|
|
41
|
+
noFlexShrink,
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
height={typeof size === 'number' ? size : sizeMap[size]}
|
|
45
|
+
width={typeof size === 'number' ? size : sizeMap[size]}
|
|
46
|
+
role={role}
|
|
47
|
+
{...accessibleProps}
|
|
48
|
+
{...props}
|
|
49
|
+
viewBox="0 0 16 16"
|
|
50
|
+
>
|
|
51
|
+
<path
|
|
52
|
+
d="M4.5 6.25C4.5 5.83579 4.83579 5.5 5.25 5.5H8.75C9.16421 5.5 9.5 5.83579 9.5 6.25C9.5 6.66421 9.16421 7 8.75 7H5.25C4.83579 7 4.5 6.66421 4.5 6.25Z"
|
|
53
|
+
fill={'currentColor'}
|
|
54
|
+
/>
|
|
55
|
+
<path
|
|
56
|
+
d="M4.5 8.75C4.5 8.33579 4.83579 8 5.25 8H6.75C7.16421 8 7.5 8.33579 7.5 8.75C7.5 9.16421 7.16421 9.5 6.75 9.5H5.25C4.83579 9.5 4.5 9.16421 4.5 8.75Z"
|
|
57
|
+
fill={'currentColor'}
|
|
58
|
+
/>
|
|
59
|
+
<path
|
|
60
|
+
fillRule="evenodd"
|
|
61
|
+
clipRule="evenodd"
|
|
62
|
+
d="M15 10L11 14H3C1.89543 14 1 13.1046 1 12V4C1 2.89543 1.89543 2 3 2H13C14.1046 2 15 2.89543 15 4V10ZM13 4H3L3 12H10V10C10 9.44772 10.4477 9 11 9H13V4Z"
|
|
63
|
+
fill={'currentColor'}
|
|
64
|
+
/>
|
|
65
|
+
</svg>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Note.displayName = 'Note';
|
|
70
|
+
Note.isGlyph = true;
|
|
71
|
+
Note.propTypes = {
|
|
72
|
+
fill: PropTypes.string,
|
|
73
|
+
size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
74
|
+
className: PropTypes.string,
|
|
75
|
+
};
|
|
76
|
+
export default Note;
|