1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-26 23:35:08 +02:00

Add progress bar

This commit is contained in:
Phuoc Nguyen
2019-11-17 15:37:29 +07:00
parent f4efd511d3
commit 87e18d0333
4 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import React from 'react';
import Frame from '../../placeholders/Frame';
const Cover = () => {
return (
<Frame>
<div className="h-100 flex flex-column items-center justify-center pa2">
<div className="h1 w-100 br-pill bg-black-10 pa1">
<div className="w-40 br-pill h-100 bg-blue" />
</div>
</div>
</Frame>
);
};
export default Cover;

View File

@@ -0,0 +1,68 @@
import React, { useState } from 'react';
import DetailsLayout from '../../DetailsLayout';
import BrowserFrame from '../../placeholders/BrowserFrame';
import SampleCode from '../../SampleCode';
import useDocumentTitle from '../../useDocumentTitle';
import useInterval from '../../hooks/useInterval';
const Details = () => {
useDocumentTitle('CSS Layout ∙ Progress bar');
const [progress, setProgress] = useState(0);
useInterval(() => {
setProgress(v => v === 100 ? 0 : v + 1);
}, 1 * 100);
return (
<DetailsLayout>
<h1 className="f1 tc">Progress bar</h1>
<BrowserFrame
content={
<div className="h-100 flex flex-column items-center justify-center">
<div className="h1 w-50 br-pill bg-black-10">
<div className="br-pill h-100 bg-blue flex items-center justify-center pa1 white f7" style={{ width: `${progress}%` }}>
{progress}%
</div>
</div>
</div>
}
source={
<SampleCode
lang="html"
code={`
<div style="
/* Colors */
background-color: rgba(0, 0, 0, .1);
/* Rounded border */
border-radius: 9999px;
">
<div style="
/* Content is centered */
align-items: center;
display: flex;
justify-content: center;
/* Colors */
background-color: #357edd;
color: #fff;
/* Rounded border */
border-radius: 9999px;
/* Width based on the number of percentages */
width: 40%;
">
<!-- The number of percentages -->
40%
</div>
</div>
`}
/>
}
/>
</DetailsLayout>
);
};
export default Details;