FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing-website/src/components/examples/ExamplesList.js at main · processing/processing-website · GitHub
processing
processing-website
Repository navigation
Code
Issues
112
(112)
Pull requests
16
(16)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
processing-website
/
src
/
components
/
examples
/
ExamplesList.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
87 lines (78 loc) · 2.83 KB
Breadcrumbs
processing-website
/
src
/
components
/
examples
/
ExamplesList.js
Copy path
File metadata and controls
87 lines (78 loc) · 2.83 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import
React
,
{
Fragment
,
memo
,
useState
}
from
'react'
;
import
classnames
from
'classnames'
;
import
{
LocalizedLink
as
Link
}
from
'gatsby-theme-i18n'
;
import
{
useIntl
}
from
'react-intl'
;
import
{
GatsbyImage
}
from
'gatsby-plugin-image'
;
import
ToggleButton
from
'../ToggleButton'
;
import
{
slugify
}
from
'../../utils'
;
import
{
useTreeSort
}
from
'../../hooks'
;
import
*
as
css
from
'./ExamplesList.module.css'
;
import
*
as
grid
from
'../../styles/grid.module.css'
;
const
ExamplesList
=
(
{
tree
}
)
=>
{
const
intl
=
useIntl
(
)
;
const
[
curated
,
setCurated
]
=
useState
(
false
)
;
const
handleToggle
=
(
toggle
)
=>
{
setCurated
(
(
curated
)
=>
!
curated
)
;
}
;
const
sortedTree
=
useTreeSort
(
tree
,
`order`
,
curated
)
;
return
(
<
div
className
=
{
classnames
(
grid
.
col
,
css
.
root
)
}
>
{
Object
.
keys
(
sortedTree
)
.
map
(
(
category
)
=>
(
<
Fragment
key
=
{
`category-
${
category
}
`
}
>
<
div
className
=
{
css
.
categoryName
}
>
<
h2
id
=
{
slugify
(
category
)
}
>
{
intl
.
formatMessage
(
{
id
:
category
}
)
}
</
h2
>
<
div
className
=
{
css
.
toggleButton
}
>
<
ToggleButton
defaultLabel
=
"A-Z"
pressedLabel
=
{
intl
.
formatMessage
(
{
id
:
'PressedSortByLevel'
}
)
}
ariaLabel
=
"Sort by level"
toggle
=
{
curated
}
onToggle
=
{
handleToggle
}
/>
</
div
>
</
div
>
<
p
className
=
{
css
.
categoryDescription
}
>
{
category
===
'Topics'
?
intl
.
formatMessage
(
{
id
:
'topicExamples'
}
)
:
intl
.
formatMessage
(
{
id
:
'basicExamples'
}
)
}
</
p
>
<
div
className
=
{
classnames
(
grid
.
grid
,
css
.
category
)
}
>
{
Object
.
keys
(
sortedTree
[
category
]
)
.
map
(
(
subcategory
)
=>
(
<
Fragment
key
=
{
`subcategory-
${
subcategory
}
`
}
>
<
h3
id
=
{
slugify
(
category
,
subcategory
)
}
className
=
{
classnames
(
grid
.
col
,
css
.
subcategoryName
)
}
>
{
intl
.
formatMessage
(
{
id
:
subcategory
}
)
}
</
h3
>
<
ul
className
=
{
classnames
(
grid
.
col
,
grid
.
grid
,
css
.
examples
)
}
>
{
sortedTree
[
category
]
[
subcategory
]
.
map
(
(
item
,
key
)
=>
(
<
ExampleItem
node
=
{
item
}
key
=
{
`item-
${
item
.
name
}
`
}
/>
)
)
}
</
ul
>
</
Fragment
>
)
)
}
</
div
>
</
Fragment
>
)
)
}
</
div
>
)
;
}
;
export
const
ExampleItem
=
memo
(
(
{
node
,
variant
}
)
=>
{
return
(
<
li
className
=
{
classnames
(
grid
.
col
,
css
.
item
,
{
[
css
[
variant
]
]
:
variant
}
)
}
>
<
Link
to
=
{
node
.
path
}
>
{
node
.
image
&&
(
<
GatsbyImage
className
=
{
css
.
cover
}
image
=
{
node
.
image
.
childImageSharp
.
gatsbyImageData
}
alt
=
{
node
.
name
}
/>
)
}
<
h4
>
{
node
.
name
}
</
h4
>
</
Link
>
</
li
>
)
;
}
)
;
export
default
memo
(
ExamplesList
)
;
Back
|
FazBrowse Home
|
New Git URL