@primer/react 0.0.0-20260805174819 → 0.0.0-20260805195449

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.
@@ -0,0 +1,7 @@
1
+ import { ThemeProviderProps } from "../ThemeProvider.js";
2
+ import React from "react";
3
+
4
+ //#region src/next/ThemeProvider.d.ts
5
+ declare const ThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderProps>>;
6
+ //#endregion
7
+ export { ThemeProvider, ThemeProvider as default };
@@ -0,0 +1,113 @@
1
+ import { useSyncedState } from "../hooks/useSyncedState.js";
2
+ import { ThemeContext } from "../ThemeContext.js";
3
+ import { useTheme } from "../useTheme.js";
4
+ import { c } from "react-compiler-runtime";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import React from "react";
7
+ //#region src/next/ThemeProvider.tsx
8
+ const defaultColorMode = "day";
9
+ const defaultDayScheme = "light";
10
+ const defaultNightScheme = "dark";
11
+ const ThemeProvider = (t0) => {
12
+ var _ref, _props$colorMode, _ref2, _props$dayScheme, _ref3, _props$nightScheme;
13
+ const $ = c(23);
14
+ let children;
15
+ let props;
16
+ if ($[0] !== t0) {
17
+ ({children, ...props} = t0);
18
+ $[0] = t0;
19
+ $[1] = children;
20
+ $[2] = props;
21
+ } else {
22
+ children = $[1];
23
+ props = $[2];
24
+ }
25
+ const { colorMode: fallbackColorMode, dayScheme: fallbackDayScheme, nightScheme: fallbackNightScheme } = useTheme();
26
+ const [colorMode, setColorMode] = useSyncedState((_ref = (_props$colorMode = props.colorMode) !== null && _props$colorMode !== void 0 ? _props$colorMode : fallbackColorMode) !== null && _ref !== void 0 ? _ref : defaultColorMode);
27
+ const [dayScheme, setDayScheme] = useSyncedState((_ref2 = (_props$dayScheme = props.dayScheme) !== null && _props$dayScheme !== void 0 ? _props$dayScheme : fallbackDayScheme) !== null && _ref2 !== void 0 ? _ref2 : defaultDayScheme);
28
+ const [nightScheme, setNightScheme] = useSyncedState((_ref3 = (_props$nightScheme = props.nightScheme) !== null && _props$nightScheme !== void 0 ? _props$nightScheme : fallbackNightScheme) !== null && _ref3 !== void 0 ? _ref3 : defaultNightScheme);
29
+ const systemColorMode = useSystemColorMode();
30
+ const resolvedColorMode = colorMode === "auto" ? systemColorMode : colorMode;
31
+ const colorScheme = resolvedColorMode === "day" || resolvedColorMode === "light" ? dayScheme : nightScheme;
32
+ let t1;
33
+ if ($[3] !== colorMode || $[4] !== colorScheme || $[5] !== dayScheme || $[6] !== nightScheme || $[7] !== resolvedColorMode || $[8] !== setColorMode || $[9] !== setDayScheme || $[10] !== setNightScheme) {
34
+ t1 = {
35
+ colorScheme,
36
+ colorMode,
37
+ resolvedColorMode,
38
+ dayScheme,
39
+ nightScheme,
40
+ setColorMode,
41
+ setDayScheme,
42
+ setNightScheme
43
+ };
44
+ $[3] = colorMode;
45
+ $[4] = colorScheme;
46
+ $[5] = dayScheme;
47
+ $[6] = nightScheme;
48
+ $[7] = resolvedColorMode;
49
+ $[8] = setColorMode;
50
+ $[9] = setDayScheme;
51
+ $[10] = setNightScheme;
52
+ $[11] = t1;
53
+ } else t1 = $[11];
54
+ const contextValue = t1;
55
+ if (props.contextOnly) {
56
+ let t2;
57
+ if ($[12] !== children || $[13] !== contextValue) {
58
+ t2 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
59
+ value: contextValue,
60
+ children
61
+ });
62
+ $[12] = children;
63
+ $[13] = contextValue;
64
+ $[14] = t2;
65
+ } else t2 = $[14];
66
+ return t2;
67
+ }
68
+ const t2 = colorMode === "auto" ? "auto" : colorScheme.includes("dark") ? "dark" : "light";
69
+ let t3;
70
+ if ($[15] !== children || $[16] !== dayScheme || $[17] !== nightScheme || $[18] !== t2) {
71
+ t3 = /*#__PURE__*/ jsx("div", {
72
+ "data-component": "ThemeProvider",
73
+ "data-color-mode": t2,
74
+ "data-light-theme": dayScheme,
75
+ "data-dark-theme": nightScheme,
76
+ children
77
+ });
78
+ $[15] = children;
79
+ $[16] = dayScheme;
80
+ $[17] = nightScheme;
81
+ $[18] = t2;
82
+ $[19] = t3;
83
+ } else t3 = $[19];
84
+ let t4;
85
+ if ($[20] !== contextValue || $[21] !== t3) {
86
+ t4 = /*#__PURE__*/ jsx(ThemeContext.Provider, {
87
+ value: contextValue,
88
+ children: t3
89
+ });
90
+ $[20] = contextValue;
91
+ $[21] = t3;
92
+ $[22] = t4;
93
+ } else t4 = $[22];
94
+ return t4;
95
+ };
96
+ function subscribeToSystemColorMode(callback) {
97
+ var _window, _window$matchMedia;
98
+ const media = (_window = window) === null || _window === void 0 ? void 0 : (_window$matchMedia = _window.matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-color-scheme: dark)");
99
+ media === null || media === void 0 || media.addEventListener("change", callback);
100
+ return () => media === null || media === void 0 ? void 0 : media.removeEventListener("change", callback);
101
+ }
102
+ function useSystemColorMode() {
103
+ return React.useSyncExternalStore(subscribeToSystemColorMode, getSystemColorMode, _temp);
104
+ }
105
+ function _temp() {
106
+ return "day";
107
+ }
108
+ function getSystemColorMode() {
109
+ var _window2, _window2$matchMedia, _window2$matchMedia$c;
110
+ return (_window2 = window) !== null && _window2 !== void 0 && (_window2$matchMedia = _window2.matchMedia) !== null && _window2$matchMedia !== void 0 && (_window2$matchMedia$c = _window2$matchMedia.call(_window2, "(prefers-color-scheme: dark)")) !== null && _window2$matchMedia$c !== void 0 && _window2$matchMedia$c.matches ? "night" : "day";
111
+ }
112
+ //#endregion
113
+ export { ThemeProvider, ThemeProvider as default };
@@ -1,2 +1,5 @@
1
+ import { ThemeProviderProps } from "../ThemeProvider.js";
2
+ import { useColorSchemeVar, useTheme } from "../useTheme.js";
1
3
  import { Tooltip, TooltipProps } from "../TooltipV2/Tooltip.js";
