Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ønskeliste: Illustration card #2136

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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);
}
}
tuva-odegard marked this conversation as resolved.
Show resolved Hide resolved
Loading