mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-13 17:44:19 +02:00
feat: Modal
This commit is contained in:
5
contents/_includes/patterns/modal.njk
Normal file
5
contents/_includes/patterns/modal.njk
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="modal">
|
||||||
|
<div class="modal__header">{% rectangle %}</div>
|
||||||
|
<div class="modal__body">{% lines "hor", 8 %}</div>
|
||||||
|
<div class="modal__footer">{% rectangle "hor", "md" %}</div>
|
||||||
|
</div>
|
@@ -72,6 +72,7 @@ eleventyExcludeFromCollections: true
|
|||||||
<div class="category">
|
<div class="category">
|
||||||
<h2 class="category__name">Feedback</h2>
|
<h2 class="category__name">Feedback</h2>
|
||||||
<div class="category__posts">
|
<div class="category__posts">
|
||||||
|
{% pattern "Modal" %}{% include "patterns/modal.njk" %}{% endpattern %}
|
||||||
{% pattern "Popover arrow" %}{% include "patterns/popover-arrow.njk" %}{% endpattern %}
|
{% pattern "Popover arrow" %}{% include "patterns/popover-arrow.njk" %}{% endpattern %}
|
||||||
{% pattern "Presence indicator" %}{% include "patterns/presence-indicator.njk" %}{% endpattern %}
|
{% pattern "Presence indicator" %}{% include "patterns/presence-indicator.njk" %}{% endpattern %}
|
||||||
{% pattern "Progress bar" %}{% include "patterns/progress-bar.njk" %}{% endpattern %}
|
{% pattern "Progress bar" %}{% include "patterns/progress-bar.njk" %}{% endpattern %}
|
||||||
|
59
contents/modal.md
Normal file
59
contents/modal.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Modal
|
||||||
|
description: Create a modal with CSS flexbox
|
||||||
|
keywords: css dialog, css flexbox, css modal
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="modal">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="modal__header">
|
||||||
|
<!-- Title -->
|
||||||
|
...
|
||||||
|
<!-- Close icon sticks to the right -->
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
...
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<div class="modal__footer">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.modal {
|
||||||
|
/* Border */
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
border-bottom: 1px solid #d1d5db;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal__footer {
|
||||||
|
display: flex;
|
||||||
|
/* Push the buttons to the right */
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
border-top: 1px solid #d1d5db;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{% demo %}
|
||||||
|
{% include "patterns/modal.njk" %}
|
||||||
|
{% enddemo %}
|
@@ -1,132 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
import Link from 'next/link';
|
|
||||||
|
|
||||||
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.Modal}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create a modal with CSS flexbox" />
|
|
||||||
<meta name="og:description" content="Create a modal with CSS flexbox" />
|
|
||||||
<meta name="twitter:description" content="Create a modal with CSS flexbox" />
|
|
||||||
<meta name="keywords" content="css dialog, css flexbox, css modal" />
|
|
||||||
</Head>
|
|
||||||
<div style={{ lineHeight: 1.5, marginBottom: '1rem' }}>
|
|
||||||
You can use the{' '}
|
|
||||||
<Link href="/close-button">
|
|
||||||
<a>close button</a>
|
|
||||||
</Link>{' '}
|
|
||||||
to represent the button for closing the modal.
|
|
||||||
</div>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<div class="modal">
|
|
||||||
<!-- Header -->
|
|
||||||
<div class="modal__header">
|
|
||||||
<!-- Title -->
|
|
||||||
...
|
|
||||||
<!-- Close icon sticks to the right -->
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Content -->
|
|
||||||
...
|
|
||||||
|
|
||||||
<!-- Footer -->
|
|
||||||
<div class="modal__footer">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.modal {
|
|
||||||
/* Border */
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.3);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
/* Border */
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal__footer {
|
|
||||||
display: flex;
|
|
||||||
/* Push the buttons to the right */
|
|
||||||
justify-content: flex-end;
|
|
||||||
/* Border */
|
|
||||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
borderRadius: '4px',
|
|
||||||
width: '50%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
padding: '16px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ width: '60%' }}>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<div style={{ color: 'rgba(0, 0, 0, 0.7)' }}>
|
|
||||||
<Circle />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style={{ padding: '16px' }}>
|
|
||||||
<div style={{ marginBottom: '16px' }}>
|
|
||||||
<Block numberOfBlocks={10} />
|
|
||||||
</div>
|
|
||||||
<Block numberOfBlocks={5} />
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
borderTop: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
padding: '16px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ marginRight: '8px', width: '30%' }}>
|
|
||||||
<Rectangle height={32} />
|
|
||||||
</div>
|
|
||||||
<div style={{ width: '30%' }}>
|
|
||||||
<Rectangle height={32} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,75 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
|
|
||||||
import Frame from '../../placeholders/Frame';
|
|
||||||
import Line from '../../placeholders/Line';
|
|
||||||
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={{
|
|
||||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
|
||||||
borderRadius: '4px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
padding: '0 4px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ width: '60%' }}>
|
|
||||||
<Rectangle height={2} />
|
|
||||||
</div>
|
|
||||||
<div style={{ color: 'rgba(0, 0, 0, 0.7)' }}>×</div>
|
|
||||||
</div>
|
|
||||||
<div style={{ padding: '4px' }}>
|
|
||||||
<div style={{ marginBottom: '4px', width: '100%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '4px', width: '80%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
<div style={{ marginBottom: '4px', width: '60%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
<div style={{ width: '40%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
padding: '4px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ marginRight: '8px', width: '33.3333%' }}>
|
|
||||||
<Rectangle height={8} />
|
|
||||||
</div>
|
|
||||||
<div style={{ width: '33.3333%' }}>
|
|
||||||
<Rectangle height={8} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -42,6 +42,7 @@
|
|||||||
@import './patterns/layered-card';
|
@import './patterns/layered-card';
|
||||||
@import './patterns/lined-paper';
|
@import './patterns/lined-paper';
|
||||||
@import './patterns/media-object';
|
@import './patterns/media-object';
|
||||||
|
@import './patterns/modal';
|
||||||
@import './patterns/overlay-play-button';
|
@import './patterns/overlay-play-button';
|
||||||
@import './patterns/popover-arrow';
|
@import './patterns/popover-arrow';
|
||||||
@import './patterns/presence-indicator';
|
@import './patterns/presence-indicator';
|
||||||
|
38
styles/patterns/_modal.scss
Normal file
38
styles/patterns/_modal.scss
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
.modal {
|
||||||
|
/* Border */
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
/* Demo */
|
||||||
|
height: 8rem;
|
||||||
|
width: 8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal__header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
border-bottom: 1px solid #d1d5db;
|
||||||
|
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal__body {
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal__footer {
|
||||||
|
display: flex;
|
||||||
|
/* Push the buttons to the right */
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
border-top: 1px solid #d1d5db;
|
||||||
|
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
}
|
Reference in New Issue
Block a user