Skip to content

Commit af95fc8

Browse files
krisantrobusPixeledCodekodiakhq[bot]
authored
Revert 4025 fix theme flash (#4254)
* Revert "Fix theme flash on paste website (#4025)" This reverts commit fb4cbc5. * fix(docs): build failure for changing to ssr * fix(docs): build failure for changing to ssr * fix(ci): resolve broken tests after delayed rendering * fix(ci): resolve broken tests after delayed rendering --------- Co-authored-by: Shoaib Ahmed <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 186475e commit af95fc8

File tree

10 files changed

+22
-23
lines changed

10 files changed

+22
-23
lines changed

cypress/integration/sitemap-vrt/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export const SITEMAP = [
316316
"/patterns/notifications-and-feedback/",
317317
"/patterns/pricing/",
318318
"/patterns/privacy/",
319-
"/patterns/status/",
319+
"/patterns/object-status/",
320320
"/primitives/combobox-primitive/",
321321
"/patterns/create/",
322322
"/primitives/",

packages/paste-website/src/components/site-wrapper/site-header/SiteHeaderSearch.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ import { SiteSearch } from "../../site-search";
1111
const SiteHeaderSearch: React.FC = () => {
1212
const [isOpen, setIsOpen] = React.useState(false);
1313
const { breakpointIndex } = useWindowSize();
14-
const isMacOS = navigator.platform.toUpperCase().includes("MAC");
14+
// navigator is not available in SSR, settign a default until it renders to client
15+
const [isMacOS, setIsMacOS] = React.useState<boolean>();
1516
const platformTriggerKey = isMacOS ? "Meta" : "Control";
1617

18+
React.useEffect(() => {
19+
setIsMacOS(typeof window !== "undefined" && navigator && navigator?.platform.toUpperCase().includes("MAC"));
20+
}, []);
21+
1722
const onOpen = (): void => {
1823
setIsOpen(true);
1924
};
@@ -68,7 +73,7 @@ const SiteHeaderSearch: React.FC = () => {
6873
Search
6974
</Text>
7075
</Box>
71-
{breakpointIndex === 0 ? null : (
76+
{breakpointIndex === 0 || isMacOS === undefined ? null : (
7277
<>
7378
<Box as="span" color="colorText" aria-hidden="true" marginLeft="space30" lineHeight="lineHeight20">
7479
<KeyboardKeyGroup {...keyCombinationState}>

packages/paste-website/src/hooks/useDarkMode.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ValidThemes = {
1313
type ValidThemeName = ValueOf<typeof ValidThemes>;
1414

1515
const isValidTheme = (themeName: ValidThemeName): boolean => {
16-
return Object.values(ValidThemes).includes(themeName);
16+
return themeName === ValidThemes.DEFAULT || themeName === ValidThemes.DARK;
1717
};
1818

1919
export const useDarkMode = (): UseDarkModeReturn => {
@@ -36,7 +36,7 @@ export const useDarkMode = (): UseDarkModeReturn => {
3636
React.useEffect(() => {
3737
const localTheme = SimpleStorage.get("theme") as ValidThemeName;
3838

39-
if (window.matchMedia?.("(prefers-color-scheme: dark)").matches && !localTheme) {
39+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches && !localTheme) {
4040
setMode(ValidThemes.DARK);
4141
} else if (localTheme && isValidTheme(localTheme)) {
4242
setTheme(localTheme);

packages/paste-website/src/pages/_app.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,12 @@ const App = ({ Component, pageProps }: AppProps): React.ReactElement => {
116116
disableAnimations={inCypress()}
117117
cacheProviderProps={{ key: "next" }}
118118
>
119-
{componentMounted ? (
120-
<DarkModeContext.Provider value={{ theme, toggleMode, componentMounted }}>
121-
<PreviewThemeContext.Provider value={{ theme: previewTheme, selectTheme: setPreviewTheme }}>
122-
<Component {...pageProps} />
123-
{cookiesAccepted === null && (
124-
<CookieConsent onAccept={handleCookieAccept} onReject={handleCookieReject} />
125-
)}
126-
</PreviewThemeContext.Provider>
127-
</DarkModeContext.Provider>
128-
) : (
129-
<></>
130-
)}
119+
<DarkModeContext.Provider value={{ theme, toggleMode, componentMounted }}>
120+
<PreviewThemeContext.Provider value={{ theme: previewTheme, selectTheme: setPreviewTheme }}>
121+
<Component {...pageProps} />
122+
{cookiesAccepted === null && <CookieConsent onAccept={handleCookieAccept} onReject={handleCookieReject} />}
123+
</PreviewThemeContext.Provider>
124+
</DarkModeContext.Provider>
131125
</Theme.Provider>
132126
</>
133127
);

packages/paste-website/src/pages/blog/2023-06-12-paste-newsletter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ We can't thank Megan enough for her contributions. Her dedication to creating a
140140
| **Navigation UI Kit components** | Complementary React components to implement our Navigation UI kit. |
141141
| **Progress Steps component** | A highly requested component that shows a user a clear path to complete a complex multi-step task. |
142142
| **Number Input component** | An input that limits data to number entry and has styled +/- buttons. |
143-
| **Status components** | Components that implement the [Status Pattern](/patterns/status), including Status Badge and Status Menu. |
143+
| **Status components** | Components that implement the [Object Status Pattern](/patterns/object-status), including Status Badge and Status Menu. |
144144
| **Checkbox and Radio Menu Items** | A menu that presents a list of items that a user can choose to perform an action with. |
145145
| **Design of the Slider component** | A component that allows a draggable input over a range of numbers. |
146146

packages/paste-website/src/pages/blog/2023-08-02-paste-newsletter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Providing a common way for a user to control or edit their account, settings or
123123

124124
<ResponsiveImage src={StatusBadgeImage} alt="Preview of the Navigation UI Kit components" />
125125

126-
The [Status Badge](/components/status-badge) further evolves from our [Status Pattern](/patterns/status), allowing you to communicate status updates for any process or connection seamlessly. It provides an implementation of the Status Pattern using an appropriate combination of status level indicators, icons and colors.
126+
The [Status Badge](/components/status-badge) further evolves from our [Object Status Pattern](/patterns/object-status), allowing you to communicate status updates for any process or connection seamlessly. It provides an implementation of the Status Pattern using an appropriate combination of status level indicators, icons and colors.
127127

128128
### [Status Menu](/components/status-menu)
129129

packages/paste-website/src/pages/components/description-list/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Use a basic Description List for conveying small, static bits of data.
8989

9090
### Description List with Icon
9191

92-
The Description List can be used with [Status Pattern](/patterns/status).
92+
The Description List can be used with [Object Status Pattern](/patterns/object-status).
9393

9494
<LivePreview
9595
scope={{

packages/paste-website/src/pages/components/status-badge/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const getStaticProps = async () => {
9090

9191
## About Status Badge
9292

93-
Status badge is an implementation of the [Status Pattern](/patterns/status) to display the status of a process or connectivity in your product.
93+
Status badge is an implementation of the [Object Status Pattern](/patterns/object-status) to display the status of a process or connectivity in your product.
9494

9595
### Accessibility
9696

packages/paste-website/src/pages/components/status-menu/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const getStaticProps = async () => {
7171

7272
### About Status Menu
7373

74-
Use a Status Menu to both display and change the status of a connection or process. It closely follows the [Status Pattern](/patterns/status) and comes with preconfigured options for displaying the status of both processes and connections, using the correct icons for each.
74+
Use a Status Menu to both display and change the status of a connection or process. It closely follows the [Object Status Pattern](/patterns/object-status) and comes with preconfigured options for displaying the status of both processes and connections, using the correct icons for each.
7575

7676
### Accessibility
7777

packages/paste-website/src/pages/patterns/object-status/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export const getStaticProps = async () => {
139139
</Heading>
140140
<Paragraph marginBottom="space0">
141141
Create a composition with <Anchor href="/primitives/box">Box</Anchor>,{' '}
142-
<Anchor href="/components/icon">Icon</Anchor>, and <Anchor href="/components/text">Text</Anchor>.
142+
<Anchor href="/components/icon">Icon</Anchor>, and <Anchor href="/primitives/text">Text</Anchor>.
143143
</Paragraph>
144144
</Card>
145145
</Column>

0 commit comments

Comments
 (0)