Skip to content

Commit

Permalink
#86 - Create a reusable StatsCard (#87)
Browse files Browse the repository at this point in the history
* adds reusable stats card

* refactors the code

* adds missing exports in index.ts file
  • Loading branch information
Koushith authored Dec 21, 2021
1 parent 7a230a5 commit 348c0e9
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/primitive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export * from './loader/loader.component';

export * from './create-card/create-card.component';

export * from './stats-card/stats-card.component';

export * from './badge/badge.component';

export * from 'react-grid-system';
19 changes: 19 additions & 0 deletions src/components/primitive/stats-card/stats-card.component.props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { TextComponentProps } from './../text/text.component.props';
import { AvatarComponentProps } from './../avatar/avatar.component.props';

export interface StatsComponentProps {
/**
* Name of the Icon.
*/
iconName: AvatarComponentProps;

/**
* Headline for Stats Card.
*/
heading: TextComponentProps;

/**
* Count for Stats Card.
*/
count?: TextComponentProps;
}
19 changes: 19 additions & 0 deletions src/components/primitive/stats-card/stats-card.component.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import styled from 'styled-components';

/**
* Styles for Stats Container.
*/
export const StatsContainer = styled.div`
display: flex;
gap: 1.6rem;
width: fit-content;
`;

/**
* Styles for CountContainer.
*/
export const CountContainer = styled.span`
display: inline-flex;
flex-direction: column;
justify-content: space-between;
`;
17 changes: 17 additions & 0 deletions src/components/primitive/stats-card/stats-card.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Avatar, Text } from 'components/primitive';
import { StatsComponentProps } from './stats-card.component.props';
import { StatsContainer, CountContainer } from './stats-card.component.styles';

export const StatsCard: React.FC<StatsComponentProps> = (props) => {
const { heading, count, iconName } = props;

return (
<StatsContainer>
<Avatar size='large' flat {...iconName} />
<CountContainer>
<Text variant='small' color='textLight' {...heading} />
<Text variant='contentHeader' {...count} />
</CountContainer>
</StatsContainer>
);
};

0 comments on commit 348c0e9

Please sign in to comment.