Skip to content

Commit 596ee8a

Browse files
committed
Add typescript section
1 parent 7cde9d0 commit 596ee8a

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

docs/pages/CodeExample.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const MultiCodeButton = styled.button<{active?: boolean}>`
6464
position: relative;
6565
top: 5px;
6666
border: 0;
67+
margin: 0;
6768
padding: 5px 20px;
6869
cursor: pointer;
6970
& + & {
@@ -76,10 +77,7 @@ export const CodeExamples = ({ children }) => {
7677
const [activeKey, setActiveKeys] = useState(keys[0]);
7778
return <CodeExampleWrapper>
7879
<CodeButtonWrapper>
79-
{keys.length === 2 && keys.map((key) => key !== activeKey && (
80-
<MultiCodeButton key={key} onClick={() => setActiveKeys(key)}>{key}</MultiCodeButton>
81-
))}
82-
{keys.length > 2 && keys.map((key) => (
80+
{keys.length > 1 && keys.map((key) => (
8381
<MultiCodeButton key={key} active={activeKey === key} onClick={() => setActiveKeys(key)}>{key}</MultiCodeButton>
8482
))}
8583
</CodeButtonWrapper>

docs/pages/Theme.js renamed to docs/pages/Theme.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const ThemeSwitchButton = styled.button`
8585
padding: 0;
8686
position: relative;
8787
overflow: hidden;
88+
font-size: 80%;
89+
cursor: pointer;
8890
:before {
8991
transition: transform 300ms ease-in-out;
9092
content: "🌙";
@@ -109,6 +111,7 @@ const ThemeSwitchButton = styled.button`
109111
export const ThemeSwitch = () => (
110112
<ThemeSwitchButton
111113
onClick={() => document.body.classList.toggle(invertedTheme)}
114+
title="Toggle Light/Dark Mode"
112115
/>
113116
);
114117

docs/pages/index.page.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,18 @@ export const globalStyles = css\`:global() {
221221

222222
<CodeExamples>
223223
{{
224-
base: `
224+
'js source': `
225225
import { tokens } from './tokens'
226226
227227
export const Headline = styled.h1\`
228228
color: \${tokens.primary};
229229
\`;
230-
`,
230+
`,
231+
'css result': `
232+
.se7gjt0-headline {
233+
color: var(--primary--1isauia0);
234+
}
235+
`,
231236
}}
232237
</CodeExamples>
233238
</SectionExample>
@@ -338,6 +343,34 @@ export const theme = {
338343
</SectionExample>
339344
</Section>
340345

346+
<Section reverse>
347+
<SectionContent>
348+
<Headline>Typed Contracts</Headline>
349+
<Text>By default any string value is a valid CSSVariable.<br /><br />But it doesn't end here - the generic interface allows to define explicitly which values are assignable</Text>
350+
</SectionContent>
351+
<SectionExample>
352+
<CodeExamples>
353+
{{
354+
base: `
355+
import { createVar } from 'css-variable';
356+
import type { CSSHexColor, CSSPixelValue } from 'css-variable';
357+
358+
export const tokens = {
359+
colors: {
360+
primary: createVar<CSSHexColor>(),
361+
secondary: createVar<CSSHexColor>(),
362+
},
363+
spacing: {
364+
large: createVar<CSSPixelValue>()
365+
}
366+
};
367+
`,
368+
}}
369+
</CodeExamples>
370+
</SectionExample>
371+
</Section>
372+
373+
341374
</Main>
342375
<Footer>
343376
<FooterContent>

0 commit comments

Comments
 (0)