Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
556c89a0
Commit
556c89a0
authored
Apr 01, 2020
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document type of icon registry
Improve documentation per PR feedback.
parent
67a51874
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
svg-icon.js
src/sidebar/components/svg-icon.js
+12
-2
No files found.
src/sidebar/components/svg-icon.js
View file @
556c89a0
...
...
@@ -3,8 +3,16 @@ import { createElement } from 'preact';
import
{
useLayoutEffect
,
useRef
}
from
'preact/hooks'
;
import
propTypes
from
'prop-types'
;
/**
* Object mapping icon names to SVG markup.
*
* @typedef {{[name: string]: string}} IconMap
*/
/**
* Map of icon name to SVG data.
*
* @type {IconMap}
*/
let
iconRegistry
=
{};
...
...
@@ -54,7 +62,7 @@ export default function SvgIcon({
SvgIcon
.
propTypes
=
{
/**
* The name of the icon to
load
.
* The name of the icon to
display
.
*
* The name must match a name that has already been registered using the
* `registerIcons` function.
...
...
@@ -74,7 +82,7 @@ SvgIcon.propTypes = {
/**
* Register icons for use with the `SvgIcon` component.
*
* @param {
Object
} icons - Object mapping icon names to SVG data.
* @param {
IconMap
} icons - Object mapping icon names to SVG data.
* @param {boolean} [options.reset] - If `true`, remove existing registered icons.
*/
export
function
registerIcons
(
icons
,
{
reset
=
false
}
=
{})
{
...
...
@@ -89,6 +97,8 @@ export function registerIcons(icons, { reset = false } = {}) {
*
* To register icons, don't mutate this directly but call `registerIcons`
* instead.
*
* @return {IconMap}
*/
export
function
availableIcons
()
{
return
iconRegistry
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment