1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-10-23 18:56:29 +02:00
Files
csslayout/client/patterns/progress-bar/Details.tsx
2019-11-24 23:09:38 +07:00

62 lines
1.7 KiB
TypeScript

import React, { useState } from 'react';
import DetailsLayout from '../../layouts/DetailsLayout';
import BrowserFrame from '../../placeholders/BrowserFrame';
import useInterval from '../../hooks/useInterval';
const Details = () => {
const [progress, setProgress] = useState(0);
useInterval(() => {
setProgress(v => v === 100 ? 0 : v + 1);
}, 1 * 100);
return (
<DetailsLayout title="Progress bar">
<div className="ph4 pv5">
<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={`
<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>
`}
/>
</div>
</DetailsLayout>
);
};
export default Details;