Skip to content

Commit 232b01c

Browse files
authored
Fix head and a11y for typing word (#1472)
1 parent ca12618 commit 232b01c

File tree

5 files changed

+200
-170
lines changed

5 files changed

+200
-170
lines changed

packages/docs/src/components/TypingWord.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import { vars } from '@/theming/vars.stylex';
1111
import * as stylex from '@stylexjs/stylex';
12+
import { Fragment } from 'react';
1213

1314
const WORDS = [
1415
'expressive',
@@ -20,11 +21,20 @@ const WORDS = [
2021

2122
export default function TypingWord() {
2223
return (
23-
<span {...stylex.props(styles.container)}>
24+
<span {...stylex.props(styles.container)} aria-hidden="true">
2425
{WORDS.map((word, index) => (
25-
<span key={index} {...stylex.props(styles.word)}>
26-
{word}
27-
</span>
26+
<Fragment key={word}>
27+
<span {...stylex.props(styles.word)}>
28+
{word}
29+
<span {...stylex.props(styles.hidden)}>
30+
{index < WORDS.length - 2
31+
? ', '
32+
: index === WORDS.length - 2
33+
? ' and '
34+
: ''}
35+
</span>
36+
</span>
37+
</Fragment>
2838
))}
2939
</span>
3040
);
@@ -114,4 +124,11 @@ const styles = stylex.create({
114124
),
115125
animationIterationCount: 'infinite',
116126
},
127+
hidden: {
128+
position: 'absolute',
129+
top: -9999,
130+
left: -9999,
131+
fontSize: '0.01em',
132+
opacity: 0.0001,
133+
},
117134
});

packages/docs/src/pages/(home)/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@ import { vars } from '@/theming/vars.stylex';
1515
export default function Home() {
1616
return (
1717
<>
18-
<title>StyleX</title>
19-
<link href="/img/favicon.svg" rel="icon" type="image/svg+xml" />
18+
<title>StyleX — styling system for ambitious interfaces</title>
2019
<main {...stylex.props(styles.main)}>
2120
<section {...stylex.props(styles.hero)}>
2221
<h1 {...stylex.props(styles.title)}>
2322
<StylexAnimatedLogo style={styles.logo} />
2423
</h1>
25-
<p {...stylex.props(styles.subtitle)}>
26-
The <TypingWord /> <br {...stylex.props(styles.mobileBreak)} />
27-
styling system for <br {...stylex.props(styles.tabletBreak)} />{' '}
28-
ambitious interfaces
24+
<p
25+
{...stylex.props(styles.subtitle)}
26+
aria-label="The expressive, type-safe, composable, predictable, and themeable styling system for ambitious interfaces"
27+
>
28+
<span aria-hidden="true">
29+
The <TypingWord />{' '}
30+
<br {...stylex.props(styles.mobileBreak)} aria-hidden="true" />
31+
styling system for{' '}
32+
<br {...stylex.props(styles.tabletBreak)} aria-hidden="true" />
33+
ambitious interfaces
34+
</span>
2935
</p>
3036
<div {...stylex.props(styles.ctaSpacer)} />
3137
<section {...stylex.props(styles.ctaSection)}>

packages/docs/src/pages/(playground)/playground.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default function PlaygroundPage() {
1414
return (
1515
<>
1616
<title>Playground | StyleX</title>
17-
<link href="/img/favicon.svg" rel="icon" type="image/svg+xml" />
1817
<main {...stylex.props(styles.main)}>
1918
<Playground />
2019
</main>

packages/docs/src/pages/_layout.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,29 @@ import '@/styles/globals.css';
1010
import DevStyleXHMR from '@/components/DevStyleXHMR';
1111
import { SidebarProvider } from '@/contexts/SidebarContext';
1212
import faviconUrl from '@/static/img/favicon.svg';
13+
import coverImageUrl from '@/static/img/stylex-cover-photo.png';
14+
15+
const DEFAULT_TITLE = 'StyleX — The styling system for ambitious interfaces';
16+
const DEFAULT_DESCRIPTION = 'The styling system that powers Meta.';
1317

1418
export default function RootLayout({ children }: { children: ReactNode }) {
1519
return (
1620
<>
1721
<head>
22+
<meta charSet="utf-8" />
23+
<meta content="width=device-width, initial-scale=1" name="viewport" />
24+
<meta content={DEFAULT_DESCRIPTION} name="description" />
25+
<meta content={DEFAULT_TITLE} property="og:title" />
26+
<meta content={DEFAULT_DESCRIPTION} property="og:description" />
27+
<meta content="website" property="og:type" />
28+
<meta content={coverImageUrl} property="og:image" />
29+
<meta content="summary_large_image" name="twitter:card" />
30+
<meta content={DEFAULT_TITLE} name="twitter:title" />
31+
<meta content={DEFAULT_DESCRIPTION} name="twitter:description" />
32+
<meta content={coverImageUrl} name="twitter:image" />
33+
<link href={faviconUrl} rel="icon" sizes="any" />
1834
<link href={faviconUrl} rel="icon" type="image/svg+xml" />
35+
<link href={faviconUrl} rel="shortcut icon" />
1936
</head>
2037
<DevStyleXHMR />
2138
<Provider>

0 commit comments

Comments
 (0)