-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24c7476
commit 1508a1c
Showing
20 changed files
with
198 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
integrations/gatsby-theme-stories/src/components/Sidebar.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Flex, LinkProps, SxStyleProp, Theme } from 'theme-ui'; | ||
|
||
const skipNavStyles: SxStyleProp = { | ||
border: (t: Theme) => `1px solid ${t.colors?.primary}`, | ||
clip: `react(0 0 0 0)`, | ||
width: '0.01em', | ||
height: '0.01em', | ||
whiteSpace: 'nowrap', | ||
padding: 0, | ||
overflow: `hidden`, | ||
position: `absolute`, | ||
flexDirection: 'column', | ||
'&:focus-within': { | ||
padding: 3, | ||
position: `fixed`, | ||
top: `50px`, | ||
left: `15px`, | ||
backgroundColor: `background`, | ||
zIndex: 15, | ||
width: `auto`, | ||
height: `auto`, | ||
clip: `auto`, | ||
textDecoration: `none`, | ||
}, | ||
}; | ||
export interface SkiLinksItemOwnProps { | ||
/** | ||
* target's id property, without the # char | ||
*/ | ||
target: string; | ||
/** | ||
* text message to be displayed | ||
*/ | ||
text: string; | ||
} | ||
|
||
export type SkiLinksItemProps = SkiLinksItemOwnProps & LinkProps; | ||
|
||
/** | ||
* single skip link anchor item | ||
*/ | ||
export const SkiLinksItem: FC<SkiLinksItemProps & LinkProps> = ({ | ||
target, | ||
text, | ||
...rest | ||
}) => ( | ||
<a {...rest} href={`#${target}`} data-skip-link="true"> | ||
{text} | ||
</a> | ||
); | ||
|
||
export interface SkipLinksProps { | ||
items: SkiLinksItemProps[]; | ||
} | ||
|
||
/** | ||
* list of anchor elements to skip to | ||
* | ||
*/ | ||
|
||
export const SkipLinks: FC<SkipLinksProps> = ({ items }) => ( | ||
<Flex | ||
sx={{ ...skipNavStyles }} | ||
as="section" | ||
aria-label="skip tab order to linked items" | ||
> | ||
{items.map((item, idx) => ( | ||
<SkiLinksItem key={`skip_link_${idx}`} {...item} /> | ||
))} | ||
</Flex> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './SkipLinks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** @jsx jsx */ | ||
import { FC, Fragment } from 'react'; | ||
import { jsx, Flex } from 'theme-ui'; | ||
import { | ||
SkipLinks, | ||
SkiLinksItemProps, | ||
} from '@component-controls/app-components'; | ||
import { useStoryContext } from '@component-controls/blocks'; | ||
import { SEO } from '../SEO'; | ||
import { Header } from '../Header'; | ||
import { Page, PagesConfig } from '../Page'; | ||
import { Footer } from '../Footer'; | ||
|
||
export interface AppProps { | ||
title?: string; | ||
pagesFn: PagesConfig; | ||
} | ||
export const App: FC<AppProps> = ({ title, pagesFn }) => { | ||
const { doc } = useStoryContext({ id: '.' }); | ||
const items: SkiLinksItemProps[] = [ | ||
{ | ||
target: 'content', | ||
text: 'skip to main content', | ||
}, | ||
]; | ||
if (!doc || !doc.fullPage) { | ||
items.push({ | ||
target: 'sidebar', | ||
text: 'skip to navigation sidebar', | ||
}); | ||
items.push({ | ||
target: 'contextbar', | ||
text: 'skip to context sidebar', | ||
}); | ||
} | ||
|
||
return ( | ||
<Fragment> | ||
<SEO title={title} /> | ||
<SkipLinks items={items} /> | ||
<Flex | ||
sx={{ | ||
minHeight: '100vh', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<Header title={title}></Header> | ||
<Page pagesFn={pagesFn} /> | ||
<Footer /> | ||
</Flex> | ||
</Fragment> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './App'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Footer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.