Skip to content

Commit 54501a8

Browse files
committed
Merge branch 'main' into mellomsteg
2 parents c073171 + 55808cd commit 54501a8

20 files changed

+159
-211
lines changed

packages/nextjs/src/components/_common/areaCard/AreaCard.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { LinkPanel } from '@navikt/ds-react';
33
import { EditorHelp } from 'components/_editor-only/editor-help/EditorHelp';
44
import { classNames } from 'utils/classnames';
5+
import { useLayoutConfig } from 'components/layouts/useLayoutConfig';
56
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase';
67
import { AreaCardGraphics } from './graphics/AreaCardGraphics';
78

@@ -17,6 +18,9 @@ type Props = {
1718
} & Omit<React.ComponentProps<typeof LinkPanel>, 'as'>;
1819

1920
export const AreaCard = ({ path, title, area, linkGroup, className, ...rest }: Props) => {
21+
const { layoutConfig } = useLayoutConfig();
22+
const analyticsLinkGroup= linkGroup ?? layoutConfig.title;
23+
2024
if (!area) {
2125
return <EditorHelp text={'Velg en grafikk for kortet'} />;
2226
}
@@ -28,7 +32,7 @@ export const AreaCard = ({ path, title, area, linkGroup, className, ...rest }: P
2832
href={path}
2933
analyticsLabel={title}
3034
analyticsComponent={'Områdekort'}
31-
analyticsLinkGroup={linkGroup}
35+
analyticsLinkGroup={analyticsLinkGroup}
3236
className={classNames(style.linkPanel, graphicsStyle.expandOnHover, className)}
3337
as={LenkeBase}
3438
>

packages/nextjs/src/components/_common/headers/headerWithParent/HeaderWithParent.module.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.textAboveTitle {
77
color: var(--a-text-subtle);
88
font-weight: 400;
9-
font-size: 20px;
9+
font-size: 18px;
1010
line-height: 28px;
1111
letter-spacing: -0.1%;
1212
}

packages/nextjs/src/components/_common/illustration/Illustration.module.scss

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
display: flex;
44
justify-content: center;
55
align-items: center;
6+
width: 100%;
7+
height: 100%;
8+
min-width: 4rem;
9+
min-height: 4rem;
610

711
&:empty {
812
display: none;

packages/nextjs/src/components/_common/lenkepanel-liste/LenkepanelListe.module.scss

-35
This file was deleted.

packages/nextjs/src/components/_common/lenkepanel-liste/LenkepanelListe.tsx

-54
This file was deleted.

packages/nextjs/src/components/_common/metatags/HeadWithMetatags.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ const getDescription = (content: ContentProps) => {
2323
return description.slice(0, DESCRIPTION_MAX_LENGTH);
2424
};
2525

26-
const contentTypesWithNoIndex = new Set([ContentType.Error, ContentType.FormIntermediateStepPage]);
26+
const contentTypesWithNoIndex = new Set([
27+
ContentType.Error,
28+
ContentType.FormIntermediateStepPage,
29+
ContentType.ContactStepPage,
30+
]);
2731

2832
const isNoIndex = (content: ContentProps) =>
29-
content.isPagePreview ||
30-
contentTypesWithNoIndex.has(content.type) ||
31-
content.data?.noindex ||
32-
content.type === 'no.nav.navno:contact-step-page';
33+
content.isPagePreview || contentTypesWithNoIndex.has(content.type) || content.data?.noindex;
3334

3435
const getCanonicalUrl = (content: ContentProps) => {
3536
return content.data?.canonicalUrl || `${appOrigin}${getPublicPathname(content)}`;

packages/nextjs/src/components/_common/moreLink/MoreLink.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,25 @@ import { LenkeStandalone } from 'components/_common/lenke/lenkeStandalone/LenkeS
55

66
import styles from './MoreLink.module.scss';
77

8-
export const MoreLink = ({ link }: { link?: LinkSelectable }) => {
9-
if (!link) {
8+
type Props = {
9+
link: LinkSelectable;
10+
analyticsGroup?: string;
11+
};
12+
13+
export const MoreLink = ( props: Props) => {
14+
if (!props.link) {
1015
return null;
1116
}
1217

13-
const { text, url } = getSelectableLinkProps(link);
18+
const { text, url } = getSelectableLinkProps(props.link);
1419

1520
return (
16-
<LenkeStandalone href={url} className={styles.moreLink} withChevron={false}>
21+
<LenkeStandalone
22+
href={url}
23+
linkGroup={props.analyticsGroup}
24+
className={styles.moreLink}
25+
withChevron={false}
26+
>
1727
<ArrowRightIcon aria-hidden={true} className={styles.arrow} />
1828
{text}
1929
</LenkeStandalone>

packages/nextjs/src/components/_common/uxsignalsWidget/UxSignalsWidget.tsx

+54-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,70 @@
11
import React, { useEffect } from 'react';
2+
import { getCurrentConsent } from '@navikt/nav-dekoratoren-moduler';
23
import { EditorHelp } from 'components/_editor-only/editor-help/EditorHelp';
34

45
import style from './UxSignalsWidget.module.scss';
56

6-
type Props = {
7+
type UxSignalsWidgetProps = {
78
embedCode: string;
89
};
910

10-
export const UxSignalsWidget = ({ embedCode }: Props) => {
11-
useEffect(() => {
11+
type Consent = {
12+
consent: {
13+
analytics: boolean;
14+
surveys: boolean;
15+
};
16+
userActionTaken: boolean;
17+
};
18+
19+
const uxSignalsScriptUrl = 'https://widget.uxsignals.com/embed.js';
20+
let scriptAddTimeout: ReturnType<typeof setTimeout>;
21+
22+
export const UxSignalsWidget = ({ embedCode }: UxSignalsWidgetProps) => {
23+
// If the cookie banner is visible, the user has not taken any action yet.
24+
// Wait and see if the user takes action before adding the script if consent is given..
25+
const checkConsentOrWait = (tries: number = 0) => {
26+
const { consent, userActionTaken }: Consent = getCurrentConsent();
27+
if (consent.surveys && consent.analytics) {
28+
addUXSignalsScript();
29+
return;
30+
}
31+
// Wait max 60 seconds for user respond to the cookie banner
32+
// (userActionTaken) or give up.
33+
if (!userActionTaken && tries < 60) {
34+
scriptAddTimeout = setTimeout(() => {
35+
checkConsentOrWait(tries + 1);
36+
}, 1000);
37+
}
38+
};
39+
40+
const addUXSignalsScript = () => {
41+
if (document.querySelector(`script[src="${uxSignalsScriptUrl}"]`)) {
42+
return;
43+
}
44+
1245
const script = document.createElement('script');
13-
script.src = 'https://widget.uxsignals.com/embed.js';
46+
script.src = uxSignalsScriptUrl;
1447
script.async = true;
1548
document.body.appendChild(script);
16-
return () => {
49+
};
50+
51+
const removeUXSignalsScript = () => {
52+
const script = document.querySelector(`script[src="${uxSignalsScriptUrl}"]`);
53+
if (script) {
1754
document.body.removeChild(script);
55+
}
56+
};
57+
58+
useEffect(() => {
59+
checkConsentOrWait();
60+
return () => {
61+
if (scriptAddTimeout) {
62+
clearTimeout(scriptAddTimeout);
63+
}
64+
removeUXSignalsScript();
1865
};
19-
});
66+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
67+
}, []);
2068

2169
return (
2270
<>

packages/nextjs/src/components/layouts/LayoutContainer.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export const LayoutContainer = ({
2020
layoutProps,
2121
layoutStyle,
2222
children,
23+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
24+
pageProps,
2325
...divElementProps
2426
}: Props) => {
2527
const { editorView } = usePageContentProps();

packages/nextjs/src/components/layouts/frontpage-loggedin-section/FrontpageLoggedinSectionLayout.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export const FrontpageLoggedinSectionLayout = ({ layoutProps, pageProps }: Props
4343
}
4444

4545
const { header, mypage } = config;
46+
const title = yourServicesText('yourServices');
47+
layoutProps.config.title = title; //for at kortene i region skal kunne plukke opp title til analytics
4648

4749
return (
4850
<AuthDependantRender renderOn={'loggedIn'}>
@@ -53,11 +55,11 @@ export const FrontpageLoggedinSectionLayout = ({ layoutProps, pageProps }: Props
5355
data-hj-suppress
5456
>
5557
<HeaderWithName headerText={header} />
56-
<Header level={'2'} size={'small'} className={style.services}>
57-
{yourServicesText('yourServices')}
58+
<Header level="3" size="small" className={style.services}>
59+
{title}
5860
</Header>
5961
<Region pageProps={pageProps} regionProps={regions.cards} className={style.cards} />
60-
<MoreLink link={mypage?.link} />
62+
<MoreLink analyticsGroup={title} link={mypage?.link} />
6163
</LayoutContainer>
6264
</AuthDependantRender>
6365
);
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
@use 'common' as common;
2-
31
.contactStepPage {
42
padding-bottom: 1rem;
3+
column-gap: 1.75rem;
4+
margin: 1.25rem auto 2.5rem;
55
display: grid;
6-
row-gap: var(--a-spacing-5);
7-
margin: 1.25rem auto var(--a-spacing-10);
6+
grid-template-columns: 1fr 40rem 1fr;
87
grid-template-areas:
9-
'header'
10-
'content'
11-
'link';
8+
'pictogram header .'
9+
'. content .'
10+
'. backLink .';
1211

13-
@media #{common.$mq-screen-tablet-and-desktop} {
14-
grid-template-columns: 1fr 40rem 1fr;
12+
@media only screen and (max-width: 1024px) {
13+
grid-template-columns: none;
1514
grid-template-areas:
16-
'pictogram header .'
15+
'. pictogram .'
16+
'. header .'
1717
'. content .'
18-
'. link .';
19-
column-gap: var(--a-spacing-10);
18+
'. backLink .';
2019
}
2120
.pictogram {
2221
grid-area: pictogram;
23-
display: none;
24-
25-
@media #{common.$mq-screen-tablet-and-desktop} {
26-
display: block;
27-
width: 7rem;
28-
justify-self: end;
22+
display: block;
23+
justify-self: end;
24+
width: 4.5rem;
25+
height: auto;
26+
position: relative;
27+
align-self: flex-start;
28+
29+
@media only screen and (max-width: 1024px) {
30+
width: 4rem;
31+
justify-self: start;
2932
}
3033
}
3134
.header {
@@ -34,11 +37,6 @@
3437

3538
.content {
3639
grid-area: content;
37-
max-width: 40rem;
38-
39-
& > * {
40-
border-radius: common.$border-radius-large;
41-
}
4240

4341
.linkPanels {
4442
display: flex;
@@ -48,19 +46,18 @@
4846
padding: 0;
4947

5048
.linkPanel {
51-
border-radius: common.$border-radius-large;
49+
border-radius: 0.5rem;
5250
border: 1px solid var(--a-border-subtle);
5351

54-
& :global {
55-
.navds-link-panel__title {
56-
color: var(--default-action-color);
57-
font-size: 1.25rem;
58-
}
52+
& :global(.navds-link-panel__title) {
53+
color: var(--default-action-color);
54+
font-size: 1.25rem;
5955
}
6056
}
6157
}
6258
}
63-
.link {
64-
grid-area: link;
59+
60+
.backLink {
61+
grid-area: backLink;
6562
}
6663
}

0 commit comments

Comments
 (0)