Skip to content

Commit

Permalink
feat: 🎸 Adds icon prop to scrollable card
Browse files Browse the repository at this point in the history
provides and optional icon prop to supply the scrollable card an icon to
place to the left of the title

✅ Closes: 744
  • Loading branch information
hvilander committed Aug 4, 2022
1 parent 51f7ec1 commit 38adea6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/SQFormScrollableCard/SQFormScrollableCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export type SQFormScrollableCardProps<Values extends FormikValues> = {
titleVariant?: TypographyVariant;
/** Boolean used to determine if the corners of the card should be squared */
isSquareCorners?: boolean;
/** An Icon to be shown to the left of the title */
icon?: React.ReactNode;
};

type useStylesProps = {
Expand Down Expand Up @@ -149,6 +151,7 @@ function SQFormScrollableCard<Values>({
validationSchema,
isHeaderDisabled = false,
isSquareCorners = true,
icon,
}: SQFormScrollableCardProps<Values>): React.ReactElement {
const hasSubHeader = Boolean(SubHeaderComponent);

Expand Down Expand Up @@ -233,6 +236,7 @@ function SQFormScrollableCard<Values>({
title={title}
className={classes.cardHeader}
titleTypographyProps={{variant: 'h5'}}
avatar={icon}
/>
)}

Expand Down
8 changes: 8 additions & 0 deletions stories/SQFormScrollableCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Yup from 'yup';
import React from 'react';

import {Paper} from '@material-ui/core';
import {Public} from '@material-ui/icons';
import {SQFormScrollableCard, SQFormTextField} from '../src';
import {createDocsPage} from './utils/createDocsPage';
import type {GridProps} from '@material-ui/core';
Expand Down Expand Up @@ -137,3 +138,10 @@ WithRoundedCorners.args = {
title: 'With Rounded Corners',
isSquareCorners: false,
};

export const WithIcon = Template.bind({});
WithIcon.args = {
...defaultArgs,
title: 'With Icon',
icon: <Public fontSize="large" />,
};

0 comments on commit 38adea6

Please sign in to comment.