-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This component links to the notebook in GitHub. Currently it assumes we're referencing the "main" branch; to fix that we'd have to store the default branch in Times Square to serve from its API.
- Loading branch information
1 parent
9e169a6
commit 2adb0af
Showing
5 changed files
with
76 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'squareone': minor | ||
--- | ||
|
||
Times Square notebook pages show a link to the source notebook on GitHub. |
25 changes: 25 additions & 0 deletions
25
apps/squareone/src/components/TimesSquareGitHubPagePanel/GitHubEditLink.js
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,25 @@ | ||
import styled from 'styled-components'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
export default function GitHubEditLink({ owner, repository, sourcePath }) { | ||
if (!owner || !repository || !sourcePath) { | ||
return null; | ||
} | ||
|
||
const editUrl = `https://github.com/${owner}/${repository}/blob/main/${sourcePath}`; | ||
|
||
return ( | ||
<p> | ||
<a href={editUrl}> | ||
<StyledFontAwesomeIcon icon="fa-brands fa-github" /> | ||
{owner}/{repository} | ||
</a> | ||
</p> | ||
); | ||
} | ||
|
||
const StyledFontAwesomeIcon = styled(FontAwesomeIcon)` | ||
margin-right: 0.2em; | ||
font-size: 1em; | ||
color: ${(props) => props.color || 'inherit'}; | ||
`; |
31 changes: 31 additions & 0 deletions
31
apps/squareone/src/components/TimesSquareGitHubPagePanel/GitHubEditLink.stories.js
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,31 @@ | ||
import React from 'react'; | ||
|
||
import GitHubEditLink from './GitHubEditLink'; | ||
|
||
export default { | ||
component: GitHubEditLink, | ||
title: 'Components/TimesSquare/GitHubEditLink', | ||
parameters: { | ||
viewport: { | ||
viewports: { | ||
sidebar: { | ||
name: 'Sidebar', | ||
styles: { | ||
width: '280px', | ||
height: '900px', | ||
}, | ||
}, | ||
}, | ||
}, | ||
defaultViewport: 'sidebar', | ||
}, | ||
}; | ||
|
||
const Template = (args) => <GitHubEditLink {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
owner: 'lsst-sqre', | ||
repository: 'times-square-demo', | ||
sourcePath: 'demo.ipynb', | ||
}; |
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