diff --git a/contents/_includes/patterns/custom-checkbox-button.njk b/contents/_includes/patterns/custom-checkbox-button.njk new file mode 100644 index 0000000..3458b7b --- /dev/null +++ b/contents/_includes/patterns/custom-checkbox-button.njk @@ -0,0 +1,9 @@ +{% for i in range(0, 3) %} + +{% endfor %} \ No newline at end of file diff --git a/contents/custom-checkbox-button.md b/contents/custom-checkbox-button.md new file mode 100644 index 0000000..7548973 --- /dev/null +++ b/contents/custom-checkbox-button.md @@ -0,0 +1,65 @@ +--- +layout: layouts/post.njk +title: Custom checkbox button +description: Create a custom checkbox button with CSS flexbox +keywords: css checkbox, css flexbox +--- + +## HTML + +```html + +``` + +## CSS + +```css +.custom-checkbox-button { + /* Center the content horizontally */ + align-items: center; + display: inline-flex; + + /* Cursor */ + cursor: pointer; +} + +.custom-checkbox-button__input { + /* Hide it */ + display: none; +} + +.custom-checkbox-button__square { + border: 1px solid #d1d5db; + border-radius: 0.25rem; + + /* Spacing */ + margin-right: 0.5rem; + padding: 0.25rem; +} + +.custom-checkbox-button__checkbox { + background-color: transparent; + border-radius: 0.25rem; + height: 1rem; + width: 1rem; +} + +.custom-checkbox-button__checkbox--selected { + /* For selected checkbox */ + background-color: #3b82f6; +} +``` + +{% demo %}{% include "patterns/custom-checkbox-button.njk" %}{% enddemo %} diff --git a/contents/index.njk b/contents/index.njk index a1ad7db..6133ffd 100644 --- a/contents/index.njk +++ b/contents/index.njk @@ -89,6 +89,7 @@ eleventyExcludeFromCollections: true
{% pattern "Button with icon" %}{% include "patterns/button-with-icon.njk" %}{% endpattern %} {% pattern "Chip" %}{% include "patterns/chip.njk" %}{% endpattern %} + {% pattern "Custom checkbox button" %}{% include "patterns/custom-checkbox-button.njk" %}{% endpattern %}
diff --git a/pages/custom-checkbox-button/index.tsx b/pages/custom-checkbox-button/index.tsx deleted file mode 100644 index 85e8a83..0000000 --- a/pages/custom-checkbox-button/index.tsx +++ /dev/null @@ -1,179 +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'; -import Rectangle from '../../placeholders/Rectangle'; - -interface CheckboxProps { - isChecked: boolean; - value: string; -} - -const Details: React.FC<{}> = () => { - const Checkbox: React.FC = ({ isChecked, value, children }) => { - const [checked, setChecked] = React.useState(isChecked); - const click = () => setChecked((c) => !c); - - return ( -