1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-09 15:46:55 +02:00

feat: Wizard

This commit is contained in:
Phuoc Nguyen
2022-09-21 15:49:56 +07:00
parent b7bd6a9d0a
commit 151fed0eaa
7 changed files with 143 additions and 308 deletions

View File

@@ -0,0 +1,12 @@
<div class="wizard">
{% for i in range(0, 3) -%}
<div class="wizard__step">
<div class="wizard__dot">
<div class="wizard__connector"></div>
<div class="wizard__number"></div>
<div class="wizard__connector"></div>
</div>
{% lines "hor", 5 %}
</div>
{%- endfor %}
</div>

View File

@@ -129,6 +129,7 @@ eleventyExcludeFromCollections: true
{% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %} {% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %}
{% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %} {% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %}
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %} {% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
{% pattern "Wizard" %}{% include "covers/wizard.njk" %}{% endpattern %}
</div> </div>
</div> </div>

84
contents/wizard.md Normal file
View File

@@ -0,0 +1,84 @@
---
layout: layouts/post.njk
title: Wizard
description: Create a wizard with CSS flexbox
keywords: css flexbox, css stepper, css wizard
---
## HTML
```html
<div class="wizard">
<!-- Step -->
<div class="wizard__step">
<div class="wizard__dot">
<!-- The left connector -->
<div class="wizard__connector"></div>
<!-- The step number -->
<div class="wizard__number">
...
</div>
<!-- The right connector -->
<div class="wizard__connector"></div>
</div>
<!-- Title of step -->
...
</div>
<!-- Repeat other steps -->
...
</div>
```
## CSS
```css
.wizard {
display: flex;
}
.wizard__step {
/* Make all steps have the same width */
flex: 1;
}
.wizard__dot {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
}
.wizard__connector {
flex: 1;
height: 1px;
background-color: #d1d5db;
}
.wizard__step:first-child .wizard__connector:first-child,
.wizard__step:last-child .wizard__connector:last-child {
background-color: transparent;
}
.wizard__number {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
/* Rounded border */
background-color: #d1d5db;
border-radius: 9999px;
height: 2rem;
width: 2rem;
/* OPTIONAL: Spacing between it and connectors */
margin-left: 0.25rem;
margin-right: 0.25rem;
}
```
{% demo %}{% include "covers/wizard.njk" %}{% enddemo %}

View File

@@ -1,196 +0,0 @@
import * as React from 'react';
import Head from 'next/head';
import { Pattern } from '../../constants/Pattern';
import { PatternLayout } from '../../layouts/PatternLayout';
import Block from '../../placeholders/Block';
import BrowserFrame from '../../placeholders/BrowserFrame';
import Circle from '../../placeholders/Circle';
import Line from '../../placeholders/Line';
const Details: React.FC<{}> = () => {
return (
<PatternLayout pattern={Pattern.Wizard}>
<Head>
<meta name="description" content="Create a wizard with CSS flexbox" />
<meta name="og:description" content="Create a wizard with CSS flexbox" />
<meta name="twitter:description" content="Create a wizard with CSS flexbox" />
<meta name="keywords" content="css flexbox, css stepper, css wizard" />
</Head>
<BrowserFrame
html={`
<div class="wizard">
<!-- Step -->
<div class="wizard__step">
<div class="wizard__dot">
<!-- The left connector -->
<div class="wizard__connector"></div>
<!-- The step number -->
<div class="wizard__number">
...
</div>
<!-- The right connector -->
<div class="wizard__connector"></div>
</div>
<!-- Title of step -->
...
</div>
<!-- Repeat other steps -->
...
</div>
`}
css={`
.wizard {
display: flex;
}
.wizard__step {
/* Make all steps have the same width */
flex: 1;
}
.wizard__dot {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
}
.wizard__connector {
flex: 1;
height: 1px;
background-color: #d1d5db;
}
.wizard__step:first-child .wizard__connector,
.wizard__step:last-child .wizard__connector {
background-color: transparent;
}
.wizard__number {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
/* Rounded border */
background-color: #d1d5db;
border-radius: 9999px;
height: 32px;
width: 32px;
/* OPTIONAL: Spacing between it and connectors */
margin-left: 4px;
margin-right: 4px;
}
`}
>
<div
style={{
alignItems: 'center',
display: 'flex',
flexDirection: 'column',
height: '100%',
justifyContent: 'center',
padding: '8px',
}}
>
<div style={{ display: 'flex', width: '80%' }}>
<div style={{ flex: 1 }}>
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
marginBottom: '16px',
}}
>
<div style={{ flex: 1 }} />
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
margin: '0 4px',
}}
>
<Circle size={32} />
</div>
<div style={{ flex: 1 }}>
<Line />
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'center', padding: '0 16px' }}>
<Block justify="center" numberOfBlocks={5} />
</div>
</div>
<div style={{ flex: 1 }}>
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
marginBottom: '16px',
}}
>
<div style={{ flex: 1 }}>
<Line />
</div>
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
margin: '0 4px',
}}
>
<Circle size={32} />
</div>
<div style={{ flex: 1 }}>
<Line />
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'center', padding: '0 16px' }}>
<Block justify="center" numberOfBlocks={5} />
</div>
</div>
<div style={{ flex: 1 }}>
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
marginBottom: '16px',
}}
>
<div style={{ flex: 1 }}>
<Line />
</div>
<div
style={{
alignItems: 'center',
display: 'flex',
justifyContent: 'center',
margin: '0 4px',
}}
>
<Circle size={32} />
</div>
<div style={{ flex: 1 }} />
</div>
<div style={{ display: 'flex', justifyContent: 'center', padding: '0 16px' }}>
<Block justify="center" numberOfBlocks={5} />
</div>
</div>
</div>
</div>
</BrowserFrame>
</PatternLayout>
);
};
export default Details;

