Skip to content
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

Change background color a little more controlled #2554

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
"react-device-detect": "2.2.3",
"react-dom": "18.3.1",
"react-dropzone": "14.2.3",
"react-helmet-async": "^2.0.5",
"react-leaflet": "^4.2.1",
"react-number-format": "^5.3.1",
"react-router-dom": "6.26.2",
Expand Down
3 changes: 2 additions & 1 deletion src/components/presentation/Presentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useCurrentParty } from 'src/features/party/PartiesProvider';
import { useProfile } from 'src/features/profile/ProfileProvider';
import { AltinnAppTheme } from 'src/theme/altinnAppTheme';
import { ProcessTaskType } from 'src/types';
import { BackgroundColor } from 'src/utils/BackgroundColor';
import type { PresentationType } from 'src/types';

export interface IPresentationProvidedProps extends PropsWithChildren {
Expand All @@ -41,10 +42,10 @@ export const PresentationComponent = ({ header, type, children, renderNavBar = t
const backgroundColor = isProcessStepsArchived
? AltinnAppTheme.altinnPalette.primary.greenLight
: AltinnAppTheme.altinnPalette.primary.greyLight;
document.body.style.background = backgroundColor;

return (
<RenderStart>
<BackgroundColor color={backgroundColor} />
<div
data-testid='presentation'
data-expanded={JSON.stringify(expandedWidth)}
Expand Down
12 changes: 9 additions & 3 deletions src/features/instantiate/containers/InstantiateContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import { UnknownError } from 'src/features/instantiate/containers/UnknownError';
import { useInstantiation } from 'src/features/instantiate/InstantiationContext';
import { useCurrentParty } from 'src/features/party/PartiesProvider';
import { AltinnAppTheme } from 'src/theme/altinnAppTheme';
import { changeBodyBackground } from 'src/utils/bodyStyling';
import { BackgroundColor } from 'src/utils/BackgroundColor';
import { HttpStatusCodes } from 'src/utils/network/networking';

export const InstantiateContainer = () => {
changeBodyBackground(AltinnAppTheme.altinnPalette.primary.greyLight);
export const InstantiateContainer = () => (
<>
<BackgroundColor color={AltinnAppTheme.altinnPalette.primary.greyLight} />
<InnerInstantiateContainer />
</>
);

const InnerInstantiateContainer = () => {
const party = useCurrentParty();
const instantiation = useInstantiation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import { Footer } from 'src/features/footer/Footer';
import classes from 'src/features/instantiate/containers/InstantiationContainer.module.css';
import { useProfile } from 'src/features/profile/ProfileProvider';
import { AltinnAppTheme } from 'src/theme/altinnAppTheme';
import { changeBodyBackground } from 'src/utils/bodyStyling';
import { BackgroundColor } from 'src/utils/BackgroundColor';

export interface IInstantiateContainerProps {
children?: React.ReactNode;
}

export function InstantiationContainer({ children }: IInstantiateContainerProps) {
changeBodyBackground(AltinnAppTheme.altinnPalette.primary.white);
const profile = useProfile();

return (
<TaskStoreProvider>
<DataLoadingProvider>
<RenderStart>
<BackgroundColor color={AltinnAppTheme.altinnPalette.primary.white} />
<div className={classes.container}>
<AltinnAppHeader profile={profile} />
<main id='main-content'>{children}</main>
Expand Down
3 changes: 0 additions & 3 deletions src/features/instantiate/containers/PartySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {
useSetHasSelectedParty,
} from 'src/features/party/PartiesProvider';
import { useNavigate } from 'src/features/routing/AppRoutingContext';
import { AltinnAppTheme } from 'src/theme/altinnAppTheme';
import { changeBodyBackground } from 'src/utils/bodyStyling';
import { HttpStatusCodes } from 'src/utils/network/networking';
import { capitalizeName } from 'src/utils/stringHelper';
import type { IParty } from 'src/types/shared';
Expand Down Expand Up @@ -77,7 +75,6 @@ const useStyles = makeStyles((theme) => ({
}));

export const PartySelection = () => {
changeBodyBackground(AltinnAppTheme.altinnPalette.primary.white);
const classes = useStyles();
const match = useMatch(`/party-selection/:errorCode`);
const errorCode = match?.params.errorCode;
Expand Down
21 changes: 12 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'core-js';

import React from 'react';
import { createRoot } from 'react-dom/client';
import { HelmetProvider } from 'react-helmet-async';
import { createHashRouter, RouterProvider, ScrollRestoration } from 'react-router-dom';
import { Slide, ToastContainer } from 'react-toastify';

Expand Down Expand Up @@ -64,15 +65,17 @@ document.addEventListener('DOMContentLoaded', () => {
<AppPrefetcher />
<ErrorBoundary>
<AppWrapper>
<LanguageProvider>
<LangToolsStoreProvider>
<ThemeWrapper>
<UiConfigProvider>
<RouterProvider router={router} />
</UiConfigProvider>
</ThemeWrapper>
</LangToolsStoreProvider>
</LanguageProvider>
<HelmetProvider>
<LanguageProvider>
<LangToolsStoreProvider>
<ThemeWrapper>
<UiConfigProvider>
<RouterProvider router={router} />
</UiConfigProvider>
</ThemeWrapper>
</LangToolsStoreProvider>
</LanguageProvider>
</HelmetProvider>
</AppWrapper>
</ErrorBoundary>
</AppQueriesProvider>,
Expand Down
10 changes: 10 additions & 0 deletions src/utils/BackgroundColor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { Helmet } from 'react-helmet-async';

export function BackgroundColor({ color }: { color: string }) {
return (
<Helmet>
<style>{`html > body { background-color: ${color}; }`}</style>
</Helmet>
);
}
3 changes: 0 additions & 3 deletions src/utils/bodyStyling.ts

This file was deleted.

28 changes: 28 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5263,6 +5263,7 @@ __metadata:
react-device-detect: "npm:2.2.3"
react-dom: "npm:18.3.1"
react-dropzone: "npm:14.2.3"
react-helmet-async: "npm:^2.0.5"
react-leaflet: "npm:^4.2.1"
react-number-format: "npm:^5.3.1"
react-refresh: "npm:0.14.2"
Expand Down Expand Up @@ -13889,6 +13890,26 @@ __metadata:
languageName: node
linkType: hard

"react-fast-compare@npm:^3.2.2":
version: 3.2.2
resolution: "react-fast-compare@npm:3.2.2"
checksum: 10c0/0bbd2f3eb41ab2ff7380daaa55105db698d965c396df73e6874831dbafec8c4b5b08ba36ff09df01526caa3c61595247e3269558c284e37646241cba2b90a367
languageName: node
linkType: hard

"react-helmet-async@npm:^2.0.5":
version: 2.0.5
resolution: "react-helmet-async@npm:2.0.5"
dependencies:
invariant: "npm:^2.2.4"
react-fast-compare: "npm:^3.2.2"
shallowequal: "npm:^1.1.0"
peerDependencies:
react: ^16.6.0 || ^17.0.0 || ^18.0.0
checksum: 10c0/f390ea8bf13c2681850e5f8eb5b73d8613f407c245a5fd23e9db9b2cc14a3700dd1ce992d3966632886d1d613083294c2aeee009193f49dfa7d145d9f13ea2b0
languageName: node
linkType: hard

"react-is@npm:^16.13.1, react-is@npm:^16.7.0":
version: 16.13.1
resolution: "react-is@npm:16.13.1"
Expand Down Expand Up @@ -14875,6 +14896,13 @@ __metadata:
languageName: node
linkType: hard

"shallowequal@npm:^1.1.0":
version: 1.1.0
resolution: "shallowequal@npm:1.1.0"
checksum: 10c0/b926efb51cd0f47aa9bc061add788a4a650550bbe50647962113a4579b60af2abe7b62f9b02314acc6f97151d4cf87033a2b15fc20852fae306d1a095215396c
languageName: node
linkType: hard

"shebang-command@npm:^2.0.0":
version: 2.0.0
resolution: "shebang-command@npm:2.0.0"
Expand Down
Loading