mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-07 14:46:38 +02:00
feat: Zigzag timeline
This commit is contained in:
8
contents/_includes/patterns/zigzag-timeline.njk
Normal file
8
contents/_includes/patterns/zigzag-timeline.njk
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<div class="zigzag-timeline">
|
||||||
|
{% for i in range(0, 2) -%}
|
||||||
|
<div class="zigzag-timeline__item">
|
||||||
|
<div class="zigzag-timeline__milestone"></div>
|
||||||
|
{% lines "hor", 5 %}
|
||||||
|
</div>
|
||||||
|
{%- endfor %}
|
||||||
|
</div>
|
@@ -295,6 +295,12 @@ eleventyExcludeFromCollections: true
|
|||||||
<div class="pattern__title">Watermark</div>
|
<div class="pattern__title">Watermark</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pattern__item">
|
||||||
|
<a class="pattern__link" href="/zigzag-timeline/">
|
||||||
|
<div class="pattern__cover">{% include "patterns/zigzag-timeline.njk" %}</div>
|
||||||
|
<div class="pattern__title">Zigzag timeline</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
72
contents/zigzag-timeline.md
Normal file
72
contents/zigzag-timeline.md
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Zigzag timeline
|
||||||
|
description: Create a zigzag timeline
|
||||||
|
keywords: css timeline, css zigzag timeline
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="zigzag-timeline__item">
|
||||||
|
<!-- Milestone -->
|
||||||
|
<div className="zigzag-timeline__milestone">...</div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Repeat other items -->
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.zigzag-timeline__item {
|
||||||
|
/* Used to position the milestone */
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
border-bottom: 1px solid #9ca3af;
|
||||||
|
|
||||||
|
/* Take full width */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zigzag-timeline__milestone {
|
||||||
|
/* Absolute position */
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
|
||||||
|
/* Circle it */
|
||||||
|
border-radius: 50%;
|
||||||
|
height: 1rem;
|
||||||
|
width: 1rem;
|
||||||
|
|
||||||
|
/* Misc */
|
||||||
|
background: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Styles for even items */
|
||||||
|
.zigzag-timeline__item:nth-child(2n) {
|
||||||
|
border-left: 1px solid #9ca3af;
|
||||||
|
}
|
||||||
|
.zigzag-timeline__item:nth-child(2n) .zigzag-timeline__milestone {
|
||||||
|
left: 0;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Styles for odd items */
|
||||||
|
.zigzag-timeline__item:nth-child(2n + 1) {
|
||||||
|
border-right: 1px solid #9ca3af;
|
||||||
|
}
|
||||||
|
.zigzag-timeline__item:nth-child(2n + 1) .zigzag-timeline__milestone {
|
||||||
|
right: 0;
|
||||||
|
transform: translate(50%, -50%);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{% demo %}
|
||||||
|
{% include "patterns/zigzag-timeline.njk" %}
|
||||||
|
{% enddemo %}
|
@@ -1,136 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import { Spacer } from '@1milligram/design';
|
|
||||||
|
|
||||||
import { Pattern } from '../../constants/Pattern';
|
|
||||||
import { RelatedPatterns } from '../../components/RelatedPatterns';
|
|
||||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
|
||||||
import Block from '../../placeholders/Block';
|
|
||||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
|
||||||
import Rectangle from '../../placeholders/Rectangle';
|
|
||||||
|
|
||||||
const Details: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<PatternLayout pattern={Pattern.ZigzagTimeline}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create a zigzag timeline" />
|
|
||||||
<meta name="og:description" content="Create a zigzag timeline" />
|
|
||||||
<meta name="twitter:description" content="Create a zigzag timeline" />
|
|
||||||
<meta name="keywords" content="css timeline, css zigzag timeline" />
|
|
||||||
</Head>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<div class="zigzag-timeline__item">
|
|
||||||
<!-- Milestone -->
|
|
||||||
<div className="zigzag-timeline__milestone">...</div>
|
|
||||||
|
|
||||||
<!-- Content -->
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Repeat other items -->
|
|
||||||
...
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.zigzag-timeline__item {
|
|
||||||
/* Used to position the milestone */
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
/* Border */
|
|
||||||
border-bottom: 1px solid #71717a;
|
|
||||||
|
|
||||||
/* Take full width */
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.zigzag-timeline__milestone {
|
|
||||||
/* Absolute position */
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
|
|
||||||
/* Circle it */
|
|
||||||
border-radius: 50%;
|
|
||||||
height: 2rem;
|
|
||||||
width: 2rem;
|
|
||||||
|
|
||||||
/* Misc */
|
|
||||||
background: #71717a;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Styles for even items */
|
|
||||||
.zigzag-timeline__item:nth-child(2n) {
|
|
||||||
border-left: 1px solid #71717a;
|
|
||||||
}
|
|
||||||
.zigzag-timeline__item:nth-child(2n) .zigzag-timeline__milestone {
|
|
||||||
left: 0;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Styles for odd items */
|
|
||||||
.zigzag-timeline__item:nth-child(2n + 1) {
|
|
||||||
border-right: 1px solid #71717a;
|
|
||||||
}
|
|
||||||
.zigzag-timeline__item:nth-child(2n + 1) .zigzag-timeline__milestone {
|
|
||||||
right: 0;
|
|
||||||
transform: translate(50%, -50%);
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
margin: '0 auto',
|
|
||||||
padding: '0.5rem',
|
|
||||||
width: '60%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="zigzag-timeline__item"
|
|
||||||
style={{
|
|
||||||
padding: '1rem 1.5rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="zigzag-timeline__milestone" />
|
|
||||||
<div style={{ marginBottom: '1rem', width: '80%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<Block numberOfBlocks={10} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="zigzag-timeline__item"
|
|
||||||
style={{
|
|
||||||
padding: '1rem 1.5rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="zigzag-timeline__milestone" />
|
|
||||||
<div style={{ marginBottom: '1rem', width: '60%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<Block numberOfBlocks={20} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className="zigzag-timeline__item"
|
|
||||||
style={{
|
|
||||||
padding: '1rem 1.5rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="zigzag-timeline__milestone" />
|
|
||||||
<div style={{ marginBottom: '1rem', width: '70%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<Block numberOfBlocks={15} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
|
|
||||||
<Spacer size="extraLarge" />
|
|
||||||
<RelatedPatterns patterns={[Pattern.Timeline]} />
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,86 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import Frame from '../../placeholders/Frame';
|
|
||||||
import Line from '../../placeholders/Line';
|
|
||||||
import Rectangle from '../../placeholders/Rectangle';
|
|
||||||
|
|
||||||
const Cover: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<Frame>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '0.5rem',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
borderBottom: '1px solid #71717A',
|
|
||||||
borderRight: '1px solid #71717A',
|
|
||||||
padding: '0.5rem 1rem',
|
|
||||||
position: 'relative',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
background: '#71717A',
|
|
||||||
borderRadius: '50%',
|
|
||||||
height: '.75rem',
|
|
||||||
position: 'absolute',
|
|
||||||
right: 0,
|
|
||||||
top: '50%',
|
|
||||||
transform: 'translate(50%, -50%)',
|
|
||||||
width: '.75rem',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div style={{ marginBottom: '0.25rem', width: '80%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '0.25rem', width: '80%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '0.25rem', width: '60%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
borderLeft: '1px solid #71717A',
|
|
||||||
padding: '0.5rem 1rem',
|
|
||||||
position: 'relative',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
background: '#71717A',
|
|
||||||
borderRadius: '50%',
|
|
||||||
height: '.75rem',
|
|
||||||
left: 0,
|
|
||||||
position: 'absolute',
|
|
||||||
top: '50%',
|
|
||||||
transform: 'translate(-50%, -50%)',
|
|
||||||
width: '.75rem',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div style={{ marginBottom: '0.25rem', width: '80%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '0.25rem', width: '60%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '0.25rem', width: '80%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -59,6 +59,7 @@
|
|||||||
@import './patterns/video-background';
|
@import './patterns/video-background';
|
||||||
@import './patterns/voting';
|
@import './patterns/voting';
|
||||||
@import './patterns/watermark';
|
@import './patterns/watermark';
|
||||||
|
@import './patterns/zigzag-timeline';
|
||||||
|
|
||||||
// Placeholders
|
// Placeholders
|
||||||
@import './placeholders/circle';
|
@import './placeholders/circle';
|
||||||
|
47
styles/patterns/_zigzag-timeline.scss
Normal file
47
styles/patterns/_zigzag-timeline.scss
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
.zigzag-timeline {
|
||||||
|
height: 8rem;
|
||||||
|
width: 8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zigzag-timeline__item {
|
||||||
|
/* Used to position the milestone */
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
border-bottom: 1px solid #9ca3af;
|
||||||
|
|
||||||
|
/* Take full width */
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zigzag-timeline__milestone {
|
||||||
|
/* Absolute position */
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
|
||||||
|
/* Circle it */
|
||||||
|
border-radius: 50%;
|
||||||
|
height: 1rem;
|
||||||
|
width: 1rem;
|
||||||
|
|
||||||
|
/* Misc */
|
||||||
|
background: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Styles for even items */
|
||||||
|
.zigzag-timeline__item:nth-child(2n) {
|
||||||
|
border-left: 1px solid #9ca3af;
|
||||||
|
}
|
||||||
|
.zigzag-timeline__item:nth-child(2n) .zigzag-timeline__milestone {
|
||||||
|
left: 0;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Styles for odd items */
|
||||||
|
.zigzag-timeline__item:nth-child(2n + 1) {
|
||||||
|
border-right: 1px solid #9ca3af;
|
||||||
|
}
|
||||||
|
.zigzag-timeline__item:nth-child(2n + 1) .zigzag-timeline__milestone {
|
||||||
|
right: 0;
|
||||||
|
transform: translate(50%, -50%);
|
||||||
|
}
|
@@ -41,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.lines {
|
.lines {
|
||||||
margin: 0.5rem 0;
|
padding: 0.5rem 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
Reference in New Issue
Block a user