@primer/react 0.0.0-20260805200651 → 0.0.0-20260805204721

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.
@@ -1,5 +1,2 @@
1
- import { ThemeProviderProps } from "../ThemeProvider.js";
2
- import { useColorSchemeVar, useTheme } from "../useTheme.js";
3
1
  import { Tooltip, TooltipProps } from "../TooltipV2/Tooltip.js";
4
- import { ThemeProvider } from "./ThemeProvider.js";
5
- export { ThemeProvider, type ThemeProviderProps, Tooltip, type TooltipProps, useColorSchemeVar, useTheme };
2
+ export { Tooltip, type TooltipProps };
@@ -1,5 +1,3 @@
1
1
  "use client";
2
- import { useColorSchemeVar, useTheme } from "../useTheme.js";
3
2
  import { Tooltip } from "../TooltipV2/Tooltip.js";
4
- import { ThemeProvider } from "./ThemeProvider.js";
5
- export { ThemeProvider, Tooltip, useColorSchemeVar, useTheme };
3
+ export { Tooltip };
package/dist/theme.d.ts CHANGED
@@ -1082,7 +1082,6 @@ declare const theme: {
1082
1082
  }>;
1083
1083
  }>;
1084
1084
  };
1085
- /** @deprecated Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values. */
1086
1085
  type ThemeColors = {
1087
1086
  fg: {
1088
1087
  default: string;
@@ -1107,21 +1106,60 @@ type ThemeColors = {
1107
1106
  muted: string;
1108
1107
  subtle: string;
1109
1108
  };
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;
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
+ };
1125
1163
  };
1126
1164
  type ThemeShadows = {
1127
1165
  shadow: {
@@ -1,7 +1,19 @@
1
- import { ThemeContextValue } from "./ThemeContext.js";
1
+ import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
2
+ import React from "react";
2
3
 
3
4
  //#region src/useTheme.d.ts
4
- declare function useTheme(): ThemeContextValue;
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
+ };
5
17
  declare function useColorSchemeVar(values: Partial<Record<string, string>>, fallback: string): string;
6
18
  //#endregion
7
19
  export { useColorSchemeVar, useTheme };
@@ -9042,7 +9042,7 @@
9042
9042
  },
9043
9043
  {
9044
9044
  "id": "components-underlinenav-features--overflow-template",
9045
- "code": "({ initialSelectedIndex = 1 }: { initialSelectedIndex?: number }) => {\n const [selectedIndex, setSelectedIndex] = React.useState<number | null>(\n initialSelectedIndex,\n )\n return (\n <UnderlineNav aria-label=\"Repository\">\n {items.map((item, index) => (\n <UnderlineNav.Item\n key={item.navigation}\n leadingVisual={item.icon}\n aria-current={index === selectedIndex ? 'page' : undefined}\n // Set so that navigation in interaction tests does not cause the\n // page to load the storybook iframe URL and instead keeps the test in\n // the local preview\n target=\"_self\"\n onSelect={(event) => {\n event.preventDefault()\n setSelectedIndex(index)\n }}\n counter={item.counter}\n href={item.href}\n >\n {item.navigation}\n </UnderlineNav.Item>\n ))}\n </UnderlineNav>\n )\n}"
9045
+ "code": "({ initialSelectedIndex = 1 }: { initialSelectedIndex?: number }) => {\n const [selectedIndex, setSelectedIndex] = React.useState<number | null>(\n initialSelectedIndex,\n )\n return (\n <UnderlineNav aria-label=\"Repository\" hideIconsBreakpoint=\"medium\">\n {items.map((item, index) => (\n <UnderlineNav.Item\n key={item.navigation}\n leadingVisual={item.icon}\n aria-current={index === selectedIndex ? 'page' : undefined}\n // Set so that navigation in interaction tests does not cause the\n // page to load the storybook iframe URL and instead keeps the test in\n // the local preview\n target=\"_self\"\n onSelect={(event) => {\n event.preventDefault()\n setSelectedIndex(index)\n }}\n counter={item.counter}\n href={item.href}\n >\n {item.navigation}\n </UnderlineNav.Item>\n ))}\n </UnderlineNav>\n )\n}"
9046
9046
  },
9047
9047
  {
9048
9048
  "id": "components-underlinenav-features--overflow-on-narrow-screen",
@@ -9078,6 +9078,12 @@
9078
9078
  "defaultValue": "false",
9079
9079
  "description": "Whether the navigation items are in loading state. Component waits for all the counters to finish loading to prevent multiple layout shifts."
9080
9080
  },
