mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-08 23:26:32 +02:00
feat: Property list
This commit is contained in:
6
contents/_includes/patterns/property-list.njk
Normal file
6
contents/_includes/patterns/property-list.njk
Normal file
@@ -0,0 +1,6 @@
|
||||
{% for i in range(0, 4) %}
|
||||
<dl class="property-list">
|
||||
<dt class="property-list__key">{% rectangle "hor" %}</dt>
|
||||
<dd class="property-list__value">{% circle %}</dd>
|
||||
</dl>
|
||||
{% endfor %}
|
@@ -211,6 +211,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="pattern__title">Pricing table</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/property-list/">
|
||||
<div class="pattern__cover">{% include "patterns/property-list.njk" %}</div>
|
||||
<div class="pattern__title">Property list</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pattern__item">
|
||||
<a class="pattern__link" href="/triangle-buttons/">
|
||||
<div class="pattern__cover">{% include "patterns/triangle-buttons.njk" %}</div>
|
||||
|
49
contents/property-list.md
Normal file
49
contents/property-list.md
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Property list
|
||||
description: Create a property list with CSS flexbox
|
||||
keywords: css flexbox, property list
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<!-- A property item -->
|
||||
<dl class="property-list">
|
||||
<!-- Property name -->
|
||||
<dt class="property-list__key">...</dt>
|
||||
|
||||
<!-- Property value -->
|
||||
<dd class="property-list__value">...</dd>
|
||||
</dl>
|
||||
|
||||
<!-- Repeat other items -->
|
||||
...
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.property-list {
|
||||
/* Content is center horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Spacing */
|
||||
margin: 0;
|
||||
padding: 0.25rem 0;
|
||||
}
|
||||
.property-list__key {
|
||||
/* Take the available width */
|
||||
flex: 1;
|
||||
}
|
||||
.property-list__value {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/property-list.njk" %}
|
||||
{% enddemo %}
|
@@ -1,145 +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<{}> = () => {
|
||||
const Item: React.FC<{}> = ({ children }) => {
|
||||
return (
|
||||
<dl
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
margin: 0,
|
||||
padding: '8px 0',
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</dl>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<PatternLayout pattern={Pattern.PropertyList}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a property list with CSS flexbox" />
|
||||
<meta name="og:description" content="Create a property list with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create a property list with CSS flexbox" />
|
||||
<meta name="keywords" content="css flexbox, property list" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<!-- A property item -->
|
||||
<dl class="container">
|
||||
<!-- Property name -->
|
||||
<dt>...</dt>
|
||||
|
||||
<!-- Property value -->
|
||||
<dd>...</dd>
|
||||
</dl>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Content is center horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/*
|
||||
The property name will stick to the left, and the value
|
||||
will stick to the right
|
||||
*/
|
||||
justify-content: space-between;
|
||||
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Spacing */
|
||||
margin: 0px;
|
||||
padding: 8px 0px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '40%' }}>
|
||||
<Item>
|
||||
<dt style={{ width: '80%' }}>
|
||||
<Rectangle />
|
||||
</dt>
|
||||
<dd>
|
||||
<Circle />
|
||||
</dd>
|
||||
</Item>
|
||||
<Item>
|
||||
<dt style={{ width: '60%' }}>
|
||||
<Rectangle />
|
||||
</dt>
|
||||
<dd>
|
||||
<Circle />
|
||||
</dd>
|
||||
</Item>
|
||||
<Item>
|
||||
<dt style={{ width: '30%' }}>
|
||||
<Rectangle />
|
||||
</dt>
|
||||
<dd>
|
||||
<Circle />
|
||||
</dd>
|
||||
</Item>
|
||||
<Item>
|
||||
<dt style={{ width: '50%' }}>
|
||||
<Rectangle />
|
||||
</dt>
|
||||
<dd>
|
||||
<Circle />
|
||||
</dd>
|
||||
</Item>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
<Spacer size="extraLarge" />
|
||||
|
||||
<section>
|
||||
<Heading level={2}>Use cases</Heading>
|
||||
|
||||
<div style={{ padding: '32px', width: '500px' }}>
|
||||
<Item>
|
||||
<dt>Name</dt>
|
||||
<dd>WebAssembly in Action</dd>
|
||||
</Item>
|
||||
<Item>
|
||||
<dt>Author</dt>
|
||||
<dd>Gerard Gallant</dd>
|
||||
</Item>
|
||||
<Item>
|
||||
<dt>Publishing date</dt>
|
||||
<dd>November 2019</dd>
|
||||
</Item>
|
||||
<Item>
|
||||
<dt>ISBN</dt>
|
||||
<dd>9781617295744</dd>
|
||||
</Item>
|
||||
</div>
|
||||
</section>
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.DotLeader, Pattern.Menu, 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={{ width: '100%' }}>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
padding: '4px 0',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '60%' }}>
|
||||
<Rectangle height={8} />
|
||||
</div>
|
||||
<Circle size={12} />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
padding: '4px 0',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '20%' }}>
|
||||
<Rectangle height={8} />
|
||||
</div>
|
||||
<Circle size={12} />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
padding: '4px 0',
|
||||
}}
|
||||
>
|
||||
<div style={{ width: '40%' }}>
|
||||
<Rectangle height={8} />
|
||||
</div>
|
||||
<Circle size={12} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -44,6 +44,7 @@
|
||||
@import './patterns/overlay-play-button';
|
||||
@import './patterns/price-tag';
|
||||
@import './patterns/pricing-table';
|
||||
@import './patterns/property-list';
|
||||
@import './patterns/triangle-buttons';
|
||||
@import './patterns/video-background';
|
||||
@import './patterns/voting';
|
||||
|
20
styles/patterns/_property-list.scss
Normal file
20
styles/patterns/_property-list.scss
Normal file
@@ -0,0 +1,20 @@
|
||||
.property-list {
|
||||
/* Content is center horizontally */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Spacing */
|
||||
margin: 0;
|
||||
padding: 0.5rem 0;
|
||||
|
||||
width: 100%;
|
||||
}
|
||||
.property-list__key {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
}
|
||||
.property-list__value {
|
||||
margin-left: 0.5rem;
|
||||
}
|
Reference in New Issue
Block a user