View File

@@ -1,112 +0,0 @@
import * as React from 'react';
import Frame from '../../placeholders/Frame';
import Line from '../../placeholders/Line';
const Cover: React.FC<{}> = () => {
return (
<Frame>
<div
style={{
alignItems: 'center',
display: 'flex',
flexDirection: 'column',
height: '100%',
justifyContent: 'center',
padding: '8px',
}}
>
<div style={{ display: 'flex', width: '100%' }}>
<div
style={{
alignItems: 'center',
display: 'flex',
flex: 1,
justifyContent: 'center',
}}
>
<div style={{ flex: 1 }} />
<div
style={{
alignItems: 'center',
backgroundColor: '#d1d5db',
borderRadius: '9999px',
color: '#FFF',
display: 'flex',
fontSize: '12px',
height: '16px',
justifyContent: 'center',
width: '16px',
}}
>
1
</div>
<div style={{ flex: 1 }}>
<Line />
</div>
</div>
<div
style={{
alignItems: 'center',
display: 'flex',
flex: 1,
justifyContent: 'center',
}}
>
<div style={{ flex: 1 }}>
<Line />
</div>
<div
style={{
alignItems: 'center',
backgroundColor: '#d1d5db',
borderRadius: '9999px',
color: '#FFF',
display: 'flex',
fontSize: '12px',
height: '16px',
justifyContent: 'center',
width: '16px',
}}
>
2
</div>
<div style={{ flex: 1 }}>
<Line />
</div>
</div>
<div
style={{
alignItems: 'center',
display: 'flex',
flex: 1,
justifyContent: 'center',
}}
>
<div style={{ flex: 1 }}>
<Line />
</div>
<div
style={{
alignItems: 'center',
backgroundColor: '#d1d5db',
borderRadius: '9999px',
color: '#FFF',
display: 'flex',
fontSize: '12px',
height: '16px',
justifyContent: 'center',
width: '16px',
}}
>
3
</div>
<div style={{ flex: 1 }} />
</div>
</div>
</div>
</Frame>
);
};
export default Cover;

View File

@@ -102,6 +102,7 @@
@import './patterns/video-background'; @import './patterns/video-background';
@import './patterns/voting'; @import './patterns/voting';
@import './patterns/watermark'; @import './patterns/watermark';
@import './patterns/wizard';
@import './patterns/zigzag-timeline'; @import './patterns/zigzag-timeline';
// Placeholders // Placeholders

View File

@@ -0,0 +1,45 @@
.wizard {
align-items: center;
display: flex;
justify-content: center;
/* Demo */
height: 8rem;
width: 8rem;
}
.wizard__step {
/* Make all steps have the same width */
flex: 1;
}
.wizard__dot {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
}
.wizard__connector {
flex: 1;
height: 1px;
background-color: #d1d5db;
}
.wizard__step:first-child .wizard__connector:first-child,
.wizard__step:last-child .wizard__connector:last-child {
background-color: transparent;
}
.wizard__number {
/* Center the content */
align-items: center;
display: flex;
justify-content: center;
/* Rounded border */
background-color: #d1d5db;
border-radius: 9999px;
height: 1rem;
width: 1rem;
}