Skip to content

Varsel i kontekst #1697

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

Merged
merged 22 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7fbd1c9
Introduserer i-kontekst-varsel og varsel for skjemaoversikt
terjeofnorway Jan 31, 2024
cef1829
Henter i-kontekst-varsel basert på riktig id
terjeofnorway Feb 1, 2024
6c9bfae
Merge master into in-kontekst-varsel
terjeofnorway Feb 8, 2024
74b9b3f
Merge master into in-kontekst-varsel
terjeofnorway Feb 12, 2024
59055b9
Reintroduserer kode etter problemer i merge-konflikt
terjeofnorway Feb 12, 2024
b59a392
Justerer uthenting av alerts etter strukturendring
terjeofnorway Feb 13, 2024
9b42761
Letter inn korrekte varsel i skjemadetaljer på produktside
terjeofnorway Feb 13, 2024
20d8609
Merge branch 'master' into in-kontekst-varsel
terjeofnorway Feb 13, 2024
c617349
Forenkler struktur for varsel i kontekst
terjeofnorway Feb 13, 2024
67bab1d
Fjerner ubrukt import for varsel i kontekst
terjeofnorway Feb 13, 2024
0442b0a
Merge master into in-kontekst-varsel
terjeofnorway Feb 13, 2024
4b79ed3
Fjerner glemt console.log
terjeofnorway Feb 13, 2024
5a7b7aa
Forbedrer håndtering av feilaktig data i i-kontekst-varsel
terjeofnorway Feb 13, 2024
968f9e1
Justerer styling på varsel i kontekst
terjeofnorway Feb 13, 2024
b0a9c0a
Forbedrer forceArray-bruk for varsel i kontekst
terjeofnorway Feb 14, 2024
d19f22d
Merge master into in-kontekst-varsel
terjeofnorway Feb 16, 2024
04a20de
Rydder i typer og komponenter etter flytting av alerts til form-details
terjeofnorway Feb 19, 2024
9357bdd
Merge branch 'master' into in-kontekst-varsel
terjeofnorway Feb 19, 2024
9d03c76
Forbedrer navning og rydder vekk ubrukte typer etter forenkling
terjeofnorway Feb 19, 2024
ff6a5ec
Legger til støtte for forhåndsvisning av varsel i kontekst
terjeofnorway Feb 20, 2024
47abc51
Kodeforbedring og forenkling av typer etter PR-review
terjeofnorway Feb 20, 2024
472c8b6
Fjerner ubrukt import
terjeofnorway Feb 20, 2024
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
2 changes: 2 additions & 0 deletions src/components/ContentMapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { FormsOverviewPage } from 'components/pages/forms-overview-page/FormsOve
import { VideoPage } from './pages/video-page/VideoPage';
import { CalculatorPage } from './pages/calculator-page/CalculatorPage';
import { UserTestsConfigPreviewPage } from 'components/pages/user-tests-config-preview-page/UserTestsConfigPreviewPage';
import { AlertInContextPage } from './pages/alert-in-context-page/AlertInContextPage';

