mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-11 16:44:57 +02:00
feat: Feature comparison
This commit is contained in:
40
contents/_includes/patterns/feature-comparison.njk
Normal file
40
contents/_includes/patterns/feature-comparison.njk
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<div class="feature-comparison">
|
||||||
|
<div class="feature-comparison__feature">
|
||||||
|
{% rectangle %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
{% rectangle %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
{% rectangle %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison">
|
||||||
|
<div class="feature-comparison__feature">
|
||||||
|
{% line "hor" %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
{% circle %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
{% circle %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison">
|
||||||
|
<div class="feature-comparison__feature">
|
||||||
|
{% line "hor" %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model"></div>
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
{% circle %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison">
|
||||||
|
<div class="feature-comparison__feature">
|
||||||
|
{% line "hor" %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
{% circle %}
|
||||||
|
</div>
|
||||||
|
<div class="feature-comparison__model"></div>
|
||||||
|
</div>
|
62
contents/feature-comparison.md
Normal file
62
contents/feature-comparison.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Feature comparison
|
||||||
|
description: Create a feature comparison list with CSS flexbox
|
||||||
|
keywords: css feature comparison, css flexbox
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="feature-comparison">
|
||||||
|
<!-- Feature name -->
|
||||||
|
<div class="feature-comparison__feature">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- The model -->
|
||||||
|
<div class="feature-comparison__model">
|
||||||
|
<!--
|
||||||
|
For the first row: display the model name (Basic, Pro, etc.)
|
||||||
|
From the second row: display a yes/no icon indicating the feature is available or not
|
||||||
|
-->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Repeated other models -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Repeated items -->
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.feature-comparison {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
/* Bottom border */
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
|
/* Spacing */
|
||||||
|
padding: 0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-comparison__feature {
|
||||||
|
/* Take available width */
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-comparison__model {
|
||||||
|
/* Center the content */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{% demo %}
|
||||||
|
{% include "patterns/feature-comparison.njk" %}
|
||||||
|
{% enddemo %}
|
@@ -127,6 +127,12 @@ eleventyExcludeFromCollections: true
|
|||||||
<div class="pattern__title">Fading long section</div>
|
<div class="pattern__title">Fading long section</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pattern__item">
|
||||||
|
<a class="pattern__link" href="/feature-comparison/">
|
||||||
|
<div class="pattern__cover">{% include "patterns/feature-comparison.njk" %}</div>
|
||||||
|
<div class="pattern__title">Feature comparison</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -1,222 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import { Spacer } from '@1milligram/design';
|
|
||||||
|
|
||||||
import { RelatedPatterns } from '../../components/RelatedPatterns';
|
|
||||||
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 Rectangle from '../../placeholders/Rectangle';
|
|
||||||
|
|
||||||
const Details: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<PatternLayout pattern={Pattern.FeatureComparison}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create a feature comparison list with CSS flexbox" />
|
|
||||||
<meta name="og:description" content="Create a feature comparison list with CSS flexbox" />
|
|
||||||
<meta name="twitter:description" content="Create a feature comparison list with CSS flexbox" />
|
|
||||||
<meta name="keywords" content="css feature comparison, css flexbox" />
|
|
||||||
</Head>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<div class="container">
|
|
||||||
<!-- Feature name -->
|
|
||||||
<div class="container__feature">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- The model -->
|
|
||||||
<div class="container__model">
|
|
||||||
<!--
|
|
||||||
For the first row: display the model name (Basic, Pro, etc.)
|
|
||||||
From the second row: display a yes/no icon indicating the feature is available or not
|
|
||||||
-->
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Repeated other models -->
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Repeated items -->
|
|
||||||
...
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.container {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
/* Bottom border */
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
|
||||||
|
|
||||||
/* Spacing */
|
|
||||||
padding: 12px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__feature {
|
|
||||||
/* Take available width */
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
/* Spacing */
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__model {
|
|
||||||
/* Center the content */
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
/* Spacing */
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ width: '60%' }}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
padding: '12px 0',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ flex: 1, marginRight: '16px' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
marginRight: '16px',
|
|
||||||
width: '75px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '50px' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
padding: '8px 0',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ flex: 1, marginRight: '16px' }}>
|
|
||||||
<Block numberOfBlocks={4} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
marginRight: '16px',
|
|
||||||
width: '75px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Circle size={8} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '50px' }}>
|
|
||||||
<Circle size={8} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
padding: '8px 0',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ flex: 1, marginRight: '16px' }}>
|
|
||||||
<Block numberOfBlocks={5} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
marginRight: '16px',
|
|
||||||
width: '75px',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '50px' }}>
|
|
||||||
<Circle size={8} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
padding: '8px 0',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ flex: 1, marginRight: '16px' }}>
|
|
||||||
<Block numberOfBlocks={4} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
marginRight: '16px',
|
|
||||||
width: '75px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Circle size={8} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '50px' }} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
padding: '8px 0',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ flex: 1, marginRight: '16px' }}>
|
|
||||||
<Block numberOfBlocks={6} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
marginRight: '16px',
|
|
||||||
width: '75px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Circle size={8} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '50px' }} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
<Spacer size="extraLarge" />
|
|
||||||
<RelatedPatterns patterns={[Pattern.FeatureList, Pattern.PricingTable]} />
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,54 +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={{
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ display: 'flex', marginBottom: '8px', width: '100%' }}>
|
|
||||||
<div style={{ flex: 1, marginRight: '8px' }}>
|
|
||||||
<Rectangle height={4} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '16px' }}>
|
|
||||||
<Circle size={4} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '16px' }}>
|
|
||||||
<Circle size={4} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', marginBottom: '8px', width: '100%' }}>
|
|
||||||
<div style={{ flex: 1, marginRight: '8px' }}>
|
|
||||||
<Rectangle height={4} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '16px' }} />
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '16px' }}>
|
|
||||||
<Circle size={4} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', marginBottom: '8px', width: '100%' }}>
|
|
||||||
<div style={{ flex: 1, marginRight: '8px' }}>
|
|
||||||
<Rectangle height={4} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '16px' }}>
|
|
||||||
<Circle size={4} />
|
|
||||||
</div>
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', width: '16px' }} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -55,6 +55,7 @@
|
|||||||
.example__content {
|
.example__content {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
@import './patterns/drop-area';
|
@import './patterns/drop-area';
|
||||||
@import './patterns/drop-cap';
|
@import './patterns/drop-cap';
|
||||||
@import './patterns/fading-long-section';
|
@import './patterns/fading-long-section';
|
||||||
|
@import './patterns/feature-comparison';
|
||||||
|
|
||||||
// Placeholders
|
// Placeholders
|
||||||
@import './placeholders/circle';
|
@import './placeholders/circle';
|
||||||
|
26
styles/patterns/_feature-comparison.scss
Normal file
26
styles/patterns/_feature-comparison.scss
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
.feature-comparison {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
/* Bottom border */
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
|
/* Spacing */
|
||||||
|
padding: 0.25rem 0;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-comparison__feature {
|
||||||
|
/* Take available width */
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feature-comparison__model {
|
||||||
|
/* Center the content */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
/* Demo */
|
||||||
|
width: 1.5rem;
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
.circle {
|
.circle {
|
||||||
background: rgba(0, 0, 0, .3);
|
background: rgba(0, 0, 0, .3);
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
height: 1rem;
|
height: 0.5rem;
|
||||||
width: 1rem;
|
width: 0.5rem;
|
||||||
}
|
}
|
Reference in New Issue
Block a user