mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-11 00:24:12 +02:00
feat: Drawer
This commit is contained in:
6
contents/_includes/covers/drawer.njk
Normal file
6
contents/_includes/covers/drawer.njk
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="drawer">
|
||||
<div class="drawer__sidebar">
|
||||
{% lines "hor", 5 %}
|
||||
</div>
|
||||
<div class="drawer__overlay"></div>
|
||||
</div>
|
65
contents/drawer.md
Normal file
65
contents/drawer.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Drawer
|
||||
description: Create a drawer navigation with CSS
|
||||
keywords: css drawer, css off-canvas
|
||||
---
|
||||
|
||||
This pattern is also known as off-canvas.
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="drawer">
|
||||
<!-- Backdrop -->
|
||||
<div class="drawer__overlay"></div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div class="drawer__sidebar">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.drawer {
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.drawer__overlay {
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
|
||||
/* User still can see the content of main page */
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.drawer__sidebar {
|
||||
/* Take full height */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 200px;
|
||||
|
||||
/* Background */
|
||||
background-color: #fff;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}{% include "covers/drawer.njk" %}{% enddemo %}
|
@@ -128,6 +128,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Breadcrumb" %}{% include "covers/breadcrumb.njk" %}{% endpattern %}
|
||||
{% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %}
|
||||
{% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %}
|
||||
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -1,106 +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.Drawer}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a drawer navigation with CSS" />
|
||||
<meta name="og:description" content="Create a drawer navigation with CSS" />
|
||||
<meta name="twitter:description" content="Create a drawer navigation with CSS" />
|
||||
<meta name="keywords" content="css drawer, css off-canvas" />
|
||||
</Head>
|
||||
<div style={{ lineHeight: 1.5, marginBottom: '16px' }}>This pattern is also known as off-canvas.</div>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<div class="container">
|
||||
<!-- Backdrop -->
|
||||
<div class="container__overlay"></div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div class="container__sidebar">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
`}
|
||||
css={`
|
||||
.container {
|
||||
/* Container takes full size */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.container__overlay {
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
|
||||
/* User still can see the content of main page */
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.container__sidebar {
|
||||
/* Take full height */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 200px;
|
||||
|
||||
/* Background */
|
||||
background-color: #fff;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: '#d1d5db',
|
||||
height: '100%',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: '100%',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: '#fff',
|
||||
height: '100%',
|
||||
left: 0,
|
||||
padding: '16px',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: '250px',
|
||||
}}
|
||||
>
|
||||
<Block numberOfBlocks={20} />
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,46 +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={{
|
||||
backgroundColor: '#d1d5db',
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: '#fff',
|
||||
height: '100%',
|
||||
left: 0,
|
||||
padding: '4px',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
width: '40%',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: '4px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginBottom: '4px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ marginBottom: '4px' }}>
|
||||
<Line />
|
||||
</div>
|
||||
<div style={{ width: '80%' }}>
|
||||
<Line />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -35,6 +35,7 @@
|
||||
@import './patterns/docked-at-corner';
|
||||
@import './patterns/dot-leader';
|
||||
@import './patterns/dot-navigation';
|
||||
@import './patterns/drawer';
|
||||
@import './patterns/drop-area';
|
||||
@import './patterns/drop-cap';
|
||||
@import './patterns/fading-long-section';
|
||||
|
21
styles/patterns/_drawer.scss
Normal file
21
styles/patterns/_drawer.scss
Normal file
@@ -0,0 +1,21 @@
|
||||
.drawer {
|
||||
/* Demo */
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 0.25rem;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.drawer__sidebar {
|
||||
/* Demo */
|
||||
border-right: 1px solid #d1d5db;
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.drawer__overlay {
|
||||
/* Demo */
|
||||
background: #4b5563;
|
||||
flex: 1;
|
||||
}
|
Reference in New Issue
Block a user