1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-10 08:04:42 +02:00

feat: Modal

This commit is contained in:
Phuoc Nguyen
2022-09-20 18:52:05 +07:00
parent 9d1dae8139
commit f3f89374d1
7 changed files with 104 additions and 207 deletions

View 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>

View File

@@ -72,6 +72,7 @@ eleventyExcludeFromCollections: true
<div class="category">
<h2 class="category__name">Feedback</h2>
<div class="category__posts">
{% pattern "Modal" %}{% include "patterns/modal.njk" %}{% endpattern %}
{% pattern "Popover arrow" %}{% include "patterns/popover-arrow.njk" %}{% endpattern %}
{% pattern "Presence indicator" %}{% include "patterns/presence-indicator.njk" %}{% endpattern %}
{% pattern "Progress bar" %}{% include "patterns/progress-bar.njk" %}{% endpattern %}

59
contents/modal.md Normal file
View 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 %}

View File

@@ -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;

View File

@@ -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)' }}>&times;</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;

View File

@@ -42,6 +42,7 @@
@import './patterns/layered-card';
@import './patterns/lined-paper';
@import './patterns/media-object';
@import './patterns/modal';
@import './patterns/overlay-play-button';
@import './patterns/popover-arrow';
@import './patterns/presence-indicator';

View 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;
}