2
- export { Tooltip, type TooltipProps };
4
+ import { ThemeProvider } from "./ThemeProvider.js";
5
+ export { ThemeProvider, type ThemeProviderProps, Tooltip, type TooltipProps, useColorSchemeVar, useTheme };
@@ -1,3 +1,5 @@
1
1
  "use client";
2
+ import { useColorSchemeVar, useTheme } from "../useTheme.js";
2
3
  import { Tooltip } from "../TooltipV2/Tooltip.js";
3
- export { Tooltip };
4
+ import { ThemeProvider } from "./ThemeProvider.js";
5
+ export { ThemeProvider, Tooltip, useColorSchemeVar, useTheme };
package/dist/theme.d.ts CHANGED
@@ -1082,6 +1082,7 @@ declare const theme: {
1082
1082
  }>;
1083
1083
  }>;
1084
1084
  };
1085
+ /** @deprecated Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values. */
1085
1086
  type ThemeColors = {
1086
1087
  fg: {
1087
1088
  default: string;
@@ -1106,60 +1107,21 @@ type ThemeColors = {
1106
1107
  muted: string;
1107
1108
  subtle: string;
1108
1109
  };
1109
- accent: {
1110
- fg: string;
1111
- emphasis: string;
1112
- muted: string;
1113
- subtle: string;
1114
- };
1115
- success: {
1116
- fg: string;
1117
- emphasis: string;
1118
- muted: string;
1119
- subtle: string;
1120
- };
1121
- attention: {
1122
- fg: string;
1123
- emphasis: string;
1124
- muted: string;
1125
- subtle: string;
1126
- };
1127
- severe: {
1128
- fg: string;
1129
- emphasis: string;
1130
- muted: string;
1131
- subtle: string;
1132
- };
1133
- danger: {
1134
- fg: string;
1135
- emphasis: string;
1136
- muted: string;
1137
- subtle: string;
1138
- };
1139
- open: {
1140
- fg: string;
1141
- emphasis: string;
1142
- muted: string;
1143
- subtle: string;
1144
- };
1145
- closed: {
1146
- fg: string;
1147
- emphasis: string;
1148
- muted: string;
1149
- subtle: string;
1150
- };
1151
- done: {
1152
- fg: string;
1153
- emphasis: string;
1154
- muted: string;
1155
- subtle: string;
1156
- };
1157
- sponsors: {
1158
- fg: string;
1159
- emphasis: string;
1160
- muted: string;
1161
- subtle: string;
1162
- };
1110
+ accent: ThemeRole;
1111
+ success: ThemeRole;
1112
+ attention: ThemeRole;
1113
+ severe: ThemeRole;
1114
+ danger: ThemeRole;
1115
+ open: ThemeRole;
1116
+ closed: ThemeRole;
1117
+ done: ThemeRole;
1118
+ sponsors: ThemeRole;
1119
+ };
1120
+ type ThemeRole = {
1121
+ fg: string;
1122
+ emphasis: string;
1123
+ muted: string;
1124
+ subtle: string;
1163
1125
  };
1164
1126
  type ThemeShadows = {
1165
1127
  shadow: {
@@ -1,19 +1,7 @@
1
- import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
2
- import React from "react";
1
+ import { ThemeContextValue } from "./ThemeContext.js";
3
2
 
4
3
  //#region src/useTheme.d.ts
5
- declare function useTheme(): {
6
- theme?: Theme;
7
- colorScheme?: string;
8
- colorMode?: ColorModeWithAuto;
9
- resolvedColorMode?: ColorMode;
10
- resolvedColorScheme?: string;
11
- dayScheme?: string;
12
- nightScheme?: string;
13
- setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
14
- setDayScheme: React.Dispatch<React.SetStateAction<string>>;
15
- setNightScheme: React.Dispatch<React.SetStateAction<string>>;
16
- };
4
+ declare function useTheme(): ThemeContextValue;
17
5
  declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
18
6
  //#endregion
19
7
  export { useColorSchemeVar, useTheme };
@@ -960,11 +960,6 @@
960
960
  {
961
961
  "name": "ThemeProviderProps",
962
962
  "properties": [
963
- {
964
- "name": "theme",
965
- "type": "{[key: string]: any}",
966
- "description": "The theme object to be applied."
967
- },
968
963
  {
969
964
  "name": "colorMode",
970
965
  "type": "'auto' | 'day' | 'night' | 'light' | 'dark'",
@@ -993,7 +988,7 @@
993
988
  {
994
989
  "name": "theme",
995
990
  "type": "Theme",
996
- "description": "The theme object that is applied."
991
+ "description": "Deprecated: Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values."
997
992
  },
998
993
  {
999
994
  "name": "colorScheme",
@@ -1008,7 +1003,7 @@
1008
1003
  {
1009
1004
  "name": "resolvedColorScheme",
1010
1005
  "type": "string",
1011
- "description": "The name of the current color scheme."
1006
+ "description": "Deprecated: Use `colorScheme` with `ThemeProvider` from `@primer/react/next`."
1012
1007
  },
1013
1008
  {
1014
1009
  "name": "resolvedColorMode",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260805174819",
4
+ "version": "0.0.0-20260805195449",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -45,7 +45,6 @@
45
45
  "build:docs:preview": "NODE_OPTIONS=--openssl-legacy-provider script/build-docs preview",
46
46
  "build:components.json": "tsx script/components-json/build.ts",
47
47
  "build:hooks.json": "tsx script/hooks-json/build.ts",
48
- "build:precompile-color-schemes": "tsx script/precompile-color-schemes.ts",
49
48
  "lint:npm": "publint --types",
50
49
  "lint:react-compiler": "node script/lint-react-compiler.ts",
51
50
  "storybook": "storybook",
@@ -64,7 +63,6 @@
64
63
  ],
65
64
  "files": [
66
65
  "dist",
67
- "!dist/legacy-theme/ts/colors",
68
66
  "generated",
69
67
  "CHANGELOG.md"
70
68
  ],
@@ -1,2 +0,0 @@
1
- .prc-ActionList-Group-lMIPQ{list-style:none}.prc-ActionList-Group-lMIPQ:not(:first-child){margin-block-start:var(--base-size-8,.5rem)}.prc-ActionList-GroupList-V5B3-{padding-inline-start:0}.prc-ActionList-GroupHeadingWrap-laXcX{color:var(--fgColor-muted,#59636e);display:flex;flex-direction:column;font-size:var(--text-body-size-small,.75rem);font-weight:var(--base-text-weight-semibold,600);line-height:18px;padding-block:var(--base-size-6,.375rem);padding-inline:var(--base-size-16,1rem)}.prc-ActionList-GroupHeadingWrap-laXcX:where([data-variant=filled]){background:var(--bgColor-muted,#f6f8fa);border-bottom:var(--borderWidth-thin,.0625rem) solid var(--borderColor-muted,#d1d9e0b3);border-top:var(--borderWidth-thin,.0625rem) solid var(--borderColor-muted,#d1d9e0b3);margin-block-end:var(--base-size-8,.5rem);margin-block-start:calc(var(--base-size-8,.5rem) - var(--borderWidth-thin,.0625rem));padding-inline:var(--base-size-16,1rem)}.prc-ActionList-GroupHeadingWrap-laXcX:where([data-variant=filled]):first-child{margin-block-start:0}.prc-ActionList-GroupHeading-STzxi{align-self:flex-start;color:var(--fgColor-muted,#59636e);font-size:var(--text-body-size-small,.75rem);font-weight:var(--base-text-weight-semibold,600);margin:0}.prc-ActionList-GroupHeadingWrap-laXcX[data-has-trailing-action]{align-items:center;flex-direction:row;gap:var(--base-size-8,.5rem);justify-content:space-between}.prc-ActionList-GroupHeadingWrap-laXcX[data-has-trailing-action]>.prc-ActionList-GroupHeading-STzxi{align-self:center}.prc-ActionList-GroupHeadingTrailingAction-jnb64{align-items:center;display:inline-flex;margin-inline-start:auto}
2
- /*# sourceMappingURL=Group-d89306a8.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ActionList/Group.module.css.js"],"names":[],"mappings":"AAAA,4BACE,eAKF,CAHE,8CACE,2CACF,CAGF,gCACE,sBACF,CAEA,uCAQE,kCAA2B,CAP3B,YAAa,CAQb,qBAAsB,CAPtB,4CAAsC,CACtC,gDAA6C,CAI7C,gBAAiB,CAIjB,wCAAiC,CADjC,uCAoBF,CAjBE,oEAIE,uCAAgC,CAEhC,uFAAqE,CADrE,oFAAkE,CAFlE,yCAAoC,CADpC,oFAAsE,CAKtE,uCAKF,CAHE,gFACE,oBACF,CAQJ,mCAKE,qBAAsB,CADtB,kCAA2B,CAF3B,4CAAsC,CACtC,gDAA6C,CAF7C,QAKF,CAEA,iEAEE,kBAAmB,CADnB,kBAAmB,CAGnB,4BAAuB,CADvB,6BAMF,CAHE,oGACE,iBACF,CAGF,iDAEE,kBAAmB,CADnB,mBAAoB,CAEpB,wBACF","file":"Group-d89306a8.css","sourcesContent":[".Group {\n list-style: none;\n\n &:not(:first-child) {\n margin-block-start: var(--base-size-8);\n }\n}\n\n.GroupList {\n padding-inline-start: 0;\n}\n\n.GroupHeadingWrap {\n display: flex;\n font-size: var(--text-body-size-small);\n font-weight: var(--base-text-weight-semibold);\n\n /* line-height: var(--text-body-lineHeight-small); use when FF rolls out */\n /* stylelint-disable-next-line primer/typography */\n line-height: 18px;\n color: var(--fgColor-muted);\n flex-direction: column;\n padding-inline: var(--base-size-16);\n padding-block: var(--base-size-6);\n\n &:where([data-variant='filled']) {\n /* stylelint-disable-next-line primer/spacing */\n margin-block-start: calc(var(--base-size-8) - var(--borderWidth-thin));\n margin-block-end: var(--base-size-8);\n background: var(--bgColor-muted);\n border-top: solid var(--borderWidth-thin) var(--borderColor-muted);\n border-bottom: solid var(--borderWidth-thin) var(--borderColor-muted);\n padding-inline: var(--base-size-16);\n\n &:first-child {\n margin-block-start: 0;\n }\n }\n\n /* & + ul:has(.GroupHeadingWrap) {\n outline: solid 1px red;\n } */\n}\n\n.GroupHeading {\n margin: 0;\n font-size: var(--text-body-size-small);\n font-weight: var(--base-text-weight-semibold);\n color: var(--fgColor-muted);\n align-self: flex-start;\n}\n\n.GroupHeadingWrap[data-has-trailing-action] {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n gap: var(--base-size-8);\n\n & > .GroupHeading {\n align-self: center;\n }\n}\n\n.GroupHeadingTrailingAction {\n display: inline-flex;\n align-items: center;\n margin-inline-start: auto;\n}\n"]}