-
Notifications
You must be signed in to change notification settings - Fork 119
Fix dark mode flicker docs #4250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
67b66e1
b27d1ee
27b1546
95a21bf
49d320b
61772bc
936d03c
ff6a92d
0d609b2
34d32e4
3526bf8
b55612c
35e52a4
7af23e2
9260386
927dece
4cb9ff7
1760cd0
19e0232
26c18ec
2ea9427
196faf0
0d5fe90
801a9ed
3aaa322
4eb27ee
752dd2d
8079b9f
73e7cd1
07a5a8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,14 @@ import { SiteSearch } from "../../site-search"; | |
const SiteHeaderSearch: React.FC = () => { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const { breakpointIndex } = useWindowSize(); | ||
const isMacOS = navigator.platform.toUpperCase().includes("MAC"); | ||
// navigator is not available in SSR, settign a default until it renders to client | ||
const [isMacOS, setIsMacOS] = React.useState<boolean>(); | ||
const platformTriggerKey = isMacOS ? "Meta" : "Control"; | ||
|
||
React.useEffect(() => { | ||
setIsMacOS(typeof window !== "undefined" && navigator && navigator?.platform.toUpperCase().includes("MAC")); | ||
}, []); | ||
|
||
const onOpen = (): void => { | ||
setIsOpen(true); | ||
}; | ||
|
@@ -68,7 +73,7 @@ const SiteHeaderSearch: React.FC = () => { | |
Search | ||
</Text> | ||
</Box> | ||
{breakpointIndex === 0 ? null : ( | ||
{breakpointIndex === 0 || isMacOS === undefined ? null : ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not render the keyboard shortcuts in the search bar until we know what OS they are using |
||
<> | ||
<Box as="span" color="colorText" aria-hidden="true" marginLeft="space30" lineHeight="lineHeight20"> | ||
<KeyboardKeyGroup {...keyCombinationState}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ export const getStaticProps = async () => { | |
</Heading> | ||
<Paragraph marginBottom="space0"> | ||
Create a composition with <Anchor href="/primitives/box">Box</Anchor>,{' '} | ||
<Anchor href="/components/icon">Icon</Anchor>, and <Anchor href="/components/text">Text</Anchor>. | ||
<Anchor href="/components/icon">Icon</Anchor>, and <Anchor href="/primitives/text">Text</Anchor>. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason the link test started failing, probably because it saw the 404 error now that we don't delay rendering |
||
</Paragraph> | ||
</Card> | ||
</Column> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ParseOptions, parse } from "cookie"; | ||
import { NextPageContext } from "next"; | ||
import { parseCookies as parseRequestCookies } from "nookies"; | ||
|
||
export { setCookie, destroyCookie } from "nookies"; | ||
|
||
const cookieStringFromSetCookie = (cookies: string[] = []): string => | ||
cookies | ||
.map((cookie) => { | ||
const [keyValuePart] = cookie.split(";"); | ||
return keyValuePart; | ||
}) | ||
.join("; "); | ||
|
||
const parseResponseCookies = (ctx: NextPageContext, options?: ParseOptions): Record<string, any> => { | ||
let responseCookies: Record<string, any> = {}; | ||
if (ctx?.res) { | ||
const setCookieHeader = ctx.res.getHeader("Set-Cookie"); | ||
const cookie = cookieStringFromSetCookie(Array.isArray(setCookieHeader) ? setCookieHeader : []); | ||
responseCookies = parse(cookie, options); | ||
} | ||
|
||
return responseCookies; | ||
}; | ||
|
||
export const getCookie = (ctx: NextPageContext, name: string, options?: ParseOptions): string => { | ||
const responseCookies = parseResponseCookies(ctx, options); | ||
const requestCookies = parseRequestCookies(ctx); | ||
return responseCookies[name] || requestCookies[name]; | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An error came up after removing the delayed rendering as navigator is only available running client side.