Skip to content

Commit 88a7032

Browse files
committed
Merge branch 'contact-step-page' of github.com:navikt/nav-enonicxp-frontend into contact-step-page
2 parents 233bae8 + b69721d commit 88a7032

File tree

2 files changed

+44
-72
lines changed

2 files changed

+44
-72
lines changed

packages/nextjs/src/components/pages/contact-step-page/ContactStepPage.module.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
grid-template-areas:
99
'header'
1010
'content'
11-
'link';
11+
'backLink';
1212

1313
@media #{common.$mq-screen-tablet-and-desktop} {
1414
grid-template-columns: 1fr 40rem 1fr;
1515
grid-template-areas:
1616
'pictogram header .'
1717
'. content .'
18-
'. link .';
18+
'. backLink .';
1919
column-gap: var(--a-spacing-10);
2020
}
2121
.pictogram {
@@ -60,7 +60,7 @@
6060
}
6161
}
6262
}
63-
.link {
64-
grid-area: link;
63+
.backLink {
64+
grid-area: backLink;
6565
}
6666
}

packages/nextjs/src/components/pages/contact-step-page/ContactStepPage.tsx

+40-68
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,22 @@ import { ParsedHtml } from 'components/_common/parsedHtml/ParsedHtml';
44
import { ContentType, ContentCommonProps } from 'types/content-props/_content-common';
55
import { IllustrationStatic } from 'components/_common/illustration/static/IllustrationStatic';
66
import { PictogramsProps } from 'types/content-props/pictograms';
7-
import { stripXpPathPrefix } from 'utils/urls';
87
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase';
98
import { LenkeInline } from 'components/_common/lenke/lenkeInline/LenkeInline';
9+
import { InternalLinkMixin } from 'types/component-props/_mixins';
1010
import style from './ContactStepPage.module.scss';
1111

12-
type LinkInternal = {
13-
external?: never;
14-
internal: { internalContent: Pick<ContentCommonProps, '_path'> };
15-
_selected: 'internal';
16-
};
17-
18-
type LinkExternal = {
19-
external: { externalUrl: string };
20-
internal?: never;
21-
_selected: 'external';
22-
};
23-
24-
type Link = LinkInternal | LinkExternal;
25-
26-
interface LinkPanel {
27-
label: string;
28-
explanation?: string;
29-
link: Link;
30-
}
31-
3212
export type ContactStepPageProps = ContentCommonProps & {
3313
type: ContentType.ContactStepPage;
3414
data: {
3515
title: string;
3616
illustration: PictogramsProps;
3717
textAboveTitle?: string;
3818
html: string;
39-
linksHeading: string;
40-
linksSubHeadline: string;
41-
links: LinkPanel[];
42-
link: {
43-
internal: {
44-
target: { _path: string };
45-
text: string;
46-
};
47-
};
19+
linkPanelsHeading: string;
20+
linkPanelsSubHeading: string;
21+
linkPanels: (InternalLinkMixin & { ingress?: string })[];
22+
backLink: InternalLinkMixin;
4823
};
4924
};
5025

@@ -54,20 +29,12 @@ export const ContactStepPage = ({ data }: ContactStepPageProps) => {
5429
illustration,
5530
textAboveTitle,
5631
html,
57-
links: linkPanels,
58-
linksHeading: linksPanelHeading,
59-
linksSubHeadline: linksPanelSubHeadline,
60-
link,
32+
linkPanelsHeading,
33+
linkPanelsSubHeading,
34+
linkPanels,
35+
backLink,
6136
} = data;
6237

63-
const getHref = (link: Link) => {
64-
return link._selected === 'internal'
65-
? stripXpPathPrefix(link.internal?.internalContent._path)
66-
: link.external.externalUrl;
67-
};
68-
69-
const { target, text } = link.internal;
70-
7138
return (
7239
<div className={style.contactStepPage}>
7340
<IllustrationStatic illustration={illustration} className={style.pictogram} />
@@ -79,36 +46,41 @@ export const ContactStepPage = ({ data }: ContactStepPageProps) => {
7946
<div className={style.content}>
8047
<ParsedHtml htmlProps={html} />
8148

82-
{linksPanelHeading && (
49+
{linkPanelsHeading && (
8350
<Heading size="medium" level="2">
84-
{linksPanelHeading}
51+
{linkPanelsHeading}
8552
</Heading>
8653
)}
87-
{linksPanelSubHeadline && <BodyShort>{linksPanelSubHeadline}</BodyShort>}
88-
{linkPanels && linkPanels.length > 0 && (
89-
<ul className={style.linkPanels}>
90-
{linkPanels.map((linkPanel, index) => (
91-
<li key={index}>
92-
<LinkPanel
93-
as={LenkeBase}
94-
href={getHref(linkPanel.link)}
95-
className={style.linkPanel}
96-
>
97-
<LinkPanel.Title>{linkPanel.label}</LinkPanel.Title>
98-
{linkPanel.explanation && (
99-
<LinkPanel.Description>
100-
{linkPanel.explanation}
101-
</LinkPanel.Description>
102-
)}
103-
</LinkPanel>
104-
</li>
105-
))}
106-
</ul>
107-
)}
108-
</div>
109-
<div className={style.link}>
110-
<LenkeInline href={target._path}>{text}</LenkeInline>
54+
{linkPanelsSubHeading && <BodyShort>{linkPanelsSubHeading}</BodyShort>}
55+
56+
<ul className={style.linkPanels}>
57+
{linkPanels.map((linkPanel, index) => (
58+
<li key={index}>
59+
<LinkPanel
60+
as={LenkeBase}
61+
href={linkPanel.target._path}
62+
className={style.linkPanel}
63+
// TODO finn utav analytics
64+
// analyticsComponent={'mellomsteg'}
65+
// analyticsLinkGroup={currentStepData.stepsHeadline}
66+
// analyticsLabel={step.label}s
67+
>
68+
<LinkPanel.Title>
69+
{linkPanel.text ?? linkPanel.target.displayName}
70+
</LinkPanel.Title>
71+
{linkPanel.ingress && (
72+
<LinkPanel.Description>
73+
{linkPanel.ingress}
74+
</LinkPanel.Description>
75+
)}
76+
</LinkPanel>
77+
</li>
78+
))}
79+
</ul>
11180
</div>
81+
<LenkeInline href={backLink.target._path} className={style.backLink}>
82+
{backLink.text ?? backLink.target.displayName}
83+
</LenkeInline>
11284
</div>
11385
);
11486
};

0 commit comments

Comments
 (0)