@openedx/paragon 22.4.0 → 23.0.0-alpha.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/README.md +36 -5
- package/bin/paragon-scripts.js +128 -9
- package/dist/ActionRow/_index.scss +2 -4
- package/dist/Alert/index.scss +41 -32
- package/dist/Annotation/_mixins.scss +104 -0
- package/dist/Annotation/index.scss +130 -103
- package/dist/Avatar/index.scss +18 -20
- package/dist/AvatarButton/index.scss +3 -5
- package/dist/Badge/index.scss +112 -2
- package/dist/Breadcrumb/index.scss +14 -16
- package/dist/Bubble/index.scss +25 -12
- package/dist/Button/_mixins.scss +14 -0
- package/dist/Button/button-group.scss +126 -0
- package/dist/Button/index.js +0 -2
- package/dist/Button/index.js.map +1 -1
- package/dist/Button/index.scss +855 -370
- package/dist/Card/card-bootstrap.scss +168 -0
- package/dist/Card/index.scss +78 -79
- package/dist/Carousel/index.scss +168 -2
- package/dist/Chip/index.scss +46 -37
- package/dist/Chip/mixins.scss +8 -3
- package/dist/ChipCarousel/index.scss +4 -4
- package/dist/CloseButton/index.scss +31 -2
- package/dist/Code/index.scss +47 -2
- package/dist/Collapsible/index.scss +15 -15
- package/dist/ColorPicker/index.scss +9 -11
- package/dist/DataTable/CollapsibleButtonGroup.js +2 -2
- package/dist/DataTable/CollapsibleButtonGroup.js.map +1 -1
- package/dist/DataTable/index.scss +48 -50
- package/dist/Dropdown/dropdown-bootstrap.scss +181 -0
- package/dist/Dropdown/index.js +0 -2
- package/dist/Dropdown/index.js.map +1 -1
- package/dist/Dropdown/index.scss +11 -12
- package/dist/Dropzone/index.scss +12 -14
- package/dist/Form/_FormText.scss +8 -8
- package/dist/Form/_bootstrap-custom-forms.scss +551 -0
- package/dist/Form/_bootstrap-forms.scss +381 -0
- package/dist/Form/_index.scss +168 -146
- package/dist/Form/_input-group.scss +188 -0
- package/dist/Form/_mixins.scss +216 -3
- package/dist/Hyperlink/index.scss +1 -1
- package/dist/Icon/index.scss +10 -12
- package/dist/IconButton/_mixins.scss +4 -0
- package/dist/IconButton/index.js +5 -11
- package/dist/IconButton/index.js.map +1 -1
- package/dist/IconButton/index.scss +387 -74
- package/dist/IconButtonToggle/index.scss +1 -1
- package/dist/Image/index.scss +53 -2
- package/dist/Menu/index.scss +25 -27
- package/dist/Modal/_ModalDialog.scss +52 -50
- package/dist/Modal/index.scss +6 -73
- package/dist/Nav/_mixins.scss +4 -4
- package/dist/Nav/index.scss +70 -66
- package/dist/Navbar/index.scss +276 -2
- package/dist/OverflowScroll/data/useOverflowScrollElementAttributes.js +3 -3
- package/dist/Overlay/index.js +2 -3
- package/dist/Overlay/index.js.map +1 -1
- package/dist/PageBanner/index.scss +17 -21
- package/dist/Pagination/index.scss +32 -34
- package/dist/Pagination/pagination-bootstrap.scss +83 -0
- package/dist/Popover/index.scss +9 -10
- package/dist/Popover/popover-bootstrap.scss +198 -0
- package/dist/ProductTour/Checkpoint.scss +71 -43
- package/dist/ProgressBar/_mixins.scss +22 -0
- package/dist/ProgressBar/bootstrap-progress.scss +49 -0
- package/dist/ProgressBar/index.scss +28 -36
- package/dist/Scrollable/index.scss +2 -2
- package/dist/SearchField/SearchFieldInput.js +2 -2
- package/dist/SearchField/SearchFieldInput.js.map +1 -1
- package/dist/SearchField/index.scss +15 -17
- package/dist/SelectableBox/index.scss +11 -13
- package/dist/Sheet/index.scss +10 -10
- package/dist/Spinner/index.scss +57 -2
- package/dist/Stack/index.scss +1 -3
- package/dist/Stepper/index.scss +19 -20
- package/dist/Sticky/index.scss +4 -6
- package/dist/Tabs/index.js +0 -2
- package/dist/Tabs/index.js.map +1 -1
- package/dist/Tabs/index.scss +26 -25
- package/dist/Toast/ToastContainer.scss +9 -11
- package/dist/Toast/bootstrap-toast.scss +46 -0
- package/dist/Toast/index.scss +9 -10
- package/dist/Tooltip/index.scss +136 -10
- package/dist/ValidationMessage/index.scss +1 -1
- package/dist/core.css +16788 -0
- package/dist/core.css.map +1 -0
- package/dist/core.min.css +2 -0
- package/dist/index.js +0 -14
- package/dist/index.scss +0 -4
- package/dist/light.css +4098 -0
- package/dist/light.css.map +1 -0
- package/dist/light.min.css +2 -0
- package/dist/theme-urls.json +21 -0
- package/dist/utils/breakpoints.js +1 -1
- package/lib/build-scss.js +188 -0
- package/lib/build-tokens.js +119 -0
- package/lib/help.js +36 -23
- package/lib/replace-variables.js +38 -0
- package/lib/utils.js +30 -0
- package/package.json +25 -10
- package/src/ActionRow/_index.scss +2 -4
- package/src/Alert/index.scss +41 -32
- package/src/Annotation/_mixins.scss +104 -0
- package/src/Annotation/index.scss +130 -103
- package/src/Avatar/index.scss +18 -20
- package/src/AvatarButton/index.scss +3 -5
- package/src/Badge/index.scss +112 -2
- package/src/Breadcrumb/index.scss +14 -16
- package/src/Bubble/index.scss +25 -12
- package/src/Button/README.md +0 -84
- package/src/Button/_mixins.scss +14 -0
- package/src/Button/button-group.scss +126 -0
- package/src/Button/index.jsx +0 -3
- package/src/Button/index.scss +855 -370
- package/src/Card/card-bootstrap.scss +168 -0
- package/src/Card/index.scss +78 -79
- package/src/Carousel/index.scss +168 -2
- package/src/Chip/index.scss +46 -37
- package/src/Chip/mixins.scss +8 -3
- package/src/ChipCarousel/index.scss +4 -4
- package/src/CloseButton/index.scss +31 -2
- package/src/Code/index.scss +47 -2
- package/src/Collapsible/index.scss +15 -15
- package/src/ColorPicker/index.scss +9 -11
- package/src/DataTable/CollapsibleButtonGroup.jsx +2 -2
- package/src/DataTable/index.scss +48 -50
- package/src/Dropdown/README.md +0 -93
- package/src/Dropdown/dropdown-bootstrap.scss +181 -0
- package/src/Dropdown/index.jsx +0 -2
- package/src/Dropdown/index.scss +11 -12
- package/src/Dropzone/index.scss +12 -14
- package/src/Form/_FormText.scss +8 -8
- package/src/Form/_bootstrap-custom-forms.scss +551 -0
- package/src/Form/_bootstrap-forms.scss +381 -0
- package/src/Form/_index.scss +168 -146
- package/src/Form/_input-group.scss +188 -0
- package/src/Form/_mixins.scss +216 -3
- package/src/Hyperlink/index.scss +1 -1
- package/src/Icon/index.scss +10 -12
- package/src/IconButton/README.md +1 -15
- package/src/IconButton/__snapshots__/IconButton.test.jsx.snap +5 -28
- package/src/IconButton/_mixins.scss +4 -0
- package/src/IconButton/index.jsx +6 -13
- package/src/IconButton/index.scss +387 -74
- package/src/IconButtonToggle/index.scss +1 -1
- package/src/Image/index.scss +53 -2
- package/src/Menu/index.scss +25 -27
- package/src/Modal/_ModalDialog.scss +52 -50
- package/src/Modal/index.scss +6 -73
- package/src/Nav/_mixins.scss +4 -4
- package/src/Nav/index.scss +70 -66
- package/src/Navbar/index.scss +276 -2
- package/src/OverflowScroll/data/useOverflowScrollElementAttributes.js +3 -3
- package/src/Overlay/index.jsx +2 -3
- package/src/PageBanner/index.scss +17 -21
- package/src/Pagination/index.scss +32 -34
- package/src/Pagination/pagination-bootstrap.scss +83 -0
- package/src/Popover/index.scss +9 -10
- package/src/Popover/popover-bootstrap.scss +198 -0
- package/src/ProductTour/Checkpoint.scss +71 -43
- package/src/ProgressBar/_mixins.scss +22 -0
- package/src/ProgressBar/bootstrap-progress.scss +49 -0
- package/src/ProgressBar/index.scss +28 -36
- package/src/Scrollable/index.scss +2 -2
- package/src/SearchField/SearchFieldInput.jsx +2 -2
- package/src/SearchField/__snapshots__/SearchField.test.jsx.snap +12 -8
- package/src/SearchField/index.scss +15 -17
- package/src/SelectableBox/index.scss +11 -13
- package/src/Sheet/index.scss +10 -10
- package/src/Spinner/index.scss +57 -2
- package/src/Stack/index.scss +1 -3
- package/src/Stepper/index.scss +19 -20
- package/src/Sticky/index.scss +4 -6
- package/src/Tabs/README.md +1 -23
- package/src/Tabs/index.jsx +0 -3
- package/src/Tabs/index.scss +26 -25
- package/src/Toast/ToastContainer.scss +9 -11
- package/src/Toast/bootstrap-toast.scss +46 -0
- package/src/Toast/index.scss +9 -10
- package/src/Tooltip/index.scss +136 -10
- package/src/TransitionReplace/README.md +4 -4
- package/src/ValidationMessage/index.scss +1 -1
- package/src/index.js +0 -14
- package/src/index.scss +0 -4
- package/src/setupTest.js +0 -6
- package/src/utils/breakpoints.js +1 -1
- package/styles/css/core/custom-media-breakpoints.css +17 -0
- package/styles/css/core/index.css +2 -0
- package/styles/css/core/variables.css +614 -0
- package/styles/css/themes/light/index.css +2 -0
- package/styles/css/themes/light/utility-classes.css +2454 -0
- package/styles/css/themes/light/variables.css +1644 -0
- package/{scss → styles/scss}/core/_functions.scss +1 -1
- package/styles/scss/core/_grid.scss +21 -0
- package/{scss → styles/scss}/core/_utilities.scss +17 -11
- package/styles/scss/core/_variables.scss +869 -0
- package/styles/scss/core/bootstrap-override/_functions.scss +104 -0
- package/styles/scss/core/bootstrap-override/_mixins.scss +4 -0
- package/styles/scss/core/bootstrap-override/_utilities.scss +4 -0
- package/styles/scss/core/bootstrap-override/bootstrap.scss +2 -0
- package/styles/scss/core/bootstrap-override/mixins/_grid-framework.scss +80 -0
- package/styles/scss/core/bootstrap-override/mixins/_grid.scss +69 -0
- package/styles/scss/core/bootstrap-override/mixins/_list-group.scss +22 -0
- package/styles/scss/core/bootstrap-override/utilities/_background.scss +7 -0
- package/styles/scss/core/bootstrap-override/utilities/_borders.scss +67 -0
- package/styles/scss/core/bootstrap-override/utilities/_spacing.scss +70 -0
- package/styles/scss/core/bootstrap-override/utilities/_text.scss +68 -0
- package/styles/scss/core/core.scss +21 -0
- package/{scss → styles/scss}/core/utilities-only.scss +1 -0
- package/tokens/README.md +158 -0
- package/tokens/css-utilities.js +56 -0
- package/tokens/map-scss-to-css.js +24 -0
- package/tokens/replace-variables.js +32 -0
- package/tokens/sass-helpers.js +98 -0
- package/tokens/src/core/alias/size.json +15 -0
- package/tokens/src/core/components/ActionRow.json +10 -0
- package/tokens/src/core/components/Alert.json +30 -0
- package/tokens/src/core/components/Annotation.json +25 -0
- package/tokens/src/core/components/Avatar.json +17 -0
- package/tokens/src/core/components/AvatarButton.json +11 -0
- package/tokens/src/core/components/Badge.json +33 -0
- package/tokens/src/core/components/Breadcrumb.json +37 -0
- package/tokens/src/core/components/Bubble.json +10 -0
- package/tokens/src/core/components/Button/core.json +105 -0
- package/tokens/src/core/components/Card.json +91 -0
- package/tokens/src/core/components/Carousel.json +37 -0
- package/tokens/src/core/components/Chip.json +43 -0
- package/tokens/src/core/components/ChipCarousel.json +15 -0
- package/tokens/src/core/components/CloseButton.json +14 -0
- package/tokens/src/core/components/Code.json +34 -0
- package/tokens/src/core/components/Collapsible.json +29 -0
- package/tokens/src/core/components/ColorPicker.json +8 -0
- package/tokens/src/core/components/Container.json +13 -0
- package/tokens/src/core/components/DataTable.json +27 -0
- package/tokens/src/core/components/Dropdown.json +67 -0
- package/tokens/src/core/components/Dropzone.json +21 -0
- package/tokens/src/core/components/Form/other.json +14 -0
- package/tokens/src/core/components/Form/size.json +233 -0
- package/tokens/src/core/components/Form/spacing.json +155 -0
- package/tokens/src/core/components/Form/transition.json +16 -0
- package/tokens/src/core/components/Form/typography.json +122 -0
- package/tokens/src/core/components/Icon.json +11 -0
- package/tokens/src/core/components/IconButton.json +15 -0
- package/tokens/src/core/components/Image.json +28 -0
- package/tokens/src/core/components/Menu.json +48 -0
- package/tokens/src/core/components/Modal.json +47 -0
- package/tokens/src/core/components/Nav.json +55 -0
- package/tokens/src/core/components/Navbar.json +70 -0
- package/tokens/src/core/components/Pagination.json +70 -0
- package/tokens/src/core/components/Popover.json +48 -0
- package/tokens/src/core/components/ProductTour.json +37 -0
- package/tokens/src/core/components/ProgressBar.json +39 -0
- package/tokens/src/core/components/SearchField.json +23 -0
- package/tokens/src/core/components/SelectableBox.json +9 -0
- package/tokens/src/core/components/Sheet.json +10 -0
- package/tokens/src/core/components/Spinner.json +19 -0
- package/tokens/src/core/components/Stack.json +7 -0
- package/tokens/src/core/components/Stepper.json +42 -0
- package/tokens/src/core/components/Sticky.json +7 -0
- package/tokens/src/core/components/Tab.json +19 -0
- package/tokens/src/core/components/Tabs.json +19 -0
- package/tokens/src/core/components/Toast.json +30 -0
- package/tokens/src/core/components/Tooltip.json +33 -0
- package/tokens/src/core/components/general/caret.json +13 -0
- package/tokens/src/core/components/general/headings.json +16 -0
- package/tokens/src/core/components/general/hr.json +10 -0
- package/tokens/src/core/components/general/input.json +51 -0
- package/tokens/src/core/components/general/link.json +30 -0
- package/tokens/src/core/components/general/list.json +26 -0
- package/tokens/src/core/components/general/text.json +24 -0
- package/tokens/src/core/global/breakpoints.json +12 -0
- package/tokens/src/core/global/display.json +21 -0
- package/tokens/src/core/global/elevation.json +19 -0
- package/tokens/src/core/global/other.json +4 -0
- package/tokens/src/core/global/spacing.json +35 -0
- package/tokens/src/core/global/transition.json +14 -0
- package/tokens/src/core/global/typography.json +91 -0
- package/tokens/src/core/utilities/color.json +12 -0
- package/tokens/src/themes/light/alias/color.json +114 -0
- package/tokens/src/themes/light/components/Alert.json +47 -0
- package/tokens/src/themes/light/components/Annotation.json +29 -0
- package/tokens/src/themes/light/components/Avatar.json +7 -0
- package/tokens/src/themes/light/components/Badge.json +186 -0
- package/tokens/src/themes/light/components/Breadcrumb.json +14 -0
- package/tokens/src/themes/light/components/Bubble.json +18 -0
- package/tokens/src/themes/light/components/Button/brand.json +260 -0
- package/tokens/src/themes/light/components/Button/core.json +24 -0
- package/tokens/src/themes/light/components/Button/danger.json +247 -0
- package/tokens/src/themes/light/components/Button/dark.json +230 -0
- package/tokens/src/themes/light/components/Button/info.json +238 -0
- package/tokens/src/themes/light/components/Button/light.json +236 -0
- package/tokens/src/themes/light/components/Button/primary.json +250 -0
- package/tokens/src/themes/light/components/Button/secondary.json +278 -0
- package/tokens/src/themes/light/components/Button/success.json +253 -0
- package/tokens/src/themes/light/components/Button/tertiary.json +109 -0
- package/tokens/src/themes/light/components/Button/warning.json +276 -0
- package/tokens/src/themes/light/components/Card.json +40 -0
- package/tokens/src/themes/light/components/Carousel.json +45 -0
- package/tokens/src/themes/light/components/Chip.json +50 -0
- package/tokens/src/themes/light/components/CloseButton.json +10 -0
- package/tokens/src/themes/light/components/Code.json +23 -0
- package/tokens/src/themes/light/components/DataTable.json +26 -0
- package/tokens/src/themes/light/components/Dropdown.json +41 -0
- package/tokens/src/themes/light/components/Dropzone.json +23 -0
- package/tokens/src/themes/light/components/Form/color.json +270 -0
- package/tokens/src/themes/light/components/Form/elevation.json +76 -0
- package/tokens/src/themes/light/components/Form/other.json +131 -0
- package/tokens/src/themes/light/components/IconButton.json +451 -0
- package/tokens/src/themes/light/components/Image.json +18 -0
- package/tokens/src/themes/light/components/Menu.json +30 -0
- package/tokens/src/themes/light/components/Modal.json +37 -0
- package/tokens/src/themes/light/components/Nav.json +166 -0
- package/tokens/src/themes/light/components/Navbar.json +136 -0
- package/tokens/src/themes/light/components/OverflowScroll.json +9 -0
- package/tokens/src/themes/light/components/PageBanner.json +24 -0
- package/tokens/src/themes/light/components/Pagination.json +45 -0
- package/tokens/src/themes/light/components/Popover.json +55 -0
- package/tokens/src/themes/light/components/ProductTour.json +35 -0
- package/tokens/src/themes/light/components/ProgressBar.json +20 -0
- package/tokens/src/themes/light/components/Scrollable.json +14 -0
- package/tokens/src/themes/light/components/SearchField.json +25 -0
- package/tokens/src/themes/light/components/Sheet.json +22 -0
- package/tokens/src/themes/light/components/Stepper.json +34 -0
- package/tokens/src/themes/light/components/Sticky.json +18 -0
- package/tokens/src/themes/light/components/Tab.json +62 -0
- package/tokens/src/themes/light/components/Toast.json +33 -0
- package/tokens/src/themes/light/components/Tooltip.json +30 -0
- package/tokens/src/themes/light/components/general/body.json +8 -0
- package/tokens/src/themes/light/components/general/headings.json +7 -0
- package/tokens/src/themes/light/components/general/hr.json +15 -0
- package/tokens/src/themes/light/components/general/input.json +18 -0
- package/tokens/src/themes/light/components/general/link.json +109 -0
- package/tokens/src/themes/light/components/general/list.json +38 -0
- package/tokens/src/themes/light/components/general/text.json +6 -0
- package/tokens/src/themes/light/global/color.json +1661 -0
- package/tokens/src/themes/light/global/elevation.json +201 -0
- package/tokens/src/themes/light/global/other.json +4 -0
- package/tokens/style-dictionary.js +223 -0
- package/tokens/utils.js +210 -0
- package/dist/ActionRow/_variables.scss +0 -2
- package/dist/Alert/_variables.scss +0 -24
- package/dist/Annotation/_variables.scss +0 -18
- package/dist/Avatar/_variables.scss +0 -10
- package/dist/AvatarButton/_variables.scss +0 -3
- package/dist/Badge/_variables.scss +0 -16
- package/dist/Breadcrumb/_variables.scss +0 -27
- package/dist/Bubble/_variables.scss +0 -8
- package/dist/Button/_variables.scss +0 -52
- package/dist/Button/deprecated/index.js +0 -149
- package/dist/Button/deprecated/index.js.map +0 -1
- package/dist/Card/_variables.scss +0 -55
- package/dist/Carousel/_variables.scss +0 -27
- package/dist/CheckBox/index.js +0 -102
- package/dist/CheckBox/index.js.map +0 -1
- package/dist/CheckBoxGroup/index.js +0 -15
- package/dist/CheckBoxGroup/index.js.map +0 -1
- package/dist/Chip/_variables.scss +0 -28
- package/dist/ChipCarousel/_variables.scss +0 -3
- package/dist/CloseButton/_variables.scss +0 -6
- package/dist/Code/_variables.scss +0 -17
- package/dist/Collapsible/_variables.scss +0 -12
- package/dist/ColorPicker/_variables.scss +0 -2
- package/dist/Container/_variables.scss +0 -5
- package/dist/DataTable/_variables.scss +0 -11
- package/dist/Dropdown/_variables.scss +0 -33
- package/dist/Dropdown/deprecated/DropdownButton.js +0 -44
- package/dist/Dropdown/deprecated/DropdownButton.js.map +0 -1
- package/dist/Dropdown/deprecated/DropdownItem.js +0 -33
- package/dist/Dropdown/deprecated/DropdownItem.js.map +0 -1
- package/dist/Dropdown/deprecated/DropdownMenu.js +0 -46
- package/dist/Dropdown/deprecated/DropdownMenu.js.map +0 -1
- package/dist/Dropdown/deprecated/index.js +0 -241
- package/dist/Dropdown/deprecated/index.js.map +0 -1
- package/dist/Dropzone/_variables.scss +0 -9
- package/dist/Fieldset/index.js +0 -117
- package/dist/Fieldset/index.js.map +0 -1
- package/dist/Fieldset/index.scss +0 -12
- package/dist/Form/_variables.scss +0 -267
- package/dist/Icon/_variables.scss +0 -7
- package/dist/Image/_variables.scss +0 -13
- package/dist/Input/index.js +0 -166
- package/dist/Input/index.js.map +0 -1
- package/dist/InputSelect/index.js +0 -105
- package/dist/InputSelect/index.js.map +0 -1
- package/dist/InputText/index.js +0 -45
- package/dist/InputText/index.js.map +0 -1
- package/dist/ListBox/index.js +0 -148
- package/dist/ListBox/index.js.map +0 -1
- package/dist/ListBoxOption/index.js +0 -94
- package/dist/ListBoxOption/index.js.map +0 -1
- package/dist/Menu/_variables.scss +0 -24
- package/dist/Modal/_variables.scss +0 -50
- package/dist/Modal/index.js +0 -292
- package/dist/Modal/index.js.map +0 -1
- package/dist/Nav/_variables.scss +0 -58
- package/dist/Navbar/_variables.scss +0 -40
- package/dist/OverflowScroll/_variables.scss +0 -5
- package/dist/OverflowScroll/index.scss +0 -1
- package/dist/Pagination/_variables.scss +0 -19
- package/dist/Popover/_variables.scss +0 -36
- package/dist/ProductTour/_variables.scss +0 -15
- package/dist/ProgressBar/_variables.scss +0 -23
- package/dist/RadioButtonGroup/index.js +0 -188
- package/dist/RadioButtonGroup/index.js.map +0 -1
- package/dist/SearchField/_variables.scss +0 -14
- package/dist/SelectableBox/_variables.scss +0 -5
- package/dist/Spinner/_variables.scss +0 -9
- package/dist/Stack/_variables.scss +0 -1
- package/dist/StatusAlert/index.js +0 -168
- package/dist/StatusAlert/index.js.map +0 -1
- package/dist/Stepper/_variables.scss +0 -18
- package/dist/Sticky/_variables.scss +0 -3
- package/dist/Table/_variables.scss +0 -34
- package/dist/Table/index.js +0 -267
- package/dist/Table/index.js.map +0 -1
- package/dist/Table/index.scss +0 -12
- package/dist/Tabs/_variables.scss +0 -24
- package/dist/Tabs/deprecated/Tabs.scss +0 -3
- package/dist/Tabs/deprecated/index.js +0 -123
- package/dist/Tabs/deprecated/index.js.map +0 -1
- package/dist/TextArea/index.js +0 -44
- package/dist/TextArea/index.js.map +0 -1
- package/dist/Toast/_variables.scss +0 -19
- package/dist/Tooltip/_variables.scss +0 -21
- package/dist/ValidationFormGroup/index.js +0 -106
- package/dist/ValidationFormGroup/index.js.map +0 -1
- package/dist/paragon.css +0 -45
- package/scss/core/_grid.scss +0 -21
- package/scss/core/_variables.scss +0 -875
- package/scss/core/core.scss +0 -21
- package/src/ActionRow/_variables.scss +0 -2
- package/src/Alert/_variables.scss +0 -24
- package/src/Annotation/_variables.scss +0 -18
- package/src/Avatar/_variables.scss +0 -10
- package/src/AvatarButton/_variables.scss +0 -3
- package/src/Badge/_variables.scss +0 -16
- package/src/Breadcrumb/_variables.scss +0 -27
- package/src/Bubble/_variables.scss +0 -8
- package/src/Button/_variables.scss +0 -52
- package/src/Button/deprecated/Button.test.jsx +0 -34
- package/src/Button/deprecated/index.jsx +0 -145
- package/src/Card/_variables.scss +0 -55
- package/src/Carousel/_variables.scss +0 -27
- package/src/CheckBox/CheckBox.test.jsx +0 -65
- package/src/CheckBox/README.md +0 -93
- package/src/CheckBox/index.jsx +0 -80
- package/src/CheckBoxGroup/CheckBoxGroup.test.jsx +0 -33
- package/src/CheckBoxGroup/README.md +0 -35
- package/src/CheckBoxGroup/index.jsx +0 -19
- package/src/Chip/_variables.scss +0 -28
- package/src/ChipCarousel/_variables.scss +0 -3
- package/src/CloseButton/_variables.scss +0 -6
- package/src/Code/_variables.scss +0 -17
- package/src/Collapsible/_variables.scss +0 -12
- package/src/ColorPicker/_variables.scss +0 -2
- package/src/Container/_variables.scss +0 -5
- package/src/DataTable/_variables.scss +0 -11
- package/src/Dropdown/_variables.scss +0 -33
- package/src/Dropdown/deprecated/Dropdown.test.jsx +0 -238
- package/src/Dropdown/deprecated/DropdownButton.jsx +0 -52
- package/src/Dropdown/deprecated/DropdownItem.jsx +0 -34
- package/src/Dropdown/deprecated/DropdownMenu.jsx +0 -50
- package/src/Dropdown/deprecated/__snapshots__/Dropdown.test.jsx.snap +0 -229
- package/src/Dropdown/deprecated/index.jsx +0 -222
- package/src/Dropzone/_variables.scss +0 -9
- package/src/Fieldset/Fieldset.test.jsx +0 -101
- package/src/Fieldset/README.md +0 -146
- package/src/Fieldset/index.jsx +0 -107
- package/src/Fieldset/index.scss +0 -12
- package/src/Form/_variables.scss +0 -267
- package/src/Icon/_variables.scss +0 -7
- package/src/Image/_variables.scss +0 -13
- package/src/Input/README.md +0 -74
- package/src/Input/__snapshots__/input.test.jsx.snap +0 -53
- package/src/Input/index.jsx +0 -151
- package/src/Input/input.test.jsx +0 -85
- package/src/InputSelect/README.md +0 -136
- package/src/InputSelect/index.jsx +0 -92
- package/src/InputText/InputText.test.jsx +0 -74
- package/src/InputText/README.md +0 -293
- package/src/InputText/index.jsx +0 -49
- package/src/ListBox/ListBox.test.jsx +0 -161
- package/src/ListBox/README.md +0 -185
- package/src/ListBox/index.jsx +0 -115
- package/src/ListBoxOption/ListBoxOption.test.jsx +0 -154
- package/src/ListBoxOption/index.jsx +0 -78
- package/src/Menu/_variables.scss +0 -24
- package/src/Modal/README.md +0 -148
- package/src/Modal/_variables.scss +0 -50
- package/src/Modal/index.jsx +0 -319
- package/src/Modal/tests/Modal.test.jsx +0 -261
- package/src/Nav/_variables.scss +0 -58
- package/src/Navbar/_variables.scss +0 -40
- package/src/OverflowScroll/_variables.scss +0 -5
- package/src/OverflowScroll/index.scss +0 -1
- package/src/Pagination/_variables.scss +0 -19
- package/src/Popover/_variables.scss +0 -36
- package/src/ProductTour/_variables.scss +0 -15
- package/src/ProgressBar/_variables.scss +0 -23
- package/src/RadioButtonGroup/README.md +0 -50
- package/src/RadioButtonGroup/RadioButtonGroup.test.jsx +0 -127
- package/src/RadioButtonGroup/index.jsx +0 -185
- package/src/SearchField/_variables.scss +0 -14
- package/src/SelectableBox/_variables.scss +0 -5
- package/src/Spinner/_variables.scss +0 -9
- package/src/Stack/_variables.scss +0 -1
- package/src/StatusAlert/README.md +0 -149
- package/src/StatusAlert/StatusAlert.test.jsx +0 -150
- package/src/StatusAlert/index.jsx +0 -144
- package/src/Stepper/_variables.scss +0 -18
- package/src/Sticky/_variables.scss +0 -3
- package/src/Table/README.md +0 -506
- package/src/Table/Table.test.jsx +0 -367
- package/src/Table/_variables.scss +0 -34
- package/src/Table/index.jsx +0 -264
- package/src/Table/index.scss +0 -12
- package/src/Tabs/_variables.scss +0 -24
- package/src/Tabs/deprecated/Tabs.scss +0 -3
- package/src/Tabs/deprecated/Tabs.test.jsx +0 -50
- package/src/Tabs/deprecated/index.jsx +0 -117
- package/src/TextArea/README.md +0 -63
- package/src/TextArea/index.jsx +0 -48
- package/src/Toast/_variables.scss +0 -19
- package/src/Tooltip/_variables.scss +0 -21
- package/src/ValidationFormGroup/README.md +0 -116
- package/src/ValidationFormGroup/ValidationFormGroup.test.jsx +0 -146
- package/src/ValidationFormGroup/__snapshots__/ValidationFormGroup.test.jsx.snap +0 -161
- package/src/ValidationFormGroup/index.jsx +0 -114
- /package/{scss → styles/scss}/core/_exports.module.scss +0 -0
- /package/{scss → styles/scss}/core/_typography.scss +0 -0
package/tokens/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Design Tokens
|
|
2
|
+
|
|
3
|
+
This module is responsible for handling design tokens in Paragon, for rationale behind design tokens see [Scaling Paragon's styles architecture with design tokens](https://openedx.atlassian.net/wiki/spaces/BPL/pages/3630923811/Scaling+Paragon+s+styles+architecture+with+design+tokens)
|
|
4
|
+
and relevant ADR(TODO: add link when we merge an ADR).
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
We heavily rely on [style-dictionary](https://github.com/amzn/style-dictionary) package to build design tokens into various formats,
|
|
9
|
+
it is recommended to read their [documentation](https://amzn.github.io/style-dictionary/#/) as well to know more about the package since we mostly focus on Paragon specifics in this document.
|
|
10
|
+
|
|
11
|
+
All tokens are located in `src` directory and divided into three categories. We try to follow CTI token naming as described [here](https://amzn.github.io/style-dictionary/#/tokens?id=category-type-item), but our schema does have some differences, see tokens files for an example of that
|
|
12
|
+
|
|
13
|
+
## Token modifications
|
|
14
|
+
|
|
15
|
+
Style dictionary allows you to apply certain modifications to tokens during build time, e.g. if you want to make some color darker without
|
|
16
|
+
manually calculating its value or trying to modify it with SASS functions after the variable has been built (note
|
|
17
|
+
that most SASS functions will not work with CSS variables as SASS does not know values during compile time).
|
|
18
|
+
|
|
19
|
+
All modifications need to be specified with `modify` key when describing a token, e.g.
|
|
20
|
+
```
|
|
21
|
+
{
|
|
22
|
+
"value": "#D4F880",
|
|
23
|
+
"modify": [{
|
|
24
|
+
"type": "darken"
|
|
25
|
+
"amount": 0.1
|
|
26
|
+
}]
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
`modify` expects a list of modification to apply, each modification is specified with an object that carries necessary metadata, see examples below.
|
|
30
|
+
|
|
31
|
+
### Color transforms
|
|
32
|
+
|
|
33
|
+
Paragon uses [chroma-js](https://gka.github.io/chroma.js/) library to perform color modifications. Some of the most common examples are:
|
|
34
|
+
|
|
35
|
+
1. `darken` – change lightness of a color (same behaviour as in respective SASS function), e.g.
|
|
36
|
+
```
|
|
37
|
+
{
|
|
38
|
+
"value": "#D4F880",
|
|
39
|
+
"modify": [{
|
|
40
|
+
"type": "darken"
|
|
41
|
+
"amount": 0.1
|
|
42
|
+
}]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
outputs `#CFF37B` value
|
|
46
|
+
|
|
47
|
+
2. `mix` – mix two colors with specific ratio (same behaviour as in respective SASS function), e.g.
|
|
48
|
+
```
|
|
49
|
+
{
|
|
50
|
+
"value": "#0A3055",
|
|
51
|
+
"modify": [
|
|
52
|
+
{
|
|
53
|
+
"type": "mix",
|
|
54
|
+
"otherColor": "#FFF",
|
|
55
|
+
"amount": "0.6"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
outputs `#9DACBB` value
|
|
61
|
+
|
|
62
|
+
3. `color-yiq` – [Bootstrap's color contrast function](https://getbootstrap.com/docs/4.0/getting-started/theming/#color-contrast) that outputs black (defaults to `#454545`) or white (defaults to `#FFF`) color depending on the specified base color, e.g.
|
|
63
|
+
```
|
|
64
|
+
{
|
|
65
|
+
"value": "#0A3055",
|
|
66
|
+
"modify": [{ "type": "color-yiq" }]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
outputs `#454545`
|
|
70
|
+
|
|
71
|
+
Generally every function from `chroma-js` that has similar signature to `darken` function (i.e., first argument is color value and second is amount by which the color should be changed) can be applied to color tokens the same way as `darken` is applied, functions with other signatures are not currently supported except for the `mix`.
|
|
72
|
+
|
|
73
|
+
### Other transforms
|
|
74
|
+
|
|
75
|
+
Currently, only one other transform is supported – `str-replace`, that replaces some string with another one across the whole token value, common usage is for values that represent an SVG image
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
{
|
|
79
|
+
"value": "url("data:image/svg+xml,<svg><path d='somesvg' fill='{color.primary.base.value}'/></svg>\")",
|
|
80
|
+
"modify": [{
|
|
81
|
+
"type": "str-replace",
|
|
82
|
+
"toReplace": "#",
|
|
83
|
+
"replaceWith": "%23"
|
|
84
|
+
}]
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
Without `str-replace` the resulting value would be `url("data:image/svg+xml,<svg><path d='somesvg' fill='#0A3055'/></svg>\"`, note that fill color starts with `#` symbol which would cause image to render invalid color, by using `str-replace` fill would become `%230A3055` and the image would render correctly.
|
|
88
|
+
|
|
89
|
+
## Outputting references
|
|
90
|
+
|
|
91
|
+
By default, tokens keep references in the output, meaning having such tokens structure
|
|
92
|
+
```
|
|
93
|
+
{
|
|
94
|
+
"color": {
|
|
95
|
+
"green": { "value": "#178253" },
|
|
96
|
+
"success": { "value": "{color.green.value}" }
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
the outputted values will be
|
|
100
|
+
```
|
|
101
|
+
--pgn-color-green: #178253,
|
|
102
|
+
--pgn-color-success: var(--pgn-color-green)
|
|
103
|
+
```
|
|
104
|
+
which is usually fine, but you might want to disable this behaviour for some tokens.
|
|
105
|
+
|
|
106
|
+
Style dictionary uses a simple algorithm while outputting references, i.e. it checks whether outputted value contains any known tokens and replaces them with references to that token, e.g.
|
|
107
|
+
if you have token with value `url("data:image/svg+xml,<svg><path d='somesvg' fill='{color.green.value}'/></svg>\")` then style dictionary would transform it into
|
|
108
|
+
`url("data:image/svg+xml,<svg><path d='somesvg' fill='var(--pgn-color-green)'/></svg>\")` which will obviously not work when rendered, and you get broken SVG.
|
|
109
|
+
|
|
110
|
+
To disable this feature for specific token use `outputReferences` flag, e.g.
|
|
111
|
+
```
|
|
112
|
+
{
|
|
113
|
+
"value": "url("data:image/svg+xml,<svg><path d='somesvg' fill='{color.green.value}'/></svg>\")",
|
|
114
|
+
"outputReferences": false,
|
|
115
|
+
"modify": [{
|
|
116
|
+
"type": "str-replace",
|
|
117
|
+
"toReplace": "#",
|
|
118
|
+
"replaceWith": "%23"
|
|
119
|
+
}]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
this will correctly output `url("data:image/svg+xml,<svg><path d='somesvg' fill='%23178253'/></svg>")`
|
|
123
|
+
|
|
124
|
+
## Utility Classes
|
|
125
|
+
|
|
126
|
+
Style Dictionary is also able to generate CSS utility classes using design tokens, although currently it is not very-well supported, and you might be better off to just hardcode CSS classes without using Style Dictionary.
|
|
127
|
+
Nevertheless, in some cases it might be useful.
|
|
128
|
+
|
|
129
|
+
The configuration to do build CSS classes lives in `src/utilities` directory in JSON files, let's take `color.json` as an example and see what it does. Its contents should look something like this:
|
|
130
|
+
```
|
|
131
|
+
{
|
|
132
|
+
"utilities": [
|
|
133
|
+
{
|
|
134
|
+
"filters": {
|
|
135
|
+
"category": ["color"],
|
|
136
|
+
"type": ["gray", "primary", "secondary", "brand", "success", "info", "warning", "danger", "light", "dark", "accent"],
|
|
137
|
+
"item": ["base", "100", "200", "300", "400", "500", "600", "700", "800", "900", "a", "b"]
|
|
138
|
+
},
|
|
139
|
+
"utilityFunctionsToApply": ["bgVariant", "textEmphasisVariant", "borderColor"]
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
Namely, this is a JSON object with only one key (`utilities`, this is how Style Dictionary knows that this file is used for generating utility classes)
|
|
145
|
+
and one value which is an array of objects that describe how to generate classes and which tokens to use.
|
|
146
|
+
Each such object is composed of 2 keys:
|
|
147
|
+
- `utilityFunctionsToApply`, which is an array of strings, these strings are the names of functions that will
|
|
148
|
+
generate utility classes based on tokens. These functions must be defined in `css-utilities.js` module and must follow
|
|
149
|
+
the same signature - accept `token` object as its only argument and output CSS class as a string (see any of `bgVariant`, `textEmphasisVariant`, `borderColor` functions for an example)
|
|
150
|
+
- `filters`, which is an object that describes which tokens will be passed as an argument to functions provided by `utilityFunctionsToApply`.
|
|
151
|
+
The keys in this object are the attributes of a `token` object and values are arrays of valid values that tokens will be filtered against.
|
|
152
|
+
For list of possible keys see https://amzn.github.io/style-dictionary/#/tokens?id=category-type-item
|
|
153
|
+
|
|
154
|
+
Basically, this file tells Style Dictionary to generate utility classes using `["bgVariant", "textEmphasisVariant", "borderColor"]`
|
|
155
|
+
functions from tokens that are of `color` category and theirs `type` is one of `["gray", "primary", ...]`
|
|
156
|
+
and `item` is one of `["base", "100", "200", ...]`.
|
|
157
|
+
|
|
158
|
+
If you want to generate additional utility classes you need to add a similar JSON file to `src/utilities` directory.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements bg-variant mixin from bootstrap. Creates utility classes for background colors based on theme color.
|
|
3
|
+
*/
|
|
4
|
+
function bgVariant(token) {
|
|
5
|
+
const { attributes: { type, item }, name, actions } = token;
|
|
6
|
+
const parent = `.bg-${type}${item === 'base' ? '' : `-${item}`}`;
|
|
7
|
+
return `${parent} {
|
|
8
|
+
background-color: ${`var(--${name})`} !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
a${parent}:hover,
|
|
12
|
+
a${parent}:focus,
|
|
13
|
+
button${parent}:hover,
|
|
14
|
+
button${parent}:focus {
|
|
15
|
+
background-color: ${actions.default} !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Implements text-emphasis-variant mixin from bootstrap. Creates utility classes for text colors based on theme color.
|
|
23
|
+
*/
|
|
24
|
+
function textEmphasisVariant(token) {
|
|
25
|
+
const { attributes: { type, item }, name, actions } = token;
|
|
26
|
+
const parent = `.text-${type}${item === 'base' ? '' : `-${item}`}`;
|
|
27
|
+
return `${parent} {
|
|
28
|
+
color: ${`var(--${name})`} !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
a${parent}:hover,
|
|
32
|
+
a${parent}:focus {
|
|
33
|
+
color: ${actions.default} !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates utility class for border color.
|
|
41
|
+
*/
|
|
42
|
+
function borderColor(token) {
|
|
43
|
+
const { attributes: { type, item }, name } = token;
|
|
44
|
+
const className = `.border-${type}${item === 'base' ? '' : `-${item}`}`;
|
|
45
|
+
return `${className} {
|
|
46
|
+
border-color: ${`var(--${name})`} !important;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
bgVariant,
|
|
54
|
+
textEmphasisVariant,
|
|
55
|
+
borderColor,
|
|
56
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { getSCSStoCSSMap, getFilesWithExtension } = require('./utils');
|
|
4
|
+
|
|
5
|
+
const BASE_PATH = path.resolve(__dirname, './src');
|
|
6
|
+
const TOKEN_PREFIX = '--pgn';
|
|
7
|
+
|
|
8
|
+
function mapSCSStoCSS(sourcePath) {
|
|
9
|
+
const SCSStoCSSMap = {};
|
|
10
|
+
const tokenPaths = getFilesWithExtension(BASE_PATH, '.json');
|
|
11
|
+
if (sourcePath) {
|
|
12
|
+
tokenPaths.push(...getFilesWithExtension(sourcePath, '.json'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
tokenPaths.forEach(tokenFile => {
|
|
16
|
+
const tokenContent = fs.readFileSync(tokenFile, 'utf-8');
|
|
17
|
+
const parsed = JSON.parse(tokenContent);
|
|
18
|
+
getSCSStoCSSMap(TOKEN_PREFIX, parsed, SCSStoCSSMap);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return SCSStoCSSMap;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = mapSCSStoCSS;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { program, Option } = require('commander');
|
|
3
|
+
const { transformInPath } = require('./utils');
|
|
4
|
+
const mapSCSStoCSS = require('./map-scss-to-css');
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.version('0.0.1')
|
|
8
|
+
.description('CLI to replace SCSS variables usages or definitions to CSS variables and vice versa in .scss files.')
|
|
9
|
+
.requiredOption('-p, --filePath <filePath>', 'Path to the file or directory where to replace variables.')
|
|
10
|
+
.addOption(new Option('-s, --source <sourcePath>', 'Type of replacement: usage or definition. If set to "definition" the command will only update SCSS variables definitions with CSS variables, if set to "usage" - all occurrences of SCSS variables will we replaced'))
|
|
11
|
+
.addOption(new Option('-t, --replacementType <replacementType>', 'Type of replacement: usage or definition. If set to "definition" the command will only update SCSS variables definitions with CSS variables, if set to "usage" - all occurrences of SCSS variables will we replaced')
|
|
12
|
+
.choices(['usage', 'definition'])
|
|
13
|
+
.default('definition'))
|
|
14
|
+
.addOption(new Option('-d, --direction <name>', 'Map direction: css-to-scss or scss-to-css, if replacement type parameter is set to "definition" this has no effect.')
|
|
15
|
+
.choices(['scss-to-css', 'css-to-scss'])
|
|
16
|
+
.default('scss-to-css'))
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const {
|
|
19
|
+
direction,
|
|
20
|
+
filePath,
|
|
21
|
+
replacementType,
|
|
22
|
+
source,
|
|
23
|
+
} = options;
|
|
24
|
+
const variablesMap = mapSCSStoCSS(source);
|
|
25
|
+
if (replacementType === 'usage') {
|
|
26
|
+
await transformInPath(filePath, variablesMap, 'usage', [], direction);
|
|
27
|
+
} else {
|
|
28
|
+
await transformInPath(filePath, variablesMap);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const chroma = require('chroma-js');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Javascript version of bootstrap's color-yiq function. Decides whether to return light color variant or dark one
|
|
8
|
+
* based on contrast value of the input color
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} args
|
|
11
|
+
* @param {Object} args.tokenName - Name of design token, used to log warnings
|
|
12
|
+
* @param {Object} args.backgroundColor - chroma-js color instance
|
|
13
|
+
* @param {String} args.light - light color variant from ./src/themes/{themeVariant}/global/other.json
|
|
14
|
+
* @param {String} args.dark - dark color variant from ./src/themes/{themeVariant}/global/other.json
|
|
15
|
+
* @param {Number} args.threshold - contrast threshold from ./src/core/global/other.json
|
|
16
|
+
* @param {String} [args.themeVariant] - theme variant name that will be used to find default contrast colors
|
|
17
|
+
*
|
|
18
|
+
* @return chroma-js color instance (one of dark or light variants)
|
|
19
|
+
*/
|
|
20
|
+
function colorYiq({
|
|
21
|
+
tokenName,
|
|
22
|
+
backgroundColor,
|
|
23
|
+
light,
|
|
24
|
+
dark,
|
|
25
|
+
threshold,
|
|
26
|
+
themeVariant = 'light',
|
|
27
|
+
}) {
|
|
28
|
+
const defaultThresholdFile = fs.readFileSync(path.resolve(__dirname, 'src/core/global', 'other.json'), 'utf8');
|
|
29
|
+
const defaultThreshold = JSON.parse(defaultThresholdFile)['yiq-contrasted-threshold'];
|
|
30
|
+
|
|
31
|
+
const defaultColorsFile = fs.readFileSync(path.resolve(__dirname, `src/themes/${themeVariant}/global`, 'other.json'), 'utf8');
|
|
32
|
+
const {
|
|
33
|
+
'yiq-text-dark': defaultDark,
|
|
34
|
+
'yiq-text-light': defaultLight,
|
|
35
|
+
} = JSON.parse(defaultColorsFile);
|
|
36
|
+
|
|
37
|
+
const contrastThreshold = threshold || defaultThreshold;
|
|
38
|
+
const lightColor = light || defaultLight;
|
|
39
|
+
const darkColor = dark || defaultDark;
|
|
40
|
+
|
|
41
|
+
const [r, g, b] = backgroundColor.rgb();
|
|
42
|
+
const yiq = ((r * 299) + (g * 587) + (b * 114)) * 0.001;
|
|
43
|
+
|
|
44
|
+
let result = yiq >= contrastThreshold ? chroma(darkColor) : chroma(lightColor);
|
|
45
|
+
|
|
46
|
+
const maxAttempts = 10; // maximum number of attempts to darken/brighten color to pass contrast ratio
|
|
47
|
+
if (yiq >= contrastThreshold) {
|
|
48
|
+
// check whether the resulting combination of colors passes a11y contrast ratio of 4:5:1
|
|
49
|
+
// if not - darken resulting color until it does until maxAttempts is reached.
|
|
50
|
+
let numDarkenAttempts = 1;
|
|
51
|
+
while (chroma.contrast(backgroundColor, result) < 4.5 && numDarkenAttempts <= maxAttempts) {
|
|
52
|
+
result = result.darken(0.1);
|
|
53
|
+
numDarkenAttempts += 1;
|
|
54
|
+
if (numDarkenAttempts === maxAttempts) {
|
|
55
|
+
const title = `[a11y] Warning: Failed to sufficiently darken token ${chalk.keyword('orange').bold(tokenName)} to pass contrast ratio of 4.5:1.`;
|
|
56
|
+
const warningMetadata = [
|
|
57
|
+
`Background color: ${backgroundColor.hex()}`,
|
|
58
|
+
`Attempted foreground color: ${result.hex()}`,
|
|
59
|
+
].join('\n ');
|
|
60
|
+
const warn = `${title}\n ${warningMetadata}`;
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.log(chalk.keyword('yellow').bold(warn));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// check whether the resulting combination of colors passes a11y contrast ratio of 4:5:1
|
|
69
|
+
// if not - brighten resulting color until it does until maxAttempts is reached.
|
|
70
|
+
let numBrightenAttempts = 1;
|
|
71
|
+
while (chroma.contrast(backgroundColor, result) < 4.5 && numBrightenAttempts <= maxAttempts) {
|
|
72
|
+
result = result.brighten(0.1);
|
|
73
|
+
numBrightenAttempts += 1;
|
|
74
|
+
if (numBrightenAttempts === maxAttempts) {
|
|
75
|
+
const title = `[a11y] Warning: Failed to sufficiently brighten token ${chalk.keyword('orange').bold(tokenName)} to pass contrast ratio of 4.5:1.`;
|
|
76
|
+
const warningMetadata = [
|
|
77
|
+
`Background color: ${backgroundColor.hex()}`,
|
|
78
|
+
`Attempted foreground color: ${result.hex()}`,
|
|
79
|
+
].join('\n ');
|
|
80
|
+
const warn = `${title}\n ${warningMetadata}`;
|
|
81
|
+
// eslint-disable-next-line no-console
|
|
82
|
+
console.log(chalk.keyword('yellow').bold(warn));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Overrides chroma-js's lighten / darken functions to behave the same way SASS functions do.
|
|
90
|
+
*/
|
|
91
|
+
const lighten = (color, hslPercent) => color.set('hsl.l', color.get('hsl.l') + hslPercent);
|
|
92
|
+
const darken = (color, hslPercent) => lighten(color, -hslPercent);
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
colorYiq,
|
|
96
|
+
darken,
|
|
97
|
+
lighten,
|
|
98
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"size": {
|
|
3
|
+
"border": {
|
|
4
|
+
"width": { "value": "1px", "type": "dimension", "source": "$border-width", "description": "Default border width." },
|
|
5
|
+
"radius": {
|
|
6
|
+
"base": { "value": "6px", "type": "dimension", "source": "$border-radius", "description": "Default border radius." },
|
|
7
|
+
"lg": { "value": "7px", "type": "dimension", "source": "$border-radius-lg", "description": "Large border radius." },
|
|
8
|
+
"sm": { "value": "4px", "type": "dimension", "source": "$border-radius-sm", "description": "Small border radius." }
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"rounded": {
|
|
12
|
+
"pill": { "value": "50rem", "type": "dimension", "source": "$rounded-pill", "description": "Pill border radius." }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spacing": {
|
|
3
|
+
"alert": {
|
|
4
|
+
"padding": {
|
|
5
|
+
"y": { "value": "1.5rem", "type": "dimension", "source": "$alert-padding-y" },
|
|
6
|
+
"x": { "value": "1.5rem", "type": "dimension", "source": "$alert-padding-x" }
|
|
7
|
+
},
|
|
8
|
+
"margin-bottom": { "value": "1rem", "type": "dimension", "source": "$alert-margin-bottom" },
|
|
9
|
+
"actions-gap": { "value": "{spacing.spacer.3}", "type": "dimension", "source": "$alert-actions-gap" },
|
|
10
|
+
"icon-space": { "value": ".8rem", "type": "dimension", "source": "$alert-icon-space" }
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"typography": {
|
|
14
|
+
"alert": {
|
|
15
|
+
"font": {
|
|
16
|
+
"weight-link": { "value": "{typography.font.weight.normal}", "type": "fontWeight", "source": "$alert-link-font-weight" },
|
|
17
|
+
"size": { "value": ".875rem", "type": "dimension", "source": "$alert-font-size" }
|
|
18
|
+
},
|
|
19
|
+
"line-height": { "value": "1.5rem", "type": "dimension", "source": "$alert-line-height" }
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"size": {
|
|
23
|
+
"alert": {
|
|
24
|
+
"border": {
|
|
25
|
+
"radius": { "value": "{size.border.radius.base}", "type": "dimension", "source": "$alert-border-radius" },
|
|
26
|
+
"width": { "value": "0", "type": "dimension", "source": "$alert-border-width" }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spacing": {
|
|
3
|
+
"annotation": {
|
|
4
|
+
"padding": { "value": ".5rem", "type": "dimension", "source": "$annotation-padding" },
|
|
5
|
+
"arrow-side": {
|
|
6
|
+
"margin": { "value": ".25rem", "type": "dimension", "source": "$annotation-arrow-side-margin" }
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"typography": {
|
|
11
|
+
"annotation": {
|
|
12
|
+
"font-size": { "value": "{typography.font.size.sm}", "type": "dimension", "source": "$annotation-font-size" },
|
|
13
|
+
"line-height": { "value": "{typography.line-height.sm}", "type": "dimension", "source": "$annotation-line-height" }
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"size": {
|
|
17
|
+
"annotation": {
|
|
18
|
+
"arrow-border": {
|
|
19
|
+
"width": { "value": ".5rem", "type": "dimension", "source": "$annotation-arrow-border-width" }
|
|
20
|
+
},
|
|
21
|
+
"max-width": { "value": "18.75rem", "type": "dimension", "source": "$annotation-max-width" },
|
|
22
|
+
"border-radius": { "value": ".25rem", "type": "dimension", "source": "$annotation-border-radius" }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"size": {
|
|
3
|
+
"avatar": {
|
|
4
|
+
"base": { "value": "3rem", "type": "dimension", "source": "$avatar-size" },
|
|
5
|
+
"xs": { "value": "1.5rem", "type": "dimension", "source": "$avatar-size-xs" },
|
|
6
|
+
"sm": { "value": "2.25rem", "type": "dimension", "source": "$avatar-size-sm" },
|
|
7
|
+
"lg": { "value": "4rem", "type": "dimension", "source": "$avatar-size-lg" },
|
|
8
|
+
"xl": { "value": "6rem", "type": "dimension", "source": "$avatar-size-xl" },
|
|
9
|
+
"xxl": { "value": "11.5rem", "type": "dimension", "source": "$avatar-size-xxl" },
|
|
10
|
+
"huge": { "value": "18.75rem", "type": "dimension", "source": "$avatar-size-huge" },
|
|
11
|
+
"border": {
|
|
12
|
+
"base": { "value": "1px", "type": "dimension", "source": "$avatar-border" },
|
|
13
|
+
"radius": { "value": "100%", "type": "percentage", "source": "$avatar-border-radius" }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spacing": {
|
|
3
|
+
"avatar-button": {
|
|
4
|
+
"padding-left": {
|
|
5
|
+
"base": { "value": ".25em", "type": "dimension", "source": "$avatar-button-padding-left" },
|
|
6
|
+
"sm": { "value": ".25em", "type": "dimension", "source": "$avatar-button-padding-left-sm" },
|
|
7
|
+
"lg": { "value": ".25em", "type": "dimension", "source": "$avatar-button-padding-left-lg" }
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"spacing": {
|
|
3
|
+
"badge": {
|
|
4
|
+
"padding": {
|
|
5
|
+
"x": {
|
|
6
|
+
"base": { "value": ".5rem", "type": "dimension", "source": "$badge-padding-x" },
|
|
7
|
+
"pill": { "value": ".6em", "type": "dimension", "source": "$badge-pill-padding-x" }
|
|
8
|
+
},
|
|
9
|
+
"y": { "value": ".125rem", "type": "dimension", "source": "$badge-padding-y" }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"typography": {
|
|
14
|
+
"badge": {
|
|
15
|
+
"font": {
|
|
16
|
+
"size": { "value": "75%", "type": "percentage", "source": "$badge-font-size" },
|
|
17
|
+
"weight": { "value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$badge-font-weight" }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"size": {
|
|
22
|
+
"badge": {
|
|
23
|
+
"border-radius": {
|
|
24
|
+
"base": { "value": ".25rem", "type": "dimension", "source": "$badge-border-radius" },
|
|
25
|
+
"pill": { "value": "10rem", "type": "dimension", "source": "$badge-pill-border-radius" }
|
|
26
|
+
},
|
|
27
|
+
"focus-width": { "value": "{size.input.btn.focus-width}", "type": "dimension", "source": "$badge-focus-width" }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"transition": {
|
|
31
|
+
"badge": { "value": "none", "type": "transition", "source": "$badge-transition" }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"typography": {
|
|
3
|
+
"breadcrumb": {
|
|
4
|
+
"font-size": { "value": "inherit", "type": "dimension", "source": "$breadcrumb-font-size" }
|
|
5
|
+
}
|
|
6
|
+
},
|
|
7
|
+
"spacing": {
|
|
8
|
+
"breadcrumb": {
|
|
9
|
+
"padding": {
|
|
10
|
+
"y": { "value": ".75rem", "type": "dimension", "source": "$breadcrumb-padding-y" },
|
|
11
|
+
"x": { "value": "1rem", "type": "dimension", "source": "$breadcrumb-padding-x" },
|
|
12
|
+
"item": { "value": ".5rem", "type": "dimension", "source": "$breadcrumb-item-padding" }
|
|
13
|
+
},
|
|
14
|
+
"margin": {
|
|
15
|
+
"bottom": { "value": "1rem", "type": "dimension", "source": "$breadcrumb-margin-bottom" },
|
|
16
|
+
"left": { "value": ".5rem", "type": "dimension", "source": "$breadcrumb-margin-left" }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"size": {
|
|
21
|
+
"breadcrumb": {
|
|
22
|
+
"border": {
|
|
23
|
+
"radius": {
|
|
24
|
+
"base": {
|
|
25
|
+
"value": "{size.border.radius.base}", "type": "dimension", "source": "$breadcrumb-border-radius"
|
|
26
|
+
},
|
|
27
|
+
"focus": { "value": ".125rem", "type": "dimension", "source": "$breadcrumb-focus-border-radius" }
|
|
28
|
+
},
|
|
29
|
+
"axis": {
|
|
30
|
+
"x-focus": { "value": ".25rem", "type": "dimension", "source": "$breadcrumb-border-focus-axis-x" },
|
|
31
|
+
"y-focus": { "value": ".5rem", "type": "dimension", "source": "$breadcrumb-border-focus-axis-y" }
|
|
32
|
+
},
|
|
33
|
+
"width-focus": { "value": ".0625rem", "type": "dimension", "source": "$breadcrumb-border-focus-width" }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|