mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-06 14:16:50 +02:00
feat: Sidebar
This commit is contained in:
8
contents/_includes/patterns/sidebar.njk
Normal file
8
contents/_includes/patterns/sidebar.njk
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="sidebar">
|
||||
<div class="sidebar__sidebar">
|
||||
{% lines "hor", 5 %}
|
||||
</div>
|
||||
<div class="sidebar__main">
|
||||
{% lines "hor", 20 %}
|
||||
</div>
|
||||
</div>
|
@@ -113,6 +113,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Holy grail" %}{% include "patterns/holy-grail.njk" %}{% endpattern %}
|
||||
{% pattern "Masonry grid" %}{% include "patterns/masonry-grid.njk" %}{% endpattern %}
|
||||
{% pattern "Same height columns" %}{% include "patterns/same-height-columns.njk" %}{% endpattern %}
|
||||
{% pattern "Sidebar" %}{% include "patterns/sidebar.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
44
contents/sidebar.md
Normal file
44
contents/sidebar.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Sidebar
|
||||
description: Create a sidebar with CSS flexbox
|
||||
keywords: css flexbox, css layout, css sidebar
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="sidebar">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar__sidebar">
|
||||
...
|
||||
</aside>
|
||||
|
||||
<!-- Main -->
|
||||
<main class="sidebar__main">
|
||||
...
|
||||
</main>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.sidebar {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.sidebar__sidebar {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.sidebar__main {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Make it scrollable */
|
||||
overflow: auto;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}{% include "patterns/sidebar.njk" %}{% enddemo %}
|
@@ -1,98 +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';
|
||||
|
||||
const Details: React.FC<{}> = () => {
|
||||
return (
|
||||
<PatternLayout pattern={Pattern.Sidebar}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a sidebar with CSS flexbox" />
|
||||
<meta name="og:description" content="Create a sidebar with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create a sidebar with CSS flexbox" />
|
||||
<meta name="keywords" content="css flexbox, css layout, css sidebar" />
|
||||
</Head>
|
||||
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>Try to scroll the main content!</div>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<!-- Sidebar -->
|
||||
<aside class="container__sidebar">
|
||||
...
|
||||
</aside>
|
||||
|
||||
<!-- Main -->
|
||||
<main class="container__main">
|
||||
...
|
||||
</main>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.container__sidebar {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.container__main {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Make it scrollable */
|
||||
overflow: auto;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div style={{ display: 'flex', height: '100%' }}>
|
||||
<div
|
||||
style={{
|
||||
borderRight: '1px solid #d1d5db',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
padding: '16px',
|
||||
width: '30%',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: '16px' }}>
|
||||
<Block numberOfBlocks={5} />
|
||||
</div>
|
||||
<div style={{ width: '80%' }}>
|
||||
<Block numberOfBlocks={4} />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
overflow: 'auto',
|
||||
padding: '16px',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: '32px' }}>
|
||||
<Block numberOfBlocks={20} />
|
||||
</div>
|
||||
<div style={{ marginBottom: '32px' }}>
|
||||
<Block numberOfBlocks={20} />
|
||||
</div>
|
||||
<div style={{ marginBottom: '32px' }}>
|
||||
<Block numberOfBlocks={20} />
|
||||
</div>
|
||||
<div style={{ marginBottom: '32px' }}>
|
||||
<Block numberOfBlocks={20} />
|
||||
</div>
|
||||
<div style={{ width: '80%' }}>
|
||||
<Block numberOfBlocks={10} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,55 +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', height: '100%' }}>
|
||||
<div
|
||||
style={{
|
||||
borderRight: '1px solid #d1d5db',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-end',
|
||||
padding: '4px',
|
||||
width: '30%',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: '4px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ width: '80%' }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
borderRight: '1px solid #d1d5db',
|
||||
borderWidth: '4px',
|
||||
display: 'flex',
|
||||
flex: 1,
|
||||
flexDirection: 'column',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: '8px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginBottom: '8px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginBottom: '8px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ width: '80%' }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -70,6 +70,7 @@
|
||||
@import './patterns/same-height-columns';
|
||||
@import './patterns/search-box';
|
||||
@import './patterns/separator';
|
||||
@import './patterns/sidebar';
|
||||
@import './patterns/slider';
|
||||
@import './patterns/spin-button';
|
||||
@import './patterns/stacked-cards';
|
||||
|
27
styles/patterns/_sidebar.scss
Normal file
27
styles/patterns/_sidebar.scss
Normal file
@@ -0,0 +1,27 @@
|
||||
.sidebar {
|
||||
display: flex;
|
||||
|
||||
/* Demo */
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sidebar__sidebar {
|
||||
border-right: 1px solid #d1d5db;
|
||||
width: 30%;
|
||||
|
||||
/* Demo */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.sidebar__main {
|
||||
/* Take the remaining width */
|
||||
flex: 1;
|
||||
|
||||
/* Make it scrollable */
|
||||
overflow: auto;
|
||||
}
|
Reference in New Issue
Block a user