@eqtylab/equality 0.0.0
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/LICENSE +190 -0
- package/dist/alert-dialog.module.module.css.module.css +275 -0
- package/dist/alert.module.module.css.module.css +112 -0
- package/dist/avatar.module.module.css.module.css +119 -0
- package/dist/badge.module.module.css.module.css +141 -0
- package/dist/bg-gradient.module.module.css.module.css +7 -0
- package/dist/button.module.module.css.module.css +253 -0
- package/dist/card-content-header.module.module.css.module.css +27 -0
- package/dist/card.module.module.css.module.css +246 -0
- package/dist/checkbox.module.module.css.module.css +124 -0
- package/dist/code-block.module.module.css.module.css +100 -0
- package/dist/command.module.module.css.module.css +210 -0
- package/dist/control-status-badge.module.module.css.module.css +49 -0
- package/dist/date-range-picker.module.module.css.module.css +147 -0
- package/dist/dialog.module.module.css.module.css +300 -0
- package/dist/display-field.module.module.css.module.css +250 -0
- package/dist/drawer.module.module.css.module.css +202 -0
- package/dist/dropdown-menu.module.module.css.module.css +271 -0
- package/dist/empty-table-state.module.module.css.module.css +34 -0
- package/dist/filter-dropdown.module.module.css.module.css +18 -0
- package/dist/form.module.module.css.module.css +35 -0
- package/dist/generated/color-vars.css +354 -0
- package/dist/generated/dark-tokens.css +105 -0
- package/dist/generated/global-dark-tokens.css +105 -0
- package/dist/generated/global-light-tokens.css +254 -0
- package/dist/generated/light-tokens.css +254 -0
- package/dist/generated/tailwind-tokens.css +252 -0
- package/dist/global-theme-config.css +15 -0
- package/dist/heading.module.module.css.module.css +41 -0
- package/dist/icon-button.module.module.css.module.css +196 -0
- package/dist/icon.module.module.css.module.css +155 -0
- package/dist/index.cjs +3419 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +819 -0
- package/dist/index.d.ts +819 -0
- package/dist/index.js +3134 -0
- package/dist/index.js.map +1 -0
- package/dist/info-card.module.module.css.module.css +25 -0
- package/dist/input.module.module.css.module.css +231 -0
- package/dist/label.module.module.css.module.css +23 -0
- package/dist/list-or-grid-view-toggle.module.module.css.module.css +52 -0
- package/dist/loading-overlay.module.module.css.module.css +151 -0
- package/dist/metric-card.module.module.css.module.css +171 -0
- package/dist/motion-collapsible.module.module.css.module.css +4 -0
- package/dist/page-not-found.module.module.css.module.css +71 -0
- package/dist/pagination.module.module.css.module.css +21 -0
- package/dist/panel-label.module.module.css.module.css +17 -0
- package/dist/popover.module.module.css.module.css +136 -0
- package/dist/progress.module.module.css.module.css +32 -0
- package/dist/radial-graph.module.module.css.module.css +223 -0
- package/dist/radio-dropdown.module.module.css.module.css +16 -0
- package/dist/radio-group.module.module.css.module.css +118 -0
- package/dist/resource-badge.module.module.css.module.css +77 -0
- package/dist/scripts.cjs +116 -0
- package/dist/scripts.cjs.map +1 -0
- package/dist/scripts.d.cts +5 -0
- package/dist/scripts.d.ts +5 -0
- package/dist/scripts.js +114 -0
- package/dist/scripts.js.map +1 -0
- package/dist/scroll-area.module.module.css.module.css +46 -0
- package/dist/search-bar.module.module.css.module.css +9 -0
- package/dist/section-heading.module.module.css.module.css +42 -0
- package/dist/select.module.module.css.module.css +362 -0
- package/dist/separator.module.module.css.module.css +13 -0
- package/dist/sheet.module.module.css.module.css +377 -0
- package/dist/skeleton.module.module.css.module.css +11 -0
- package/dist/sort-button.module.module.css.module.css +42 -0
- package/dist/sort-selector.module.module.css.module.css +11 -0
- package/dist/spinner.module.module.css.module.css +82 -0
- package/dist/switch.module.module.css.module.css +226 -0
- package/dist/table-components.module.module.css.module.css +116 -0
- package/dist/table.module.module.css.module.css +145 -0
- package/dist/tabs-components.module.module.css.module.css +136 -0
- package/dist/tabs.module.module.css.module.css +139 -0
- package/dist/textarea.module.module.css.module.css +115 -0
- package/dist/theme/lib/utils.cjs +125 -0
- package/dist/theme/lib/utils.cjs.map +1 -0
- package/dist/theme/lib/utils.d.cts +26 -0
- package/dist/theme/lib/utils.d.ts +26 -0
- package/dist/theme/lib/utils.js +110 -0
- package/dist/theme/lib/utils.js.map +1 -0
- package/dist/theme-base.css +51 -0
- package/dist/theme-components.css +27 -0
- package/dist/theme-preflight-global.css +260 -0
- package/dist/theme-preflight-scoped.css +261 -0
- package/dist/theme-utilities.css +54 -0
- package/dist/theme.module.css +15 -0
- package/dist/theme.module.module.css.module.css +978 -0
- package/dist/toast-components.module.module.css.module.css +393 -0
- package/dist/toast.module.module.css.module.css +11 -0
- package/dist/tokens.css +3 -0
- package/dist/tooltip.module.module.css.module.css +139 -0
- package/dist/truncated-description.module.module.css.module.css +15 -0
- package/package.json +101 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */
|
|
2
|
+
.tabs {
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
.tabs-list {
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
.tabs-list--transparent {
|
|
10
|
+
border-bottom-style: var(--tw-border-style);
|
|
11
|
+
border-bottom-width: 1px;
|
|
12
|
+
border-color: var(--color-border);
|
|
13
|
+
}
|
|
14
|
+
.tabs-list--filled {
|
|
15
|
+
background-color: var(--color-background-sunken);
|
|
16
|
+
--tw-inset-shadow: inset 0 1px 1px var(--tw-inset-shadow-color, rgb(0 0 0 / 0.05));
|
|
17
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
border-radius: var(--radius-md, 0.375rem);
|
|
20
|
+
}
|
|
21
|
+
.tabs-trigger--filled {
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding-inline: calc(0.25rem * 3);
|
|
24
|
+
padding-block: calc(0.25rem * 1.5);
|
|
25
|
+
color: var(--color-text-secondary);
|
|
26
|
+
}
|
|
27
|
+
.tabs-icon {
|
|
28
|
+
color: inherit;
|
|
29
|
+
}
|
|
30
|
+
.tabs-list .tabs-trigger--filled {
|
|
31
|
+
&[data-state="active"] {
|
|
32
|
+
color: var(--color-button-primary-text);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
.tabs-list .tabs-trigger--transparent {
|
|
36
|
+
&[data-state="active"] {
|
|
37
|
+
color: var(--color-text-primary);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
.active-tab-indicator {
|
|
41
|
+
position: absolute;
|
|
42
|
+
z-index: -1;
|
|
43
|
+
width: 100%;
|
|
44
|
+
background-color: var(--color-button-primary-fill);
|
|
45
|
+
}
|
|
46
|
+
.active-tab-indicator--filled {
|
|
47
|
+
inset: calc(0.25rem * 0);
|
|
48
|
+
height: 100%;
|
|
49
|
+
border-radius: 0.25rem;
|
|
50
|
+
}
|
|
51
|
+
.active-tab-indicator--transparent {
|
|
52
|
+
height: calc(0.25rem * 0.5);
|
|
53
|
+
right: calc(0.25rem * 0);
|
|
54
|
+
bottom: calc(0.25rem * 0);
|
|
55
|
+
left: calc(0.25rem * 0);
|
|
56
|
+
}
|
|
57
|
+
.content {
|
|
58
|
+
margin-top: calc(0.25rem * 5);
|
|
59
|
+
:where(& > :not(:last-child)) {
|
|
60
|
+
--tw-space-y-reverse: 0;
|
|
61
|
+
margin-block-start: calc(calc(0.25rem * 6) * var(--tw-space-y-reverse));
|
|
62
|
+
margin-block-end: calc(calc(0.25rem * 6) * calc(1 - var(--tw-space-y-reverse)));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
@property --tw-border-style {
|
|
66
|
+
syntax: "*";
|
|
67
|
+
inherits: false;
|
|
68
|
+
initial-value: solid;
|
|
69
|
+
}
|
|
70
|
+
@property --tw-shadow {
|
|
71
|
+
syntax: "*";
|
|
72
|
+
inherits: false;
|
|
73
|
+
initial-value: 0 0 #0000;
|
|
74
|
+
}
|
|
75
|
+
@property --tw-shadow-color {
|
|
76
|
+
syntax: "*";
|
|
77
|
+
inherits: false;
|
|
78
|
+
}
|
|
79
|
+
@property --tw-shadow-alpha {
|
|
80
|
+
syntax: "<percentage>";
|
|
81
|
+
inherits: false;
|
|
82
|
+
initial-value: 100%;
|
|
83
|
+
}
|
|
84
|
+
@property --tw-inset-shadow {
|
|
85
|
+
syntax: "*";
|
|
86
|
+
inherits: false;
|
|
87
|
+
initial-value: 0 0 #0000;
|
|
88
|
+
}
|
|
89
|
+
@property --tw-inset-shadow-color {
|
|
90
|
+
syntax: "*";
|
|
91
|
+
inherits: false;
|
|
92
|
+
}
|
|
93
|
+
@property --tw-inset-shadow-alpha {
|
|
94
|
+
syntax: "<percentage>";
|
|
95
|
+
inherits: false;
|
|
96
|
+
initial-value: 100%;
|
|
97
|
+
}
|
|
98
|
+
@property --tw-ring-color {
|
|
99
|
+
syntax: "*";
|
|
100
|
+
inherits: false;
|
|
101
|
+
}
|
|
102
|
+
@property --tw-ring-shadow {
|
|
103
|
+
syntax: "*";
|
|
104
|
+
inherits: false;
|
|
105
|
+
initial-value: 0 0 #0000;
|
|
106
|
+
}
|
|
107
|
+
@property --tw-inset-ring-color {
|
|
108
|
+
syntax: "*";
|
|
109
|
+
inherits: false;
|
|
110
|
+
}
|
|
111
|
+
@property --tw-inset-ring-shadow {
|
|
112
|
+
syntax: "*";
|
|
113
|
+
inherits: false;
|
|
114
|
+
initial-value: 0 0 #0000;
|
|
115
|
+
}
|
|
116
|
+
@property --tw-ring-inset {
|
|
117
|
+
syntax: "*";
|
|
118
|
+
inherits: false;
|
|
119
|
+
}
|
|
120
|
+
@property --tw-ring-offset-width {
|
|
121
|
+
syntax: "<length>";
|
|
122
|
+
inherits: false;
|
|
123
|
+
initial-value: 0px;
|
|
124
|
+
}
|
|
125
|
+
@property --tw-ring-offset-color {
|
|
126
|
+
syntax: "*";
|
|
127
|
+
inherits: false;
|
|
128
|
+
initial-value: #fff;
|
|
129
|
+
}
|
|
130
|
+
@property --tw-ring-offset-shadow {
|
|
131
|
+
syntax: "*";
|
|
132
|
+
inherits: false;
|
|
133
|
+
initial-value: 0 0 #0000;
|
|
134
|
+
}
|
|
135
|
+
@property --tw-space-y-reverse {
|
|
136
|
+
syntax: "*";
|
|
137
|
+
inherits: false;
|
|
138
|
+
initial-value: 0;
|
|
139
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */
|
|
2
|
+
.textarea {
|
|
3
|
+
display: flex;
|
|
4
|
+
padding-inline: calc(0.25rem * 3);
|
|
5
|
+
padding-block: calc(0.25rem * 2);
|
|
6
|
+
min-height: calc(0.25rem * 20);
|
|
7
|
+
width: 100%;
|
|
8
|
+
border-radius: var(--radius-md, 0.375rem);
|
|
9
|
+
border-style: var(--tw-border-style);
|
|
10
|
+
border-width: 1px;
|
|
11
|
+
border-color: var(--color-border);
|
|
12
|
+
background-color: var(--color-background);
|
|
13
|
+
font-size: 1rem;
|
|
14
|
+
line-height: var(--tw-leading, calc(1.5 / 1));
|
|
15
|
+
color: var(--color-text-primary);
|
|
16
|
+
@media (width >= 48rem) {
|
|
17
|
+
font-size: 0.875rem;
|
|
18
|
+
line-height: var(--tw-leading, calc(1.25 / 0.875));
|
|
19
|
+
}
|
|
20
|
+
&::placeholder {
|
|
21
|
+
color: var(--color-text-secondary);
|
|
22
|
+
}
|
|
23
|
+
--tw-ring-offset-color: var(--color-background);
|
|
24
|
+
&:focus-visible {
|
|
25
|
+
--tw-ring-color: var(--color-focus-ring);
|
|
26
|
+
}
|
|
27
|
+
&:focus-visible {
|
|
28
|
+
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
|
29
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
30
|
+
}
|
|
31
|
+
&:focus-visible {
|
|
32
|
+
--tw-ring-offset-width: 2px;
|
|
33
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
34
|
+
}
|
|
35
|
+
&:focus-visible {
|
|
36
|
+
--tw-outline-style: none;
|
|
37
|
+
outline-style: none;
|
|
38
|
+
}
|
|
39
|
+
&:disabled {
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
}
|
|
42
|
+
&:disabled {
|
|
43
|
+
opacity: 50%;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
@property --tw-border-style {
|
|
47
|
+
syntax: "*";
|
|
48
|
+
inherits: false;
|
|
49
|
+
initial-value: solid;
|
|
50
|
+
}
|
|
51
|
+
@property --tw-shadow {
|
|
52
|
+
syntax: "*";
|
|
53
|
+
inherits: false;
|
|
54
|
+
initial-value: 0 0 #0000;
|
|
55
|
+
}
|
|
56
|
+
@property --tw-shadow-color {
|
|
57
|
+
syntax: "*";
|
|
58
|
+
inherits: false;
|
|
59
|
+
}
|
|
60
|
+
@property --tw-shadow-alpha {
|
|
61
|
+
syntax: "<percentage>";
|
|
62
|
+
inherits: false;
|
|
63
|
+
initial-value: 100%;
|
|
64
|
+
}
|
|
65
|
+
@property --tw-inset-shadow {
|
|
66
|
+
syntax: "*";
|
|
67
|
+
inherits: false;
|
|
68
|
+
initial-value: 0 0 #0000;
|
|
69
|
+
}
|
|
70
|
+
@property --tw-inset-shadow-color {
|
|
71
|
+
syntax: "*";
|
|
72
|
+
inherits: false;
|
|
73
|
+
}
|
|
74
|
+
@property --tw-inset-shadow-alpha {
|
|
75
|
+
syntax: "<percentage>";
|
|
76
|
+
inherits: false;
|
|
77
|
+
initial-value: 100%;
|
|
78
|
+
}
|
|
79
|
+
@property --tw-ring-color {
|
|
80
|
+
syntax: "*";
|
|
81
|
+
inherits: false;
|
|
82
|
+
}
|
|
83
|
+
@property --tw-ring-shadow {
|
|
84
|
+
syntax: "*";
|
|
85
|
+
inherits: false;
|
|
86
|
+
initial-value: 0 0 #0000;
|
|
87
|
+
}
|
|
88
|
+
@property --tw-inset-ring-color {
|
|
89
|
+
syntax: "*";
|
|
90
|
+
inherits: false;
|
|
91
|
+
}
|
|
92
|
+
@property --tw-inset-ring-shadow {
|
|
93
|
+
syntax: "*";
|
|
94
|
+
inherits: false;
|
|
95
|
+
initial-value: 0 0 #0000;
|
|
96
|
+
}
|
|
97
|
+
@property --tw-ring-inset {
|
|
98
|
+
syntax: "*";
|
|
99
|
+
inherits: false;
|
|
100
|
+
}
|
|
101
|
+
@property --tw-ring-offset-width {
|
|
102
|
+
syntax: "<length>";
|
|
103
|
+
inherits: false;
|
|
104
|
+
initial-value: 0px;
|
|
105
|
+
}
|
|
106
|
+
@property --tw-ring-offset-color {
|
|
107
|
+
syntax: "*";
|
|
108
|
+
inherits: false;
|
|
109
|
+
initial-value: #fff;
|
|
110
|
+
}
|
|
111
|
+
@property --tw-ring-offset-shadow {
|
|
112
|
+
syntax: "*";
|
|
113
|
+
inherits: false;
|
|
114
|
+
initial-value: 0 0 #0000;
|
|
115
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/theme/lib/utils.ts
|
|
4
|
+
var STORAGE_KEY = "equality-theme";
|
|
5
|
+
var UPDATE_EVENT = "equality-theme-change";
|
|
6
|
+
var FALLBACK_THEME = "light";
|
|
7
|
+
var getFallbackTheme = (options = {}) => {
|
|
8
|
+
const { canFallbackToBrowserSettings = false } = options;
|
|
9
|
+
if (typeof window === "undefined" || !canFallbackToBrowserSettings) {
|
|
10
|
+
return FALLBACK_THEME;
|
|
11
|
+
}
|
|
12
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
13
|
+
};
|
|
14
|
+
var getDefaultTheme = () => {
|
|
15
|
+
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
16
|
+
if (themeProviderRootElement) {
|
|
17
|
+
return themeProviderRootElement.getAttribute("data-equality-theme") || void 0;
|
|
18
|
+
} else {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var getThemeFromLocalStorage = () => {
|
|
23
|
+
const safeReadStorage = (key) => {
|
|
24
|
+
try {
|
|
25
|
+
return window.localStorage.getItem(key);
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const themeLocalStorageValue = safeReadStorage(STORAGE_KEY);
|
|
31
|
+
return themeLocalStorageValue;
|
|
32
|
+
};
|
|
33
|
+
var getThemeFromWindow = () => {
|
|
34
|
+
return window.__equalityTheme;
|
|
35
|
+
};
|
|
36
|
+
var applyThemeToDom = (theme) => {
|
|
37
|
+
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
38
|
+
if (themeProviderRootElement) {
|
|
39
|
+
themeProviderRootElement.setAttribute("data-equality-theme", theme);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var setThemeInLocalStorage = (theme) => {
|
|
43
|
+
try {
|
|
44
|
+
window.localStorage.setItem(STORAGE_KEY, theme);
|
|
45
|
+
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
46
|
+
} catch {
|
|
47
|
+
console.error("Failed to set theme in localStorage");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var setThemeOnWindow = (theme) => {
|
|
51
|
+
window.__equalityTheme = theme;
|
|
52
|
+
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
53
|
+
};
|
|
54
|
+
var setTheme = (theme) => {
|
|
55
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
56
|
+
if (isUsingLocalStorage) {
|
|
57
|
+
setThemeInLocalStorage(theme);
|
|
58
|
+
} else {
|
|
59
|
+
setThemeOnWindow(theme);
|
|
60
|
+
}
|
|
61
|
+
applyThemeToDom(theme);
|
|
62
|
+
};
|
|
63
|
+
var getCurrentThemeState = (options = {}) => {
|
|
64
|
+
const { canFallbackToBrowserSettings = false } = options;
|
|
65
|
+
if (typeof window === "undefined") {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
69
|
+
const storedTheme = isUsingLocalStorage ? getThemeFromLocalStorage() : getThemeFromWindow();
|
|
70
|
+
const theme = storedTheme || getDefaultTheme() || getFallbackTheme({ canFallbackToBrowserSettings });
|
|
71
|
+
if (!storedTheme) {
|
|
72
|
+
setTheme(theme);
|
|
73
|
+
}
|
|
74
|
+
return theme;
|
|
75
|
+
};
|
|
76
|
+
var initializeTheme = (options = {}) => {
|
|
77
|
+
const { shouldStoreTheme = false } = options;
|
|
78
|
+
window.__equalityIsUsingLocalStorage = shouldStoreTheme;
|
|
79
|
+
const theme = getCurrentThemeState({ canFallbackToBrowserSettings: true });
|
|
80
|
+
if (theme) applyThemeToDom(theme);
|
|
81
|
+
};
|
|
82
|
+
var subscribeToThemeChange = (listener) => {
|
|
83
|
+
if (typeof window === "undefined") {
|
|
84
|
+
return () => {
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
88
|
+
if (isUsingLocalStorage) {
|
|
89
|
+
const storageListener = (event) => {
|
|
90
|
+
if (event.key === STORAGE_KEY) listener();
|
|
91
|
+
};
|
|
92
|
+
const updateListener = () => listener();
|
|
93
|
+
window.addEventListener("storage", storageListener);
|
|
94
|
+
window.addEventListener(UPDATE_EVENT, updateListener);
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener("storage", storageListener);
|
|
97
|
+
window.removeEventListener(UPDATE_EVENT, updateListener);
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
const windowListener = () => {
|
|
101
|
+
listener();
|
|
102
|
+
};
|
|
103
|
+
window.addEventListener(UPDATE_EVENT, windowListener);
|
|
104
|
+
return () => {
|
|
105
|
+
window.removeEventListener(UPDATE_EVENT, windowListener);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
exports.FALLBACK_THEME = FALLBACK_THEME;
|
|
111
|
+
exports.STORAGE_KEY = STORAGE_KEY;
|
|
112
|
+
exports.UPDATE_EVENT = UPDATE_EVENT;
|
|
113
|
+
exports.applyThemeToDom = applyThemeToDom;
|
|
114
|
+
exports.getCurrentThemeState = getCurrentThemeState;
|
|
115
|
+
exports.getDefaultTheme = getDefaultTheme;
|
|
116
|
+
exports.getFallbackTheme = getFallbackTheme;
|
|
117
|
+
exports.getThemeFromLocalStorage = getThemeFromLocalStorage;
|
|
118
|
+
exports.getThemeFromWindow = getThemeFromWindow;
|
|
119
|
+
exports.initializeTheme = initializeTheme;
|
|
120
|
+
exports.setTheme = setTheme;
|
|
121
|
+
exports.setThemeInLocalStorage = setThemeInLocalStorage;
|
|
122
|
+
exports.setThemeOnWindow = setThemeOnWindow;
|
|
123
|
+
exports.subscribeToThemeChange = subscribeToThemeChange;
|
|
124
|
+
//# sourceMappingURL=utils.cjs.map
|
|
125
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/theme/lib/utils.ts"],"names":[],"mappings":";;;AAAA,IAAM,WAAA,GAAc;AACpB,IAAM,YAAA,GAAe;AACrB,IAAM,cAAA,GAAiB;AAevB,IAAM,gBAAA,GAAmB,CAAC,OAAA,GAAmC,EAAC,KAAa;AACzE,EAAA,MAAM,EAAE,4BAAA,GAA+B,KAAA,EAAM,GAAI,OAAA;AAEjD,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,CAAC,4BAAA,EAA8B;AAClE,IAAA,OAAO,cAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA,CAAO,UAAA,CAAW,8BAA8B,CAAA,CAAE,UAAU,MAAA,GAAS,OAAA;AAC9E;AAEA,IAAM,kBAAkB,MAAyB;AAC/C,EAAA,MAAM,wBAAA,GACJ,QAAA,CAAS,aAAA,CAAc,uBAAuB,KAAK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AAClC;AAEA,IAAM,sBAAA,GAAyB,CAAC,QAAA,KAAyB;AACvD,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,MAAM;AAAA,IAAC,CAAA;AAAA,EAChB;AAEA,EAAA,MAAM,sBAAsB,MAAA,CAAO,6BAAA;AACnC,EAAA,IAAI,mBAAA,EAAqB;AAEvB,IAAA,MAAM,eAAA,GAAkB,CAAC,KAAA,KAAwB;AAC/C,MAAA,IAAI,KAAA,CAAM,GAAA,KAAQ,WAAA,EAAa,QAAA,EAAS;AAAA,IAC1C,CAAA;AACA,IAAA,MAAM,cAAA,GAAiB,MAAM,QAAA,EAAS;AAEtC,IAAA,MAAA,CAAO,gBAAA,CAAiB,WAAW,eAAe,CAAA;AAClD,IAAA,MAAA,CAAO,gBAAA,CAAiB,cAAc,cAAc,CAAA;AACpD,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,eAAe,CAAA;AACrD,MAAA,MAAA,CAAO,mBAAA,CAAoB,cAAc,cAAc,CAAA;AAAA,IACzD,CAAA;AAAA,EACF,CAAA,MAAO;AAEL,IAAA,MAAM,iBAAiB,MAAM;AAC3B,MAAA,QAAA,EAAS;AAAA,IACX,CAAA;AACA,IAAA,MAAA,CAAO,gBAAA,CAAiB,cAAc,cAAc,CAAA;AACpD,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,cAAc,cAAc,CAAA;AAAA,IACzD,CAAA;AAAA,EACF;AACF","file":"utils.cjs","sourcesContent":["const STORAGE_KEY = 'equality-theme';\nconst UPDATE_EVENT = 'equality-theme-change';\nconst FALLBACK_THEME = 'light';\ntype Theme = 'light' | 'dark';\n\ninterface InitializeThemeOptions {\n shouldStoreTheme?: boolean;\n}\n\ninterface GetCurrentThemeStateOptions {\n canFallbackToBrowserSettings?: boolean;\n}\n\ninterface GetFallbackThemeOptions {\n canFallbackToBrowserSettings?: boolean;\n}\n\nconst getFallbackTheme = (options: GetFallbackThemeOptions = {}): Theme => {\n const { canFallbackToBrowserSettings = false } = options;\n\n if (typeof window === 'undefined' || !canFallbackToBrowserSettings) {\n return FALLBACK_THEME;\n }\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n};\n\nconst getDefaultTheme = (): Theme | undefined => {\n const themeProviderRootElement =\n document.querySelector('[data-equality-theme]') || document.documentElement;\n if (themeProviderRootElement) {\n return (themeProviderRootElement.getAttribute('data-equality-theme') || undefined) as\n | Theme\n | undefined;\n } else {\n return undefined;\n }\n};\n\nconst getThemeFromLocalStorage = (): Theme | null => {\n const safeReadStorage = (key: string) => {\n try {\n return window.localStorage.getItem(key) as Theme | null;\n } catch {\n return null;\n }\n };\n\n const themeLocalStorageValue = safeReadStorage(STORAGE_KEY);\n return themeLocalStorageValue;\n};\n\nconst getThemeFromWindow = (): Theme | undefined => {\n return window.__equalityTheme as Theme | undefined;\n};\n\nconst applyThemeToDom = (theme: Theme) => {\n const themeProviderRootElement =\n document.querySelector('[data-equality-theme]') || document.documentElement;\n if (themeProviderRootElement) {\n themeProviderRootElement.setAttribute('data-equality-theme', theme); // This sets the theme that controls the styling color variables used\n }\n};\n\nconst setThemeInLocalStorage = (theme: Theme) => {\n try {\n window.localStorage.setItem(STORAGE_KEY, theme);\n window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));\n } catch {\n console.error('Failed to set theme in localStorage');\n }\n};\n\nconst setThemeOnWindow = (theme: Theme) => {\n window.__equalityTheme = theme;\n window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));\n};\n\nconst setTheme = (theme: Theme) => {\n const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;\n if (isUsingLocalStorage) {\n setThemeInLocalStorage(theme);\n } else {\n setThemeOnWindow(theme);\n }\n applyThemeToDom(theme);\n};\n\nconst getCurrentThemeState = (options: GetCurrentThemeStateOptions = {}) => {\n const { canFallbackToBrowserSettings = false } = options;\n\n // First, use stored theme if available\n // Then, use default theme set on data-equality-theme attribute if available\n // Then, use fallback theme from browser settings if available\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;\n const storedTheme = isUsingLocalStorage ? getThemeFromLocalStorage() : getThemeFromWindow();\n const theme =\n storedTheme || getDefaultTheme() || getFallbackTheme({ canFallbackToBrowserSettings });\n if (!storedTheme) {\n setTheme(theme);\n }\n return theme;\n};\n\nconst initializeTheme = (options: InitializeThemeOptions = {}) => {\n // This is only needed if the initial state needs to be dynamic\n const { shouldStoreTheme = false } = options;\n\n window.__equalityIsUsingLocalStorage = shouldStoreTheme;\n const theme = getCurrentThemeState({ canFallbackToBrowserSettings: true });\n if (theme) applyThemeToDom(theme);\n};\n\nconst subscribeToThemeChange = (listener: () => void) => {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;\n if (isUsingLocalStorage) {\n // use localStorage\n const storageListener = (event: StorageEvent) => {\n if (event.key === STORAGE_KEY) listener();\n };\n const updateListener = () => listener();\n\n window.addEventListener('storage', storageListener);\n window.addEventListener(UPDATE_EVENT, updateListener);\n return () => {\n window.removeEventListener('storage', storageListener);\n window.removeEventListener(UPDATE_EVENT, updateListener);\n };\n } else {\n // use window object\n const windowListener = () => {\n listener();\n };\n window.addEventListener(UPDATE_EVENT, windowListener);\n return () => {\n window.removeEventListener(UPDATE_EVENT, windowListener);\n };\n }\n};\n\nexport {\n Theme,\n InitializeThemeOptions,\n STORAGE_KEY,\n UPDATE_EVENT,\n FALLBACK_THEME,\n getCurrentThemeState,\n applyThemeToDom,\n initializeTheme,\n setTheme,\n subscribeToThemeChange,\n getFallbackTheme,\n getDefaultTheme,\n getThemeFromLocalStorage,\n getThemeFromWindow,\n setThemeInLocalStorage,\n setThemeOnWindow,\n};\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const STORAGE_KEY = "equality-theme";
|
|
2
|
+
declare const UPDATE_EVENT = "equality-theme-change";
|
|
3
|
+
declare const FALLBACK_THEME = "light";
|
|
4
|
+
type Theme = 'light' | 'dark';
|
|
5
|
+
interface InitializeThemeOptions {
|
|
6
|
+
shouldStoreTheme?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface GetCurrentThemeStateOptions {
|
|
9
|
+
canFallbackToBrowserSettings?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface GetFallbackThemeOptions {
|
|
12
|
+
canFallbackToBrowserSettings?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const getFallbackTheme: (options?: GetFallbackThemeOptions) => Theme;
|
|
15
|
+
declare const getDefaultTheme: () => Theme | undefined;
|
|
16
|
+
declare const getThemeFromLocalStorage: () => Theme | null;
|
|
17
|
+
declare const getThemeFromWindow: () => Theme | undefined;
|
|
18
|
+
declare const applyThemeToDom: (theme: Theme) => void;
|
|
19
|
+
declare const setThemeInLocalStorage: (theme: Theme) => void;
|
|
20
|
+
declare const setThemeOnWindow: (theme: Theme) => void;
|
|
21
|
+
declare const setTheme: (theme: Theme) => void;
|
|
22
|
+
declare const getCurrentThemeState: (options?: GetCurrentThemeStateOptions) => Theme | undefined;
|
|
23
|
+
declare const initializeTheme: (options?: InitializeThemeOptions) => void;
|
|
24
|
+
declare const subscribeToThemeChange: (listener: () => void) => () => void;
|
|
25
|
+
|
|
26
|
+
export { FALLBACK_THEME, type InitializeThemeOptions, STORAGE_KEY, type Theme, UPDATE_EVENT, applyThemeToDom, getCurrentThemeState, getDefaultTheme, getFallbackTheme, getThemeFromLocalStorage, getThemeFromWindow, initializeTheme, setTheme, setThemeInLocalStorage, setThemeOnWindow, subscribeToThemeChange };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const STORAGE_KEY = "equality-theme";
|
|
2
|
+
declare const UPDATE_EVENT = "equality-theme-change";
|
|
3
|
+
declare const FALLBACK_THEME = "light";
|
|
4
|
+
type Theme = 'light' | 'dark';
|
|
5
|
+
interface InitializeThemeOptions {
|
|
6
|
+
shouldStoreTheme?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface GetCurrentThemeStateOptions {
|
|
9
|
+
canFallbackToBrowserSettings?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface GetFallbackThemeOptions {
|
|
12
|
+
canFallbackToBrowserSettings?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const getFallbackTheme: (options?: GetFallbackThemeOptions) => Theme;
|
|
15
|
+
declare const getDefaultTheme: () => Theme | undefined;
|
|
16
|
+
declare const getThemeFromLocalStorage: () => Theme | null;
|
|
17
|
+
declare const getThemeFromWindow: () => Theme | undefined;
|
|
18
|
+
declare const applyThemeToDom: (theme: Theme) => void;
|
|
19
|
+
declare const setThemeInLocalStorage: (theme: Theme) => void;
|
|
20
|
+
declare const setThemeOnWindow: (theme: Theme) => void;
|
|
21
|
+
declare const setTheme: (theme: Theme) => void;
|
|
22
|
+
declare const getCurrentThemeState: (options?: GetCurrentThemeStateOptions) => Theme | undefined;
|
|
23
|
+
declare const initializeTheme: (options?: InitializeThemeOptions) => void;
|
|
24
|
+
declare const subscribeToThemeChange: (listener: () => void) => () => void;
|
|
25
|
+
|
|
26
|
+
export { FALLBACK_THEME, type InitializeThemeOptions, STORAGE_KEY, type Theme, UPDATE_EVENT, applyThemeToDom, getCurrentThemeState, getDefaultTheme, getFallbackTheme, getThemeFromLocalStorage, getThemeFromWindow, initializeTheme, setTheme, setThemeInLocalStorage, setThemeOnWindow, subscribeToThemeChange };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/theme/lib/utils.ts
|
|
2
|
+
var STORAGE_KEY = "equality-theme";
|
|
3
|
+
var UPDATE_EVENT = "equality-theme-change";
|
|
4
|
+
var FALLBACK_THEME = "light";
|
|
5
|
+
var getFallbackTheme = (options = {}) => {
|
|
6
|
+
const { canFallbackToBrowserSettings = false } = options;
|
|
7
|
+
if (typeof window === "undefined" || !canFallbackToBrowserSettings) {
|
|
8
|
+
return FALLBACK_THEME;
|
|
9
|
+
}
|
|
10
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11
|
+
};
|
|
12
|
+
var getDefaultTheme = () => {
|
|
13
|
+
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
14
|
+
if (themeProviderRootElement) {
|
|
15
|
+
return themeProviderRootElement.getAttribute("data-equality-theme") || void 0;
|
|
16
|
+
} else {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var getThemeFromLocalStorage = () => {
|
|
21
|
+
const safeReadStorage = (key) => {
|
|
22
|
+
try {
|
|
23
|
+
return window.localStorage.getItem(key);
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const themeLocalStorageValue = safeReadStorage(STORAGE_KEY);
|
|
29
|
+
return themeLocalStorageValue;
|
|
30
|
+
};
|
|
31
|
+
var getThemeFromWindow = () => {
|
|
32
|
+
return window.__equalityTheme;
|
|
33
|
+
};
|
|
34
|
+
var applyThemeToDom = (theme) => {
|
|
35
|
+
const themeProviderRootElement = document.querySelector("[data-equality-theme]") || document.documentElement;
|
|
36
|
+
if (themeProviderRootElement) {
|
|
37
|
+
themeProviderRootElement.setAttribute("data-equality-theme", theme);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var setThemeInLocalStorage = (theme) => {
|
|
41
|
+
try {
|
|
42
|
+
window.localStorage.setItem(STORAGE_KEY, theme);
|
|
43
|
+
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
44
|
+
} catch {
|
|
45
|
+
console.error("Failed to set theme in localStorage");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var setThemeOnWindow = (theme) => {
|
|
49
|
+
window.__equalityTheme = theme;
|
|
50
|
+
window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));
|
|
51
|
+
};
|
|
52
|
+
var setTheme = (theme) => {
|
|
53
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
54
|
+
if (isUsingLocalStorage) {
|
|
55
|
+
setThemeInLocalStorage(theme);
|
|
56
|
+
} else {
|
|
57
|
+
setThemeOnWindow(theme);
|
|
58
|
+
}
|
|
59
|
+
applyThemeToDom(theme);
|
|
60
|
+
};
|
|
61
|
+
var getCurrentThemeState = (options = {}) => {
|
|
62
|
+
const { canFallbackToBrowserSettings = false } = options;
|
|
63
|
+
if (typeof window === "undefined") {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
67
|
+
const storedTheme = isUsingLocalStorage ? getThemeFromLocalStorage() : getThemeFromWindow();
|
|
68
|
+
const theme = storedTheme || getDefaultTheme() || getFallbackTheme({ canFallbackToBrowserSettings });
|
|
69
|
+
if (!storedTheme) {
|
|
70
|
+
setTheme(theme);
|
|
71
|
+
}
|
|
72
|
+
return theme;
|
|
73
|
+
};
|
|
74
|
+
var initializeTheme = (options = {}) => {
|
|
75
|
+
const { shouldStoreTheme = false } = options;
|
|
76
|
+
window.__equalityIsUsingLocalStorage = shouldStoreTheme;
|
|
77
|
+
const theme = getCurrentThemeState({ canFallbackToBrowserSettings: true });
|
|
78
|
+
if (theme) applyThemeToDom(theme);
|
|
79
|
+
};
|
|
80
|
+
var subscribeToThemeChange = (listener) => {
|
|
81
|
+
if (typeof window === "undefined") {
|
|
82
|
+
return () => {
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;
|
|
86
|
+
if (isUsingLocalStorage) {
|
|
87
|
+
const storageListener = (event) => {
|
|
88
|
+
if (event.key === STORAGE_KEY) listener();
|
|
89
|
+
};
|
|
90
|
+
const updateListener = () => listener();
|
|
91
|
+
window.addEventListener("storage", storageListener);
|
|
92
|
+
window.addEventListener(UPDATE_EVENT, updateListener);
|
|
93
|
+
return () => {
|
|
94
|
+
window.removeEventListener("storage", storageListener);
|
|
95
|
+
window.removeEventListener(UPDATE_EVENT, updateListener);
|
|
96
|
+
};
|
|
97
|
+
} else {
|
|
98
|
+
const windowListener = () => {
|
|
99
|
+
listener();
|
|
100
|
+
};
|
|
101
|
+
window.addEventListener(UPDATE_EVENT, windowListener);
|
|
102
|
+
return () => {
|
|
103
|
+
window.removeEventListener(UPDATE_EVENT, windowListener);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export { FALLBACK_THEME, STORAGE_KEY, UPDATE_EVENT, applyThemeToDom, getCurrentThemeState, getDefaultTheme, getFallbackTheme, getThemeFromLocalStorage, getThemeFromWindow, initializeTheme, setTheme, setThemeInLocalStorage, setThemeOnWindow, subscribeToThemeChange };
|
|
109
|
+
//# sourceMappingURL=utils.js.map
|
|
110
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/theme/lib/utils.ts"],"names":[],"mappings":";AAAA,IAAM,WAAA,GAAc;AACpB,IAAM,YAAA,GAAe;AACrB,IAAM,cAAA,GAAiB;AAevB,IAAM,gBAAA,GAAmB,CAAC,OAAA,GAAmC,EAAC,KAAa;AACzE,EAAA,MAAM,EAAE,4BAAA,GAA+B,KAAA,EAAM,GAAI,OAAA;AAEjD,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,CAAC,4BAAA,EAA8B;AAClE,IAAA,OAAO,cAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA,CAAO,UAAA,CAAW,8BAA8B,CAAA,CAAE,UAAU,MAAA,GAAS,OAAA;AAC9E;AAEA,IAAM,kBAAkB,MAAyB;AAC/C,EAAA,MAAM,wBAAA,GACJ,QAAA,CAAS,aAAA,CAAc,uBAAuB,KAAK,QAAA,CAAS,eAAA;AAC9D,EAAA,IAAI,wBAAA,EAA0B;AAC5B,IAAA,OAAQ,wBAAA,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,WAAA,EAAa;AACjC,IAAA,OAAO,MAAM;AAAA,IAAC,CAAA;AAAA,EAChB;AAEA,EAAA,MAAM,sBAAsB,MAAA,CAAO,6BAAA;AACnC,EAAA,IAAI,mBAAA,EAAqB;AAEvB,IAAA,MAAM,eAAA,GAAkB,CAAC,KAAA,KAAwB;AAC/C,MAAA,IAAI,KAAA,CAAM,GAAA,KAAQ,WAAA,EAAa,QAAA,EAAS;AAAA,IAC1C,CAAA;AACA,IAAA,MAAM,cAAA,GAAiB,MAAM,QAAA,EAAS;AAEtC,IAAA,MAAA,CAAO,gBAAA,CAAiB,WAAW,eAAe,CAAA;AAClD,IAAA,MAAA,CAAO,gBAAA,CAAiB,cAAc,cAAc,CAAA;AACpD,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,WAAW,eAAe,CAAA;AACrD,MAAA,MAAA,CAAO,mBAAA,CAAoB,cAAc,cAAc,CAAA;AAAA,IACzD,CAAA;AAAA,EACF,CAAA,MAAO;AAEL,IAAA,MAAM,iBAAiB,MAAM;AAC3B,MAAA,QAAA,EAAS;AAAA,IACX,CAAA;AACA,IAAA,MAAA,CAAO,gBAAA,CAAiB,cAAc,cAAc,CAAA;AACpD,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,cAAc,cAAc,CAAA;AAAA,IACzD,CAAA;AAAA,EACF;AACF","file":"utils.js","sourcesContent":["const STORAGE_KEY = 'equality-theme';\nconst UPDATE_EVENT = 'equality-theme-change';\nconst FALLBACK_THEME = 'light';\ntype Theme = 'light' | 'dark';\n\ninterface InitializeThemeOptions {\n shouldStoreTheme?: boolean;\n}\n\ninterface GetCurrentThemeStateOptions {\n canFallbackToBrowserSettings?: boolean;\n}\n\ninterface GetFallbackThemeOptions {\n canFallbackToBrowserSettings?: boolean;\n}\n\nconst getFallbackTheme = (options: GetFallbackThemeOptions = {}): Theme => {\n const { canFallbackToBrowserSettings = false } = options;\n\n if (typeof window === 'undefined' || !canFallbackToBrowserSettings) {\n return FALLBACK_THEME;\n }\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n};\n\nconst getDefaultTheme = (): Theme | undefined => {\n const themeProviderRootElement =\n document.querySelector('[data-equality-theme]') || document.documentElement;\n if (themeProviderRootElement) {\n return (themeProviderRootElement.getAttribute('data-equality-theme') || undefined) as\n | Theme\n | undefined;\n } else {\n return undefined;\n }\n};\n\nconst getThemeFromLocalStorage = (): Theme | null => {\n const safeReadStorage = (key: string) => {\n try {\n return window.localStorage.getItem(key) as Theme | null;\n } catch {\n return null;\n }\n };\n\n const themeLocalStorageValue = safeReadStorage(STORAGE_KEY);\n return themeLocalStorageValue;\n};\n\nconst getThemeFromWindow = (): Theme | undefined => {\n return window.__equalityTheme as Theme | undefined;\n};\n\nconst applyThemeToDom = (theme: Theme) => {\n const themeProviderRootElement =\n document.querySelector('[data-equality-theme]') || document.documentElement;\n if (themeProviderRootElement) {\n themeProviderRootElement.setAttribute('data-equality-theme', theme); // This sets the theme that controls the styling color variables used\n }\n};\n\nconst setThemeInLocalStorage = (theme: Theme) => {\n try {\n window.localStorage.setItem(STORAGE_KEY, theme);\n window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));\n } catch {\n console.error('Failed to set theme in localStorage');\n }\n};\n\nconst setThemeOnWindow = (theme: Theme) => {\n window.__equalityTheme = theme;\n window.dispatchEvent(new CustomEvent(UPDATE_EVENT, { detail: theme }));\n};\n\nconst setTheme = (theme: Theme) => {\n const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;\n if (isUsingLocalStorage) {\n setThemeInLocalStorage(theme);\n } else {\n setThemeOnWindow(theme);\n }\n applyThemeToDom(theme);\n};\n\nconst getCurrentThemeState = (options: GetCurrentThemeStateOptions = {}) => {\n const { canFallbackToBrowserSettings = false } = options;\n\n // First, use stored theme if available\n // Then, use default theme set on data-equality-theme attribute if available\n // Then, use fallback theme from browser settings if available\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;\n const storedTheme = isUsingLocalStorage ? getThemeFromLocalStorage() : getThemeFromWindow();\n const theme =\n storedTheme || getDefaultTheme() || getFallbackTheme({ canFallbackToBrowserSettings });\n if (!storedTheme) {\n setTheme(theme);\n }\n return theme;\n};\n\nconst initializeTheme = (options: InitializeThemeOptions = {}) => {\n // This is only needed if the initial state needs to be dynamic\n const { shouldStoreTheme = false } = options;\n\n window.__equalityIsUsingLocalStorage = shouldStoreTheme;\n const theme = getCurrentThemeState({ canFallbackToBrowserSettings: true });\n if (theme) applyThemeToDom(theme);\n};\n\nconst subscribeToThemeChange = (listener: () => void) => {\n if (typeof window === 'undefined') {\n return () => {};\n }\n\n const isUsingLocalStorage = window.__equalityIsUsingLocalStorage;\n if (isUsingLocalStorage) {\n // use localStorage\n const storageListener = (event: StorageEvent) => {\n if (event.key === STORAGE_KEY) listener();\n };\n const updateListener = () => listener();\n\n window.addEventListener('storage', storageListener);\n window.addEventListener(UPDATE_EVENT, updateListener);\n return () => {\n window.removeEventListener('storage', storageListener);\n window.removeEventListener(UPDATE_EVENT, updateListener);\n };\n } else {\n // use window object\n const windowListener = () => {\n listener();\n };\n window.addEventListener(UPDATE_EVENT, windowListener);\n return () => {\n window.removeEventListener(UPDATE_EVENT, windowListener);\n };\n }\n};\n\nexport {\n Theme,\n InitializeThemeOptions,\n STORAGE_KEY,\n UPDATE_EVENT,\n FALLBACK_THEME,\n getCurrentThemeState,\n applyThemeToDom,\n initializeTheme,\n setTheme,\n subscribeToThemeChange,\n getFallbackTheme,\n getDefaultTheme,\n getThemeFromLocalStorage,\n getThemeFromWindow,\n setThemeInLocalStorage,\n setThemeOnWindow,\n};\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@custom-variant dark (&:where(html[data-equality-theme=dark], html[data-equality-theme=dark] *, [data-equality-theme=dark] .root, [data-equality-theme=dark] .root *));
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
/* RADIUS */
|
|
5
|
+
--radius-md: 0.375rem;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@theme inline {
|
|
9
|
+
/* FONT FAMILY */
|
|
10
|
+
--font-sans: 'TWK Lausanne', 'Inter', sans-serif;
|
|
11
|
+
|
|
12
|
+
/* FONT SIZE */
|
|
13
|
+
--text-xxs: 0.625rem;
|
|
14
|
+
|
|
15
|
+
/* Z-INDEX */
|
|
16
|
+
--z-index-behind: -1;
|
|
17
|
+
--z-index-base: 0;
|
|
18
|
+
--z-index-above: 10;
|
|
19
|
+
--z-index-overlay: 50;
|
|
20
|
+
--z-index-modal: 50;
|
|
21
|
+
--z-index-dropdown: 50;
|
|
22
|
+
--z-index-highest: 9999;
|
|
23
|
+
|
|
24
|
+
--color-shadow-sunken: rgba(0, 0, 0, 0.05);
|
|
25
|
+
--color-shadow-base: transparent;
|
|
26
|
+
--color-shadow-raised: rgba(0, 0, 0, 0.05);
|
|
27
|
+
--color-shadow-overlay: rgba(0, 0, 0, 0.1);
|
|
28
|
+
--color-shadow-floating: rgba(0, 0, 0, 0.15);
|
|
29
|
+
|
|
30
|
+
/* Animation */
|
|
31
|
+
--animate-grow-in: grow-in 800ms ease-in-out backwards;
|
|
32
|
+
--animate-fade-in: fade-in 800ms ease-in-out backwards;
|
|
33
|
+
|
|
34
|
+
@keyframes grow-in {
|
|
35
|
+
from {
|
|
36
|
+
transform: scaleY(0.75);
|
|
37
|
+
}
|
|
38
|
+
to {
|
|
39
|
+
transform: scaleY(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@keyframes fade-in {
|
|
44
|
+
0% {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
100% {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.styled-horizontal-scrollbar {
|
|
3
|
+
&::-webkit-scrollbar {
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 0.375rem;
|
|
6
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
7
|
+
border-radius: 999px;
|
|
8
|
+
}
|
|
9
|
+
&::-webkit-scrollbar-thumb {
|
|
10
|
+
background-color: #7f738f;
|
|
11
|
+
border-radius: 999px;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.styled-vertical-scrollbar {
|
|
16
|
+
&::-webkit-scrollbar {
|
|
17
|
+
height: 100%;
|
|
18
|
+
width: 0.375rem;
|
|
19
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
20
|
+
border-radius: 999px;
|
|
21
|
+
}
|
|
22
|
+
&::-webkit-scrollbar-thumb {
|
|
23
|
+
background-color: #7f738f;
|
|
24
|
+
border-radius: 999px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|