1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-07 14:46:38 +02:00

feat: Holy grail

This commit is contained in:
Phuoc Nguyen
2022-09-21 13:02:02 +07:00
parent 92ff05cd4f
commit 3d74fde098
7 changed files with 116 additions and 249 deletions

View File

@@ -0,0 +1,9 @@
<div class="holy-grail">
<div class="holy-grail__header">{% rectangle %}</div>
<div class="holy-grail__main">
<div class="holy-grail__left">{% lines "hor", 4 %}</div>
<div class="holy-grail__middle">{% lines "hor", 10 %}</div>
<div class="holy-grail__right">{% lines "hor", 8 %}</div>
</div>
<div class="holy-grail__footer">{% rectangle %}</div>
</div>

62
contents/holy-grail.md Normal file
View File

@@ -0,0 +1,62 @@
---
layout: layouts/post.njk
title: Holy grail
description: Create a holy grail layout with CSS flexbox
keywords: css flexbox, css holy grail layout, css layout
---
## HTML
```html
<div class="holy-grail">
<header>
...
</header>
<main class="holy-grail__main">
<!-- Left sidebar -->
<aside class="holy-grail__left">...</aside>
<!-- Main content -->
<article class="holy-grail__middle">...</article>
<!-- Right sidebar -->
<nav class="holy-grail__right">...</nav>
</main>
<footer>
...
</footer>
</div>
```
## CSS
```css
.holy-grail {
display: flex;
flex-direction: column;
}
.holy-grail__main {
/* Take the remaining height */
flex-grow: 1;
/* Layout the left sidebar, main content and right sidebar */
display: flex;
flex-direction: row;
}
.holy-grail__left {
width: 25%;
}
.holy-grail__middle {
/* Take the remaining width */
flex-grow: 1;
}
.holy-grail__right {
width: 20%;
}
```
{% demo %}{% include "patterns/holy-grail.njk" %}{% enddemo %}

View File

@@ -110,6 +110,7 @@ eleventyExcludeFromCollections: true
<h2 class="category__name">Layout</h2>
<div class="category__posts">
{% pattern "Card layout" %}{% include "patterns/card-layout.njk" %}{% endpattern %}
{% pattern "Holy grail" %}{% include "patterns/holy-grail.njk" %}{% endpattern %}
</div>
</div>

View File

@@ -1,127 +0,0 @@
import * as React from 'react';
import Head from 'next/head';
import { Pattern } from '../../constants/Pattern';
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.HolyGrail}>
<Head>
<meta name="description" content="Create a holy grail layout with CSS flexbox" />
<meta name="og:description" content="Create a holy grail layout with CSS flexbox" />
<meta name="twitter:description" content="Create a holy grail layout with CSS flexbox" />
<meta name="keywords" content="css flexbox, css holy grail layout, css layout" />
</Head>
<BrowserFrame
html={`
<div class="container">
<header>
...
</header>
<main class="container__main">
<!-- Left sidebar -->
<aside class="container__left">...</aside>
<!-- Main content -->
<article class="container__middle">...</article>
<!-- Right sidebar -->
<nav class="container__right">...</nav>
</main>
<footer>
...
</footer>
</div>
`}
css={`
.container {
display: flex;
flex-direction: column;
}
.container__main {
/* Take the remaining height */
flex-grow: 1;
/* Layout the left sidebar, main content and right sidebar */
display: flex;
flex-direction: row;
}
.container__left {
width: 25%;
}
.container__middle {
/* Take the remaining width */
flex-grow: 1;
}
.container__right {
width: 20%;
}
`}
>
<div
style={{
display: 'flex',
flexDirection: 'column',
height: '100%',
}}
>
<div
style={{
borderBottom: '1px solid #d1d5db',
flexShrink: 0,
padding: '16px',
}}
>
<div style={{ width: '50%' }}>
<Rectangle />
</div>
</div>
<div style={{ display: 'flex', flexGrow: 1 }}>
<div
style={{
borderRight: '1px solid #d1d5db',
padding: '16px',
width: '25%',
}}
>
<Block numberOfBlocks={10} />
</div>
<div style={{ flex: 1, padding: '16px' }}>
<Block numberOfBlocks={20} />
</div>
<div
style={{
borderLeft: '1px solid #d1d5db',
padding: '16px',
width: '20%',
}}
>
<Block numberOfBlocks={5} />
</div>
</div>
<div
style={{
borderTop: '1px solid #d1d5db',
flexShrink: 0,
padding: '16px',
}}
>
<div style={{ width: '40%' }}>
<Rectangle />
</div>
</div>
</div>
</BrowserFrame>
</PatternLayout>
);
};
export default Details;

