-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from perimetre/3.4.6
3.4.6
- Loading branch information
Showing
8 changed files
with
173 additions
and
2 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
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,48 @@ | ||
import React from 'react'; | ||
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1 | ||
import { Story, Meta } from '@storybook/react/types-6-0'; | ||
import { BaseCard, BaseCardProps } from '.'; | ||
|
||
export default { | ||
title: 'Components/BaseCard', | ||
component: BaseCard, | ||
argTypes: { | ||
className: { | ||
defaultValue: 'max-w-md', | ||
control: { | ||
type: 'text' | ||
} | ||
}, | ||
imageUrl: { | ||
defaultValue: 'https://fakeimg.pl/370x110/', | ||
control: { | ||
type: 'text' | ||
} | ||
}, | ||
imageAlt: { | ||
defaultValue: 'Image description', | ||
control: { | ||
type: 'text' | ||
} | ||
}, | ||
children: { | ||
defaultValue: 'this is the content of the card', | ||
control: { | ||
type: 'text' | ||
} | ||
} | ||
} | ||
} as Meta; | ||
|
||
/** | ||
* A story that displays a list connector | ||
* | ||
* @param props the story props | ||
* @param props.children the color property set on controls | ||
* @param props.className the classes for element | ||
* @param props.imageUrl the image url set on controls | ||
* @param props.imageAlt the image url set on controls | ||
*/ | ||
const Template: Story<BaseCardProps & { color?: string }> = ({ ...props }) => <BaseCard {...props} />; | ||
|
||
export const Default = Template.bind({}); |
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 @@ | ||
@layer components { | ||
.pui-baseCard { | ||
/* Adds the expected placeholder color for the bg */ | ||
@apply flex w-full pui-rounded-Card overflow-hidden pui-boxshadow-lg; | ||
} | ||
|
||
.pui-rounded-gradient-bar { | ||
border-radius: var(--pui-rounded-gradient-bar, 0.75rem 0 0 0.75rem); | ||
} | ||
|
||
.gradient-bar { | ||
@apply w-2.5 h-auto min-h-full block pui-rounded-gradient-bar; | ||
} | ||
} |
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,97 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
|
||
export type BaseCardProps = { | ||
/** | ||
* Show gradient background for the card image | ||
* | ||
* @default true | ||
*/ | ||
imageGradient?: boolean; | ||
/** | ||
* Show left gradient bar on the card | ||
* | ||
* @default true | ||
*/ | ||
leftGradientBar?: boolean; | ||
/** | ||
* Card Image url | ||
* | ||
* @default string | ||
*/ | ||
imageUrl?: string; | ||
/** | ||
* Card title | ||
* | ||
* @default string | ||
*/ | ||
imageAlt?: string; | ||
/** | ||
* Extended classes | ||
* | ||
* @default string | ||
*/ | ||
className: string; | ||
/** | ||
* Extended classes for content | ||
* | ||
* @default string; | ||
*/ | ||
classNameContent?: string; | ||
/** | ||
* Extended classes for filter | ||
* | ||
* @default string | ||
*/ | ||
classNameGradientImage?: string; | ||
}; | ||
|
||
/** | ||
* A Percentage Circle | ||
* | ||
* @param props The input props | ||
* @param props.imageGradient The gradient background over the image | ||
* @param props.leftGradientBar The left gradient bar on the card | ||
* @param props.imageUrl Set the image for the card | ||
* @param props.imageAlt Set the title for the card | ||
* @param props.className The input className | ||
* @param props.classNameContent The content on the card className | ||
* @param props.classNameGradientImage The filter className | ||
* @param props.children The content of the card | ||
*/ | ||
export const BaseCard: React.FC<BaseCardProps> = ({ | ||
imageGradient, | ||
leftGradientBar, | ||
imageUrl, | ||
imageAlt, | ||
children, | ||
className, | ||
classNameContent, | ||
classNameGradientImage | ||
}) => { | ||
return ( | ||
<div className={classnames('pui-baseCard', className)}> | ||
{leftGradientBar && ( | ||
<div className={classnames('gradient-bar', `bg-gradient-to-b from-pui-primary to-pui-secondary`)}></div> | ||
)} | ||
<div className="flex flex-col w-full"> | ||
{imageUrl && ( | ||
<div className="w-full h-28 overflow-hidden relative"> | ||
<img src={imageUrl} alt={imageAlt} className="w-full h-full" /> | ||
|
||
{imageGradient && ( | ||
<div | ||
className={classnames( | ||
'absolute opacity-25 z-10 inset-0 w-full h-full bg-gradient-to-r from-pui-primary to-pui-secondary', | ||
classNameGradientImage | ||
)} | ||
/> | ||
)} | ||
</div> | ||
)} | ||
<div className={classnames('flex flex-col flex-1 p-6', classNameContent)}>{children}</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -30,3 +30,4 @@ | |
@import './ResourcesCard'; | ||
@import './ExpertCard'; | ||
@import './ProgramCard'; | ||
@import './BaseCard'; |
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