mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-17 19:37:26 +02:00
feat: Progress bar
This commit is contained in:
3
contents/_includes/patterns/progress-bar.njk
Normal file
3
contents/_includes/patterns/progress-bar.njk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="progress-bar">
|
||||||
|
<div class="progress-bar__progress">40%</div>
|
||||||
|
</div>
|
@@ -64,7 +64,7 @@ eleventyExcludeFromCollections: true
|
|||||||
{% pattern "Triangle buttons" %}{% include "patterns/triangle-buttons.njk" %}{% endpattern %}
|
{% pattern "Triangle buttons" %}{% include "patterns/triangle-buttons.njk" %}{% endpattern %}
|
||||||
{% pattern "Video background" %}{% include "patterns/video-background.njk" %}{% endpattern %}
|
{% pattern "Video background" %}{% include "patterns/video-background.njk" %}{% endpattern %}
|
||||||
{% pattern "Voting" %}{% include "patterns/voting.njk" %}{% endpattern %}
|
{% pattern "Voting" %}{% include "patterns/voting.njk" %}{% endpattern %}
|
||||||
{% pattern "Watermark" %}{% include "patterns/Watermark.njk" %}{% endpattern %}
|
{% pattern "Watermark" %}{% include "patterns/watermark.njk" %}{% endpattern %}
|
||||||
{% pattern "Zigzag timeline" %}{% include "patterns/zigzag-timeline.njk" %}{% endpattern %}
|
{% pattern "Zigzag timeline" %}{% include "patterns/zigzag-timeline.njk" %}{% endpattern %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -73,6 +73,7 @@ eleventyExcludeFromCollections: true
|
|||||||
<h2 class="category__name">Feedback</h2>
|
<h2 class="category__name">Feedback</h2>
|
||||||
<div class="category__posts">
|
<div class="category__posts">
|
||||||
{% pattern "Popover arrow" %}{% include "patterns/popover-arrow.njk" %}{% endpattern %}
|
{% pattern "Popover arrow" %}{% include "patterns/popover-arrow.njk" %}{% endpattern %}
|
||||||
|
{% pattern "Progress bar" %}{% include "patterns/progress-bar.njk" %}{% endpattern %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
49
contents/progress-bar.md
Normal file
49
contents/progress-bar.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Progress bar
|
||||||
|
description: Create a progress bar with CSS flexbox
|
||||||
|
keywords: css flexbox, css progress bar
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="container">
|
||||||
|
<!-- Width based on the number of percentages -->
|
||||||
|
<div class="container__progress" style="width: 40%;">
|
||||||
|
<!-- The number of percentages -->
|
||||||
|
40%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.progress-bar {
|
||||||
|
/* Colors */
|
||||||
|
background-color: #d1d5db;
|
||||||
|
|
||||||
|
/* Rounded border */
|
||||||
|
border-radius: 9999px;
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar__progress {
|
||||||
|
/* Center the content */
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
/* Colors */
|
||||||
|
background-color: #3b82f6;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
/* Rounded border */
|
||||||
|
border-radius: 9999px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{% demo %}
|
||||||
|
{% include "patterns/progress-bar.njk" %}
|
||||||
|
{% enddemo %}
|
@@ -1,100 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import { Pattern } from '../../constants/Pattern';
|
|
||||||
|
|
||||||
import useInterval from '../../hooks/useInterval';
|
|
||||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
|
||||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
|
||||||
|
|
||||||
const Details: React.FC<{}> = () => {
|
|
||||||
const [progress, setProgress] = React.useState(0);
|
|
||||||
useInterval(() => {
|
|
||||||
setProgress((v) => (v === 100 ? 0 : v + 1));
|
|
||||||
}, 1 * 100);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PatternLayout pattern={Pattern.ProgressBar}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create a progress bar with CSS flexbox" />
|
|
||||||
<meta name="og:description" content="Create a progress bar with CSS flexbox" />
|
|
||||||
<meta name="twitter:description" content="Create a progress bar with CSS flexbox" />
|
|
||||||
<meta name="keywords" content="css flexbox, css progress bar" />
|
|
||||||
</Head>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<div class="container">
|
|
||||||
<div class="container__progress" style="
|
|
||||||
/* Width based on the number of percentages */
|
|
||||||
width: 40%;
|
|
||||||
">
|
|
||||||
<!-- The number of percentages -->
|
|
||||||
40%
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.container {
|
|
||||||
/* Colors */
|
|
||||||
background-color: rgba(0, 0, 0, 0.1);
|
|
||||||
|
|
||||||
/* Rounded border */
|
|
||||||
border-radius: 9999px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__progress {
|
|
||||||
/* Center the content */
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
/* Colors */
|
|
||||||
background-color: #357edd;
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
/* Rounded border */
|
|
||||||
border-radius: 9999px;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
||||||
borderRadius: '9999px',
|
|
||||||
height: '16px',
|
|
||||||
width: '50%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: '#357EDD',
|
|
||||||
borderRadius: '9999px',
|
|
||||||
color: '#FFF',
|
|
||||||
display: 'flex',
|
|
||||||
fontSize: '12px',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '4px',
|
|
||||||
width: `${progress}%`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{progress}%
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,41 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import Frame from '../../placeholders/Frame';
|
|
||||||
|
|
||||||
const Cover: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<Frame>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
||||||
borderRadius: '9999px',
|
|
||||||
height: '16px',
|
|
||||||
padding: '4px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
||||||
borderRadius: '9999px',
|
|
||||||
height: '100%',
|
|
||||||
width: '40%',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -46,6 +46,7 @@
|
|||||||
@import './patterns/popover-arrow';
|
@import './patterns/popover-arrow';
|
||||||
@import './patterns/price-tag';
|
@import './patterns/price-tag';
|
||||||
@import './patterns/pricing-table';
|
@import './patterns/pricing-table';
|
||||||
|
@import './patterns/progress-bar';
|
||||||
@import './patterns/property-list';
|
@import './patterns/property-list';
|
||||||
@import './patterns/questions-and-answers';
|
@import './patterns/questions-and-answers';
|
||||||
@import './patterns/ribbon';
|
@import './patterns/ribbon';
|
||||||
|
27
styles/patterns/_progress-bar.scss
Normal file
27
styles/patterns/_progress-bar.scss
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
.progress-bar {
|
||||||
|
/* Colors */
|
||||||
|
background-color: #d1d5db;
|
||||||
|
|
||||||
|
/* Rounded border */
|
||||||
|
border-radius: 9999px;
|
||||||
|
padding: 0.25rem;
|
||||||
|
|
||||||
|
/* Demo */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar__progress {
|
||||||
|
/* Center the content */
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
/* Colors */
|
||||||
|
background-color: #3b82f6;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
/* Rounded border */
|
||||||
|
border-radius: 9999px;
|
||||||
|
|
||||||
|
width: 40%;
|
||||||
|
}
|
Reference in New Issue
Block a user