mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 06:07:33 +02:00
feat: Slider
This commit is contained in:
5
contents/_includes/patterns/slider.njk
Normal file
5
contents/_includes/patterns/slider.njk
Normal file
@@ -0,0 +1,5 @@
|
||||
<div class="slider">
|
||||
<div class="slider__left" style="width: 20%"></div>
|
||||
<div class="slider__circle"></div>
|
||||
<div class="slider__right"></div>
|
||||
</div>
|
@@ -95,6 +95,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Radio switch" %}{% include "patterns/radio-switch.njk" %}{% endpattern %}
|
||||
{% pattern "Rating" %}{% include "patterns/rating.njk" %}{% endpattern %}
|
||||
{% pattern "Search box" %}{% include "patterns/search-box.njk" %}{% endpattern %}
|
||||
{% pattern "Slider" %}{% include "patterns/slider.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
65
contents/slider.md
Normal file
65
contents/slider.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Slider
|
||||
description: Create a slider with CSS flexbox
|
||||
keywords: css flexbox, css slider
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="slider">
|
||||
<!-- Left side -->
|
||||
<!-- Width based on the current value -->
|
||||
<div class="slider__left" style="width: 20%"></div>
|
||||
|
||||
<!-- Circle -->
|
||||
<div class="slider__circle"></div>
|
||||
|
||||
<!-- Right side -->
|
||||
<div class="slider__right"></div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.slider {
|
||||
/* Content is centered horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Size */
|
||||
height: 2rem;
|
||||
}
|
||||
|
||||
.slider__left {
|
||||
height: 2px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.slider__circle {
|
||||
/* Size */
|
||||
height: 2rem;
|
||||
width: 2rem;
|
||||
|
||||
/* Rounded border */
|
||||
border-radius: 9999px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #3b82f6;
|
||||
}
|
||||
|
||||
.slider__right {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}{% include "patterns/slider.njk" %}{% enddemo %}
|
@@ -1,104 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Head from 'next/head';
|
||||
|
||||
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.Slider}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a slider with CSS flexbox" />
|
||||
<meta name="og:description" content="Create a slider with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create a slider with CSS flexbox" />
|
||||
<meta name="keywords" content="css flexbox, css slider" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<!-- Left side -->
|
||||
<!-- Width based on the current value -->
|
||||
<div class="container__left" style="width: 20%"></div>
|
||||
|
||||
<!-- Circle -->
|
||||
<div class="container__circle"></div>
|
||||
|
||||
<!-- Right side -->
|
||||
<div class="container__right"></div>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Content is centered horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Size */
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.container__left {
|
||||
height: 2px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.container__circle {
|
||||
/* Size */
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
|
||||
/* Rounded border */
|
||||
border-radius: 9999px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.container__right {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '16px',
|
||||
width: '256px',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '20%' }}>
|
||||
<Rectangle height={2} />
|
||||
</div>
|
||||
<Circle size={32} />
|
||||
<div style={{ flex: 1 }}>
|
||||
<Rectangle height={2} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,41 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Circle from '../../placeholders/Circle';
|
||||
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={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '16px',
|
||||
width: '80%',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '20%' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<Circle />
|
||||
<div style={{ flex: 1 }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -64,6 +64,7 @@
|
||||
@import './patterns/ribbon';
|
||||
@import './patterns/search-box';
|
||||
@import './patterns/separator';
|
||||
@import './patterns/slider';
|
||||
@import './patterns/stacked-cards';
|
||||
@import './patterns/stamp-border';
|
||||
@import './patterns/statistic';
|
||||
|
39
styles/patterns/_slider.scss
Normal file
39
styles/patterns/_slider.scss
Normal file
@@ -0,0 +1,39 @@
|
||||
.slider {
|
||||
/* Content is centered horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Size */
|
||||
height: 2rem;
|
||||
|
||||
/* Demo */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.slider__left {
|
||||
height: 2px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
||||
|
||||
.slider__circle {
|
||||
/* Size */
|
||||
height: 2rem;
|
||||
width: 2rem;
|
||||
|
||||
/* Rounded border */
|
||||
border-radius: 9999px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #3b82f6;
|
||||
}
|
||||
|
||||
.slider__right {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
|
||||
/* Colors */
|
||||
background-color: #d1d5db;
|
||||
}
|
Reference in New Issue
Block a user