Skip to content

Commit

Permalink
feat: add Github avatar to author columnn
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stoyanov committed Feb 24, 2021
1 parent 3943285 commit caf3dd7
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions ui/blocks/src/ComponentCommits/ComponentCommits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import {
BlockContainerProps,
Table,
} from '@component-controls/components';
import { StoryInputProps, useStoryComponent } from '@component-controls/store';
import {
StoryInputProps,
useConfig,
useStoryComponent,
} from '@component-controls/store';
import { Commit, dateToLocalString } from '@component-controls/core';
import { GithubAvatar } from '@component-controls/components';
import { useCustomProps } from '../context';

export type ComponentCommitsProps = BlockContainerProps & StoryInputProps;
Expand All @@ -25,27 +30,46 @@ export const ComponentCommits: FC<ComponentCommitsProps> = ({
const props = useCustomProps<ComponentCommitsProps>('commits', rest);
const component = useStoryComponent({ id, name });

const config = useConfig();
const { tokens } = config;

console.log(component);

const columns = useMemo(
() =>
[
{
Header: 'Date',
accessor: 'authorData',
accessor: 'authorDate',
Cell: ({
row: {
original: { authorData },
original: { authorDate },
},
}) => (
<span>
{authorData ? dateToLocalString(new Date(authorData)) : 'N/A'}
{authorDate ? dateToLocalString(new Date(authorDate)) : 'N/A'}
</span>
),
},
{
Header: 'Author',
accessor: 'authorName',
Cell: ({
row: {
original: { authorName },
},
}) => {
return authorName ? (
<div style={{ display: 'flex' }}>
<p style={{ paddingRight: '10px' }}>{authorName}</p>
<GithubAvatar
username={authorName}
size={22}
githubAccessToken={tokens?.githubAccessToken}
/>
</div>
) : null;
},
},
{
Header: 'Commit Message',
Expand Down

0 comments on commit caf3dd7

Please sign in to comment.