Skip to content

Commit a6b0ef8

Browse files
committed
feat(ffe-cards-react)!: Semantiske farger
BREAKING CHANGE: Fjerner shadow som paramater siden cards går over til å bruke boarder i stede
1 parent 20037a1 commit a6b0ef8

File tree

8 files changed

+21
-56
lines changed

8 files changed

+21
-56
lines changed
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Canvas, Meta, Controls } from '@storybook/blocks';
1+
import { Canvas, Controls, Meta } from '@storybook/blocks';
22
import * as CardBaseStories from './CardBase.stories.tsx';
33

44
<Meta of={CardBaseStories} />
@@ -7,7 +7,7 @@ import * as CardBaseStories from './CardBase.stories.tsx';
77

88
Dette er basisen for alle kort. Komponeten kan brukes direkte for å få en ramme du kan fylle dersom du trenger et spesialtilpassert kort.
99

10-
Du kan skru av/på box-shadow med `shadow`-prop, skru av margin med `noMargin`-prop, og sette bakgrunnsfargen i både light- og darkmode med `bgColorog` `bgDarkmodeColor`.
10+
Du kan skru av margin med `noMargin`-prop, og sette bakgrunnsfargen i både light- og darkmode med `bgColorog` `bgDarkmodeColor`.
1111

1212
<Canvas of={CardBaseStories.Standard} />
1313
<Controls of={CardBaseStories.Standard} />

packages/ffe-cards-react/src/CardBase.spec.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { render, screen, within } from '@testing-library/react';
12
import React from 'react';
23
import { CardBase } from './CardBase';
3-
import { render, screen, within } from '@testing-library/react';
44

55
const TEST_ID = 'test-id';
66

