mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-07 22:56:51 +02:00
feat: Input addon
This commit is contained in:
9
contents/_includes/patterns/input-addon.njk
Normal file
9
contents/_includes/patterns/input-addon.njk
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<div class="input-addon">
|
||||||
|
<div class="input-addon__addon input-addon__addon--prepended">{% circle "md" %}</div>
|
||||||
|
<input type="text" class="input-addon__input" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-addon">
|
||||||
|
<input type="text" class="input-addon__input" />
|
||||||
|
<div class="input-addon__addon input-addon__addon--appended">{% circle "md" %}</div>
|
||||||
|
</div>
|
@@ -91,6 +91,7 @@ eleventyExcludeFromCollections: true
|
|||||||
{% pattern "Chip" %}{% include "patterns/chip.njk" %}{% endpattern %}
|
{% pattern "Chip" %}{% include "patterns/chip.njk" %}{% endpattern %}
|
||||||
{% pattern "Custom checkbox button" %}{% include "patterns/custom-checkbox-button.njk" %}{% endpattern %}
|
{% pattern "Custom checkbox button" %}{% include "patterns/custom-checkbox-button.njk" %}{% endpattern %}
|
||||||
{% pattern "Custom radio button" %}{% include "patterns/custom-radio-button.njk" %}{% endpattern %}
|
{% pattern "Custom radio button" %}{% include "patterns/custom-radio-button.njk" %}{% endpattern %}
|
||||||
|
{% pattern "Input addon" %}{% include "patterns/input-addon.njk" %}{% endpattern %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
81
contents/input-addon.md
Normal file
81
contents/input-addon.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
---
|
||||||
|
layout: layouts/post.njk
|
||||||
|
title: Input addon
|
||||||
|
description: Create an input add-on with CSS flexbox
|
||||||
|
keywords: css flexbox, css input add-on
|
||||||
|
---
|
||||||
|
|
||||||
|
## HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- Add-on prepended -->
|
||||||
|
<div class="input-addon">
|
||||||
|
<!-- Add-on -->
|
||||||
|
<div class="input-addon__addon input-addon__addon--prepended">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Input -->
|
||||||
|
<input type="text" class="input-addon__input" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add-on appended -->
|
||||||
|
<div class="input-addon">
|
||||||
|
<!-- Input -->
|
||||||
|
<input type="text" class="input-addon__input" />
|
||||||
|
|
||||||
|
<!-- Add-on -->
|
||||||
|
<div class="input-addon__addon input-addon__addon--appended">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Appended and prepended add-ons -->
|
||||||
|
<div class="input-addon">
|
||||||
|
<!-- Add-on -->
|
||||||
|
<div class="input-addon__addon input-addon__addon--prepended">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Input -->
|
||||||
|
<input type="text" class="input-addon__input" />
|
||||||
|
|
||||||
|
<!-- Add-on -->
|
||||||
|
<div class="input-addon__addon input-addon__addon--appended">
|
||||||
|
...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSS
|
||||||
|
|
||||||
|
```css
|
||||||
|
.input-addon {
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-addon__input {
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
/* Take the remaining width */
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-addon__addon {
|
||||||
|
/* Center the content */
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-addon__addon--prepended {
|
||||||
|
border-right: 1px solid #d1d5db;
|
||||||
|
}
|
||||||
|
.input-addon__addon--appended {
|
||||||
|
border-left: 1px solid #d1d5db;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
{% demo %}{% include "patterns/input-addon.njk" %}{% enddemo %}
|
@@ -1,207 +0,0 @@
|
|||||||
import * as React from 'react';
|
|
||||||
import Head from 'next/head';
|
|
||||||
|
|
||||||
import { Pattern } from '../../constants/Pattern';
|
|
||||||
import { PatternLayout } from '../../layouts/PatternLayout';
|
|
||||||
import BrowserFrame from '../../placeholders/BrowserFrame';
|
|
||||||
import Rectangle from '../../placeholders/Rectangle';
|
|
||||||
|
|
||||||
const Details: React.FC<{}> = () => {
|
|
||||||
return (
|
|
||||||
<PatternLayout pattern={Pattern.InputAddon}>
|
|
||||||
<Head>
|
|
||||||
<meta name="description" content="Create an input add-on with CSS flexbox" />
|
|
||||||
<meta name="og:description" content="Create an input add-on with CSS flexbox" />
|
|
||||||
<meta name="twitter:description" content="Create an input add-on with CSS flexbox" />
|
|
||||||
<meta name="keywords" content="css flexbox, css input add-on" />
|
|
||||||
</Head>
|
|
||||||
<BrowserFrame
|
|
||||||
html={`
|
|
||||||
<!-- Add-on prepended -->
|
|
||||||
<div class="container">
|
|
||||||
<!-- Add-on -->
|
|
||||||
<div class="container__addon">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Input -->
|
|
||||||
<input type="text" class="container__input" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Add-on appended -->
|
|
||||||
<div class="container">
|
|
||||||
<!-- Input -->
|
|
||||||
<input type="text" class="container__input" />
|
|
||||||
|
|
||||||
<!-- Add-on -->
|
|
||||||
<div class="container__addon">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Appended and prepended add-ons -->
|
|
||||||
<div class="container">
|
|
||||||
<!-- Add-on -->
|
|
||||||
<div class="container__addon">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Input -->
|
|
||||||
<input type="text" class="container__input" />
|
|
||||||
|
|
||||||
<!-- Add-on -->
|
|
||||||
<div class="container__addon">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
css={`
|
|
||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
/* Take full size */
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__input {
|
|
||||||
/* Take the remaining width */
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container__addon {
|
|
||||||
/* Center the content */
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ width: '256px' }}>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: '1px solid #d1d5db',
|
|
||||||
borderRadius: '4px',
|
|
||||||
display: 'flex',
|
|
||||||
height: '32px',
|
|
||||||
marginBottom: '16px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
||||||
borderRight: '1px solid #d1d5db',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
width: '30%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
style={{
|
|
||||||
borderColor: 'transparent',
|
|
||||||
flex: 1,
|
|
||||||
marginRight: '1px',
|
|
||||||
padding: '4px',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: '1px solid #d1d5db',
|
|
||||||
borderRadius: '4px',
|
|
||||||
display: 'flex',
|
|
||||||
height: '32px',
|
|
||||||
marginBottom: '16px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
style={{
|
|
||||||
borderColor: 'transparent',
|
|
||||||
flex: 1,
|
|
||||||
marginLeft: '1px',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
||||||
borderLeft: '1px solid #d1d5db',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
width: '40%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: '1px solid #d1d5db',
|
|
||||||
borderRadius: '4px',
|
|
||||||
display: 'flex',
|
|
||||||
height: '32px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
||||||
borderRight: '1px solid #d1d5db',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
width: '20%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
style={{
|
|
||||||
borderColor: 'transparent',
|
|
||||||
flex: 1,
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
||||||
borderLeft: '1px solid #d1d5db',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
width: '30%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Rectangle />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</BrowserFrame>
|
|
||||||
</PatternLayout>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Details;
|
|
@@ -1,48 +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={{
|
|
||||||
alignItems: 'center',
|
|
||||||
display: 'flex',
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '8px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
border: '1px solid #d1d5db',
|
|
||||||
borderRadius: '4px',
|
|
||||||
display: 'flex',
|
|
||||||
height: '24px',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
alignItems: 'center',
|
|
||||||
borderRight: '1px solid #d1d5db',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
padding: '0 8px',
|
|
||||||
width: '30%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div style={{ width: '100%' }}>
|
|
||||||
<Line />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style={{ flex: 1 }} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Frame>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Cover;
|
|
@@ -41,6 +41,7 @@
|
|||||||
@import './patterns/folder-structure';
|
@import './patterns/folder-structure';
|
||||||
@import './patterns/full-background';
|
@import './patterns/full-background';
|
||||||
@import './patterns/initial-avatar';
|
@import './patterns/initial-avatar';
|
||||||
|
@import './patterns/input-addon';
|
||||||
@import './patterns/inverted-corners';
|
@import './patterns/inverted-corners';
|
||||||
@import './patterns/keyboard-shortcut';
|
@import './patterns/keyboard-shortcut';
|
||||||
@import './patterns/layered-card';
|
@import './patterns/layered-card';
|
||||||
|
36
styles/patterns/_input-addon.scss
Normal file
36
styles/patterns/_input-addon.scss
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
.input-addon {
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
/* Demo */
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-addon__input {
|
||||||
|
border: none;
|
||||||
|
/* Take the remaining width */
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
/* Demo */
|
||||||
|
padding: 0.25rem;
|
||||||
|
margin: 0 0.25rem;
|
||||||
|
width: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-addon__addon {
|
||||||
|
/* Center the content */
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
/* Demo */
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-addon__addon--prepended {
|
||||||
|
border-right: 1px solid #d1d5db;
|
||||||
|
}
|
||||||
|
.input-addon__addon--appended {
|
||||||
|
border-left: 1px solid #d1d5db;
|
||||||
|
}
|
@@ -8,7 +8,7 @@
|
|||||||
--circle-size: 0.5rem;
|
--circle-size: 0.5rem;
|
||||||
}
|
}
|
||||||
.circle--md {
|
.circle--md {
|
||||||
--circle-size: 2rem;
|
--circle-size: 1.5rem;
|
||||||
}
|
}
|
||||||
.circle--lg {
|
.circle--lg {
|
||||||
--circle-size: 4rem;
|
--circle-size: 4rem;
|
||||||
|
Reference in New Issue
Block a user