diff --git a/package-lock.json b/package-lock.json index bbf13282..1fca60f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@toniq-labs/design-system-root", - "version": "16.16.4", + "version": "16.17.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@toniq-labs/design-system-root", - "version": "16.16.4", + "version": "16.17.0", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -13297,7 +13297,7 @@ }, "packages/design-system": { "name": "@toniq-labs/design-system", - "version": "16.16.4", + "version": "16.17.0", "license": "MIT", "dependencies": { "@augment-vir/common": "^23.3.4", @@ -13337,7 +13337,7 @@ }, "packages/native-elements-test": { "name": "@toniq-labs/design-system-native-elements-test", - "version": "16.16.4", + "version": "16.17.0", "dependencies": { "@toniq-labs/design-system": "*", "element-vir": "*", @@ -13359,7 +13359,7 @@ }, "packages/scripts": { "name": "@toniq-labs/design-system-scripts", - "version": "16.16.4", + "version": "16.17.0", "dependencies": { "@augment-vir/common": "^23.3.4", "@augment-vir/node-js": "^23.3.4", diff --git a/package.json b/package.json index 9138cdfc..03839c38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/design-system-root", - "version": "16.16.4", + "version": "16.17.0", "private": true, "description": "Root design system mono-repo package.", "homepage": "https://github.com/Toniq-Labs/toniq-labs-design-system", diff --git a/packages/design-system/package.json b/packages/design-system/package.json index ada5baf0..c8a8429a 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -1,6 +1,6 @@ { "name": "@toniq-labs/design-system", - "version": "16.16.4", + "version": "16.17.0", "private": false, "description": "Design system elements for Toniq Labs", "keywords": [ diff --git a/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.book.ts b/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.book.ts index 76f93e7e..de867700 100644 --- a/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.book.ts +++ b/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.book.ts @@ -6,7 +6,7 @@ import { cssVarsToPageControls, } from '../../element-book/book-helpers/css-var-page-controls'; import {elementsBookPage} from '../../element-book/book-pages/elements.book'; -import {ToniqCheckbox} from './toniq-checkbox.element'; +import {ToniqCheckbox, ToniqCheckboxVariantEnum} from './toniq-checkbox.element'; const exampleVariations: ReadonlyArray<{ title: string; @@ -16,6 +16,12 @@ const exampleVariations: ReadonlyArray<{ title: 'default', inputs: {}, }, + { + title: 'button', + inputs: { + variant: ToniqCheckboxVariantEnum.Button, + }, + }, { title: 'disabled', inputs: { diff --git a/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.ts b/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.ts index 3940995b..f5d6b42f 100644 --- a/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.ts +++ b/packages/design-system/src/elements/toniq-checkbox/toniq-checkbox.element.ts @@ -1,4 +1,4 @@ -import {classMap, css, defineElementEvent, html, listen} from 'element-vir'; +import {classMap, css, defineElementEvent, html, listen, renderIf} from 'element-vir'; import {noNativeFormStyles, noUserSelect} from 'vira'; import {CheckMark24Icon} from '../../icons/svgs/core-24/check-mark-24.icon'; import {toniqDurations} from '../../styles/animation'; @@ -7,11 +7,18 @@ import {toniqDisabledStyles} from '../../styles/disabled'; import {createFocusStyles} from '../../styles/focus'; import {toniqFontStyles} from '../../styles/fonts'; import {defineToniqElement} from '../define-toniq-element'; +import {ToniqButton, ToniqButtonVariantEnum} from '../toniq-button/toniq-button.element'; import {ToniqIcon} from '../toniq-icon/toniq-icon.element'; +export enum ToniqCheckboxVariantEnum { + Default = 'default', + Button = 'button', +} + export const ToniqCheckbox = defineToniqElement<{ text?: string | undefined; disabled?: boolean | undefined; + variant?: ToniqCheckboxVariantEnum; checked: boolean; }>()({ tagName: 'toniq-checkbox', @@ -113,31 +120,45 @@ export const ToniqCheckbox = defineToniqElement<{ } `, renderCallback({inputs, dispatch, events}) { - const iconTemplate = html` - - <${ToniqIcon.assign({icon: CheckMark24Icon})} - class="check-mark ${classMap({hidden: !inputs.checked})}" - > - - `; + const iconTemplate = renderIf( + inputs.variant !== ToniqCheckboxVariantEnum.Button, + html` + + <${ToniqIcon.assign({icon: CheckMark24Icon})} + class="check-mark ${classMap({hidden: !inputs.checked})}" + > + + `, + ); - const textTemplate = html` - - - ${inputs.text} - - - `; + + ${inputs.text} + + + `, + html` + <${ToniqButton.assign({ + text: inputs.text, + variant: inputs.checked + ? ToniqButtonVariantEnum.Default + : ToniqButtonVariantEnum.Outline, + })}> + `, + ); return html`