-
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.
feat: edit this page block, add to classic page
- Loading branch information
1 parent
578d820
commit 4865e70
Showing
10 changed files
with
88 additions
and
11 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
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
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,43 @@ | ||
/** @jsx jsx */ | ||
/* eslint react/jsx-key: 0 */ | ||
import { jsx } from 'theme-ui'; | ||
import { FC } from 'react'; | ||
import { Box, Text } from 'theme-ui'; | ||
import Octicon, { MarkGithub } from '@primer/octicons-react'; | ||
import { ExternalLink } from '@component-controls/components'; | ||
import { useStoryContext } from '../context'; | ||
|
||
/** | ||
* Display a Edit this page link at the top of the page. | ||
* In order for this to work, you need to set up the `repository` field in `package.json`. | ||
*/ | ||
export const EditPage: FC = () => { | ||
const { kind, ...rest } = useStoryContext({ id: '.', name }); | ||
const { repository } = kind || {}; | ||
console.log(rest, kind, repository); | ||
return repository && repository.browse ? ( | ||
<Box | ||
sx={{ | ||
position: 'absolute', | ||
right: 0, | ||
top: 0, | ||
p: 2, | ||
}} | ||
> | ||
<ExternalLink href={repository.browse} aria-label="edit this page"> | ||
<Box | ||
sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }} | ||
> | ||
<Octicon icon={MarkGithub} /> | ||
<Text | ||
sx={{ | ||
pl: 2, | ||
}} | ||
> | ||
Edit this page | ||
</Text> | ||
</Box> | ||
</ExternalLink> | ||
</Box> | ||
) : null; | ||
}; |
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 './EditPage'; |
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