Visualize Your Ideas With Code
feat(ui): custom checkbox style (#529)
Jacobaf98db103d66
diff --git a/packages/ui/src/components/controls/Checkbox.tsx b/packages/ui/src/components/controls/Checkbox.tsxnew file mode 100644index 00000000..f2271462--- /dev/null+++ b/packages/ui/src/components/controls/Checkbox.tsx@@ -0,0 +1,8 @@+import styles from './Controls.module.scss';+import type {JSX} from 'preact';++type InputProps = JSX.HTMLAttributes<HTMLInputElement>;++export function Checkbox(props: InputProps) {+ return <input type="checkbox" className={styles.checkbox} {...props} />;+}diff --git a/packages/ui/src/components/controls/Controls.module.scss b/packages/ui/src/components/controls/Controls.module.scssindex ba130d35..be482739 100644--- a/packages/ui/src/components/controls/Controls.module.scss+++ b/packages/ui/src/components/controls/Controls.module.scss@@ -109,6 +109,30 @@}}+.checkbox {+ width: 16px;+ height: 16px;+ margin: 0;+ align-self: center;+ border: none;+ background-color: var(--surface-color-light);+ border-radius: 4px;+ appearance: none;+ cursor: pointer;++ &:hover {+ background-color: var(--surface-color-hover);+ }++ &:checked {+ background: var(--theme) url('../../img/checkmark.svg') no-repeat;++ &:hover {+ box-shadow: 0 0 0 2px white inset;+ }+ }+}+.input[type='number'] {text-align: right;&::-webkit-inner-spin-button,@@ -136,10 +160,22 @@}}-.select.main {- background: var(--theme)- url("data:image/svg+xml;charset=UTF-8,%3csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M16.71 10.71L15.29 9.28998L12 12.59L8.71001 9.28998L7.29001 10.71L12 15.41L16.71 10.71Z' fill='black'/%3e%3c/svg%3e")- no-repeat 100% 50%;+.select {+ background-image: url('../../img/dropdown-light.svg');+ background-repeat: no-repeat;+ background-origin: content-box;+ background-position: 100% 50%;+ background-size: 16px;+ min-width: 24px;+ padding-right: 4px;+ -moz-appearance: none;+ -webkit-appearance: none;+ appearance: none;++ &.main {+ background-color: var(--theme);+ background-image: url('../../img/dropdown.svg');+ }}.colorPreview {diff --git a/packages/ui/src/components/controls/index.ts b/packages/ui/src/components/controls/index.tsindex fe2f0989..c5399c93 100644--- a/packages/ui/src/components/controls/index.ts+++ b/packages/ui/src/components/controls/index.ts@@ -1,5 +1,6 @@export * from './Button';export * from './ButtonSelect';+export * from './Checkbox';export * from './ColorInput';export * from './InputSelect';export * from './Group';diff --git a/packages/ui/src/components/settings/RenderingSettings.tsx b/packages/ui/src/components/settings/RenderingSettings.tsxindex 83d13f88..0981e4df 100644--- a/packages/ui/src/components/settings/RenderingSettings.tsx+++ b/packages/ui/src/components/settings/RenderingSettings.tsx@@ -1,5 +1,5 @@import {useRenderingSettings} from '../../hooks';-import {Group, Input, InputSelect, Label, Select} from '../controls';+import {Checkbox, Group, Input, InputSelect, Label, Select} from '../controls';import {useApplication} from '../../contexts';import type {CanvasColorSpace,@@ -71,8 +71,7 @@ export function RenderingSettings() {)}<Group><Label>group by scene</Label>- <Input- type="checkbox"+ <Checkboxchecked={state.groupByScene}onChange={() => {meta.rendering.groupByScene.set(!state.groupByScene);diff --git a/packages/ui/src/img/checkmark.svg b/packages/ui/src/img/checkmark.svgnew file mode 100644index 00000000..ee7dcd12--- /dev/null+++ b/packages/ui/src/img/checkmark.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">+ <path+ d='M11.185,5l-4.25,4.24l-2.12,-2.12l-1.41,1.41l3.53,3.54l5.66,-5.66l-1.41,-1.41Z'+ fill="#000"+ />+</svg>\ No newline at end of filediff --git a/packages/ui/src/img/dropdown-light.svg b/packages/ui/src/img/dropdown-light.svgnew file mode 100644index 00000000..253f5d0c--- /dev/null+++ b/packages/ui/src/img/dropdown-light.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">+ <path+ d="M7.995,8.67l-3.17,-3.17l-1.41,1.41l4.58,4.59l4.59,-4.59l-1.42,-1.41l-3.17,3.17Z"+ fill="rgba(255, 255, 255, 0.54)"+ />+</svg>\ No newline at end of filediff --git a/packages/ui/src/img/dropdown.svg b/packages/ui/src/img/dropdown.svgnew file mode 100644index 00000000..a817d681--- /dev/null+++ b/packages/ui/src/img/dropdown.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">+ <path+ d="M7.995,8.67l-3.17,-3.17l-1.41,1.41l4.58,4.59l4.59,-4.59l-1.42,-1.41l-3.17,3.17Z"+ fill="#000"+ />+</svg>\ No newline at end of filediff --git a/packages/ui/src/index.scss b/packages/ui/src/index.scssindex 13b84936..d437e0b2 100644--- a/packages/ui/src/index.scss+++ b/packages/ui/src/index.scss@@ -71,11 +71,3 @@ button {border: 0;padding: 0;}--select {- background: url("data:image/svg+xml;charset=UTF-8,%3csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M16.71 10.71L15.29 9.28998L12 12.59L8.71001 9.28998L7.29001 10.71L12 15.41L16.71 10.71Z' fill='gray'/%3e%3c/svg%3e")- no-repeat 100% 50%;- -moz-appearance: none;- -webkit-appearance: none;- appearance: none;-}