@crystallize/design-system 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +118 -0
- package/dist/TableComponent-I2YOOYOU.css +281 -0
- package/dist/TableComponent-QINOO453.mjs +1377 -0
- package/dist/arrow-clockwise-Z2G6UEGP.svg +1 -0
- package/dist/arrow-counterclockwise-2O5EYVJT.svg +1 -0
- package/dist/bg-color-HB2WDYGO.svg +1 -0
- package/dist/camera-CR7D2PNH.svg +1 -0
- package/dist/caret-right-fill-FFBNEXVX.svg +1 -0
- package/dist/chat-square-quote-CI6PUJHH.svg +1 -0
- package/dist/chevron-down-3FRWSIKS.svg +1 -0
- package/dist/chunk-VUXQZRSP.mjs +737 -0
- package/dist/clipboard-OSEFDF25.svg +1 -0
- package/dist/close-FH57ZMJF.svg +1 -0
- package/dist/code-SEVR6TIQ.svg +1 -0
- package/dist/copy-DMGDODUL.svg +1 -0
- package/dist/diagram-2-CEJUD2B4.svg +1 -0
- package/dist/download-JXUGIUCX.svg +1 -0
- package/dist/draggable-block-menu-KKHDNKJA.svg +1 -0
- package/dist/dropdown-more-BHZ5COKX.svg +1 -0
- package/dist/file-image-TIQPFJX4.svg +1 -0
- package/dist/filetype-gif-OG2BEYYK.svg +1 -0
- package/dist/font-color-J4GA3ZJO.svg +1 -0
- package/dist/font-family-ZU5N6TTE.svg +1 -0
- package/dist/gear-ICMT4NTP.svg +1 -0
- package/dist/horizontal-rule-N6RD2V7H.svg +1 -0
- package/dist/indent-MJ6JIMCK.svg +1 -0
- package/dist/index.css +4209 -0
- package/dist/index.d.ts +450 -3
- package/dist/index.js +11526 -5
- package/dist/index.mjs +9437 -0
- package/dist/journal-code-XUT44HDV.svg +1 -0
- package/dist/justify-J7X5JEEX.svg +1 -0
- package/dist/link-W52N4JKZ.svg +1 -0
- package/dist/list-ol-2ZEUN4Z7.svg +1 -0
- package/dist/list-ul-DVKNUP47.svg +1 -0
- package/dist/lock-WCYOZOHW.svg +1 -0
- package/dist/lock-fill-JZSKOSHK.svg +1 -0
- package/dist/markdown-4BGQNLLT.svg +1 -0
- package/dist/mic-H5FNOMM7.svg +1 -0
- package/dist/outdent-2LUMUMIP.svg +1 -0
- package/dist/paint-bucket-VCISMZTH.svg +1 -0
- package/dist/palette-SWGFPRWZ.svg +1 -0
- package/dist/pencil-fill-STFSC26F.svg +1 -0
- package/dist/plug-HGGGEVS3.svg +1 -0
- package/dist/plug-fill-OTG3U4TN.svg +1 -0
- package/dist/plus-CQISIKEC.svg +1 -0
- package/dist/plus-slash-minus-N22JU4TI.svg +1 -0
- package/dist/prettier-WUJ7B5NV.svg +1 -0
- package/dist/prettier-error-DYJSLYDP.svg +1 -0
- package/dist/square-check-UTG6FU6D.svg +1 -0
- package/dist/success-YVXUMPEZ.svg +1 -0
- package/dist/table-BR6DI4ZQ.svg +1 -0
- package/dist/text-center-UQI6PAEF.svg +1 -0
- package/dist/text-left-KT2B6TR3.svg +1 -0
- package/dist/text-paragraph-MFTUIIQG.svg +1 -0
- package/dist/text-right-SKELPISG.svg +1 -0
- package/dist/trash-UOM6D7TD.svg +1 -0
- package/dist/type-bold-PY7COC3N.svg +1 -0
- package/dist/type-h1-6KJP7YOM.svg +1 -0
- package/dist/type-h2-VHI2USC3.svg +1 -0
- package/dist/type-h3-JIU77CHO.svg +1 -0
- package/dist/type-h4-P5EHKDAL.svg +1 -0
- package/dist/type-h5-CS2KYVRG.svg +1 -0
- package/dist/type-h6-J2O74LJZ.svg +1 -0
- package/dist/type-italic-3DSFOSG2.svg +1 -0
- package/dist/type-strikethrough-E2KKQFSX.svg +1 -0
- package/dist/type-subscript-BMPTRIBU.svg +1 -0
- package/dist/type-superscript-EDF6EPAA.svg +1 -0
- package/dist/type-underline-CBFA5VLF.svg +1 -0
- package/dist/upload-Q6KICGZW.svg +1 -0
- package/dist/user-EOI2NEFZ.svg +1 -0
- package/package.json +114 -79
- package/readme.md +9 -0
- package/src/action-menu/ActionMenu.stories.tsx +25 -0
- package/src/action-menu/action-item.tsx +16 -0
- package/src/action-menu/action-menu.css +38 -0
- package/src/action-menu/action-menu.tsx +25 -0
- package/src/action-menu/index.tsx +3 -0
- package/src/avatar/Avatar.stories.tsx +20 -0
- package/src/avatar/avatar.css +23 -0
- package/src/avatar/avatar.tsx +34 -0
- package/src/avatar/get-initials.ts +5 -0
- package/src/avatar/index.ts +1 -0
- package/src/button/Button.stories.tsx +105 -0
- package/src/button/button.css +116 -0
- package/src/button/button.tsx +136 -0
- package/src/button/index.ts +3 -0
- package/src/card/card.css +7 -0
- package/src/card/card.stories.tsx +24 -0
- package/src/card/card.tsx +27 -0
- package/src/card/index.ts +3 -0
- package/src/checkbox/checkbox.css +30 -0
- package/src/checkbox/checkbox.stories.tsx +62 -0
- package/src/checkbox/checkbox.test.tsx +16 -0
- package/src/checkbox/checkbox.tsx +28 -0
- package/src/checkbox/index.ts +1 -0
- package/src/colors/Colors.stories.tsx +127 -0
- package/src/colors/color-defaults.json +15 -0
- package/src/colors/color-pairing.json +12 -0
- package/src/colors/colors.json +158 -0
- package/src/colors/index.ts +1 -0
- package/src/colors/old-to-new.txt +19 -0
- package/src/colors/types.ts +29 -0
- package/src/dialog/Dialog.stories.tsx +168 -0
- package/src/dialog/Dialog.test.tsx +25 -0
- package/src/dialog/config.tsx +139 -0
- package/src/dialog/confirm-dialog.tsx +70 -0
- package/src/dialog/destroyFns.ts +1 -0
- package/src/dialog/dialog.css +27 -0
- package/src/dialog/dialog.tsx +95 -0
- package/src/dialog/index.tsx +40 -0
- package/src/dialog/types.ts +70 -0
- package/src/dropdown-menu/DropdownMenu.stories.tsx +38 -0
- package/src/dropdown-menu/dropdown-menu-item.tsx +15 -0
- package/src/dropdown-menu/dropdown-menu-label.tsx +10 -0
- package/src/dropdown-menu/dropdown-menu-root.tsx +33 -0
- package/src/dropdown-menu/dropdown-menu.css +20 -0
- package/src/dropdown-menu/index.ts +11 -0
- package/src/icon-button/IconButton.stories.tsx +45 -0
- package/src/icon-button/icon-button.css +50 -0
- package/src/icon-button/icon-button.tsx +39 -0
- package/src/icon-button/index.ts +3 -0
- package/src/iconography/Icon.stories.tsx +47 -0
- package/src/iconography/add.tsx +30 -0
- package/src/iconography/arrow.tsx +15 -0
- package/src/iconography/atom.tsx +59 -0
- package/src/iconography/cancel.tsx +26 -0
- package/src/iconography/catalogue.tsx +26 -0
- package/src/iconography/copy.tsx +24 -0
- package/src/iconography/crystal.tsx +93 -0
- package/src/iconography/customers.tsx +38 -0
- package/src/iconography/edit.tsx +30 -0
- package/src/iconography/error.tsx +40 -0
- package/src/iconography/fulfilment.tsx +58 -0
- package/src/iconography/glasses.tsx +62 -0
- package/src/iconography/graphQL.tsx +90 -0
- package/src/iconography/grid.tsx +84 -0
- package/src/iconography/hooks.tsx +26 -0
- package/src/iconography/image.tsx +47 -0
- package/src/iconography/index.ts +63 -0
- package/src/iconography/info.tsx +41 -0
- package/src/iconography/key.tsx +19 -0
- package/src/iconography/language.tsx +38 -0
- package/src/iconography/nail-polish.tsx +84 -0
- package/src/iconography/order.tsx +38 -0
- package/src/iconography/particle.tsx +88 -0
- package/src/iconography/percentage.tsx +44 -0
- package/src/iconography/price-tag.tsx +40 -0
- package/src/iconography/shapes.tsx +48 -0
- package/src/iconography/subscription.tsx +34 -0
- package/src/iconography/topics.tsx +58 -0
- package/src/iconography/triangle.tsx +27 -0
- package/src/iconography/usage.tsx +34 -0
- package/src/iconography/users.tsx +44 -0
- package/src/iconography/warning.tsx +51 -0
- package/src/index.css +14 -0
- package/src/index.ts +33 -0
- package/src/inline-radio/index.ts +1 -0
- package/src/inline-radio/inline-radio.css +36 -0
- package/src/inline-radio/inline-radio.stories.tsx +81 -0
- package/src/inline-radio/inline-radio.tsx +41 -0
- package/src/input/Input.stories.tsx +26 -0
- package/src/input/index.ts +1 -0
- package/src/input/input.css +7 -0
- package/src/input/input.tsx +20 -0
- package/src/input-with-label/InputWithLabel.stories.tsx +98 -0
- package/src/input-with-label/index.ts +3 -0
- package/src/input-with-label/input-with-label.css +35 -0
- package/src/input-with-label/input-with-label.tsx +59 -0
- package/src/label/index.ts +1 -0
- package/src/label/label.css +3 -0
- package/src/label/label.stories.tsx +19 -0
- package/src/label/label.tsx +13 -0
- package/src/progress/Progress.stories.tsx +26 -0
- package/src/progress/index.ts +1 -0
- package/src/progress/progress.css +7 -0
- package/src/progress/progress.tsx +17 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio.css +20 -0
- package/src/radio/radio.stories.tsx +142 -0
- package/src/radio/radio.tsx +19 -0
- package/src/rich-text-editor/appSettings.ts +28 -0
- package/src/rich-text-editor/context/SettingsContext.tsx +71 -0
- package/src/rich-text-editor/context/SharedAutocompleteContext.tsx +60 -0
- package/src/rich-text-editor/context/SharedHistoryContext.tsx +25 -0
- package/src/rich-text-editor/hooks/useReport.ts +64 -0
- package/src/rich-text-editor/images/cat-typing.gif +0 -0
- package/src/rich-text-editor/images/emoji/1F600.png +0 -0
- package/src/rich-text-editor/images/emoji/1F641.png +0 -0
- package/src/rich-text-editor/images/emoji/1F642.png +0 -0
- package/src/rich-text-editor/images/emoji/2764.png +0 -0
- package/src/rich-text-editor/images/emoji/LICENSE.md +5 -0
- package/src/rich-text-editor/images/icons/LICENSE.md +5 -0
- package/src/rich-text-editor/images/icons/arrow-clockwise.svg +1 -0
- package/src/rich-text-editor/images/icons/arrow-counterclockwise.svg +1 -0
- package/src/rich-text-editor/images/icons/bg-color.svg +1 -0
- package/src/rich-text-editor/images/icons/camera.svg +1 -0
- package/src/rich-text-editor/images/icons/card-checklist.svg +1 -0
- package/src/rich-text-editor/images/icons/caret-right-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-left-text.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right-dots.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right-text.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-square-quote.svg +1 -0
- package/src/rich-text-editor/images/icons/chevron-down.svg +1 -0
- package/src/rich-text-editor/images/icons/clipboard.svg +1 -0
- package/src/rich-text-editor/images/icons/close.svg +1 -0
- package/src/rich-text-editor/images/icons/code.svg +1 -0
- package/src/rich-text-editor/images/icons/comments.svg +1 -0
- package/src/rich-text-editor/images/icons/copy.svg +1 -0
- package/src/rich-text-editor/images/icons/diagram-2.svg +1 -0
- package/src/rich-text-editor/images/icons/download.svg +1 -0
- package/src/rich-text-editor/images/icons/draggable-block-menu.svg +1 -0
- package/src/rich-text-editor/images/icons/dropdown-more.svg +1 -0
- package/src/rich-text-editor/images/icons/figma.svg +1 -0
- package/src/rich-text-editor/images/icons/file-image.svg +1 -0
- package/src/rich-text-editor/images/icons/filetype-gif.svg +1 -0
- package/src/rich-text-editor/images/icons/font-color.svg +1 -0
- package/src/rich-text-editor/images/icons/font-family.svg +1 -0
- package/src/rich-text-editor/images/icons/gear.svg +1 -0
- package/src/rich-text-editor/images/icons/horizontal-rule.svg +1 -0
- package/src/rich-text-editor/images/icons/indent.svg +1 -0
- package/src/rich-text-editor/images/icons/journal-code.svg +1 -0
- package/src/rich-text-editor/images/icons/journal-text.svg +1 -0
- package/src/rich-text-editor/images/icons/justify.svg +1 -0
- package/src/rich-text-editor/images/icons/link.svg +1 -0
- package/src/rich-text-editor/images/icons/list-ol.svg +1 -0
- package/src/rich-text-editor/images/icons/list-ul.svg +1 -0
- package/src/rich-text-editor/images/icons/lock-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/lock.svg +1 -0
- package/src/rich-text-editor/images/icons/markdown.svg +1 -0
- package/src/rich-text-editor/images/icons/mic.svg +1 -0
- package/src/rich-text-editor/images/icons/outdent.svg +1 -0
- package/src/rich-text-editor/images/icons/paint-bucket.svg +1 -0
- package/src/rich-text-editor/images/icons/palette.svg +1 -0
- package/src/rich-text-editor/images/icons/pencil-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/plug-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/plug.svg +1 -0
- package/src/rich-text-editor/images/icons/plus-slash-minus.svg +1 -0
- package/src/rich-text-editor/images/icons/plus.svg +1 -0
- package/src/rich-text-editor/images/icons/prettier-error.svg +1 -0
- package/src/rich-text-editor/images/icons/prettier.svg +1 -0
- package/src/rich-text-editor/images/icons/send.svg +1 -0
- package/src/rich-text-editor/images/icons/square-check.svg +1 -0
- package/src/rich-text-editor/images/icons/sticky.svg +1 -0
- package/src/rich-text-editor/images/icons/success.svg +1 -0
- package/src/rich-text-editor/images/icons/table.svg +1 -0
- package/src/rich-text-editor/images/icons/text-center.svg +1 -0
- package/src/rich-text-editor/images/icons/text-left.svg +1 -0
- package/src/rich-text-editor/images/icons/text-paragraph.svg +1 -0
- package/src/rich-text-editor/images/icons/text-right.svg +1 -0
- package/src/rich-text-editor/images/icons/trash.svg +1 -0
- package/src/rich-text-editor/images/icons/trash3.svg +1 -0
- package/src/rich-text-editor/images/icons/tweet.svg +1 -0
- package/src/rich-text-editor/images/icons/type-bold.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h1.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h2.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h3.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h4.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h5.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h6.svg +1 -0
- package/src/rich-text-editor/images/icons/type-italic.svg +1 -0
- package/src/rich-text-editor/images/icons/type-strikethrough.svg +1 -0
- package/src/rich-text-editor/images/icons/type-subscript.svg +1 -0
- package/src/rich-text-editor/images/icons/type-superscript.svg +1 -0
- package/src/rich-text-editor/images/icons/type-underline.svg +1 -0
- package/src/rich-text-editor/images/icons/upload.svg +1 -0
- package/src/rich-text-editor/images/icons/user.svg +1 -0
- package/src/rich-text-editor/images/icons/youtube.svg +1 -0
- package/src/rich-text-editor/images/image/LICENSE.md +5 -0
- package/src/rich-text-editor/images/landscape.jpg +0 -0
- package/src/rich-text-editor/images/logo.svg +1 -0
- package/src/rich-text-editor/images/yellow-flower-small.jpg +0 -0
- package/src/rich-text-editor/images/yellow-flower.jpg +0 -0
- package/src/rich-text-editor/index.ts +1 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/code.ts +39 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/headings.ts +12 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/index.ts +69 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/link.ts +9 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/table.ts +16 -0
- package/src/rich-text-editor/model/crystallize-to-lexical.ts +186 -0
- package/src/rich-text-editor/model/lexical-to-crystallize.ts +232 -0
- package/src/rich-text-editor/nodes/AutocompleteNode.tsx +96 -0
- package/src/rich-text-editor/nodes/BaseNodes.ts +45 -0
- package/src/rich-text-editor/nodes/KeywordNode.ts +73 -0
- package/src/rich-text-editor/nodes/TableCellNodes.ts +31 -0
- package/src/rich-text-editor/nodes/TableComponent.tsx +1547 -0
- package/src/rich-text-editor/nodes/TableNode.tsx +398 -0
- package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +83 -0
- package/src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx +47 -0
- package/src/rich-text-editor/plugins/AutocompletePlugin/index.tsx +2536 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +60 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +14 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +140 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.css +46 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.tsx +155 -0
- package/src/rich-text-editor/plugins/CodeHighlightPlugin/index.ts +21 -0
- package/src/rich-text-editor/plugins/ComponentPickerPlugin/index.tsx +320 -0
- package/src/rich-text-editor/plugins/DragDropPastePlugin/index.ts +40 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.css +36 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.tsx +368 -0
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.css +40 -0
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx +305 -0
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +128 -0
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +351 -0
- package/src/rich-text-editor/plugins/LinkPlugin/index.tsx +16 -0
- package/src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts +86 -0
- package/src/rich-text-editor/plugins/MarkdownShortcutPlugin/index.tsx +16 -0
- package/src/rich-text-editor/plugins/MarkdownTransformers/index.ts +195 -0
- package/src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx +49 -0
- package/src/rich-text-editor/plugins/SpeechToTextPlugin/index.ts +113 -0
- package/src/rich-text-editor/plugins/TabFocusPlugin/index.tsx +65 -0
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +481 -0
- package/src/rich-text-editor/plugins/TableCellResizer/index.css +12 -0
- package/src/rich-text-editor/plugins/TableCellResizer/index.tsx +386 -0
- package/src/rich-text-editor/plugins/TablePlugin.tsx +190 -0
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +726 -0
- package/src/rich-text-editor/plugins/TreeViewPlugin/index.tsx +25 -0
- package/src/rich-text-editor/plugins/TypingPerfPlugin/index.ts +117 -0
- package/src/rich-text-editor/rich-text-editor.css +1396 -0
- package/src/rich-text-editor/rich-text-editor.stories.tsx +385 -0
- package/src/rich-text-editor/rich-text-editor.tsx +228 -0
- package/src/rich-text-editor/tests/rich-text-editor-basic-rendering.test.tsx +47 -0
- package/src/rich-text-editor/tests/rich-text-editor-code.test.tsx +39 -0
- package/src/rich-text-editor/tests/rich-text-editor-model-basics.test.tsx +56 -0
- package/src/rich-text-editor/tests/rich-text-editor-model-conversions.test.tsx +195 -0
- package/src/rich-text-editor/tests/rich-text-editor-onchange.test.tsx +37 -0
- package/src/rich-text-editor/tests/rich-text-editor-quote.test.tsx +36 -0
- package/src/rich-text-editor/tests/rich-text-editor-text-formats.test.tsx +135 -0
- package/src/rich-text-editor/tests/rich-text-editor-typing.test.tsx +73 -0
- package/src/rich-text-editor/tests/utils.ts +23 -0
- package/src/rich-text-editor/themes/PlaygroundEditorTheme.css +433 -0
- package/src/rich-text-editor/themes/PlaygroundEditorTheme.ts +113 -0
- package/src/rich-text-editor/types.ts +5 -0
- package/src/rich-text-editor/ui/ContentEditable.css +13 -0
- package/src/rich-text-editor/ui/ContentEditable.tsx +15 -0
- package/src/rich-text-editor/ui/LinkPreview.css +57 -0
- package/src/rich-text-editor/ui/LinkPreview.tsx +169 -0
- package/src/rich-text-editor/utils/environment.ts +1 -0
- package/src/rich-text-editor/utils/getDOMRangeRect.ts +42 -0
- package/src/rich-text-editor/utils/getSelectedNode.ts +27 -0
- package/src/rich-text-editor/utils/guard.ts +10 -0
- package/src/rich-text-editor/utils/isMobileWidth.ts +7 -0
- package/src/rich-text-editor/utils/joinClasses.ts +13 -0
- package/src/rich-text-editor/utils/point.ts +55 -0
- package/src/rich-text-editor/utils/rect.ts +158 -0
- package/src/rich-text-editor/utils/setFloatingElemPosition.ts +46 -0
- package/src/rich-text-editor/utils/swipe.ts +127 -0
- package/src/rich-text-editor/utils/url.ts +33 -0
- package/src/select/index.ts +1 -0
- package/src/select/select-item.tsx +18 -0
- package/src/select/select-root.tsx +50 -0
- package/src/select/select.css +44 -0
- package/src/select/select.stories.tsx +74 -0
- package/src/select/select.ts +9 -0
- package/src/slider/Slider.stories.tsx +54 -0
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.css +27 -0
- package/src/slider/slider.tsx +20 -0
- package/src/spinner/Spinner.stories.tsx +19 -0
- package/src/spinner/index.tsx +48 -0
- package/src/spinner/spinner.css +11 -0
- package/src/tag/Tag.stories.tsx +32 -0
- package/src/tag/index.ts +1 -0
- package/src/tag/tag.css +7 -0
- package/src/tag/tag.tsx +27 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.cjs +51 -0
- package/LICENSE +0 -21
- package/README.md +0 -87
- package/dist/components/Button.d.ts +0 -11
- package/dist/components/Checkbox.d.ts +0 -29
- package/dist/components/Typography.d.ts +0 -14
- package/dist/design-system.cjs.development.js +0 -251
- package/dist/design-system.cjs.development.js.map +0 -1
- package/dist/design-system.cjs.production.min.js +0 -2
- package/dist/design-system.cjs.production.min.js.map +0 -1
- package/dist/design-system.esm.js +0 -245
- package/dist/design-system.esm.js.map +0 -1
- package/dist/styles/theme.d.ts +0 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { Button } from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Button> = {
|
|
5
|
+
title: 'Components/Button',
|
|
6
|
+
component: Button,
|
|
7
|
+
argTypes: {
|
|
8
|
+
variant: {
|
|
9
|
+
defaultValue: 'default',
|
|
10
|
+
},
|
|
11
|
+
intent: {
|
|
12
|
+
defaultValue: 'default',
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
defaultValue: 'sm',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof Button>;
|
|
22
|
+
|
|
23
|
+
const variants = ['default', 'elevate'] as const;
|
|
24
|
+
const intent = ['default', 'action', 'danger'] as const;
|
|
25
|
+
const sizes = ['xs', 'sm', 'md', 'lg'] as const;
|
|
26
|
+
|
|
27
|
+
export const AllButton: Story = {
|
|
28
|
+
name: 'All Buttons',
|
|
29
|
+
render: () => {
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
<div className="grid grid-cols-6 justify-items-center gap-6">
|
|
33
|
+
{sizes.map(size =>
|
|
34
|
+
variants.map(variant =>
|
|
35
|
+
intent.map(intent => (
|
|
36
|
+
<Button variant={variant} size={size} intent={intent} status="loading">
|
|
37
|
+
Button
|
|
38
|
+
</Button>
|
|
39
|
+
)),
|
|
40
|
+
),
|
|
41
|
+
)}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
intent: 'default',
|
|
51
|
+
variant: 'default',
|
|
52
|
+
children: 'Button',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Elevate: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
intent: 'default',
|
|
59
|
+
variant: 'elevate',
|
|
60
|
+
children: 'Button',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Action: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
intent: 'action',
|
|
67
|
+
variant: 'default',
|
|
68
|
+
children: 'Button',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const Danger: Story = {
|
|
73
|
+
args: {
|
|
74
|
+
intent: 'danger',
|
|
75
|
+
variant: 'default',
|
|
76
|
+
children: 'Button',
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const Prepend: Story = {
|
|
81
|
+
args: {
|
|
82
|
+
intent: 'default',
|
|
83
|
+
variant: 'default',
|
|
84
|
+
children: 'Button',
|
|
85
|
+
prepend: '🤓',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const Append: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
intent: 'default',
|
|
92
|
+
variant: 'default',
|
|
93
|
+
children: 'Button',
|
|
94
|
+
append: '🤓',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const IsLoading: Story = {
|
|
99
|
+
args: {
|
|
100
|
+
intent: 'default',
|
|
101
|
+
variant: 'default',
|
|
102
|
+
children: 'Button',
|
|
103
|
+
status: 'loading',
|
|
104
|
+
},
|
|
105
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
.c-btn {
|
|
2
|
+
@apply inline-grid cursor-pointer grid-flow-col items-center gap-2 whitespace-nowrap rounded border-none bg-transparent font-sans font-semibold text-gray no-underline -outline-offset-1;
|
|
3
|
+
|
|
4
|
+
&:focus-visible {
|
|
5
|
+
@apply outline outline-1 outline-inherit;
|
|
6
|
+
outline-color: currentColor;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&:disabled {
|
|
10
|
+
@apply cursor-default text-gray-300-600;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__prepend,
|
|
14
|
+
&__append {
|
|
15
|
+
@apply flex items-center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__prepend {
|
|
19
|
+
@apply -ml-2;
|
|
20
|
+
}
|
|
21
|
+
&__append {
|
|
22
|
+
@apply -mr-2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__loading-spinner {
|
|
26
|
+
@apply absolute left-1 flex items-center justify-center;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.c-btn {
|
|
31
|
+
&,
|
|
32
|
+
.c-btn__loading-spinner {
|
|
33
|
+
@apply bg-purple-50-900;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:not(:disabled):hover {
|
|
37
|
+
@apply outline outline-1 outline-purple-200-700;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:not(:disabled):active {
|
|
41
|
+
@apply bg-purple-100-800;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.c-btn-loading {
|
|
46
|
+
@apply relative;
|
|
47
|
+
|
|
48
|
+
.c-btn__prepend,
|
|
49
|
+
.c-btn__append {
|
|
50
|
+
@apply opacity-0 transition-opacity;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.c-btn-elevate {
|
|
55
|
+
@apply shadow;
|
|
56
|
+
|
|
57
|
+
&,
|
|
58
|
+
.c-btn__loading-spinner {
|
|
59
|
+
@apply bg-elevate;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:not(:disabled):hover {
|
|
63
|
+
@apply outline-gray-100-800;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:not(:disabled):active {
|
|
67
|
+
@apply bg-purple-50-900;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.c-btn-action {
|
|
72
|
+
&,
|
|
73
|
+
.c-btn__loading-spinner {
|
|
74
|
+
@apply bg-cyan-100-800;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:not(:disabled):hover {
|
|
78
|
+
@apply outline outline-1 outline-cyan-300-600;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:not(:disabled):active {
|
|
82
|
+
@apply bg-cyan-200-700;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.c-btn-danger {
|
|
87
|
+
@apply text-pink-600-300;
|
|
88
|
+
|
|
89
|
+
&:not(:disabled):hover {
|
|
90
|
+
@apply outline-pink-300-600;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.c-btn-xs {
|
|
95
|
+
@apply h-6 py-2 px-4;
|
|
96
|
+
|
|
97
|
+
.c-btn__loading-spinner {
|
|
98
|
+
@apply left-[3px];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.c-btn-sm {
|
|
103
|
+
@apply h-9 px-6 text-sm;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.c-btn-md {
|
|
107
|
+
@apply h-11 px-8 text-base;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.c-btn-lg {
|
|
111
|
+
@apply h-14 px-10 text-lg;
|
|
112
|
+
|
|
113
|
+
.c-btn__loading-spinner {
|
|
114
|
+
@apply left-2;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, forwardRef } from 'react';
|
|
2
|
+
import { cva, VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import './button.css';
|
|
5
|
+
import { Spinner } from '../spinner';
|
|
6
|
+
|
|
7
|
+
export const buttonTokens = {
|
|
8
|
+
variant: {
|
|
9
|
+
default: 'c-btn',
|
|
10
|
+
elevate: 'c-btn-elevate',
|
|
11
|
+
},
|
|
12
|
+
intent: {
|
|
13
|
+
default: 'c-btn',
|
|
14
|
+
action: 'c-btn-action',
|
|
15
|
+
danger: 'c-btn-danger',
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
xs: 'c-btn-xs',
|
|
19
|
+
sm: 'c-btn-sm',
|
|
20
|
+
md: 'c-btn-md',
|
|
21
|
+
lg: 'c-btn-lg',
|
|
22
|
+
},
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
type ButtonStylesProps = VariantProps<typeof buttonStyles>;
|
|
26
|
+
const buttonStyles = cva('c-btn', {
|
|
27
|
+
variants: {
|
|
28
|
+
intent: {
|
|
29
|
+
default: '',
|
|
30
|
+
action: '',
|
|
31
|
+
danger: '',
|
|
32
|
+
},
|
|
33
|
+
variant: {
|
|
34
|
+
default: '',
|
|
35
|
+
elevate: '',
|
|
36
|
+
},
|
|
37
|
+
status: {
|
|
38
|
+
loading: 'c-btn-loading',
|
|
39
|
+
},
|
|
40
|
+
size: {
|
|
41
|
+
xs: 'c-btn-xs',
|
|
42
|
+
sm: 'c-btn-sm',
|
|
43
|
+
md: 'c-btn-md',
|
|
44
|
+
lg: 'c-btn-lg',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
compoundVariants: [
|
|
48
|
+
{
|
|
49
|
+
intent: 'default',
|
|
50
|
+
variant: 'elevate',
|
|
51
|
+
class: 'c-btn-elevate',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
intent: 'action',
|
|
55
|
+
variant: 'default',
|
|
56
|
+
class: 'c-btn-action',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
intent: 'danger',
|
|
60
|
+
variant: 'default',
|
|
61
|
+
class: 'c-btn-danger',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
intent: 'danger',
|
|
65
|
+
variant: 'elevate',
|
|
66
|
+
class: 'c-btn-danger c-btn-elevate',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
intent: 'default',
|
|
71
|
+
variant: 'default',
|
|
72
|
+
size: 'sm',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export type ButtonProps = ComponentPropsWithRef<'button'> &
|
|
77
|
+
ButtonStylesProps & {
|
|
78
|
+
prepend?: React.ReactNode;
|
|
79
|
+
append?: React.ReactNode;
|
|
80
|
+
as?: React.ElementType;
|
|
81
|
+
// To support this button being used as a link
|
|
82
|
+
to?: string;
|
|
83
|
+
href?: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const spinnerSizeMap: Record<NonNullable<ButtonProps['size']>, number> = {
|
|
87
|
+
xs: 10,
|
|
88
|
+
sm: 12,
|
|
89
|
+
md: 14,
|
|
90
|
+
lg: 16,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
children,
|
|
97
|
+
className,
|
|
98
|
+
type = 'button',
|
|
99
|
+
as: El = 'button',
|
|
100
|
+
size,
|
|
101
|
+
variant,
|
|
102
|
+
intent,
|
|
103
|
+
prepend,
|
|
104
|
+
append,
|
|
105
|
+
status,
|
|
106
|
+
...delegated
|
|
107
|
+
},
|
|
108
|
+
ref,
|
|
109
|
+
) => {
|
|
110
|
+
let isAnchor = false;
|
|
111
|
+
|
|
112
|
+
if ('to' in delegated || 'href' in delegated) {
|
|
113
|
+
isAnchor = true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<El
|
|
118
|
+
ref={ref}
|
|
119
|
+
type={isAnchor ? undefined : type}
|
|
120
|
+
className={buttonStyles({ size, variant, intent, status, className })}
|
|
121
|
+
{...delegated}
|
|
122
|
+
>
|
|
123
|
+
{!prepend ? null : <span className="c-btn__prepend">{prepend}</span>}
|
|
124
|
+
{children}
|
|
125
|
+
{status !== 'loading' ? null : (
|
|
126
|
+
<span className="c-btn__loading-spinner">
|
|
127
|
+
<Spinner size={size ? spinnerSizeMap[size] : spinnerSizeMap.md} />
|
|
128
|
+
</span>
|
|
129
|
+
)}
|
|
130
|
+
{!append ? null : <span className="c-btn__append">{append}</span>}
|
|
131
|
+
</El>
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
Button.displayName = 'Button';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { Card } from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Card> = {
|
|
5
|
+
title: 'Components/Card',
|
|
6
|
+
component: Card,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof Card>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
children: 'Hello World 🌍',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const WhiteCard: Story = {
|
|
19
|
+
name: 'Elevated Card',
|
|
20
|
+
args: {
|
|
21
|
+
children: 'Hello World 🌍',
|
|
22
|
+
variant: 'elevate',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import { cva, VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import './card.css';
|
|
5
|
+
|
|
6
|
+
type CardStylesProps = VariantProps<typeof cardStyles>;
|
|
7
|
+
const cardStyles = cva('c-card', {
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: 'c-card',
|
|
11
|
+
elevate: 'c-card-elevate',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
variant: 'default',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
type CardProps = HTMLAttributes<HTMLDivElement> & CardStylesProps;
|
|
20
|
+
|
|
21
|
+
export function Card({ children, className, variant, ...delegated }: CardProps) {
|
|
22
|
+
return (
|
|
23
|
+
<section className={cardStyles({ variant, className })} {...delegated}>
|
|
24
|
+
{children}
|
|
25
|
+
</section>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.c-checkbox {
|
|
2
|
+
@apply flex h-3.5 w-3.5 cursor-pointer items-center justify-center rounded-sm border border-solid border-gray-100-800 bg-elevate;
|
|
3
|
+
|
|
4
|
+
&[aria-checked='true'] {
|
|
5
|
+
@apply border-cyan-700-200 bg-cyan-200-700;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&:focus {
|
|
9
|
+
@apply outline-none ring-1 ring-cyan-700-200 ring-offset-1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:disabled {
|
|
13
|
+
@apply cursor-default opacity-40;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&:readonly {
|
|
17
|
+
@apply cursor-default;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__svg {
|
|
21
|
+
@apply h-2 w-2;
|
|
22
|
+
|
|
23
|
+
&-p1 {
|
|
24
|
+
@apply fill-cyan-700-200;
|
|
25
|
+
}
|
|
26
|
+
&-p2 {
|
|
27
|
+
@apply stroke-cyan-700-200;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Label } from '../label';
|
|
5
|
+
import { Checkbox } from './checkbox';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Checkbox> = {
|
|
8
|
+
title: 'Components/Checkbox',
|
|
9
|
+
component: Checkbox,
|
|
10
|
+
argTypes: {},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
16
|
+
|
|
17
|
+
export const Example: Story = {
|
|
18
|
+
render: () => {
|
|
19
|
+
return <Checkbox defaultChecked={true} />;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Uncontrolled: Story = {
|
|
24
|
+
render: () => {
|
|
25
|
+
return <Checkbox defaultChecked={true} />;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Controlled: Story = {
|
|
30
|
+
render: () => {
|
|
31
|
+
const [checked, setChecked] = useState(false);
|
|
32
|
+
return <Checkbox checked={checked} onCheckedChange={c => setChecked(Boolean(c))} />;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const WithLabel: Story = {
|
|
37
|
+
render: () => {
|
|
38
|
+
return (
|
|
39
|
+
<div className="flex items-center space-x-2">
|
|
40
|
+
<Checkbox id="with-label-c1" defaultChecked={true} />
|
|
41
|
+
<Label htmlFor="with-label-c1">Accept terms and conditions.</Label>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Disabled: Story = {
|
|
48
|
+
render: () => {
|
|
49
|
+
return (
|
|
50
|
+
<div className="space-y-4">
|
|
51
|
+
<div className="flex items-center space-x-2">
|
|
52
|
+
<Checkbox id="disabled-c1" defaultChecked={true} disabled />
|
|
53
|
+
<Label htmlFor="disabled-c1">Accept terms and conditions.</Label>
|
|
54
|
+
</div>
|
|
55
|
+
<div className="flex items-center space-x-2">
|
|
56
|
+
<Checkbox id="disabled-c2" defaultChecked={false} disabled />
|
|
57
|
+
<Label htmlFor="disabled-c2">Accept terms and conditions.</Label>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
|
|
3
|
+
import { Checkbox } from '.';
|
|
4
|
+
|
|
5
|
+
describe('testing the checkbox', () => {
|
|
6
|
+
it('should trigger the onCheckedChange', () => {
|
|
7
|
+
const onChange = vi.fn();
|
|
8
|
+
|
|
9
|
+
render(<Checkbox onCheckedChange={onChange} defaultChecked={true} data-testid="chk" />);
|
|
10
|
+
|
|
11
|
+
fireEvent.click(screen.getByTestId('chk'));
|
|
12
|
+
|
|
13
|
+
expect(onChange).toBeCalledWith(false);
|
|
14
|
+
expect(onChange).toBeCalledTimes(1);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
2
|
+
import { ComponentProps, forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import './checkbox.css';
|
|
5
|
+
|
|
6
|
+
export type CheckboxRef = HTMLButtonElement;
|
|
7
|
+
export type CheckboxProps = ComponentProps<typeof CheckboxPrimitive.Root>;
|
|
8
|
+
|
|
9
|
+
export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<CheckboxPrimitive.Root {...props} ref={ref} className="c-checkbox">
|
|
12
|
+
<CheckboxPrimitive.Indicator>
|
|
13
|
+
<svg viewBox="0 0 9 9" fill="none" className="c-checkbox__svg">
|
|
14
|
+
<path
|
|
15
|
+
className="c-checkbox__svg-p1"
|
|
16
|
+
d="M1.12 5.51a.559.559 0 01.832-.101l2.201 1.953-.427.624a.326.326 0 01-.486.06L1.21 6.245a.559.559 0 01-.09-.734z"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
className="c-checkbox__svg-p2"
|
|
20
|
+
d="M7.883 1.087c.043.03.053.09.023.132L3.669 7.132l-.154-.105L7.754 1.11a.093.093 0 01.129-.023z"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
</CheckboxPrimitive.Indicator>
|
|
24
|
+
</CheckboxPrimitive.Root>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
Checkbox.displayName = 'Checkbox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './checkbox';
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
|
+
import { useDarkMode } from 'storybook-dark-mode';
|
|
4
|
+
|
|
5
|
+
import rawColors from './colors.json';
|
|
6
|
+
import colorPairing from './color-pairing.json';
|
|
7
|
+
import colorDefaults from './color-defaults.json';
|
|
8
|
+
import type { Color, ColorName, Colors } from './types';
|
|
9
|
+
|
|
10
|
+
const meta: Meta = {
|
|
11
|
+
title: 'Colors',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const colors: Colors = rawColors;
|
|
15
|
+
|
|
16
|
+
// The application for colors coming from Figma
|
|
17
|
+
const applications: {
|
|
18
|
+
colorName: ColorName;
|
|
19
|
+
shade: number; // Defaults to light mode
|
|
20
|
+
application: string;
|
|
21
|
+
}[] = [
|
|
22
|
+
{
|
|
23
|
+
colorName: 'pink',
|
|
24
|
+
shade: 300,
|
|
25
|
+
application: 'pricelist-bg',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
colorName: 'pink',
|
|
29
|
+
shade: 600,
|
|
30
|
+
application: 'error',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
colorName: 'gray',
|
|
34
|
+
shade: 50,
|
|
35
|
+
application: 'bg-gray',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
colorName: 'gray',
|
|
39
|
+
shade: 100,
|
|
40
|
+
application: 'gutter',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
colorName: 'gray',
|
|
44
|
+
shade: 500,
|
|
45
|
+
application: 'label',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
colorName: 'gray',
|
|
49
|
+
shade: 700,
|
|
50
|
+
application: 'text, btn-text',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
colorName: 'purple',
|
|
54
|
+
shade: 50,
|
|
55
|
+
application: 'btn-bg',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
colorName: 'purple',
|
|
59
|
+
shade: 700,
|
|
60
|
+
application: 'pricelist-text',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export default meta;
|
|
65
|
+
|
|
66
|
+
function ColorItem({ colorName, color }: { colorName: ColorName; color: Color }) {
|
|
67
|
+
const shades = Object.keys(color);
|
|
68
|
+
|
|
69
|
+
const isDark = useDarkMode();
|
|
70
|
+
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
const applicationsForMode = !isDark ? applications : applications.map(a => ({ ...a, shade: colorPairing[a.shade] }));
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div>
|
|
76
|
+
<h2 className="text-gray">{colorName}</h2>
|
|
77
|
+
<div className="grid grid-cols-10">
|
|
78
|
+
{shades.map(shade => {
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
const def = color[shade] as string;
|
|
81
|
+
|
|
82
|
+
const applicatedAt = applicationsForMode.filter(a => a.colorName === colorName && a.shade == shade);
|
|
83
|
+
const isDefault = colorDefaults[colorName] == shade;
|
|
84
|
+
|
|
85
|
+
const textColor = parseInt(shade) > 400 ? '#fff' : `rgb(var(--c-color-${colorName}-900))`;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<div
|
|
90
|
+
style={{ background: def, color: textColor }}
|
|
91
|
+
className={cx('relative flex h-24 flex-1 items-center justify-center')}
|
|
92
|
+
>
|
|
93
|
+
{!isDefault ? null : (
|
|
94
|
+
<div
|
|
95
|
+
className="h-[8px] w-[8px] rounded"
|
|
96
|
+
style={{
|
|
97
|
+
backgroundColor: 'currentColor',
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
<div className="absolute top-2 left-2 right-2 text-center text-sm">{shade}</div>
|
|
102
|
+
</div>
|
|
103
|
+
<div className={cx('p-4 text-center text-sm text-gray')}>
|
|
104
|
+
{applicatedAt.map(a => (
|
|
105
|
+
<div key={a.application}>{a.application}</div>
|
|
106
|
+
))}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const colorNames = Object.keys(colors) as ColorName[];
|
|
117
|
+
|
|
118
|
+
export const Default: StoryObj = {
|
|
119
|
+
args: {},
|
|
120
|
+
render: () => (
|
|
121
|
+
<div>
|
|
122
|
+
{colorNames.map(colorName => (
|
|
123
|
+
<ColorItem key={colorName} colorName={colorName} color={colors[colorName]} />
|
|
124
|
+
))}
|
|
125
|
+
</div>
|
|
126
|
+
),
|
|
127
|
+
};
|