-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathdocs.progress.jsx
More file actions
88 lines (77 loc) · 2.43 KB
/
Copy pathdocs.progress.jsx
File metadata and controls
88 lines (77 loc) · 2.43 KB
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
88
import { useEffect, useRef, useState } from "react";
import Code from "~/components/Code";
import Heading from "~/components/Heading";
import Content from "~/components/docs/Content";
import EditOnGithub from "~/components/docs/EditOnGithub";
import Header from "~/components/docs/Header";
import TableOfContents from "~/components/docs/TableOfContents";
import metaData from "~/data/meta";
const { titleSuffix } = metaData;
export const meta = () => [
{ title: `Progress ${titleSuffix}` },
{
name: "description",
content: "The progress bar element in pure HTML, without JavaScript.",
},
];
// Generate a random number between 5 and 95
const randomProgressValue = () => Math.floor(Math.random() * 90) + 5;
export default function Progress() {
const syntaxRef = useRef();
const indeterminateRef = useRef();
// Update progress value every x seconds
const [progressValue, setProgressValue] = useState(randomProgressValue());
useEffect(() => {
const interval = setInterval(() => {
setProgressValue(randomProgressValue());
}, 5000);
return () => clearInterval(interval);
});
return (
<>
{/* Header */}
<Header
title="Progress"
description="The progress bar element in pure HTML, without JavaScript."
/>
{/* Table of content */}
<TableOfContents
data={[
{
anchor: "",
title: "Syntax",
ref: syntaxRef,
},
{
anchor: "indeterminate",
title: "Indeterminate",
ref: indeterminateRef,
},
]}
/>
{/* Content */}
<Content>
<section ref={syntaxRef}>
<article aria-label="Progress example" className="component">
<progress value={progressValue} max="100" />
<Code
as="footer"
display="small"
>{`<progress value="${progressValue}" max="100" />`}</Code>
</article>
</section>
<section ref={indeterminateRef}>
<Heading level={2} anchor="indeterminate">
Indeterminate
</Heading>
<article aria-label="Indeterminate progress example" className="component">
<progress />
<Code as="footer" display="small">{`<progress />`}</Code>
</article>
</section>
{/* Edit on GitHub */}
<EditOnGithub file="docs.progress.jsx" />
</Content>
</>
);
}