@refraktor/core 0.0.4 → 0.0.5
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/build/components/progress-circle/progress-circle.d.ts.map +1 -1
- package/build/components/progress-circle/progress-circle.js +6 -6
- package/build/components/progress-circle/progress-circle.styles.d.ts +2 -7
- package/build/components/progress-circle/progress-circle.styles.d.ts.map +1 -1
- package/build/components/progress-circle/progress-circle.styles.js +2 -23
- package/build/components/progress-circle/progress-circle.types.d.ts +4 -3
- package/build/components/progress-circle/progress-circle.types.d.ts.map +1 -1
- package/build/components/slider/slider.d.ts.map +1 -1
- package/build/components/slider/slider.js +69 -20
- package/build/components/tooltip/tooltip.js +1 -1
- package/build/style.css +2 -2
- package/package.json +30 -3
- package/.turbo/turbo-build.log +0 -4
- package/refraktor-core-0.0.1-alpha.0.tgz +0 -0
- package/src/components/accordion/accordion-control/accordion-control.tsx +0 -156
- package/src/components/accordion/accordion-control/index.ts +0 -1
- package/src/components/accordion/accordion-item/accordion-item.tsx +0 -40
- package/src/components/accordion/accordion-item/index.ts +0 -1
- package/src/components/accordion/accordion-panel/accordion-panel.tsx +0 -58
- package/src/components/accordion/accordion-panel/index.ts +0 -1
- package/src/components/accordion/accordion.context.ts +0 -93
- package/src/components/accordion/accordion.styles.ts +0 -60
- package/src/components/accordion/accordion.test.tsx +0 -174
- package/src/components/accordion/accordion.tsx +0 -203
- package/src/components/accordion/accordion.types.ts +0 -126
- package/src/components/accordion/index.ts +0 -17
- package/src/components/avatar/avatar-group/avatar-group.tsx +0 -73
- package/src/components/avatar/avatar-group/index.ts +0 -1
- package/src/components/avatar/avatar.styles.ts +0 -11
- package/src/components/avatar/avatar.tsx +0 -142
- package/src/components/avatar/avatar.types.ts +0 -86
- package/src/components/avatar/index.ts +0 -8
- package/src/components/badge/badge.styles.ts +0 -21
- package/src/components/badge/badge.tsx +0 -62
- package/src/components/badge/badge.types.ts +0 -40
- package/src/components/badge/index.ts +0 -2
- package/src/components/breadcrumbs/breadcrumbs.styles.ts +0 -55
- package/src/components/breadcrumbs/breadcrumbs.test.tsx +0 -136
- package/src/components/breadcrumbs/breadcrumbs.tsx +0 -199
- package/src/components/breadcrumbs/breadcrumbs.types.ts +0 -78
- package/src/components/breadcrumbs/breadcrumbs.utils.ts +0 -70
- package/src/components/breadcrumbs/index.ts +0 -6
- package/src/components/button/button.styles.ts +0 -28
- package/src/components/button/button.test.tsx +0 -57
- package/src/components/button/button.tsx +0 -110
- package/src/components/button/button.types.ts +0 -69
- package/src/components/button/index.ts +0 -2
- package/src/components/checkbox/checkbox-group/checkbox-group.tsx +0 -93
- package/src/components/checkbox/checkbox-group/index.ts +0 -1
- package/src/components/checkbox/checkbox.context.ts +0 -14
- package/src/components/checkbox/checkbox.styles.ts +0 -49
- package/src/components/checkbox/checkbox.test.tsx +0 -80
- package/src/components/checkbox/checkbox.tsx +0 -192
- package/src/components/checkbox/checkbox.types.ts +0 -125
- package/src/components/checkbox/index.ts +0 -10
- package/src/components/chip/chip-group/chip-group.tsx +0 -107
- package/src/components/chip/chip-group/index.ts +0 -1
- package/src/components/chip/chip.context.ts +0 -15
- package/src/components/chip/chip.styles.ts +0 -36
- package/src/components/chip/chip.test.tsx +0 -197
- package/src/components/chip/chip.tsx +0 -208
- package/src/components/chip/chip.types.ts +0 -134
- package/src/components/chip/index.ts +0 -10
- package/src/components/color-swatch/color-swatch.styles.ts +0 -11
- package/src/components/color-swatch/color-swatch.test.tsx +0 -80
- package/src/components/color-swatch/color-swatch.tsx +0 -84
- package/src/components/color-swatch/color-swatch.types.ts +0 -46
- package/src/components/color-swatch/index.ts +0 -2
- package/src/components/drawer/drawer-body/drawer-body.tsx +0 -29
- package/src/components/drawer/drawer-body/index.ts +0 -1
- package/src/components/drawer/drawer-close/drawer-close.tsx +0 -43
- package/src/components/drawer/drawer-close/index.ts +0 -1
- package/src/components/drawer/drawer-content/drawer-content.tsx +0 -135
- package/src/components/drawer/drawer-content/index.ts +0 -1
- package/src/components/drawer/drawer-header/drawer-header.tsx +0 -40
- package/src/components/drawer/drawer-header/index.ts +0 -1
- package/src/components/drawer/drawer-overlay/drawer-overlay.tsx +0 -87
- package/src/components/drawer/drawer-overlay/index.ts +0 -1
- package/src/components/drawer/drawer-root/drawer-root.tsx +0 -93
- package/src/components/drawer/drawer-root/index.ts +0 -1
- package/src/components/drawer/drawer.context.ts +0 -26
- package/src/components/drawer/drawer.styles.ts +0 -32
- package/src/components/drawer/drawer.test.tsx +0 -274
- package/src/components/drawer/drawer.tsx +0 -58
- package/src/components/drawer/drawer.types.ts +0 -192
- package/src/components/drawer/index.ts +0 -18
- package/src/components/drawer/use-drawer.ts +0 -94
- package/src/components/file-input/file-input.test.tsx +0 -134
- package/src/components/file-input/file-input.tsx +0 -224
- package/src/components/file-input/file-input.types.ts +0 -78
- package/src/components/file-input/file-input.utils.test.ts +0 -36
- package/src/components/file-input/file-input.utils.ts +0 -130
- package/src/components/file-input/index.ts +0 -2
- package/src/components/for/for.test.tsx +0 -66
- package/src/components/for/for.tsx +0 -53
- package/src/components/for/for.types.ts +0 -40
- package/src/components/for/index.ts +0 -2
- package/src/components/index.ts +0 -35
- package/src/components/input/index.ts +0 -2
- package/src/components/input/input-description/index.ts +0 -2
- package/src/components/input/input-description/input-description.tsx +0 -36
- package/src/components/input/input-error/index.ts +0 -2
- package/src/components/input/input-error/input-error.tsx +0 -36
- package/src/components/input/input-field/index.ts +0 -1
- package/src/components/input/input-field/input-field.styles.ts +0 -23
- package/src/components/input/input-field/input-field.tsx +0 -94
- package/src/components/input/input-label/index.ts +0 -2
- package/src/components/input/input-label/input-label.tsx +0 -47
- package/src/components/input/input-wrapper/index.ts +0 -2
- package/src/components/input/input-wrapper/input-wrapper.tsx +0 -43
- package/src/components/input/input.tsx +0 -71
- package/src/components/input/input.types.ts +0 -111
- package/src/components/loader/index.ts +0 -2
- package/src/components/loader/loader.tsx +0 -89
- package/src/components/loader/loader.types.ts +0 -33
- package/src/components/menu/index.ts +0 -24
- package/src/components/menu/menu-dropdown/index.ts +0 -1
- package/src/components/menu/menu-dropdown/menu-dropdown.tsx +0 -220
- package/src/components/menu/menu-item/index.ts +0 -1
- package/src/components/menu/menu-item/menu-item.tsx +0 -126
- package/src/components/menu/menu-label/index.ts +0 -1
- package/src/components/menu/menu-label/menu-label.tsx +0 -30
- package/src/components/menu/menu-separator/index.ts +0 -1
- package/src/components/menu/menu-separator/menu-separator.tsx +0 -28
- package/src/components/menu/menu-sub/index.ts +0 -1
- package/src/components/menu/menu-sub/menu-sub.tsx +0 -117
- package/src/components/menu/menu-sub-dropdown/index.ts +0 -1
- package/src/components/menu/menu-sub-dropdown/menu-sub-dropdown.tsx +0 -221
- package/src/components/menu/menu-sub-trigger/index.ts +0 -1
- package/src/components/menu/menu-sub-trigger/menu-sub-trigger.tsx +0 -164
- package/src/components/menu/menu-trigger/index.ts +0 -1
- package/src/components/menu/menu-trigger/menu-trigger.tsx +0 -98
- package/src/components/menu/menu.context.ts +0 -162
- package/src/components/menu/menu.test.tsx +0 -136
- package/src/components/menu/menu.tsx +0 -133
- package/src/components/menu/menu.types.ts +0 -291
- package/src/components/menu/use-menu.ts +0 -204
- package/src/components/modal/index.ts +0 -18
- package/src/components/modal/modal-body/index.ts +0 -1
- package/src/components/modal/modal-body/modal-body.tsx +0 -29
- package/src/components/modal/modal-close/index.ts +0 -1
- package/src/components/modal/modal-close/modal-close.tsx +0 -43
- package/src/components/modal/modal-content/index.ts +0 -1
- package/src/components/modal/modal-content/modal-content.tsx +0 -119
- package/src/components/modal/modal-header/index.ts +0 -1
- package/src/components/modal/modal-header/modal-header.tsx +0 -40
- package/src/components/modal/modal-overlay/index.ts +0 -1
- package/src/components/modal/modal-overlay/modal-overlay.tsx +0 -87
- package/src/components/modal/modal-root/index.ts +0 -1
- package/src/components/modal/modal-root/modal-root.tsx +0 -93
- package/src/components/modal/modal.context.ts +0 -26
- package/src/components/modal/modal.test.tsx +0 -316
- package/src/components/modal/modal.tsx +0 -58
- package/src/components/modal/modal.types.ts +0 -189
- package/src/components/modal/use-modal.ts +0 -94
- package/src/components/number-input/index.ts +0 -2
- package/src/components/number-input/number-input.styles.ts +0 -37
- package/src/components/number-input/number-input.test.tsx +0 -22
- package/src/components/number-input/number-input.tsx +0 -381
- package/src/components/number-input/number-input.types.ts +0 -58
- package/src/components/pagination/index.ts +0 -7
- package/src/components/pagination/pagination.styles.ts +0 -84
- package/src/components/pagination/pagination.test.tsx +0 -117
- package/src/components/pagination/pagination.tsx +0 -371
- package/src/components/pagination/pagination.types.ts +0 -95
- package/src/components/pagination/pagination.utils.ts +0 -88
- package/src/components/password-input/index.ts +0 -2
- package/src/components/password-input/password-input.test.tsx +0 -72
- package/src/components/password-input/password-input.tsx +0 -85
- package/src/components/password-input/password-input.types.ts +0 -30
- package/src/components/pin-input/index.ts +0 -2
- package/src/components/pin-input/pin-input.test.tsx +0 -149
- package/src/components/pin-input/pin-input.tsx +0 -473
- package/src/components/pin-input/pin-input.types.ts +0 -78
- package/src/components/popover/index.ts +0 -12
- package/src/components/popover/popover-dropdown/index.ts +0 -1
- package/src/components/popover/popover-dropdown/popover-dropdown.tsx +0 -94
- package/src/components/popover/popover-trigger/index.ts +0 -1
- package/src/components/popover/popover-trigger/popover-trigger.tsx +0 -49
- package/src/components/popover/popover.context.ts +0 -20
- package/src/components/popover/popover.tsx +0 -113
- package/src/components/popover/popover.types.ts +0 -137
- package/src/components/popover/use-popover.ts +0 -219
- package/src/components/portal/index.ts +0 -2
- package/src/components/portal/portal.test.tsx +0 -39
- package/src/components/portal/portal.tsx +0 -104
- package/src/components/portal/portal.types.ts +0 -31
- package/src/components/progress/index.ts +0 -2
- package/src/components/progress/progress.styles.ts +0 -25
- package/src/components/progress/progress.test.tsx +0 -107
- package/src/components/progress/progress.tsx +0 -93
- package/src/components/progress/progress.types.ts +0 -52
- package/src/components/progress-circle/index.ts +0 -5
- package/src/components/progress-circle/progress-circle.styles.ts +0 -31
- package/src/components/progress-circle/progress-circle.test.tsx +0 -140
- package/src/components/progress-circle/progress-circle.tsx +0 -124
- package/src/components/progress-circle/progress-circle.types.ts +0 -52
- package/src/components/radio/index.ts +0 -10
- package/src/components/radio/radio-group/index.ts +0 -1
- package/src/components/radio/radio-group/radio-group.tsx +0 -89
- package/src/components/radio/radio.context.ts +0 -14
- package/src/components/radio/radio.styles.ts +0 -49
- package/src/components/radio/radio.test.tsx +0 -75
- package/src/components/radio/radio.tsx +0 -173
- package/src/components/radio/radio.types.ts +0 -126
- package/src/components/scroll-area/index.ts +0 -6
- package/src/components/scroll-area/scroll-area.test.tsx +0 -72
- package/src/components/scroll-area/scroll-area.tsx +0 -70
- package/src/components/scroll-area/scroll-area.types.ts +0 -37
- package/src/components/segmented-control/index.ts +0 -6
- package/src/components/segmented-control/segmented-control.styles.ts +0 -37
- package/src/components/segmented-control/segmented-control.test.tsx +0 -170
- package/src/components/segmented-control/segmented-control.tsx +0 -255
- package/src/components/segmented-control/segmented-control.types.ts +0 -78
- package/src/components/select/index.ts +0 -20
- package/src/components/select/select-dropdown/index.ts +0 -1
- package/src/components/select/select-dropdown/select-dropdown.tsx +0 -299
- package/src/components/select/select-group/index.ts +0 -1
- package/src/components/select/select-group/select-group.tsx +0 -47
- package/src/components/select/select-item/index.ts +0 -1
- package/src/components/select/select-item/select-item.tsx +0 -157
- package/src/components/select/select-root/index.ts +0 -1
- package/src/components/select/select-root/select-root.tsx +0 -333
- package/src/components/select/select-trigger/index.ts +0 -1
- package/src/components/select/select-trigger/select-trigger.tsx +0 -123
- package/src/components/select/select.context.ts +0 -140
- package/src/components/select/select.test.tsx +0 -190
- package/src/components/select/select.tsx +0 -82
- package/src/components/select/select.types.ts +0 -272
- package/src/components/select/use-select.ts +0 -170
- package/src/components/slider/index.ts +0 -7
- package/src/components/slider/slider.styles.ts +0 -37
- package/src/components/slider/slider.tsx +0 -275
- package/src/components/slider/slider.types.ts +0 -82
- package/src/components/switch/index.ts +0 -2
- package/src/components/switch/switch.styles.ts +0 -31
- package/src/components/switch/switch.tsx +0 -132
- package/src/components/switch/switch.types.ts +0 -62
- package/src/components/table/index.ts +0 -24
- package/src/components/table/table-body/index.ts +0 -1
- package/src/components/table/table-body/table-body.tsx +0 -37
- package/src/components/table/table-caption/index.ts +0 -1
- package/src/components/table/table-caption/table-caption.tsx +0 -32
- package/src/components/table/table-cell/index.ts +0 -1
- package/src/components/table/table-cell/table-cell.tsx +0 -33
- package/src/components/table/table-head/index.ts +0 -1
- package/src/components/table/table-head/table-head.tsx +0 -29
- package/src/components/table/table-header-cell/index.ts +0 -1
- package/src/components/table/table-header-cell/table-header-cell.tsx +0 -33
- package/src/components/table/table-row/index.ts +0 -1
- package/src/components/table/table-row/table-row.tsx +0 -30
- package/src/components/table/table.context.ts +0 -18
- package/src/components/table/table.styles.ts +0 -62
- package/src/components/table/table.test.tsx +0 -145
- package/src/components/table/table.tsx +0 -91
- package/src/components/table/table.types.ts +0 -145
- package/src/components/tabs/index.ts +0 -18
- package/src/components/tabs/tabs-list/index.ts +0 -1
- package/src/components/tabs/tabs-list/tabs-list.tsx +0 -42
- package/src/components/tabs/tabs-panel/index.ts +0 -1
- package/src/components/tabs/tabs-panel/tabs-panel.tsx +0 -58
- package/src/components/tabs/tabs-tab/index.ts +0 -1
- package/src/components/tabs/tabs-tab/tabs-tab.tsx +0 -210
- package/src/components/tabs/tabs.context.ts +0 -88
- package/src/components/tabs/tabs.styles.ts +0 -92
- package/src/components/tabs/tabs.test.tsx +0 -167
- package/src/components/tabs/tabs.tsx +0 -137
- package/src/components/tabs/tabs.types.ts +0 -128
- package/src/components/textarea/index.ts +0 -2
- package/src/components/textarea/textarea-field/index.ts +0 -1
- package/src/components/textarea/textarea-field/textarea-field.styles.ts +0 -34
- package/src/components/textarea/textarea-field/textarea-field.tsx +0 -96
- package/src/components/textarea/textarea.tsx +0 -64
- package/src/components/textarea/textarea.types.ts +0 -80
- package/src/components/timeline/index.ts +0 -11
- package/src/components/timeline/timeline-item/index.ts +0 -1
- package/src/components/timeline/timeline-item/timeline-item.tsx +0 -158
- package/src/components/timeline/timeline.context.ts +0 -21
- package/src/components/timeline/timeline.styles.ts +0 -135
- package/src/components/timeline/timeline.test.tsx +0 -150
- package/src/components/timeline/timeline.tsx +0 -124
- package/src/components/timeline/timeline.types.ts +0 -91
- package/src/components/tooltip/index.ts +0 -8
- package/src/components/tooltip/tooltip.tsx +0 -164
- package/src/components/tooltip/tooltip.types.ts +0 -104
- package/src/components/tooltip/use-tooltip.ts +0 -200
- package/src/components/transition/index.ts +0 -11
- package/src/components/transition/transition.test.tsx +0 -126
- package/src/components/transition/transition.tsx +0 -441
- package/src/components/transition/transition.types.ts +0 -97
- package/src/components/transition/transitions.ts +0 -140
- package/src/icons/check.tsx +0 -25
- package/src/icons/chevron.tsx +0 -46
- package/src/icons/eye-off.tsx +0 -30
- package/src/icons/eye.tsx +0 -24
- package/src/icons/index.ts +0 -7
- package/src/icons/minus.tsx +0 -24
- package/src/icons/types.ts +0 -9
- package/src/icons/user.tsx +0 -18
- package/src/icons/x.tsx +0 -35
- package/src/index.ts +0 -5
- package/src/style.css +0 -334
- package/src/theme/ThemeProvider/ThemeProvider.tsx +0 -111
- package/src/theme/ThemeProvider/context.ts +0 -7
- package/src/theme/ThemeProvider/generateVariables.test.ts +0 -49
- package/src/theme/ThemeProvider/generateVariables.ts +0 -124
- package/src/theme/ThemeProvider/index.ts +0 -3
- package/src/theme/ThemeProvider/types.ts +0 -37
- package/src/theme/createTheme/createTheme.ts +0 -41
- package/src/theme/createTheme/index.ts +0 -7
- package/src/theme/createTheme/types.ts +0 -62
- package/src/theme/defaults/colors.ts +0 -203
- package/src/theme/defaults/settings.ts +0 -8
- package/src/theme/index.ts +0 -4
- package/src/theme/types.ts +0 -31
- package/src/theme/utils/get-radius.ts +0 -23
- package/src/theme/utils/get-shade.ts +0 -16
- package/src/theme/utils/index.ts +0 -3
- package/src/theme/utils/use-theme.ts +0 -27
- package/src/utils/configs/create-config.ts +0 -15
- package/src/utils/configs/index.ts +0 -3
- package/src/utils/configs/use-class-names.ts +0 -41
- package/src/utils/configs/use-props.ts +0 -55
- package/src/utils/cx/index.ts +0 -6
- package/src/utils/factory/factory.ts +0 -23
- package/src/utils/factory/index.ts +0 -14
- package/src/utils/factory/types.ts +0 -92
- package/src/utils/index.ts +0 -3
- package/src/vitest/index.ts +0 -1
- package/src/vitest/setup.tsx +0 -20
- package/src/vitest/utils.tsx +0 -59
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.js +0 -19
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createTheme } from "../createTheme";
|
|
3
|
-
import { generateVariables } from "./generateVariables";
|
|
4
|
-
|
|
5
|
-
describe("generateVariables", () => {
|
|
6
|
-
it("uses dark text on light primary colors when autoContrast is enabled", () => {
|
|
7
|
-
const themeConfig = createTheme({
|
|
8
|
-
defaults: {
|
|
9
|
-
primaryColor: "cloud",
|
|
10
|
-
primaryShade: 5,
|
|
11
|
-
autoContrast: true
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const variables = generateVariables("light", themeConfig);
|
|
16
|
-
|
|
17
|
-
expect(variables["--refraktor-primary"]).toBe("#dbe2ea");
|
|
18
|
-
expect(variables["--refraktor-primary-text"]).toBe("#000000");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("keeps shade-based text color when autoContrast is disabled", () => {
|
|
22
|
-
const themeConfig = createTheme({
|
|
23
|
-
defaults: {
|
|
24
|
-
primaryColor: "cloud",
|
|
25
|
-
primaryShade: 5,
|
|
26
|
-
autoContrast: false
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const variables = generateVariables("light", themeConfig);
|
|
31
|
-
|
|
32
|
-
expect(variables["--refraktor-primary-text"]).toBe("#ffffff");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("supports custom hex primary colors and chooses readable text", () => {
|
|
36
|
-
const themeConfig = createTheme({
|
|
37
|
-
defaults: {
|
|
38
|
-
primaryColor: "#f8fafc",
|
|
39
|
-
autoContrast: true
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const variables = generateVariables("light", themeConfig);
|
|
44
|
-
|
|
45
|
-
expect(variables["--refraktor-primary"]).toBe("#f8fafc");
|
|
46
|
-
expect(variables["--refraktor-primary-hover"]).toBe("#f8fafc");
|
|
47
|
-
expect(variables["--refraktor-primary-text"]).toBe("#000000");
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { getAutoContrastTextColor } from "@refraktor/utils";
|
|
2
|
-
import { RefraktorTheme } from "../createTheme";
|
|
3
|
-
import { Theme } from "../types";
|
|
4
|
-
import { getShade } from "../utils";
|
|
5
|
-
|
|
6
|
-
const COLORS_TEMPLATE = "--refraktor-colors-{{color}}-{{index}}";
|
|
7
|
-
const SEMANTIC_TEMPLATE = "--refraktor-{{key}}";
|
|
8
|
-
|
|
9
|
-
export type ThemeVariables = {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function getColorShadeFromTheme(
|
|
14
|
-
themeConfig: RefraktorTheme,
|
|
15
|
-
color: string,
|
|
16
|
-
shade: number
|
|
17
|
-
): string {
|
|
18
|
-
const colorValue = themeConfig.colors[color];
|
|
19
|
-
|
|
20
|
-
if (typeof colorValue === "string") return colorValue;
|
|
21
|
-
|
|
22
|
-
if (Array.isArray(colorValue))
|
|
23
|
-
return colorValue[Math.min(Math.max(0, shade), 9)] ?? colorValue[5];
|
|
24
|
-
|
|
25
|
-
return color;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const getSemanticColors = (themeConfig: RefraktorTheme) => ({
|
|
29
|
-
light: {
|
|
30
|
-
bg: getShade(themeConfig.colors, "light", 2),
|
|
31
|
-
"bg-hover": getShade(themeConfig.colors, "light", 3),
|
|
32
|
-
"bg-subtle": getShade(themeConfig.colors, "light", 1),
|
|
33
|
-
"bg-elevated": getShade(themeConfig.colors, "light", 0),
|
|
34
|
-
|
|
35
|
-
text: getShade(themeConfig.colors, "black", 0),
|
|
36
|
-
"text-secondary": getShade(themeConfig.colors, "dark", 6),
|
|
37
|
-
"text-tertiary": getShade(themeConfig.colors, "dark", 7),
|
|
38
|
-
|
|
39
|
-
border: getShade(themeConfig.colors, "light", 4),
|
|
40
|
-
"border-hover": getShade(themeConfig.colors, "light", 5),
|
|
41
|
-
|
|
42
|
-
"scroll-track": "transparent",
|
|
43
|
-
"scroll-thumb": getShade(themeConfig.colors, "light", 4),
|
|
44
|
-
"scroll-thumb-hover": getShade(themeConfig.colors, "light", 5)
|
|
45
|
-
},
|
|
46
|
-
dark: {
|
|
47
|
-
bg: getShade(themeConfig.colors, "dark", 6),
|
|
48
|
-
"bg-hover": getShade(themeConfig.colors, "dark", 5),
|
|
49
|
-
"bg-subtle": getShade(themeConfig.colors, "dark", 7),
|
|
50
|
-
"bg-elevated": getShade(themeConfig.colors, "dark", 5),
|
|
51
|
-
|
|
52
|
-
text: getShade(themeConfig.colors, "white", 0),
|
|
53
|
-
"text-secondary": getShade(themeConfig.colors, "dark", 1),
|
|
54
|
-
"text-tertiary": getShade(themeConfig.colors, "dark", 2),
|
|
55
|
-
|
|
56
|
-
border: getShade(themeConfig.colors, "dark", 4),
|
|
57
|
-
"border-hover": getShade(themeConfig.colors, "dark", 3),
|
|
58
|
-
|
|
59
|
-
"scroll-track": "transparent",
|
|
60
|
-
"scroll-thumb": getShade(themeConfig.colors, "dark", 4),
|
|
61
|
-
"scroll-thumb-hover": getShade(themeConfig.colors, "dark", 3)
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export const generateVariables = (
|
|
66
|
-
theme: Theme,
|
|
67
|
-
themeConfig: RefraktorTheme
|
|
68
|
-
): ThemeVariables => {
|
|
69
|
-
const variables: ThemeVariables = {};
|
|
70
|
-
const { colors, defaults } = themeConfig;
|
|
71
|
-
|
|
72
|
-
const { primaryColor, primaryShade, autoContrast } = defaults;
|
|
73
|
-
|
|
74
|
-
const primaryColorValue = getColorShadeFromTheme(
|
|
75
|
-
themeConfig,
|
|
76
|
-
primaryColor,
|
|
77
|
-
primaryShade
|
|
78
|
-
);
|
|
79
|
-
const primaryTextFallback = getColorShadeFromTheme(
|
|
80
|
-
themeConfig,
|
|
81
|
-
primaryColor,
|
|
82
|
-
0
|
|
83
|
-
);
|
|
84
|
-
const darkText = getShade(themeConfig.colors, "black", 0);
|
|
85
|
-
const lightText = getShade(themeConfig.colors, "white", 0);
|
|
86
|
-
|
|
87
|
-
Object.entries(getSemanticColors(themeConfig)[theme]).forEach(
|
|
88
|
-
([key, value]) => {
|
|
89
|
-
if (value !== undefined)
|
|
90
|
-
variables[SEMANTIC_TEMPLATE.replace("{{key}}", key)] = value;
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
Object.assign(variables, {
|
|
95
|
-
"--refraktor-primary": primaryColorValue,
|
|
96
|
-
"--refraktor-primary-hover": getColorShadeFromTheme(
|
|
97
|
-
themeConfig,
|
|
98
|
-
primaryColor,
|
|
99
|
-
primaryShade - 1
|
|
100
|
-
),
|
|
101
|
-
"--refraktor-primary-text": autoContrast
|
|
102
|
-
? getAutoContrastTextColor(
|
|
103
|
-
primaryColorValue,
|
|
104
|
-
darkText,
|
|
105
|
-
lightText,
|
|
106
|
-
primaryTextFallback
|
|
107
|
-
)
|
|
108
|
-
: primaryTextFallback
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
Object.entries(colors).forEach(([color, shade]) => {
|
|
112
|
-
if (!Array.isArray(shade)) return;
|
|
113
|
-
|
|
114
|
-
shade.forEach((shade, index) => {
|
|
115
|
-
const varName = COLORS_TEMPLATE.replace("{{color}}", color).replace(
|
|
116
|
-
"{{index}}",
|
|
117
|
-
index.toString()
|
|
118
|
-
);
|
|
119
|
-
variables[varName] = shade;
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return variables;
|
|
124
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import { Theme } from "../types";
|
|
3
|
-
import { RefraktorTheme, ComponentsConfig } from "../createTheme";
|
|
4
|
-
|
|
5
|
-
export type ThemePersistenceOptions = {
|
|
6
|
-
/** Whether to persist the theme in localStorage @default `true` */
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
|
|
9
|
-
/** Key to use for the localStorage item @default `refraktor-theme` */
|
|
10
|
-
storageKey?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type ThemeProviderProps = {
|
|
14
|
-
/** The children to render. */
|
|
15
|
-
children: ReactNode;
|
|
16
|
-
|
|
17
|
-
/** Theme to use by default @default `dark` */
|
|
18
|
-
theme?: Theme;
|
|
19
|
-
|
|
20
|
-
/** Theme configuration @default `defaultTheme` */
|
|
21
|
-
themeConfig?: RefraktorTheme;
|
|
22
|
-
|
|
23
|
-
/** Components configuration */
|
|
24
|
-
components?: ComponentsConfig;
|
|
25
|
-
|
|
26
|
-
/** Options for persisting the theme in localStorage */
|
|
27
|
-
persistence?: ThemePersistenceOptions;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type ThemeProviderContextValue = {
|
|
31
|
-
theme: Theme;
|
|
32
|
-
setTheme: (theme: Theme) => void;
|
|
33
|
-
toggleTheme: () => void;
|
|
34
|
-
persistenceEnabled: boolean;
|
|
35
|
-
themeConfig: RefraktorTheme;
|
|
36
|
-
components: ComponentsConfig;
|
|
37
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import defaultColors from "../defaults/colors";
|
|
2
|
-
import { defaultSettings } from "../defaults/settings";
|
|
3
|
-
import {
|
|
4
|
-
ColorsConfig,
|
|
5
|
-
RefraktorTheme,
|
|
6
|
-
ThemeDefaults,
|
|
7
|
-
ThemeInput
|
|
8
|
-
} from "./types";
|
|
9
|
-
|
|
10
|
-
export const defaultTheme: RefraktorTheme = {
|
|
11
|
-
defaults: defaultSettings,
|
|
12
|
-
colors: defaultColors
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function mergeColors(
|
|
16
|
-
base: ColorsConfig,
|
|
17
|
-
override?: Partial<ColorsConfig>
|
|
18
|
-
): ColorsConfig {
|
|
19
|
-
if (!override) return base;
|
|
20
|
-
|
|
21
|
-
return { ...base, ...override } as ColorsConfig;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createTheme(settings: ThemeInput): RefraktorTheme {
|
|
25
|
-
const defaults: Required<ThemeDefaults> = {
|
|
26
|
-
radius: settings.defaults?.radius ?? defaultSettings.radius,
|
|
27
|
-
primaryColor:
|
|
28
|
-
settings.defaults?.primaryColor ?? defaultSettings.primaryColor,
|
|
29
|
-
primaryShade:
|
|
30
|
-
settings.defaults?.primaryShade ?? defaultSettings.primaryShade,
|
|
31
|
-
autoContrast:
|
|
32
|
-
settings.defaults?.autoContrast ?? defaultSettings.autoContrast
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const colors = mergeColors(defaultColors, settings.colors);
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
defaults,
|
|
39
|
-
colors
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { ColorShade, PrimaryColor, RefraktorRadius } from "../types";
|
|
2
|
-
|
|
3
|
-
export type ColorScale = readonly [
|
|
4
|
-
string,
|
|
5
|
-
string,
|
|
6
|
-
string,
|
|
7
|
-
string,
|
|
8
|
-
string,
|
|
9
|
-
string,
|
|
10
|
-
string,
|
|
11
|
-
string,
|
|
12
|
-
string,
|
|
13
|
-
string
|
|
14
|
-
];
|
|
15
|
-
export type ColorsConfig = {
|
|
16
|
-
[key: string]: ColorScale | string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type ThemeDefaults = {
|
|
20
|
-
/** Default border radius @default `md` */
|
|
21
|
-
radius?: RefraktorRadius;
|
|
22
|
-
|
|
23
|
-
/** Primary color. Can be a hex code or a color from the default colors @default `cloud` */
|
|
24
|
-
|
|
25
|
-
primaryColor?: PrimaryColor | string;
|
|
26
|
-
|
|
27
|
-
/** Primary color shade @default `5` */
|
|
28
|
-
primaryShade?: ColorShade;
|
|
29
|
-
|
|
30
|
-
/** Automatically choose readable primary text color @default `true` */
|
|
31
|
-
autoContrast?: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type RefraktorTheme = {
|
|
35
|
-
defaults: Required<ThemeDefaults>;
|
|
36
|
-
colors: Required<ColorsConfig>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type ThemeInput = {
|
|
40
|
-
/** Colors for the theme */
|
|
41
|
-
colors?: ColorsConfig;
|
|
42
|
-
|
|
43
|
-
/** Default settings for the theme */
|
|
44
|
-
defaults?: ThemeDefaults;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type ClassNamesRecord = Record<string, string | undefined>;
|
|
48
|
-
|
|
49
|
-
export type ComponentConfigObject<
|
|
50
|
-
Props = Record<string, any>,
|
|
51
|
-
ClassNames extends ClassNamesRecord = ClassNamesRecord
|
|
52
|
-
> = {
|
|
53
|
-
/** Default props for the component */
|
|
54
|
-
defaultProps?: Partial<Props>;
|
|
55
|
-
|
|
56
|
-
/* Default class names for the component */
|
|
57
|
-
classNames?: ClassNames;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type ComponentsConfig = {
|
|
61
|
-
[componentName: string]: ComponentConfigObject<any, any>;
|
|
62
|
-
};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { ColorsConfig } from "../createTheme/types";
|
|
2
|
-
|
|
3
|
-
const defaultColors: ColorsConfig = {
|
|
4
|
-
white: "#ffffff",
|
|
5
|
-
black: "#000000",
|
|
6
|
-
|
|
7
|
-
dark: [
|
|
8
|
-
"#c9c9c9",
|
|
9
|
-
"#b8b8b8",
|
|
10
|
-
"#828282",
|
|
11
|
-
"#696969",
|
|
12
|
-
"#424242",
|
|
13
|
-
"#3b3b3b",
|
|
14
|
-
"#2e2e2e",
|
|
15
|
-
"#242424",
|
|
16
|
-
"#1f1f1f",
|
|
17
|
-
"#141414"
|
|
18
|
-
],
|
|
19
|
-
|
|
20
|
-
light: [
|
|
21
|
-
"#ffffff",
|
|
22
|
-
"#f9f9f9",
|
|
23
|
-
"#f2f2f2",
|
|
24
|
-
"#e5e5e5",
|
|
25
|
-
"#d1d1d1",
|
|
26
|
-
"#b2b2b2",
|
|
27
|
-
"#8c8c8c",
|
|
28
|
-
"#666666",
|
|
29
|
-
"#3f3f3f",
|
|
30
|
-
"#262626"
|
|
31
|
-
],
|
|
32
|
-
|
|
33
|
-
gray: [
|
|
34
|
-
"#fafafa",
|
|
35
|
-
"#f4f4f5",
|
|
36
|
-
"#e4e4e7",
|
|
37
|
-
"#d4d4d8",
|
|
38
|
-
"#a1a1aa",
|
|
39
|
-
"#71717a",
|
|
40
|
-
"#52525b",
|
|
41
|
-
"#3f3f46",
|
|
42
|
-
"#27272a",
|
|
43
|
-
"#18181b"
|
|
44
|
-
],
|
|
45
|
-
|
|
46
|
-
cloud: [
|
|
47
|
-
"#ffffff",
|
|
48
|
-
"#fcfcfd",
|
|
49
|
-
"#f8fafc",
|
|
50
|
-
"#eef2f6",
|
|
51
|
-
"#e2e8f0",
|
|
52
|
-
"#dbe2ea",
|
|
53
|
-
"#c2ccd6",
|
|
54
|
-
"#94a3b8",
|
|
55
|
-
"#64748b",
|
|
56
|
-
"#1f2937"
|
|
57
|
-
],
|
|
58
|
-
|
|
59
|
-
green: [
|
|
60
|
-
"#ebfbee",
|
|
61
|
-
"#d3f9d8",
|
|
62
|
-
"#b2f2bb",
|
|
63
|
-
"#8ce99a",
|
|
64
|
-
"#69db7c",
|
|
65
|
-
"#51cf66",
|
|
66
|
-
"#40c057",
|
|
67
|
-
"#37b24d",
|
|
68
|
-
"#2f9e44",
|
|
69
|
-
"#2b8a3e"
|
|
70
|
-
],
|
|
71
|
-
|
|
72
|
-
mint: [
|
|
73
|
-
"#ecfdf5",
|
|
74
|
-
"#d1fae5",
|
|
75
|
-
"#a7f3d0",
|
|
76
|
-
"#6ee7b7",
|
|
77
|
-
"#34d399",
|
|
78
|
-
"#10b981",
|
|
79
|
-
"#059669",
|
|
80
|
-
"#047857",
|
|
81
|
-
"#065f46",
|
|
82
|
-
"#064e3b"
|
|
83
|
-
],
|
|
84
|
-
|
|
85
|
-
red: [
|
|
86
|
-
"#ffeaea",
|
|
87
|
-
"#ffc5c5",
|
|
88
|
-
"#ffa0a0",
|
|
89
|
-
"#ff7a7a",
|
|
90
|
-
"#ff5555",
|
|
91
|
-
"#e64545",
|
|
92
|
-
"#c13838",
|
|
93
|
-
"#9d2c2c",
|
|
94
|
-
"#781f1f",
|
|
95
|
-
"#541414"
|
|
96
|
-
],
|
|
97
|
-
|
|
98
|
-
blue: [
|
|
99
|
-
"#e7f2ff",
|
|
100
|
-
"#b8dcff",
|
|
101
|
-
"#89c6ff",
|
|
102
|
-
"#5ab0ff",
|
|
103
|
-
"#2b9aff",
|
|
104
|
-
"#1485e6",
|
|
105
|
-
"#106ec1",
|
|
106
|
-
"#0d589d",
|
|
107
|
-
"#094179",
|
|
108
|
-
"#062b54"
|
|
109
|
-
],
|
|
110
|
-
|
|
111
|
-
cyan: [
|
|
112
|
-
"#eefbfc",
|
|
113
|
-
"#d6f4f6",
|
|
114
|
-
"#bcecee",
|
|
115
|
-
"#9ee3e6",
|
|
116
|
-
"#7ed9de",
|
|
117
|
-
"#5fcfd6",
|
|
118
|
-
"#46b8bf",
|
|
119
|
-
"#329fa6",
|
|
120
|
-
"#1f7f85",
|
|
121
|
-
"#145f64"
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
teal: [
|
|
125
|
-
"#ecf8f6",
|
|
126
|
-
"#d0efe9",
|
|
127
|
-
"#b2e5dc",
|
|
128
|
-
"#8fdbc9",
|
|
129
|
-
"#6fd1b6",
|
|
130
|
-
"#52c7a4",
|
|
131
|
-
"#3dad8c",
|
|
132
|
-
"#2f8f74",
|
|
133
|
-
"#226f5b",
|
|
134
|
-
"#184f41"
|
|
135
|
-
],
|
|
136
|
-
|
|
137
|
-
yellow: [
|
|
138
|
-
"#fffce5",
|
|
139
|
-
"#fff4b8",
|
|
140
|
-
"#ffeb8a",
|
|
141
|
-
"#ffe25c",
|
|
142
|
-
"#ffd92e",
|
|
143
|
-
"#e6c020",
|
|
144
|
-
"#c1a319",
|
|
145
|
-
"#9d8613",
|
|
146
|
-
"#79690c",
|
|
147
|
-
"#544c06"
|
|
148
|
-
],
|
|
149
|
-
|
|
150
|
-
orange: [
|
|
151
|
-
"#fff7e0",
|
|
152
|
-
"#ffd29d",
|
|
153
|
-
"#ffbb75",
|
|
154
|
-
"#ff9e4d",
|
|
155
|
-
"#ff8025",
|
|
156
|
-
"#e66a00",
|
|
157
|
-
"#c95300",
|
|
158
|
-
"#a43c00",
|
|
159
|
-
"#7f2b00",
|
|
160
|
-
"#5a1c00"
|
|
161
|
-
],
|
|
162
|
-
|
|
163
|
-
purple: [
|
|
164
|
-
"#f4f0ff",
|
|
165
|
-
"#dbceff",
|
|
166
|
-
"#c2acff",
|
|
167
|
-
"#a98aff",
|
|
168
|
-
"#9068ff",
|
|
169
|
-
"#774fe6",
|
|
170
|
-
"#613fc1",
|
|
171
|
-
"#4c319d",
|
|
172
|
-
"#372479",
|
|
173
|
-
"#221654"
|
|
174
|
-
],
|
|
175
|
-
|
|
176
|
-
magenta: [
|
|
177
|
-
"#f7ecf6",
|
|
178
|
-
"#ebd1ea",
|
|
179
|
-
"#deb5de",
|
|
180
|
-
"#d19ad2",
|
|
181
|
-
"#c37fc6",
|
|
182
|
-
"#b065ba",
|
|
183
|
-
"#9652a0",
|
|
184
|
-
"#7b3f85",
|
|
185
|
-
"#602c6a",
|
|
186
|
-
"#45194f"
|
|
187
|
-
],
|
|
188
|
-
|
|
189
|
-
pink: [
|
|
190
|
-
"#fcebf2",
|
|
191
|
-
"#f6d2e1",
|
|
192
|
-
"#efb8cf",
|
|
193
|
-
"#e79ebb",
|
|
194
|
-
"#de84a6",
|
|
195
|
-
"#d36a90",
|
|
196
|
-
"#b85778",
|
|
197
|
-
"#9c4662",
|
|
198
|
-
"#7d344b",
|
|
199
|
-
"#5c2436"
|
|
200
|
-
]
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export default defaultColors;
|
package/src/theme/index.ts
DELETED
package/src/theme/types.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type Theme = "dark" | "light";
|
|
2
|
-
|
|
3
|
-
export type PrimaryColor =
|
|
4
|
-
| "gray"
|
|
5
|
-
| "cloud"
|
|
6
|
-
| "green"
|
|
7
|
-
| "mint"
|
|
8
|
-
| "red"
|
|
9
|
-
| "blue"
|
|
10
|
-
| "cyan"
|
|
11
|
-
| "teal"
|
|
12
|
-
| "yellow"
|
|
13
|
-
| "orange"
|
|
14
|
-
| "purple"
|
|
15
|
-
| "magenta"
|
|
16
|
-
| "pink";
|
|
17
|
-
export type ColorShade = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
18
|
-
|
|
19
|
-
export type RefraktorRadius =
|
|
20
|
-
| "none"
|
|
21
|
-
| "default"
|
|
22
|
-
| "xs"
|
|
23
|
-
| "sm"
|
|
24
|
-
| "md"
|
|
25
|
-
| "lg"
|
|
26
|
-
| "xl"
|
|
27
|
-
| "2xl"
|
|
28
|
-
| "3xl"
|
|
29
|
-
| "4xl"
|
|
30
|
-
| "full";
|
|
31
|
-
export type RefraktorSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ThemeDefaults } from "../createTheme";
|
|
2
|
-
import type { RefraktorRadius } from "../types";
|
|
3
|
-
|
|
4
|
-
const radiusMap: Record<RefraktorRadius, string> = {
|
|
5
|
-
none: "rounded-[var(--refraktor-radius-none)]",
|
|
6
|
-
default: "rounded-[var(--refraktor-radius-md)]",
|
|
7
|
-
xs: "rounded-[var(--refraktor-radius-xs)]",
|
|
8
|
-
sm: "rounded-[var(--refraktor-radius-sm)]",
|
|
9
|
-
md: "rounded-[var(--refraktor-radius-md)]",
|
|
10
|
-
lg: "rounded-[var(--refraktor-radius-lg)]",
|
|
11
|
-
xl: "rounded-[var(--refraktor-radius-xl)]",
|
|
12
|
-
"2xl": "rounded-[var(--refraktor-radius-2xl)]",
|
|
13
|
-
"3xl": "rounded-[var(--refraktor-radius-3xl)]",
|
|
14
|
-
"4xl": "rounded-[var(--refraktor-radius-4xl)]",
|
|
15
|
-
full: "rounded-[var(--refraktor-radius-full)]"
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function getRadius(radius: RefraktorRadius, defaults?: ThemeDefaults) {
|
|
19
|
-
const effectiveRadius =
|
|
20
|
-
radius === "default" ? defaults?.radius ?? "md" : radius;
|
|
21
|
-
|
|
22
|
-
return radiusMap[effectiveRadius] ?? radiusMap.default;
|
|
23
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ColorsConfig } from "../createTheme/types";
|
|
2
|
-
import defaultColors from "../defaults/colors";
|
|
3
|
-
|
|
4
|
-
export function getShade(
|
|
5
|
-
colors: ColorsConfig,
|
|
6
|
-
color: keyof typeof defaultColors,
|
|
7
|
-
tone: number
|
|
8
|
-
) {
|
|
9
|
-
const value = colors[color] ?? defaultColors[color];
|
|
10
|
-
|
|
11
|
-
if (Array.isArray(value)) {
|
|
12
|
-
return value[Math.min(Math.max(0, tone), 9)] ?? value[5];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return value;
|
|
16
|
-
}
|
package/src/theme/utils/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useThemeContext } from "../ThemeProvider";
|
|
2
|
-
import { RefraktorRadius } from "../types";
|
|
3
|
-
import { getRadius } from "./get-radius";
|
|
4
|
-
import { cx } from "../../utils";
|
|
5
|
-
|
|
6
|
-
export function useTheme() {
|
|
7
|
-
const { theme, setTheme, toggleTheme, themeConfig } = useThemeContext();
|
|
8
|
-
|
|
9
|
-
if (!theme)
|
|
10
|
-
throw new Error(
|
|
11
|
-
"[@refraktor/core] ThemeProvider was not found in the tree"
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const _getRadius = (radius: RefraktorRadius = "default") =>
|
|
15
|
-
getRadius(radius, themeConfig.defaults);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
theme,
|
|
19
|
-
setTheme,
|
|
20
|
-
toggleTheme,
|
|
21
|
-
getRadius: _getRadius,
|
|
22
|
-
|
|
23
|
-
colors: themeConfig.colors,
|
|
24
|
-
|
|
25
|
-
cx
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ClassNamesRecord } from "../../theme/createTheme";
|
|
2
|
-
|
|
3
|
-
export function createComponentConfig<Props extends Record<string, any>>() {
|
|
4
|
-
return function configure(defaultProps: Partial<Props>): Partial<Props> {
|
|
5
|
-
return defaultProps;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function createClassNamesConfig<ClassNames extends ClassNamesRecord>() {
|
|
10
|
-
return function classNames(
|
|
11
|
-
classNamesConfig: Partial<ClassNames>
|
|
12
|
-
): Partial<ClassNames> {
|
|
13
|
-
return classNamesConfig;
|
|
14
|
-
};
|
|
15
|
-
}
|