View File

@@ -1,122 +0,0 @@
import * as React from 'react';
import Frame from '../../placeholders/Frame';
import Line from '../../placeholders/Line';
const Cover: React.FC<{}> = () => {
return (
<Frame>
<div
style={{
display: 'flex',
flexDirection: 'column',
height: '100%',
}}
>
<div
style={{
borderBottom: '1px solid #d1d5db',
flexShrink: 0,
}}
>
<div
style={{
alignItems: 'center',
display: 'flex',
padding: '8px',
width: '100%',
}}
>
<div style={{ width: '16px' }}>
<Line />
</div>
<div style={{ marginLeft: 'auto', width: '16px' }}>
<Line />
</div>
<div style={{ marginLeft: '4px', width: '16px' }}>
<Line />
</div>
</div>
</div>
<div style={{ display: 'flex', flexGrow: 1 }}>
<div
style={{
borderRight: '1px solid #d1d5db',
padding: '8px',
width: '30%',
}}
>
<div style={{ marginBottom: '4px' }}>
<Line />
</div>
<div style={{ width: '80%' }}>
<Line />
</div>
</div>
<div style={{ flex: 1, padding: '8px' }}>
<div style={{ marginBottom: '4px' }}>
<Line />
</div>
<div style={{ marginBottom: '4px', width: '60%' }}>
<Line />
</div>
<div style={{ marginBottom: '8px', width: '80%' }}>
<Line />
</div>
<div style={{ marginBottom: '4px' }}>
<Line />
</div>
<div style={{ marginBottom: '4px', width: '60%' }}>
<Line />
</div>
<div style={{ marginBottom: '4px', width: '80%' }}>
<Line />
</div>
</div>
<div
style={{
borderLeft: '1px solid #d1d5db',
padding: '8px',
width: '30%',
}}
>
<div style={{ marginBottom: '4px' }}>
<Line />
</div>
<div style={{ width: '80%' }}>
<Line />
</div>
</div>
</div>
<div
style={{
borderTop: '1px solid #d1d5db',
flexShrink: 0,
}}
>
<div
style={{
alignItems: 'center',
display: 'flex',
padding: '8px',
width: '100%',
}}
>
<div style={{ width: '16px' }}>
<Line />
</div>
<div style={{ marginLeft: '4px', width: '16px' }}>
<Line />
</div>
<div style={{ marginLeft: '4px', width: '16px' }}>
<Line />
</div>
</div>
</div>
</div>
</Frame>
);
};
export default Cover;

View File

@@ -42,6 +42,7 @@
@import './patterns/floating-label';
@import './patterns/folder-structure';
@import './patterns/full-background';
@import './patterns/holy-grail';
@import './patterns/initial-avatar';
@import './patterns/input-addon';
@import './patterns/inverted-corners';

View File

@@ -0,0 +1,43 @@
.holy-grail {
display: flex;
flex-direction: column;
/* Demo */
border: 1px solid #d1d5db;
border-radius: 0.25rem;
height: 100%;
width: 100%;
}
.holy-grail__header,
.holy-grail__footer {
padding: 0.25rem;
}
.holy-grail__main {
border-top: 1px solid #d1d5db;
border-bottom: 1px solid #d1d5db;
/* Take the remaining height */
flex-grow: 1;
/* Layout the left sidebar, main content and right sidebar */
display: flex;
flex-direction: row;
}
.holy-grail__left {
width: 25%;
}
.holy-grail__middle {
border-left: 1px solid #d1d5db;
border-right: 1px solid #d1d5db;
/* Take the remaining width */
flex-grow: 1;
}
.holy-grail__right {
width: 20%;
}