Skip to content

Commit

Permalink
feat: create story for ComponentCommits
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stoyanov committed Feb 25, 2021
1 parent 2a2ad8c commit 4e9e3fa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
20 changes: 20 additions & 0 deletions ui/blocks/src/ComponentCommits/ComponentCommits.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { Document, Example } from '@component-controls/core';
import { ComponentCommits } from './ComponentCommits';
import { makeDecorators } from '../test/MockContext';
import { store } from '../test/storyStore';

export default {
title: 'Blocks/ComponentCommits',
component: ComponentCommits,
category: ' Component',
} as Document;

export const overview: Example = () => (
<ComponentCommits
id="."
name="Commits"
storeComponent={store.components['Control']}
/>
);
overview.decorators = makeDecorators();
10 changes: 7 additions & 3 deletions ui/blocks/src/ComponentCommits/ComponentCommits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ import {
useConfig,
useStoryComponent,
} from '@component-controls/store';
import { Commit, dateToLocalString } from '@component-controls/core';
import { Commit, Component, dateToLocalString } from '@component-controls/core';
import { GithubAvatar } from '@component-controls/components';
import { useCustomProps } from '../context';

export type ComponentCommitsProps = BlockContainerProps & StoryInputProps;
export type ComponentCommitsProps = BlockContainerProps &
StoryInputProps & { storeComponent?: Component };

/**
* Displays commit history for a component
*/
export const ComponentCommits: FC<ComponentCommitsProps> = ({
id,
name,
storeComponent,
...rest
}) => {
const props = useCustomProps<ComponentCommitsProps>('commits', rest);
const component = useStoryComponent({ id, name });
const component = storeComponent
? storeComponent
: useStoryComponent({ id, name });

const config = useConfig();
const { tokens } = config;
Expand Down
9 changes: 7 additions & 2 deletions ui/blocks/src/test/storyStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,20 @@ and a [link](https://google.com)
{
committerName: 'hasparus',
authorName: 'hasparus',
authorDate: '2021-02-23T22:48:26.000Z',
subject: 'third commit',
},
{
committerName: 'hasparus',
authorName: 'lachlanjc',
authorDate: '2021-02-22T22:48:26.000Z',
subject: '(งツ)ว',
},
{
committerName: 'lachlanjc',

committerName: 'atanasster',
authorName: 'atanasster',
authorDate: '2021-02-21T22:48:26.000Z',
subject: 'first commit!',
},
],
},
Expand Down

0 comments on commit 4e9e3fa

Please sign in to comment.