Skip to content

Commit d5dc1b8

Browse files
authored
Merge pull request #2029 from navikt/header-types-and-stories
Stories og types Themed Page Header
2 parents 9d943d9 + 703ce2c commit d5dc1b8

File tree

56 files changed

+571
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+571
-107
lines changed

.storybook/modes.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const allModes = {
2+
small: {
3+
viewport: 'small',
4+
},
5+
large: {
6+
viewport: 'large',
7+
},
8+
};

.storybook/preview.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
import type { Preview } from '@storybook/react';
2+
import { allModes } from '../.storybook/modes';
23
import '../src/global.scss';
34

45
const preview: Preview = {
56
parameters: {
6-
layout: 'centered',
7+
viewport: {
8+
viewports: {
9+
small: { name: 'small', styles: { width: '390px', height: '100%' } },
10+
large: { name: 'large', styles: { width: '820px', height: '100%' } },
11+
},
12+
},
13+
chromatic: {
14+
modes: {
15+
small: allModes['small'],
16+
large: allModes['large'],
17+
},
18+
},
719
},
820
tags: ['autodocs'],
921
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { CallOption } from './CallOption';
4+
5+
const meta = {
6+
component: CallOption,
7+
parameters: {
8+
backgrounds: {
9+
values: [{ name: 'ContactBackground', value: '#f2f3f5' }],
10+
default: 'ContactBackground',
11+
},
12+
},
13+
} satisfies Meta<typeof CallOption>;
14+
15+
export default meta;
16+
17+
type Story = StoryObj<typeof meta>;
18+
19+
export const Default: Story = {};
20+
21+
export const WithAlert: Story = { args: { alertText: 'Alert!' } };

src/components/_common/contact-option/CallOption.tsx src/components/_common/contact-option/CallOption/CallOption.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { LenkeBase } from 'components/_common/lenke/LenkeBase';
55
import { AnalyticsEvents } from 'utils/amplitude';
66
import { useLayoutConfig } from 'components/layouts/useLayoutConfig';
77
import { ParsedHtml } from 'components/_common/parsed-html/ParsedHtml';
8-
import { OpeningInfo } from 'components/_common/contact-option/opening-info/OpeningInfo';
8+
import { OpeningInfo } from 'components/_common/contact-option/openingInfo/OpeningInfo';
99
import { Audience, getAudience } from 'types/component-props/_mixins';
1010
import { ProcessedHtmlProps } from 'types/processed-html-props';
1111
import { usePageContentProps } from 'store/pageContext';
1212
import { TelephoneData } from 'components/parts/contact-option/ContactOptionPart';
1313
import { Icon } from 'components/_common/contact-option/icon/Icon';
1414

15-
import sharedStyle from './ContactOption.module.scss';
16-
import alertStyle from './Alert.module.scss';
15+
import sharedStyle from 'components/_common/contact-option/ContactOption.module.scss';
16+
import alertStyle from 'components/_common/contact-option/Alert.module.scss';
1717
import style from './CallOption.module.scss';
1818

1919
const contactURLs: Record<Audience, Record<'no' | 'en', string>> = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { ChatOption } from './ChatOption';
4+
5+
const meta = {
6+
component: ChatOption,
7+
parameters: {
8+
backgrounds: {
9+
values: [{ name: 'ContactBackground', value: '#f2f3f5' }],
10+
default: 'ContactBackground',
11+
},
12+
},
13+
} satisfies Meta<typeof ChatOption>;
14+
15+
export default meta;
16+
17+
type Story = StoryObj<typeof meta>;
18+
19+
export const Default: Story = { args: {} };
20+
21+
export const WithAlert: Story = { args: { alertText: 'Alert!' } };

src/components/_common/contact-option/ChatOption.tsx src/components/_common/contact-option/ChatOption/ChatOption.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { ParsedHtml } from 'components/_common/parsed-html/ParsedHtml';
1010
import TextWithIndicator from 'components/_common/textWithIndicator/TextWithIndicator';
1111
import { ChatData } from 'components/parts/contact-option/ContactOptionPart';
1212
import { Icon } from 'components/_common/contact-option/icon/Icon';
13-
import { OpeningInfo } from './opening-info/OpeningInfo';
13+
import { OpeningInfo } from 'components/_common/contact-option/openingInfo/OpeningInfo';
1414

15-
import sharedStyle from './ContactOption.module.scss';
16-
import alertStyle from './Alert.module.scss';
15+
import sharedStyle from 'components/_common/contact-option/ContactOption.module.scss';
16+
import alertStyle from 'components/_common/contact-option/Alert.module.scss';
1717

1818
export const ChatOption = (props: ChatData) => {
1919
const { ingress, title, alertText, regularOpeningHours, specialOpeningHours } = props;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { DefaultOption } from './DefaultOption';
4+
5+
const meta = {
6+
component: DefaultOption,
7+
parameters: {
8+
backgrounds: {
9+
values: [{ name: 'ContactBackground', value: '#f2f3f5' }],
10+
default: 'ContactBackground',
11+
},
12+
},
13+
} satisfies Meta<typeof DefaultOption>;
14+
15+
export default meta;
16+
17+
type Story = StoryObj<typeof meta>;
18+
19+
export const AidCentral: Story = { args: { channel: 'aidcentral' } };
20+
21+
export const NavOffice: Story = { args: { channel: 'navoffice' } };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { WriteOption } from './WriteOption';
4+
5+
const meta = {
6+
component: WriteOption,
7+
parameters: {
8+
backgrounds: {
9+
values: [{ name: 'ContactBackground', value: '#f2f3f5' }],
10+
default: 'ContactBackground',
11+
},
12+
},
13+
} satisfies Meta<typeof WriteOption>;
14+
15+
export default meta;
16+
17+
type Story = StoryObj<typeof meta>;
18+
19+
export const Default: Story = {};
20+
21+
export const WithAlert: Story = { args: { alertText: 'Alert!' } };

src/components/_common/contact-option/WriteOption.tsx src/components/_common/contact-option/WriteOption/WriteOption.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import Config from 'config';
99
import { WriteData } from 'components/parts/contact-option/ContactOptionPart';
1010
import { Icon } from 'components/_common/contact-option/icon/Icon';
1111

12-
import sharedStyle from './ContactOption.module.scss';
13-
import alertStyle from './Alert.module.scss';
12+
import sharedStyle from 'components/_common/contact-option/ContactOption.module.scss';
13+
import alertStyle from 'components/_common/contact-option/Alert.module.scss';
1414

1515
type Props = WriteData;
1616

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { OpeningInfo } from './OpeningInfo';
4+
5+
const meta = {
6+
component: OpeningInfo,
7+
} satisfies Meta<typeof OpeningInfo>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Closed: Story = {
14+
args: {
15+
regularOpeningHours: {
16+
hours: [
17+
{ status: 'CLOSED', dayName: 'monday' },
18+
{ status: 'CLOSED', dayName: 'tuesday' },
19+
{ status: 'CLOSED', dayName: 'wednesday' },
20+
{ status: 'CLOSED', dayName: 'thursday' },
21+
{ status: 'CLOSED', dayName: 'friday' },
22+
{ status: 'CLOSED', dayName: 'saturday' },
23+
{ status: 'CLOSED', dayName: 'sunday' },
24+
],
25+
},
26+
specialOpeningHours: {
27+
validFrom: '2023-03-01T00:00:00Z',
28+
validTo: '2050-03-01T00:00:00Z',
29+
},
30+
},
31+
};
32+
33+
export const Open: Story = {
34+
args: {
35+
regularOpeningHours: {
36+
hours: [
37+
{ status: 'OPEN', dayName: 'monday', from: '00:00', to: '23:59' },
38+
{ status: 'OPEN', dayName: 'tuesday', from: '00:00', to: '23:59' },
39+
{ status: 'OPEN', dayName: 'wednesday', from: '00:00', to: '23:59' },
40+
{ status: 'OPEN', dayName: 'thursday', from: '00:00', to: '23:59' },
41+
{ status: 'OPEN', dayName: 'friday', from: '00:00', to: '23:59' },
42+
{ status: 'OPEN', dayName: 'saturday', from: '00:00', to: '23:59' },
43+
{ status: 'OPEN', dayName: 'sunday', from: '00:00', to: '23:59' },
44+
],
45+
},
46+
specialOpeningHours: {
47+
validFrom: '2023-01-01T00:00:00Z',
48+
validTo: '2050-01-01T00:00:00Z',
49+
},
50+
},
51+
};

src/components/_common/contact-option/opening-info/OpeningInfo.tsx src/components/_common/contact-option/openingInfo/OpeningInfo.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useEffect, useState } from 'react';
22
import { Loader } from '@navikt/ds-react';
3-
import { getCurrentOpeningHours } from 'components/_common/contact-option/opening-info/helpers/openingInfoUtils';
3+
import { getCurrentOpeningHours } from 'components/_common/contact-option/openingInfo/helpers/openingInfoUtils';
44
import { usePageContentProps } from 'store/pageContext';
5-
import { OpeningHours } from 'components/_common/contact-option/opening-info/helpers/openingInfoTypes';
6-
import { getOpeningInfoText } from 'components/_common/contact-option/opening-info/helpers/openingInfoText';
7-
import { processOpeningHours } from 'components/_common/contact-option/opening-info/helpers/processOpeningHours';
5+
import { OpeningHours } from 'components/_common/contact-option/openingInfo/helpers/openingInfoTypes';
6+
import { getOpeningInfoText } from 'components/_common/contact-option/openingInfo/helpers/openingInfoText';
7+
import { processOpeningHours } from 'components/_common/contact-option/openingInfo/helpers/processOpeningHours';
88

99
import TextWithIndicator from 'components/_common/textWithIndicator/TextWithIndicator';
1010
import {

src/components/_common/contact-option/opening-info/helpers/openingInfo.test.ts src/components/_common/contact-option/openingInfo/helpers/openingInfo.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { processOpeningHours } from 'components/_common/contact-option/opening-info/helpers/processOpeningHours';
2-
import { getCurrentOpeningHours } from 'components/_common/contact-option/opening-info/helpers/openingInfoUtils';
3-
import { getOpeningInfoText } from 'components/_common/contact-option/opening-info/helpers/openingInfoText';
1+
import { processOpeningHours } from 'components/_common/contact-option/openingInfo/helpers/processOpeningHours';
2+
import { getCurrentOpeningHours } from 'components/_common/contact-option/openingInfo/helpers/openingInfoUtils';
3+
import { getOpeningInfoText } from 'components/_common/contact-option/openingInfo/helpers/openingInfoText';
44
import { translator } from 'translations';
55
import {
66
OpeningHourRegularRaw,

src/components/_common/contact-option/opening-info/helpers/openingInfoText.ts src/components/_common/contact-option/openingInfo/helpers/openingInfoText.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import timezone from 'dayjs/plugin/timezone';
44
import {
55
OpeningHours,
66
OpeningHoursOpen,
7-
} from 'components/_common/contact-option/opening-info/helpers/openingInfoTypes';
7+
} from 'components/_common/contact-option/openingInfo/helpers/openingInfoTypes';
88
import { Language, translator } from 'translations';
99
import { norwayTz } from 'utils/datetime';
1010
import {
1111
getOpeningHoursForDateTime,
1212
openingHourDateFormat,
1313
openingHourTimeFormat,
14-
} from 'components/_common/contact-option/opening-info/helpers/openingInfoUtils';
14+
} from 'components/_common/contact-option/openingInfo/helpers/openingInfoUtils';
1515

1616
dayjs.extend(utc);
1717
dayjs.extend(timezone);

src/components/_common/contact-option/opening-info/helpers/openingInfoUtils.ts src/components/_common/contact-option/openingInfo/helpers/openingInfoUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import utc from 'dayjs/plugin/utc';
33
import timezone from 'dayjs/plugin/timezone';
44
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
55
import { daysNameArray, norwayTz } from 'utils/datetime';
6-
import { OpeningHours } from 'components/_common/contact-option/opening-info/helpers/openingInfoTypes';
6+
import { OpeningHours } from 'components/_common/contact-option/openingInfo/helpers/openingInfoTypes';
77

88
dayjs.extend(utc);
99
dayjs.extend(timezone);

src/components/_common/contact-option/opening-info/helpers/processOpeningHours.ts src/components/_common/contact-option/openingInfo/helpers/processOpeningHours.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import customParseFormat from 'dayjs/plugin/customParseFormat';
33
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
44
import utc from 'dayjs/plugin/utc';
55
import timezone from 'dayjs/plugin/timezone';
6-
import { openingHourDateFormat } from 'components/_common/contact-option/opening-info/helpers/openingInfoUtils';
6+
import { openingHourDateFormat } from 'components/_common/contact-option/openingInfo/helpers/openingInfoUtils';
77
import { dayNameToIndex, daysNameArray } from 'utils/datetime';
8-
import { OpeningHours } from 'components/_common/contact-option/opening-info/helpers/openingInfoTypes';
8+
import { OpeningHours } from 'components/_common/contact-option/openingInfo/helpers/openingInfoTypes';
99
import {
1010
OpeningHourRaw,
1111
OpeningHourRegularRaw,

src/components/_common/headers/featured-header/DateLine.tsx

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { DateLine } from './DateLine';
4+
5+
const meta = {
6+
component: DateLine,
7+
} satisfies Meta<typeof DateLine>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Default: Story = {
14+
args: {
15+
content: {
16+
modifiedTime: '2023-07-03T07:02:26.724412Z',
17+
createdTime: '2023-07-03T07:02:26.724412Z',
18+
language: 'no',
19+
},
20+
},
21+
};
22+
23+
export const English: Story = {
24+
args: {
25+
content: {
26+
...Default.args.content,
27+
language: 'en',
28+
},
29+
},
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Detail } from '@navikt/ds-react';
2+
import { getPublishedAndModifiedString, GetPublishedAndModifiedStringProps } from 'utils/datetime';
3+
4+
import styles from './DateLine.module.scss';
5+
6+
export const DateLine = ({ content }: GetPublishedAndModifiedStringProps) => {
7+
const dateString = getPublishedAndModifiedString({ content });
8+
9+
return (
10+
<div className={styles.dateLine}>
11+
<div className={styles.container}>
12+
<Detail className={styles.dateLabel}>{dateString}</Detail>
13+
</div>
14+
</div>
15+
);
16+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
3+
import { FeaturedHeader } from './FeaturedHeader';
4+
5+
const meta = {
6+
component: FeaturedHeader,
7+
} satisfies Meta<typeof FeaturedHeader>;
8+
9+
export default meta;
10+
11+
type Story = StoryObj<typeof meta>;
12+
13+
export const Default: Story = {
14+
args: {
15+
contentProps: {
16+
displayName: 'displayNameFallback',
17+
modifiedTime: '2023-07-03T07:02:26.724412Z',
18+
createdTime: '2023-07-03T07:02:26.724412Z',
19+
data: {
20+
title: 'Featured Header',
21+
},
22+
},
23+
},
24+
};

0 commit comments

Comments
 (0)