mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-11 00:24:12 +02:00
feat: Add arrow buttons
This commit is contained in:
@@ -17,6 +17,15 @@ module.exports = function(eleventyConfig) {
|
||||
|
||||
// Shortcodes
|
||||
|
||||
eleventyConfig.addPairedShortcode('demo', function(content) {
|
||||
return `<div class="example example--border">
|
||||
<div class="example__ribbon example__ribbon--tr">
|
||||
<span class="example__title">Demo</span>
|
||||
</div>
|
||||
<div class="example__content example__content--medium">${content}</div>
|
||||
</div>`;
|
||||
});
|
||||
|
||||
eleventyConfig.addShortcode('circle', function() {
|
||||
return `<div class="circle"></div>`;
|
||||
});
|
||||
|
14
contents/_includes/covers/arrow-buttons.njk
Normal file
14
contents/_includes/covers/arrow-buttons.njk
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="arrow-buttons">
|
||||
<div class="arrow-buttons__corner arrow-buttons__corner--t">
|
||||
<div class="arrow-button arrow-button--t"></div>
|
||||
</div>
|
||||
<div class="arrow-buttons__corner arrow-buttons__corner--r">
|
||||
<div class="arrow-button arrow-button--r"></div>
|
||||
</div>
|
||||
<div class="arrow-buttons__corner arrow-buttons__corner--b">
|
||||
<div class="arrow-button arrow-button--b"></div>
|
||||
</div>
|
||||
<div class="arrow-buttons__corner arrow-buttons__corner--l">
|
||||
<div class="arrow-button arrow-button--l"></div>
|
||||
</div>
|
||||
</div>
|
@@ -5,8 +5,6 @@ description: Create an accordion with CSS flexbox
|
||||
keywords: css accordion, css flexbox
|
||||
---
|
||||
|
||||
{% include "covers/accordion.njk" %}
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
@@ -84,4 +82,8 @@ keywords: css accordion, css flexbox
|
||||
.accordion__item--expanded .accordion__content {
|
||||
display: block;
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "covers/accordion.njk" %}
|
||||
{% enddemo %}
|
||||
|
91
contents/arrow-buttons.md
Normal file
91
contents/arrow-buttons.md
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Arrow buttons
|
||||
description: Create arrow buttons with CSS
|
||||
keywords: css arrow buttons
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<!-- Up arrow button -->
|
||||
<button class="arrow-buttons">
|
||||
<!-- Arrow -->
|
||||
<div class="arrow-button arrow-button--t"></div>
|
||||
|
||||
<!-- Content -->
|
||||
...
|
||||
</button>
|
||||
|
||||
<!-- Right arrow button -->
|
||||
<button class="arrow-buttons">
|
||||
<!-- Content -->
|
||||
...
|
||||
|
||||
<!-- Arrow -->
|
||||
<div class="arrow-button arrow-button--r"></div>
|
||||
</button>
|
||||
|
||||
<!-- Down arrow button -->
|
||||
<button class="arrow-buttons">
|
||||
<!-- Arrow -->
|
||||
<div class="arrow-button arrow-button--b"></div>
|
||||
|
||||
<!-- Content -->
|
||||
...
|
||||
</button>
|
||||
|
||||
<!-- Left arrow button -->
|
||||
<button class="arrow-buttons">
|
||||
<!-- Arrow -->
|
||||
<div class="arrow-button arrow-button--l"></div>
|
||||
|
||||
<!-- Content -->
|
||||
...
|
||||
</button>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.arrow-button {
|
||||
/* Transparent background */
|
||||
background-color: transparent;
|
||||
|
||||
/* Size */
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.arrow-button--t {
|
||||
/* Edges */
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateY(25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow-button--r {
|
||||
/* Edges */
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateX(-25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow-button--b {
|
||||
/* Edges */
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateY(-25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow-button--l {
|
||||
/* Edges */
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateX(25%) rotate(45deg);
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}
|
||||
{% include "covers/arrow-buttons.njk" %}
|
||||
{% enddemo %}
|
@@ -15,10 +15,16 @@ eleventyExcludeFromCollections: true
|
||||
<div class="category__posts">
|
||||
<div class="card__item">
|
||||
<a class="card__link" href="/accordion/">
|
||||
{% include "covers/accordion.njk" %}
|
||||
<div class="card__cover">{% include "covers/accordion.njk" %}</div>
|
||||
<div class="card__title">Accordion</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card__item">
|
||||
<a class="card__link" href="/arrow-buttons/">
|
||||
<div class="card__cover">{% include "covers/arrow-buttons.njk" %}</div>
|
||||
<div class="card__title">Arrow buttons</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -1,256 +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.ArrowButtons}>
|
||||
<Head>
|
||||
<meta name="description" content="Create arrow buttons with CSS" />
|
||||
<meta name="og:description" content="Create arrow buttons with CSS" />
|
||||
<meta name="twitter:description" content="Create arrow buttons with CSS" />
|
||||
<meta name="keywords" content="css arrow buttons" />
|
||||
</Head>
|
||||
<BrowserFrame
|
||||
html={`
|
||||
<!-- Up arrow button -->
|
||||
<button class="button">
|
||||
<!-- Arrow -->
|
||||
<div class="button__arrow button__arrow--up"></div>
|
||||
|
||||
<!-- Content -->
|
||||
...
|
||||
</button>
|
||||
|
||||
<!-- Right arrow button -->
|
||||
<button class="button">
|
||||
<!-- Content -->
|
||||
...
|
||||
|
||||
<!-- Arrow -->
|
||||
<div class="button__arrow button__arrow--right"></div>
|
||||
</button>
|
||||
|
||||
<!-- Down arrow button -->
|
||||
<button class="button">
|
||||
<!-- Arrow -->
|
||||
<div class="button__arrow button__arrow--down"></div>
|
||||
|
||||
<!-- Content -->
|
||||
...
|
||||
</button>
|
||||
|
||||
<!-- Left arrow button -->
|
||||
<button class="button">
|
||||
<!-- Arrow -->
|
||||
<div class="button__arrow button__arrow--left"></div>
|
||||
|
||||
<!-- Content -->
|
||||
...
|
||||
</button>
|
||||
`}
|
||||
css={`
|
||||
.button {
|
||||
/* Center the content */
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
/* Spacing */
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.button__arrow {
|
||||
/* Transparent background */
|
||||
background-color: transparent;
|
||||
|
||||
/* Size */
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.button__arrow--up {
|
||||
/* Edges */
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateY(25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.button__arrow--right {
|
||||
/* Edges */
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateX(-25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.button__arrow--down {
|
||||
/* Edges */
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateY(-25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.button__arrow--left {
|
||||
/* Edges */
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateX(25%) rotate(45deg);
|
||||
}
|
||||
`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
display: 'flex',
|
||||
height: '100%',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
height: '200px',
|
||||
position: 'relative',
|
||||
width: '200px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
transform: 'translate(-50%, -50%)',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'transparent',
|
||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
borderLeft: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderTop: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '12px',
|
||||
transform: 'translateY(25%) rotate(45deg)',
|
||||
width: '12px',
|
||||
}}
|
||||
/>
|
||||
<div style={{ marginLeft: '8px' }}>Up</div>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
top: '50%',
|
||||
transform: 'translate(50%, -50%)',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'transparent',
|
||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div style={{ marginRight: '8px' }}>Right</div>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
borderRight: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderTop: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '12px',
|
||||
transform: 'translateX(-25%) rotate(45deg)',
|
||||
width: '12px',
|
||||
}}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
bottom: 0,
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
transform: 'translate(-50%, 50%)',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'transparent',
|
||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderRight: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '12px',
|
||||
transform: 'translateY(-25%) rotate(45deg)',
|
||||
width: '12px',
|
||||
}}
|
||||
/>
|
||||
<div style={{ marginLeft: '8px' }}>Down</div>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
backgroundColor: 'transparent',
|
||||
border: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
padding: '8px',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderLeft: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '12px',
|
||||
transform: 'translateX(25%) rotate(45deg)',
|
||||
width: '12px',
|
||||
}}
|
||||
/>
|
||||
<div style={{ marginLeft: '8px' }}>Left</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserFrame>
|
||||
|
||||
<Spacer size="extraLarge" />
|
||||
<RelatedPatterns patterns={[Pattern.CloseButton, Pattern.PopoverArrow, Pattern.TriangleButtons]} />
|
||||
</PatternLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default Details;
|
@@ -1,73 +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: '24px',
|
||||
}}
|
||||
>
|
||||
<div style={{ height: '100%', position: 'relative', width: '100%' }}>
|
||||
<div
|
||||
style={{
|
||||
borderLeft: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderTop: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '16px',
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
transform: 'translate(-50%, -50%) rotate(45deg)',
|
||||
width: '16px',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
borderRight: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderTop: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '16px',
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
top: '50%',
|
||||
transform: 'translate(50%, -50%) rotate(45deg)',
|
||||
width: '16px',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderRight: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
bottom: '-16px',
|
||||
height: '16px',
|
||||
left: '50%',
|
||||
position: 'absolute',
|
||||
transform: 'translate(-50%, -50%) rotate(45deg)',
|
||||
width: '16px',
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
borderBottom: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
borderLeft: '1px solid rgba(0, 0, 0, 0.3)',
|
||||
height: '16px',
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
transform: 'translate(-50%, -50%) rotate(45deg)',
|
||||
width: '16px',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Frame>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cover;
|
@@ -2,10 +2,9 @@
|
||||
background-color: #fff;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 0 1.5rem rgba(0, 0, 0, 0.1);
|
||||
padding: 0.5rem 1rem;
|
||||
padding: 0.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.card__link {
|
||||
color: #6366f1;
|
||||
font-size: 1.25rem;
|
||||
@@ -13,3 +12,8 @@
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
.card__cover {
|
||||
height: 8rem;
|
||||
width: 100%;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
66
styles/blocks/_example.scss
Normal file
66
styles/blocks/_example.scss
Normal file
@@ -0,0 +1,66 @@
|
||||
.example {
|
||||
box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
|
||||
margin: 2rem 0;
|
||||
position: relative;
|
||||
}
|
||||
.example--border {
|
||||
border: 1px solid #d1d5db;
|
||||
}
|
||||
.example__ribbon {
|
||||
height: 8rem;
|
||||
width: 8rem;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
border: 0.25rem solid #4338ca;
|
||||
content: '';
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
||||
.example__title {
|
||||
background-color: #818cf8;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
padding: 0.5rem 0;
|
||||
text-transform: uppercase;
|
||||
text-align: center;
|
||||
// It is a result of height * Math.sqrt(2)
|
||||
width: 181px;
|
||||
}
|
||||
.example__ribbon--tr {
|
||||
top: -0.5rem;
|
||||
right: -0.5rem;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
border-top-color: transparent;
|
||||
border-right-color: transparent;
|
||||
}
|
||||
&::after {
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
&::before {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.example__title {
|
||||
transform: translate(-13px, 30px) rotate(45deg);
|
||||
}
|
||||
}
|
||||
.example__content {
|
||||
padding: 1rem;
|
||||
}
|
||||
.example__content--small {
|
||||
height: 20rem;
|
||||
}
|
||||
.example__content--medium {
|
||||
height: 30rem;
|
||||
}
|
||||
.example__content--large {
|
||||
height: 40rem;
|
||||
}
|
66
styles/covers/_arrow-buttons.scss
Normal file
66
styles/covers/_arrow-buttons.scss
Normal file
@@ -0,0 +1,66 @@
|
||||
.arrow-buttons {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.arrow-button {
|
||||
/* Transparent background */
|
||||
background-color: transparent;
|
||||
|
||||
/* Size */
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.arrow-button--t {
|
||||
/* Edges */
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateY(25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow-button--r {
|
||||
/* Edges */
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateX(-25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow-button--b {
|
||||
/* Edges */
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateY(-25%) rotate(45deg);
|
||||
}
|
||||
|
||||
.arrow-button--l {
|
||||
/* Edges */
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||
transform: translateX(25%) rotate(45deg);
|
||||
}
|
||||
|
||||
/* Demo */
|
||||
.arrow-buttons__corner {
|
||||
position: absolute;
|
||||
}
|
||||
.arrow-buttons__corner--t {
|
||||
left: 50%;
|
||||
top: 0;
|
||||
transform: translate(-50%, 0%);
|
||||
}
|
||||
.arrow-buttons__corner--r {
|
||||
right: 0;
|
||||
top: 50%;
|
||||
transform: translate(0%, -50%);
|
||||
}
|
||||
.arrow-buttons__corner--b {
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0%);
|
||||
}
|
||||
.arrow-buttons__corner--l {
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translate(0%, -50%);
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
|
||||
@import './blocks/card';
|
||||
@import './blocks/category';
|
||||
@import './blocks/example';
|
||||
@import './blocks/hero';
|
||||
@import './blocks/follow';
|
||||
@import './blocks/footer';
|
||||
@@ -11,6 +12,7 @@
|
||||
|
||||
// Cover
|
||||
@import './covers/accordion';
|
||||
@import './covers/arrow-buttons';
|
||||
|
||||
// Placeholders
|
||||
@import './placeholders/circle';
|
||||
|
Reference in New Issue
Block a user