mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-15 10:34:05 +02:00
feat: Add close button pattern
This commit is contained in:
4
contents/_includes/patterns/close-button.njk
Normal file
4
contents/_includes/patterns/close-button.njk
Normal file
@@ -0,0 +1,4 @@
|
||||
<button class="close-button">
|
||||
<div class="close-button__line close-button__line--first"></div>
|
||||
<div class="close-button__line close-button__line--second"></div>
|
||||
</button>
|
73
contents/close-button.md
Normal file
73
contents/close-button.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Close button
|
||||
description: Create a close button with CSS flexbox
|
||||
keywords: css close button, css flexbox
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<button class="close-button">
|
||||
<div class="close-button__line close-button__line--first"></div>
|
||||
<div class="close-button__line close-button__line--second"></div>
|
||||
</button>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.close-button {
|
||||
/* Reset */
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
|
||||
/* Cursor */
|
||||
cursor: pointer;
|
||||
|
||||
/* Size */
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
|
||||
/* Used to position the inner */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.close-button__line {
|
||||
/* Background color */
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Position */
|
||||
position: absolute;
|
||||
|
||||
/* Size */
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.close-button__line--first {
|
||||
/* Position */
|
||||
left: 0px;
|
||||
top: 50%;
|
||||
transform: translate(0%, -50%) rotate(45deg);
|
||||
|
||||
/* Size */
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.close-button__line--second {
|
||||
/* Position */
|
||||
left: 50%;
|
||||
top: 0px;
|
||||
transform: translate(-50%, 0%) rotate(45deg);
|
||||
|
||||
/* Size */
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "patterns/close-button.njk" %}
|
||||
{% enddemo %}
|
@@ -49,6 +49,12 @@ eleventyExcludeFromCollections: true
|
||||
<div class="card__title">Centering</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card__item">
|
||||
<a class="card__link" href="/close-button/">
|
||||
<div class="card__cover">{% include "patterns/close-button.njk" %}</div>
|
||||
<div class="card__title">Close button</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -1,131 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import Head from 'next/head';
|
||||
import { Spacer } from '@1milligram/design';
|
||||
|
||||
import { RelatedPatterns } from '../../components/RelatedPatterns';
|
||||
import { Pattern } from '../../constants/Pattern';
|
||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
||||
|
||||
const Details: React.FC<{}> = () => {
|
||||
return (
|
||||
<PatternLayout pattern={Pattern.CloseButton}>
|
||||
<Head>
|
||||
<meta name="description" content="Create a close button with CSS flexbox" />
|
||||
<meta name="og:description" content="Create a close button with CSS flexbox" />
|
||||
<meta name="twitter:description" content="Create a close button with CSS flexbox" />
|
||||
<meta name="keywords" content="css close button, css flexbox" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<button class="button">
|
||||
<div class="button__line button__line--first"></div>
|
||||
|
||||
<div class="button__line button__line--second"></div>
|
||||
</button>
|
||||
`}
|
||||
css={`
|
||||
.button {
|
||||
/* Reset */
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
|
||||
/* Cursor */
|
||||
cursor: pointer;
|
||||
|
||||
/* Size */
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
|
||||
/* Used to position the inner */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.button__line {
|
||||
/* Background color */
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Position */
|
||||
position: absolute;
|
||||
|
||||
/* Size */
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.button__line--first {
|
||||
/* Position */
|
||||
left: 0px;
|
||||
top: 50%;
|
||||
transform: translate(0%, -50%) rotate(45deg);
|
||||
|
||||
/* Size */
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.button__line--second {
|
||||
/* Position */
|
||||
left: 50%;
|
||||
top: 0px;
|
||||
transform: translate(-50%, 0%) rotate(45deg);
|
||||
|
||||
/* Size */
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
borderColor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
height: '32px',
|
||||
position: 'relative',
|
||||
width: '32px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||
height: '1px',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
transform: 'translate(0%, -50%) rotate(45deg)',
|
||||
width: '100%',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||
height: '100%',
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
transform: 'translate(-50%, 0%) rotate(45deg)',
|
||||
width: '1px',
|
||||
}}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.ArrowButtons, Pattern.Chip, Pattern.Modal, Pattern.Notification]} />
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,56 +0,0 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import Frame from '../../placeholders/Frame';
|
||||
|
||||
const Cover: React.FC<{}> = () => {
|
||||
return (
|
||||
<Frame>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
borderColor: 'transparent',
|
||||
cursor: 'pointer',
|
||||
height: '32px',
|
||||
position: 'relative',
|
||||
width: '32px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||
height: '1px',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
transform: 'translate(0%, -50%) rotate(45deg)',
|
||||
width: '100%',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||
height: '100%',
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
transform: 'translate(-50%, 0%) rotate(45deg)',
|
||||
width: '1px',
|
||||
}}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -17,6 +17,7 @@
|
||||
@import './patterns/avatar-list';
|
||||
@import './patterns/badge';
|
||||
@import './patterns/centering';
|
||||
@import './patterns/close-button';
|
||||
|
||||
// Placeholders
|
||||
@import './placeholders/circle';
|
||||
|
49
styles/patterns/_close-button.scss
Normal file
49
styles/patterns/_close-button.scss
Normal file
@@ -0,0 +1,49 @@
|
||||
.close-button {
|
||||
/* Reset */
|
||||
background-color: transparent;
|
||||
border-color: transparent;
|
||||
|
||||
/* Cursor */
|
||||
cursor: pointer;
|
||||
|
||||
/* Size */
|
||||
height: 3rem;
|
||||
width: 3rem;
|
||||
|
||||
/* Used to position the inner */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.close-button__line {
|
||||
/* Background color */
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
|
||||
/* Position */
|
||||
position: absolute;
|
||||
|
||||
/* Size */
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.close-button__line--first {
|
||||
/* Position */
|
||||
left: 0px;
|
||||
top: 50%;
|
||||
transform: translate(0%, -50%) rotate(45deg);
|
||||
|
||||
/* Size */
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.close-button__line--second {
|
||||
/* Position */
|
||||
left: 50%;
|
||||
top: 0px;
|
||||
transform: translate(-50%, 0%) rotate(45deg);
|
||||
|
||||
/* Size */
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
}
|
Reference in New Issue
Block a user