9081
+ {
9082
+ "name": "hideIconsBreakpoint",
9083
+ "type": "'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | null",
9084
+ "defaultValue": "'medium'",
9085
+ "description": "Controls the container width below which icons are hidden to save space. To keep icons visible in a narrow container, use a smaller breakpoint such as `xsmall`, or set to `null` to always show icons."
9086
+ },
9081
9087
  {
9082
9088
  "name": "variant",
9083
9089
  "type": "'inset' | 'flush'",
@@ -960,6 +960,11 @@
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
+ },
963
968
  {
964
969
  "name": "colorMode",
965
970
  "type": "'auto' | 'day' | 'night' | 'light' | 'dark'",
@@ -988,7 +993,7 @@
988
993
  {
989
994
  "name": "theme",
990
995
  "type": "Theme",
991
- "description": "Deprecated: Use `ThemeProvider` from `@primer/react/next` to migrate away from JavaScript theme values."
996
+ "description": "The theme object that is applied."
992
997
  },
993
998
  {
994
999
  "name": "colorScheme",
@@ -1003,7 +1008,7 @@
1003
1008
  {
1004
1009
  "name": "resolvedColorScheme",
1005
1010
  "type": "string",
1006
- "description": "Deprecated: Use `colorScheme` with `ThemeProvider` from `@primer/react/next`."
1011
+ "description": "The name of the current color scheme."
1007
1012
  },
1008
1013
  {
1009
1014
  "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-20260805200651",
4
+ "version": "0.0.0-20260805204721",
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,6 +45,7 @@
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",
48
49
  "lint:npm": "publint --types",
49
50
  "lint:react-compiler": "node script/lint-react-compiler.ts",
50
51
  "storybook": "storybook",
@@ -63,6 +64,7 @@
63
64
  ],
64
65
  "files": [
65
66
  "dist",
67
+ "!dist/legacy-theme/ts/colors",
66
68
  "generated",
67
69
  "CHANGELOG.md"
68
70
  ],
@@ -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-Group-lMIPQ:not(:first-child):has(.prc-ActionList-GroupHeadingWrap-laXcX+ul>.prc-ActionList-GroupHeadingWrap-laXcX)>.prc-ActionList-GroupHeadingWrap-laXcX{display:none}.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-efcb39da.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ActionList/Group.module.css.js"],"names":[],"mappings":"AAAA,4BACE,eAcF,CAZE,8CACE,2CAUF,CAJI,2KACE,YACF,CAKN,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-efcb39da.css","sourcesContent":[".Group {\n list-style: none;\n\n &:not(:first-child) {\n margin-block-start: var(--base-size-8);\n\n /* If somebody tries to pass the `title` prop AND a `NavList.GroupHeading` as a child, hide the `ActionList.GroupHeading */\n /* stylelint-disable-next-line selector-max-specificity, selector-pseudo-class-disallowed-list -- scoped to CSS Module, audited (github/github-ui#17224) */\n &:has(.GroupHeadingWrap + ul > .GroupHeadingWrap) {\n /* stylelint-disable-next-line selector-max-specificity */\n & > .GroupHeadingWrap {\n display: none;\n }\n }\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"]}
@@ -1,20 +0,0 @@
1
- import { ColorMode, ColorModeWithAuto, Theme } from "./ThemeProvider.js";
2
- import React from "react";
3
-
4
- //#region src/ThemeContext.d.ts
5
- interface ThemeContextValue {
6
- /** @deprecated Use `ThemeProvider` and `useTheme` from `@primer/react/next` to migrate away from JavaScript theme values. */
7
- theme?: Theme;
8
- colorScheme?: string;
9
- colorMode?: ColorModeWithAuto;
10
- resolvedColorMode?: ColorMode;
11
- /** @deprecated Use `ThemeProvider` and `useTheme` from `@primer/react/next` to migrate away from JavaScript theme values. */
12
- resolvedColorScheme?: string;
13
- dayScheme?: string;
14
- nightScheme?: string;
15
- setColorMode: React.Dispatch<React.SetStateAction<ColorModeWithAuto>>;
16
- setDayScheme: React.Dispatch<React.SetStateAction<string>>;
17
- setNightScheme: React.Dispatch<React.SetStateAction<string>>;
18
- }
19
- //#endregion
20
- export { ThemeContextValue };
@@ -1,7 +0,0 @@
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 };
@@ -1,113 +0,0 @@
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 };