Skip to content

Commit 18bd1c7

Browse files
fix(ThemeProvider): default colorScheme to global colorScheme
1 parent 68524ac commit 18bd1c7

File tree

3 files changed

+49
-47
lines changed

3 files changed

+49
-47
lines changed

packages/core/css/reset/_theme.css

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,45 @@
2121
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
*/
2323

24-
@layer theme {
24+
@layer theme {
25+
:root {
26+
/* app default primary */
27+
--color-primary: var(--color-denim-500);
28+
--color-accent: var(--color-jade-500);
29+
--color-tint: var(--color-silver-500);
30+
31+
/* default rounding */
32+
--rounding: 0.25rem;
33+
--rounding-cap: 0.25rem;
34+
--gutter: 0.5rem;
35+
36+
/* z levels */
37+
--z-overlay-mask: 25;
38+
--z-overlay: 30;
39+
--z-popover-mask: 45;
40+
--z-popover: 50;
41+
--z-tooltip: 60;
42+
--z-notifications: 60;
43+
}
44+
45+
[data-rounding="sm"] {
46+
/* default rounding */
47+
--rounding: 2px;
48+
--rounding-cap: 2px;
49+
}
50+
51+
[data-rounding="md"] {
52+
/* default rounding */
53+
--rounding: 0.5rem;
54+
--rounding-cap: 0.5rem;
55+
}
56+
57+
[data-rounding="full"] {
58+
/* default rounding */
59+
--rounding: 9999px;
60+
--rounding-cap: 0.5rem;
61+
}
62+
2563
[data-color-scheme="light"] {
2664
--fabric-bg: var(--color-white);
2765
--fabric-text: var(--color-black);
@@ -43,27 +81,7 @@
4381
}
4482
}
4583

46-
@layer base {
47-
:root {
48-
/* app default primary */
49-
--color-primary: var(--color-denim-500);
50-
--color-accent: var(--color-jade-500);
51-
--color-tint: var(--color-silver-500);
52-
53-
/* default rounding */
54-
--rounding: 0.25rem;
55-
--rounding-cap: 0.25rem;
56-
--gutter: 0.5rem;
57-
58-
/* z levels */
59-
--z-overlay-mask: 25;
60-
--z-overlay: 30;
61-
--z-popover-mask: 45;
62-
--z-popover: 50;
63-
--z-tooltip: 60;
64-
--z-notifications: 60;
65-
}
66-
84+
@layer theme {
6785
[data-color-scheme] {
6886
/* primary */
6987
--color-primary-50: color-mix(in oklab, var(--color-primary) 10%, var(--fabric-bg));
@@ -366,28 +384,6 @@
366384
--border-color-light: color-mix(in oklab, var(--color-white) 75%, var(--color-tint));
367385

368386
color: color-mix(in lab, var(--fabric-text) 95%, var(--color-tint));
369-
background-color: color-mix(
370-
in lab,
371-
var(--fabric-bg) 92%,
372-
var(--color-tint)
373-
);
387+
background-color: color-mix(in lab, var(--fabric-bg) 92%, var(--color-tint));
374388
}
375-
376-
[data-rounding="sm"] {
377-
/* default rounding */
378-
--rounding: 2px;
379-
--rounding-cap: 2px;
380-
}
381-
382-
[data-rounding="md"] {
383-
/* default rounding */
384-
--rounding: 0.5rem;
385-
--rounding-cap: 0.5rem;
386-
}
387-
388-
[data-rounding="full"] {
389-
/* default rounding */
390-
--rounding: 9999px;
391-
--rounding-cap: 0.5rem;
392-
}
393-
}
389+
}

packages/core/css/theme/_utilities.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
unicode-bidi: plaintext;
8282
}
8383

84+
@utility flex-auto {
85+
flex: 0 0 auto;
86+
}
87+
8488
@utility flex-full {
8589
flex: 1 1 100%;
8690
}

packages/core/src/core/theme/ThemeProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { isColor } from "@react-fabric/utilities";
2525
import classNames from "classnames";
2626
import { useMemo } from "react";
2727
import { type ChildrenProp } from "../../types";
28+
import { useApplicationContext } from "../../context/Global";
2829

2930
export interface ThemeProps {
3031
/**
@@ -71,6 +72,7 @@ export const ThemeProvider = ({
7172
colorScheme,
7273
rounding,
7374
}: ThemeProps & ChildrenProp) => {
75+
const { currentColorScheme } = useApplicationContext();
7476
const styles = useMemo(() => {
7577
const ret: KeyValue = {};
7678
if (primaryColor && isColor(primaryColor)) {
@@ -97,7 +99,7 @@ export const ThemeProvider = ({
9799
return (
98100
<div
99101
style={styles}
100-
data-color-scheme={colorScheme}
102+
data-color-scheme={colorScheme ?? currentColorScheme}
101103
data-rounding={rounding}
102104
className={classNames(
103105
"fabric-themeProvider",

0 commit comments

Comments
 (0)