-
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: block component CommitsPopover
- Loading branch information
1 parent
bb983a5
commit 11b3f91
Showing
6 changed files
with
91 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { Document, Example } from '@component-controls/core'; | ||
import { CommitsPopover } from './CommitsPopover'; | ||
import { store } from '../test/storyStore'; | ||
|
||
export default { | ||
title: 'Blocks/CommitsPopover', | ||
component: CommitsPopover, | ||
category: ' Component', | ||
} as Document; | ||
|
||
export const overview: Example = () => ( | ||
<CommitsPopover component={store.components['Control']} /> | ||
); |
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,56 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Box, Link } from 'theme-ui'; | ||
import { Component } from '@component-controls/core'; | ||
import { Popover, Value } from '@component-controls/components'; | ||
import { BaseComponentCommits } from '../ComponentCommits'; | ||
|
||
export interface CommmitsPopoverProps { | ||
/** | ||
* component that will be displayed the commits | ||
*/ | ||
component?: Component; | ||
} | ||
|
||
/** | ||
* link displaying the total commits on a component | ||
* with a popover on click that will display the list of commits | ||
*/ | ||
export const CommitsPopover: FC<CommmitsPopoverProps> = ({ component }) => { | ||
return !!component?.fileInfo?.commits?.length ? ( | ||
<Popover | ||
trigger="click" | ||
placement="auto" | ||
tooltip={() => ( | ||
<Box sx={{ padding: 1 }}> | ||
<BaseComponentCommits | ||
component={component} | ||
pagination={{ pageSize: 3 }} | ||
/> | ||
</Box> | ||
)} | ||
> | ||
<Link | ||
sx={{ | ||
':hover': { cursor: 'pointer' }, | ||
}} | ||
> | ||
<Value | ||
label={ | ||
<Box | ||
sx={{ | ||
fontSize: 0, | ||
mr: 1, | ||
lineHeight: 'heading', | ||
textDecoration: 'underline', | ||
}} | ||
> | ||
commits: | ||
</Box> | ||
} | ||
value={component.fileInfo?.commits?.length} | ||
/> | ||
</Link> | ||
</Popover> | ||
) : 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 './CommitsPopover'; |
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