@@ -48,15 +48,6 @@ describe('<CardBase/>', () => {
4848
card.classList.contains('ffe-card-base--dm-bg-natt'),
4949
).toBeTruthy();
5050
});
51-
it('should set shadow-prop correctly', () => {
52-
render(
53-
<CardBase data-testid={TEST_ID} shadow={true}>
54-
<div />
55-
</CardBase>,
56-
);
57-
const card = screen.getByTestId(TEST_ID);
58-
expect(card.classList.contains('ffe-card-base--shadow')).toBeTruthy();
59-
});
6051
it('should set noMargin-prop correctly', () => {
6152
render(
6253
<CardBase data-testid={TEST_ID} noMargin={true}>

packages/ffe-cards-react/src/CardBase.stories.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
12
import React from 'react';
23
import { CardBase } from './CardBase';
3-
import type { StoryObj, Meta } from '@storybook/react';
44

55
const Custom: React.FC<React.ComponentProps<'div'>> = props => (
66
<div {...props}>
@@ -30,7 +30,6 @@ type Story = StoryObj<typeof CardBase<any>>;
3030
export const Standard: Story = {
3131
args: {
3232
as: 'div',
33-
shadow: true,
3433
},
3534
render: args => (
3635
<CardBase {...args}>Dette er basisen for alle kort</CardBase>

packages/ffe-cards-react/src/CardBase.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import React, { ElementType, ForwardedRef } from 'react';
21
import classNames from 'classnames';
3-
import { WithCardActionProps, WithCardAction } from './components';
2+
import React, { ElementType, ForwardedRef } from 'react';
3+
import { WithCardAction, WithCardActionProps } from './components';
4+
import { fixedForwardRef } from './fixedForwardRef';
45
import {
56
BgColor,
67
BgColorDarkmode,
7-
ComponentAsPropParams,
88
CardActionRenderProps,
9+
ComponentAsPropParams,
910
} from './types';
10-
import { fixedForwardRef } from './fixedForwardRef';
1111

1212
export type CardBaseProps<As extends ElementType = 'div'> = Omit<
1313
ComponentAsPropParams<As>,
1414
'children'
1515
> & {
16-
shadow?: boolean;
1716
/** No margin on card */
1817
noMargin?: boolean;
1918
textCenter?: boolean;
@@ -29,7 +28,6 @@ function CardBaseWithForwardRef<As extends ElementType>(
2928
) {
3029
const {
3130
className,
32-
shadow,
3331
noMargin,
3432
textCenter,
3533
bgColor,
@@ -45,7 +43,6 @@ function CardBaseWithForwardRef<As extends ElementType>(
4543
className={classNames('ffe-card-base', className, {
4644
[`ffe-card-base--bg-${bgColor}`]: bgColor,
4745
[`ffe-card-base--dm-bg-${bgDarkmodeColor}`]: bgDarkmodeColor,
48-
'ffe-card-base--shadow': shadow,
4946
'ffe-card-base--no-margin': noMargin,
5047
'ffe-card-base--text-center': textCenter,
5148
'ffe-card-base--no-padding': noPadding,

packages/ffe-cards-react/src/GroupCard/GroupCard.mdx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Canvas, Meta, Controls } from '@storybook/blocks';
1+
import { Canvas, Controls, Meta } from '@storybook/blocks';
22
import * as GroupCardStories from './GroupCard.stories.tsx';
33

44
<Meta of={GroupCardStories} />
@@ -10,10 +10,6 @@ GroupCard er et kort med en liste av elementer inni. Det kan bestå av `GroupCar
1010
<Canvas of={GroupCardStories.Standard} />
1111
<Controls of={GroupCardStories.Standard} />
1212

13-
Man kan modifisere GroupCard til å ikke ha skygge med `shadow={false}`.
14-
15-
<Canvas of={GroupCardStories.ShadowFalse} />
16-
1713
`GroupCardElement` har linjer mellom elementene som standard, men det kan fjernes med `noSeparator`.
1814

1915
<Canvas of={GroupCardStories.NoSeparator} />

packages/ffe-cards-react/src/GroupCard/GroupCard.stories.tsx

+5-20
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { Heading2, Paragraph } from '@sb1/ffe-core-react';
2+
import type { Meta, StoryObj } from '@storybook/react';
13
import React from 'react';
4+
import { CardRenderProps } from '../types';
25
import { GroupCard } from './GroupCard';
3-
import { GroupCardTitle } from './GroupCardTitle';
46
import { GroupCardElement } from './GroupCardElement';
57
import { GroupCardFooter } from './GroupCardFooter';
6-
import { Heading2, Paragraph } from '@sb1/ffe-core-react';
7-
import type { StoryObj, Meta } from '@storybook/react';
8-
import { CardRenderProps } from '../types';
8+
import { GroupCardTitle } from './GroupCardTitle';
99

1010
const meta: Meta<typeof GroupCard> = {
1111
title: 'Komponenter/Cards/GroupCard',
@@ -16,9 +16,7 @@ export default meta;
1616
type Story = StoryObj<typeof GroupCard>;
1717

1818
export const Standard: Story = {
19-
args: {
20-
shadow: true,
21-
},
19+
args: {},
2220
render: args => (
2321
<GroupCard {...args}>
2422
<GroupCardTitle>
@@ -38,19 +36,6 @@ export const Standard: Story = {
3836
),
3937
};
4038

41-
export const ShadowFalse: Story = {
42-
args: {
43-
...Standard.args,
44-
shadow: false,
45-
},
46-
render: args => (
47-
<GroupCard {...args}>
48-
<GroupCardElement>Innhold nr 1</GroupCardElement>
49-
<GroupCardElement>Innhold nr 2</GroupCardElement>
50-
<GroupCardElement>Innhold nr 3</GroupCardElement>
51-
</GroupCard>
52-
),
53-
};
5439
export const NoSeparator: Story = {
5540
args: {
5641
...Standard.args,

packages/ffe-cards-react/src/GroupCard/GroupCard.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import React, { ForwardedRef } from 'react';
21
import classNames from 'classnames';
2+
import React, { ForwardedRef } from 'react';
33
import { fixedForwardRef } from '../fixedForwardRef';
44
import { BgColor, BgColorDarkmode } from '../types';
55

66
export interface GroupCardProps
77
extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
8-
shadow?: boolean;
98
/** The children of the GroupCard component */
109
children: React.ReactNode;
1110
/** The background color of the whole groupcard element */
@@ -18,7 +17,6 @@ export interface GroupCardProps
1817

1918
function GroupCardWithForwardRef(
2019
{
21-
shadow,
2220
className,
2321
children,
2422
bgColor,
@@ -33,7 +31,6 @@ function GroupCardWithForwardRef(
3331
className={classNames(
3432
'ffe-group-card',
3533
{
36-
'ffe-group-card--shadow': shadow,
3734
'ffe-group-card--no-margin': noMargin,
3835
[`ffe-group-card--bg-${bgColor}`]: bgColor,
3936
[`ffe-group-card--dm-bg-${bgDarkmodeColor}`]:

packages/ffe-cards-react/src/components/CardAction.stories.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
2-
import { CardAction as CardActionComponent } from './CardAction';
3-
import type { StoryObj, Meta } from '@storybook/react';
4-
import { CardBase } from '../CardBase';
51
import { Heading2, Paragraph } from '@sb1/ffe-core-react';
62
import { Icon } from '@sb1/ffe-icons-react';
3+
import type { Meta, StoryObj } from '@storybook/react';
4+
import React from 'react';
5+
import { CardBase } from '../CardBase';
76
import { IconCard } from '../IconCard/IconCard';
87
import { CardActionRenderProps, CardRenderProps } from '../types';
8+
import { CardAction as CardActionComponent } from './CardAction';
99

1010
const Custom: React.FC<React.ComponentProps<'a'>> = props => (
1111
<a {...props}>
@@ -39,7 +39,7 @@ export const Standard: Story = {
3939
href: 'https://design.sparebank1.no',
4040
},
4141
render: args => (
42-
<CardBase shadow={true}>
42+
<CardBase>
4343
{({ CardAction }: CardActionRenderProps) => (
4444
<>
4545
<Heading2>
@@ -58,7 +58,7 @@ export const AsButton: Story = {
5858
type: 'button',
5959
},
6060
render: args => (
61-
<CardBase shadow={true}>
61+
<CardBase>
6262
{({ CardAction }: CardActionRenderProps) => (
6363
<>
6464
<Heading2>

0 commit comments

Comments
 (0)