-
Notifications
You must be signed in to change notification settings - Fork 83
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 #2136 from SpareBank1/develop-illustration-card
Ønskeliste: Illustration card
- Loading branch information
Showing
7 changed files
with
1,077 additions
and
0 deletions.
There are no files selected for viewing
295 changes: 295 additions & 0 deletions
295
component-overview/examples/cards/IllustrationCard-condensed.jsx
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
384 changes: 384 additions & 0 deletions
384
packages/ffe-cards-react/src/IllustrationCard/IllustrationCard.spec.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
packages/ffe-cards-react/src/IllustrationCard/IllustrationCard.tsx
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,61 @@ | ||
import React, { ElementType, ForwardedRef, ReactElement } from 'react'; | ||
import { CardRenderProps, ComponentAsPropParams } from '../types'; | ||
import classNames from 'classnames'; | ||
import { WithCardAction, Text, Subtext, Title, CardName } from '../components'; | ||
import { fixedForwardRef } from '../fixedForwardRef'; | ||
|
||
export type IllustrationCardProps<As extends ElementType = 'div'> = Omit< | ||
ComponentAsPropParams<As>, | ||
'children' | ||
> & { | ||
/** Element of illustration */ | ||
img: ReactElement; | ||
/** Smaller illustration and less space */ | ||
condensed?: boolean; | ||
children: | ||
| React.ReactNode | ||
| ((cardRenderProps: CardRenderProps) => React.ReactNode); | ||
}; | ||
|
||
function IllustrationCardWithForwardRef<As extends ElementType>( | ||
props: IllustrationCardProps<As>, | ||
ref: ForwardedRef<any>, | ||
) { | ||
const { className, condensed, img, children, ...rest } = props; | ||
return ( | ||
<WithCardAction | ||
className={classNames( | ||
'ffe-illustration-card', | ||
{ 'ffe-illustration-card--condensed': condensed }, | ||
className, | ||
)} | ||
{...(rest as Record<string, unknown>)} | ||
ref={ref} | ||
> | ||
{({ CardAction }) => ( | ||
<> | ||
<div | ||
className={classNames( | ||
'ffe-illustration-card__illustration', | ||
)} | ||
> | ||
{img} | ||
</div> | ||
<div className="ffe-illustration-card__body"> | ||
{typeof children === 'function' | ||
? children({ | ||
Text, | ||
Subtext, | ||
Title, | ||
CardName, | ||
CardAction, | ||
}) | ||
: children} | ||
</div> | ||
</> | ||
)} | ||
</WithCardAction> | ||
); | ||
} | ||
|
||
export const IllustrationCard = fixedForwardRef(IllustrationCardWithForwardRef); |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
export { CardBase, CardBaseProps } from './CardBase'; | ||
export { TextCard, TextCardProps } from './TextCard/TextCard'; | ||
export { IconCard, IconCardProps } from './IconCard/IconCard'; | ||
export { | ||
IllustrationCard, | ||
IllustrationCardProps, | ||
} from './IllustrationCard/IllustrationCard'; | ||
export { ImageCard, ImageCardProps } from './ImageCard/ImageCard'; | ||
export { StippledCard, StippledCardProps } from './StippledCard/StippledCard'; |
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,17 @@ | ||
@import 'common-card-styling'; | ||
@import 'components'; | ||
|
||
.ffe-illustration-card { | ||
.common-card-styling(); | ||
|
||
display: grid; | ||
grid-template-columns: auto 1fr; | ||
column-gap: var(--ffe-spacing-md); | ||
padding: var(--ffe-spacing-md); | ||
align-items: center; | ||
|
||
&--condensed { | ||
column-gap: var(--ffe-spacing-sm); | ||
padding: var(--ffe-spacing-sm); | ||
} | ||
} |