mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-11 16:44:57 +02:00
feat: Dot leader
This commit is contained in:
7
contents/_includes/patterns/dot-leader.njk
Normal file
7
contents/_includes/patterns/dot-leader.njk
Normal file
@@ -0,0 +1,7 @@
|
||||
{% for i in range(0, 3) %}
|
||||
<div class="dot-leader">
|
||||
{% rectangle %}
|
||||
<div class="dot-leader__dots"></div>
|
||||
{% circle %}
|
||||
</div>
|
||||
{% endfor %}
|
47
contents/dot-leader.md
Normal file
47
contents/dot-leader.md
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Dot leader
|
||||
description: Create dot leaders with CSS flexbox
|
||||
keywords: css dot leader, css flexbox
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="dot-leader">
|
||||
<!-- Left side -->
|
||||
<div>...</div>
|
||||
|
||||
<!-- Dots -->
|
||||
<div class="dot-leader__dots"></div>
|
||||
|
||||
<!-- Right side -->
|
||||
<div>...</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.dot-leader {
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.dot-leader__dots {
|
||||
/* Bottom border */
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Take remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Spacing */
|
||||
margin: 0 0.25rem;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/dot-leader.njk" %}
|
||||
{% enddemo %}
|
@@ -103,6 +103,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="pattern__title">Docked at corner</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/dot-leader/">
|
||||
<div class="pattern__cover">{% include "patterns/dot-leader.njk" %}</div>
|
||||
<div class="pattern__title">Dot leader</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -1,181 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Head from 'next/head';
|
||||
import { Heading, Spacer } from '@1milligram/design';
|
||||
|
||||
import { RelatedPatterns } from '../../components/RelatedPatterns';
|
||||
import { Pattern } from '../../constants/Pattern';
|
||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||
import Circle from '../../placeholders/Circle';
|
||||
import Rectangle from '../../placeholders/Rectangle';
|
||||
|
||||
const Details: React.FC<{}> = () => {
|
||||
return (
|
||||
<PatternLayout pattern={Pattern.DotLeader}>
|
||||
<Head>
|
||||
<meta name="description" content="Create dot leaders with CSS flexbox" />
|
||||
<meta name="og:description" content="Create dot leaders with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create dot leaders with CSS flexbox" />
|
||||
<meta name="keywords" content="css dot leader, css flexbox" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<!-- Left side -->
|
||||
<div>...</div>
|
||||
|
||||
<!-- Dots -->
|
||||
<div class="container__dots"></div>
|
||||
|
||||
<!-- Right side -->
|
||||
<div>...</div>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.container__dots {
|
||||
/* Bottom border */
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Take remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Spacing */
|
||||
margin: 0px 4px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '400px' }}>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '60%' }}>
|
||||
<Rectangle />
|
||||
</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<Circle />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '40%' }}>
|
||||
<Rectangle />
|
||||
</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<Circle />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '30%' }}>
|
||||
<Rectangle />
|
||||
</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<Circle />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
|
||||
<Spacer size="extraLarge" />
|
||||
|
||||
<section>
|
||||
<Heading level={2}>Use cases</Heading>
|
||||
|
||||
<div style={{ padding: '32px' }}>
|
||||
<div style={{ marginBottom: '16px', width: '60%' }}>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div>Chapter 1</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<div>5</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div>Chapter 2</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<div>40</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ width: '300px' }}>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div>Egg</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<div>3$</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '8px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div>Coffee</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<div>5$</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.Menu, Pattern.PropertyList, Pattern.SplitNavigation]} />
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,69 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Circle from '../../placeholders/Circle';
|
||||
import Frame from '../../placeholders/Frame';
|
||||
import Rectangle from '../../placeholders/Rectangle';
|
||||
|
||||
const Cover: React.FC<{}> = () => {
|
||||
return (
|
||||
<Frame>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '4px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '60%' }}>
|
||||
<Rectangle height={4} />
|
||||
</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<Circle size={8} />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
marginBottom: '4px',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '40%' }}>
|
||||
<Rectangle height={4} />
|
||||
</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<Circle size={8} />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '30%' }}>
|
||||
<Rectangle height={4} />
|
||||
</div>
|
||||
<div style={{ borderBottom: '1px dotted rgba(0, 0, 0, 0.3)', flex: 1, margin: '0 4px' }} />
|
||||
<Circle size={8} />
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -16,6 +16,7 @@
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
height: 8rem;
|
||||
|
@@ -26,6 +26,7 @@
|
||||
@import './patterns/curved-background';
|
||||
@import './patterns/diagonal-section';
|
||||
@import './patterns/docked-at-corner';
|
||||
@import './patterns/dot-leader';
|
||||
|
||||
// Placeholders
|
||||
@import './placeholders/circle';
|
||||
|
19
styles/patterns/_dot-leader.scss
Normal file
19
styles/patterns/_dot-leader.scss
Normal file
@@ -0,0 +1,19 @@
|
||||
.dot-leader {
|
||||
width: 100%;
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
.dot-leader__dots {
|
||||
/* Bottom border */
|
||||
border-bottom: 1px dotted rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Take remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Spacing */
|
||||
margin: 0 0.25rem;
|
||||
}
|
Reference in New Issue
Block a user