Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
7e2fedb0
Unverified
Commit
7e2fedb0
authored
Mar 27, 2020
by
Alex Khomenko
Committed by
GitHub
Mar 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storybook: Sort icons by name (#23115)
* Storybook: Sort icons by name * Storybook: Add icon search
parent
be157b84
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
packages/grafana-ui/src/components/Icon/Icon.story.tsx
+24
-24
No files found.
packages/grafana-ui/src/components/Icon/Icon.story.tsx
View file @
7e2fedb0
import
React
from
'react'
;
import
React
,
{
ChangeEvent
,
useState
}
from
'react'
;
import
{
css
}
from
'emotion'
;
import
{
Forms
}
from
'../index'
;
import
{
Icon
}
from
'./Icon'
;
import
{
getAvailableIcons
,
IconType
}
from
'./types'
;
import
{
withCenteredStory
}
from
'../../utils/storybook/withCenteredStory'
;
...
...
@@ -32,8 +33,6 @@ const IconWrapper: React.FC<{ name: IconType }> = ({ name }) => {
<
div
className=
{
css
`
width: 150px;
height: 60px;
display: table-cell;
padding: 12px;
border: 1px solid ${borderColor};
text-align: center;
...
...
@@ -63,41 +62,42 @@ const IconWrapper: React.FC<{ name: IconType }> = ({ name }) => {
);
};
const
icons
=
getAvailableIcons
().
sort
((
a
,
b
)
=>
a
.
localeCompare
(
b
));
export
const
simple
=
()
=>
{
const
icons
=
getAvailableIcons
();
const
iconsPerRow
=
10
;
const
rows
:
IconType
[][]
=
[[]];
let
rowIdx
=
0
;
const
[
filter
,
setFilter
]
=
useState
(
''
);
icons
.
forEach
((
i
:
IconType
,
idx
:
number
)
=>
{
if
(
idx
%
iconsPerRow
===
0
)
{
rows
.
push
([]);
rowIdx
++
;
}
rows
[
rowIdx
].
push
(
i
);
});
const
searchIcon
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setFilter
(
event
.
target
.
value
);
};
return
(
<
div
className=
{
css
`
display:
table
;
table-layout: fixed
;
border-collapse: collapse
;
display:
flex
;
flex-direction: column
;
width: 100%
;
`
}
>
{
rows
.
map
(
r
=>
{
return
(
<
Forms
.
Field
className=
{
css
`
width: 300px;
`
}
>
<
Forms
.
Input
onChange=
{
searchIcon
}
placeholder=
"Search icons by name"
/>
</
Forms
.
Field
>
<
div
className=
{
css
`
display: table-row;
display: flex;
flex-wrap: wrap;
`
}
>
{
r
.
map
((
i
,
index
)
=>
{
return
<
IconWrapper
name=
{
i
}
/>;
{
icons
.
filter
(
val
=>
val
.
includes
(
filter
))
.
map
(
i
=>
{
return
<
IconWrapper
name=
{
i
}
key=
{
i
}
/>;
})
}
</
div
>
);
})
}
</
div
>
);
};
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