-
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: repository actions for ComponentSource
- Loading branch information
1 parent
5fb3c47
commit 1e0f77b
Showing
7 changed files
with
60 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { Repository } from '@component-controls/specification'; | ||
import { ActionItem, ExternalLink } from '@component-controls/components'; | ||
|
||
export const repositoryActions = ( | ||
repository?: Repository, | ||
): ActionItem[] | undefined => { | ||
if (repository) { | ||
const { browse, docs, issues } = repository; | ||
if (browse || docs || issues) { | ||
const actions: ActionItem[] = []; | ||
if (browse) { | ||
actions.push({ | ||
title: <ExternalLink href={browse}>browse</ExternalLink>, | ||
}); | ||
} | ||
if (docs) { | ||
actions.push({ | ||
title: <ExternalLink href={docs}>docs</ExternalLink>, | ||
}); | ||
} | ||
if (issues) { | ||
actions.push({ | ||
title: <ExternalLink href={issues}>issues</ExternalLink>, | ||
}); | ||
} | ||
return actions; | ||
} | ||
} | ||
return undefined; | ||
}; |
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,8 @@ | ||
import React, { FC } from 'react'; | ||
import { Link, LinkProps } from 'theme-ui'; | ||
|
||
export type ExternalLinkProps = LinkProps; | ||
|
||
export const ExternalLink: FC<ExternalLinkProps> = (props: LinkProps) => ( | ||
<Link {...props} target="_blank" rel="noopener noreferrer" /> | ||
); |
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 './ExternalLink'; |
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