const contentToReactComponent: {
[key in ContentType]?: React.FunctionComponent<ContentProps<key>>;
Expand Down Expand Up @@ -59,6 +60,7 @@ const contentToReactComponent: {
[ContentType.FormsOverview]: FormsOverviewPage,
[ContentType.Calculator]: CalculatorPage,
[ContentType.UserTestsConfig]: UserTestsConfigPreviewPage,
[ContentType.AlertInContext]: AlertInContextPage,

[ContentType.AreaPage]: DynamicPage,
[ContentType.FrontPage]: DynamicPage,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.alertInContext {
margin: 0 0 1rem 0;
border: 0;
padding-top: var(--a-spacing-3);
padding-bottom: var(--a-spacing-3);
}
23 changes: 23 additions & 0 deletions src/components/_common/alert-in-context/AlertInContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { AlertData } from 'types/content-props/alerts';
import { AlertBox } from '../alert-box/AlertBox';

import style from './AlertInContext.module.scss';

type Props = {
alert: AlertData;
};

export const AlertInContext = ({ alert }: Props) => {
if (!alert) {
return null;
}

const variant = alert.data.type === 'critical' ? 'warning' : 'info';

return (
<AlertBox className={style.alertInContext} variant={variant}>
{alert.data.text}
</AlertBox>
);
};
15 changes: 13 additions & 2 deletions src/components/_common/form-details/FormDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ParsedHtml } from '../parsed-html/ParsedHtml';
import { FormDetailsData, Variation } from 'types/content-props/form-details';
import { FormDetailsButton } from './FormDetailsButton';
import { InfoBox } from '../info-box/InfoBox';
import { AlertInContext } from '../alert-in-context/AlertInContext';

import style from './FormDetails.module.scss';

Expand Down Expand Up @@ -39,8 +40,14 @@ export const FormDetails = ({
showTitleAsLevel4 = false, // Temporary solution until all product pages have been re-organized.
} = displayConfig;

const { formNumbers, formType, languageDisclaimer, ingress, title } =
formDetails;
const {
formNumbers,
formType,
languageDisclaimer,
ingress,
title,
alerts,
} = formDetails;

const variations = formType.reduce((acc, cur) => {
const { _selected } = cur;
Expand Down Expand Up @@ -111,6 +118,10 @@ export const FormDetails = ({
</div>
)}
{languageDisclaimer && <InfoBox>{languageDisclaimer}</InfoBox>}
{alerts &&
alerts.map((alert, index) => (
<AlertInContext key={index} alert={alert} />
))}
{variations.length > 0 && (
<div className={style.variation}>
{variations.map((variation, index) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@use 'common' as common;

$margin: 2rem;

.alertInContextPage {
display: flex;
flex-direction: column;
max-width: common.$sectionMaxWidth;
}
14 changes: 14 additions & 0 deletions src/components/pages/alert-in-context-page/AlertInContextPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

import { AlertInContext } from 'components/_common/alert-in-context/AlertInContext';
import { AlertData } from 'types/content-props/alerts';

import style from './AlertInContextPage.module.scss';

export const AlertInContextPage = (props: AlertData) => {
return (
<div className={style.alertInContextPage}>
<AlertInContext alert={props} />
</div>
);
};
4 changes: 1 addition & 3 deletions src/components/parts/form-details/FormDetailsPart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { FormDetailsProps } from 'types/component-props/parts/form-details';
import { EditorHelp } from 'components/_editor-only/editor-help/EditorHelp';
import { FormDetails } from 'components/_common/form-details/FormDetails';
import { FilteredContent } from '../../_common/filtered-content/FilteredContent';
import {
ContentType,
} from 'types/content-props/_content-common';
import { ContentType } from 'types/content-props/_content-common';

export const FormDetailsPart = ({ config, pageProps }: FormDetailsProps) => {
const { targetFormDetails, ...displayConfig } = config;
Expand Down
1 change: 1 addition & 0 deletions src/types/content-props/_content-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export enum ContentType {
FormsOverview = 'no.nav.navno:forms-overview',
UserTestsConfig = 'no.nav.navno:user-tests-config',
Video = 'no.nav.navno:video',
AlertInContext = 'no.nav.navno:alert-in-context',
}

export type ContentAndMediaCommonProps = {
Expand Down
14 changes: 14 additions & 0 deletions src/types/content-props/alerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { OptionSetSingle } from 'types/util-types';

export interface AlertData {
data: {
type: 'information' | 'critical';
text: string;
target: {
_selected: string;
formDetails: OptionSetSingle<{
targetContent: string;
}>;
};
};
}
2 changes: 2 additions & 0 deletions src/types/content-props/form-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { OptionSetSingle } from 'types/util-types';
import { ContentCommonProps, ContentType } from './_content-common';
import { ProcessedHtmlProps } from 'types/processed-html-props';
import { LinkSelectable } from 'types/component-props/_mixins';
import { AlertData } from './alerts';

export type FormComplaintTypes = 'complaint' | 'appeal';

Expand All @@ -16,6 +17,7 @@ export interface FormDetailsData {
title?: string;
ingress?: ProcessedHtmlProps;
languageDisclaimer?: string;
alerts: AlertData[];
formType: OptionSetSingle<{
application: {
variations: Variation[];
Expand Down