Skip to content

Commit

Permalink
Merge pull request #2136 from SpareBank1/develop-illustration-card
Browse files Browse the repository at this point in the history
Ønskeliste: Illustration card
  • Loading branch information
tuva-odegard authored Jul 1, 2024
2 parents 69d97e8 + 0960089 commit d1de633
Show file tree
Hide file tree
Showing 7 changed files with 1,077 additions and 0 deletions.
295 changes: 295 additions & 0 deletions component-overview/examples/cards/IllustrationCard-condensed.jsx

Large diffs are not rendered by default.

315 changes: 315 additions & 0 deletions component-overview/examples/cards/IllustrationCard.jsx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions packages/ffe-cards-react/src/IllustrationCard/IllustrationCard.tsx
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);
4 changes: 4 additions & 0 deletions packages/ffe-cards-react/src/index.ts
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';
1 change: 1 addition & 0 deletions packages/ffe-cards/less/cards.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
@import 'card-base';
@import 'text-card';
@import 'icon-card';
@import 'illustration-card';
@import 'image-card';
@import 'stippled-card';
17 changes: 17 additions & 0 deletions packages/ffe-cards/less/illustration-card.less
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);
}
}

0 comments on commit d1de633

Please sign in to comment.