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

UU landmarks #177

Merged
merged 2 commits into from
Jan 17, 2024
Merged
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
4 changes: 1 addition & 3 deletions packages/server/src/render-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ export default async ({
}) => {
const { language, breadcrumbs, availableLanguages } = data;
const localTexts = texts[language];

const features = unleashService.getFeatures();


const decoratorUtils = DecoratorUtils({
breadcrumbs,
availableLanguages,
localTexts,
utilsBackground: data.utilsBackground,
hidden: isExternallyAvailable(clientEnv.APP_URL)
});
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/request-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const requestHandler = async (
const decoratorUtils = DecoratorUtils({
breadcrumbs,
availableLanguages,
localTexts,
utilsBackground,
hidden: isExternallyAvailable(clientEnv.APP_URL)
});
Expand Down
3 changes: 3 additions & 0 deletions packages/server/src/texts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const nb = {
login: 'Logg inn',
logout: 'Logg ut',
logged_in: 'Logget inn',
language_selector: 'Velg språk',
notifications: 'Varsler',
notifications_empty_list: 'Du har ingen nye varsler',
notifications_empty_list_description: 'Vi varsler deg når noe skjer.',
Expand Down Expand Up @@ -109,6 +110,7 @@ export const texts: Record<Language, Texts> = {
login: 'Log in',
logout: 'Log out',
logged_in: 'Logged in',
language_selector: 'Choose language',
notifications: 'Notifications',
notifications_empty_list: 'You have no new notifications',
notifications_empty_list_description:
Expand Down Expand Up @@ -191,6 +193,7 @@ export const texts: Record<Language, Texts> = {
login: 'Sisačáliheapmi',
logout: 'Olggosčáliheapmi',
logged_in: 'Logget inn',
language_selector: 'Velg språk',
notifications: 'Varsler',
notifications_empty_list: 'Du har ingen nye varsler',
notifications_empty_list_description: 'Vi varsler deg når noe skjer.',
Expand Down
48 changes: 26 additions & 22 deletions packages/server/src/views/decorator-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,38 @@ import clsx from 'clsx';
import cls from 'decorator-client/src/styles/decorator-utils.module.css';
import html from 'decorator-shared/html';
import {
AvailableLanguage,
Breadcrumb,
UtilsBackground,
AvailableLanguage,
Breadcrumb,
UtilsBackground,
} from 'decorator-shared/params';
import { Texts } from 'decorator-shared/types';
import utilsCls from 'decorator-client/src/styles/utilities.module.css';
import { Breadcrumbs } from 'decorator-shared/views/breadcrumbs';
import { LanguageSelector } from './language-selector';

export type DecoratorUtilsProps = {
breadcrumbs: Breadcrumb[];
availableLanguages: AvailableLanguage[];
utilsBackground: UtilsBackground;
hidden: boolean
breadcrumbs: Breadcrumb[];
availableLanguages: AvailableLanguage[];
localTexts: Texts;
utilsBackground: UtilsBackground;
hidden: boolean
};

export const DecoratorUtils = ({
breadcrumbs,
availableLanguages,
utilsBackground,
hidden,
}: DecoratorUtilsProps) =>
html`<decorator-utils
class="${clsx(utilsCls.contentContainer, cls.decoratorUtils, {
[cls.hidden]: (availableLanguages.length === 0 && breadcrumbs.length === 0) || hidden,
[cls.white]: utilsBackground === 'white',
[cls.gray]: utilsBackground === 'gray',
})}"
>
<nav is="d-breadcrumbs">${Breadcrumbs({ breadcrumbs })}</nav>
${LanguageSelector({ availableLanguages })}
</decorator-utils>`;
breadcrumbs,
availableLanguages,
localTexts,
utilsBackground,
hidden,
}: DecoratorUtilsProps) => html`
<decorator-utils
class="${clsx(utilsCls.contentContainer, cls.decoratorUtils, {
[cls.hidden]: (availableLanguages.length === 0 && breadcrumbs.length === 0) || hidden,
[cls.white]: utilsBackground === 'white',
[cls.gray]: utilsBackground === 'gray',
})}"
>
<nav is="d-breadcrumbs">${Breadcrumbs({ breadcrumbs })}</nav>
${LanguageSelector({ availableLanguages, localTexts })}
</decorator-utils>
`;
2 changes: 2 additions & 0 deletions packages/server/src/views/language-selector.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { LanguageSelectorProps } from './language-selector';
import { LanguageSelector } from './language-selector';
import { LanguageSelector as ClientComponent } from 'decorator-client/src/views/language-selector';
import html from 'decorator-shared/html';
import { texts } from '../texts';

const meta: Meta<LanguageSelectorProps> = {
title: 'header/language-selector',
Expand Down Expand Up @@ -33,5 +34,6 @@ export const Default: Story = {
{ locale: 'nb', handleInApp: true },
{ locale: 'en', url: 'https://www.nav.no/en/person', handleInApp: false },
],
localTexts: texts['en']
},
};
35 changes: 19 additions & 16 deletions packages/server/src/views/language-selector.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import clsx from 'clsx';
import html from 'decorator-shared/html';
import { AvailableLanguage } from 'decorator-shared/params';
import { Texts } from "decorator-shared/types";
import { DownChevronIcon, GlobeIcon } from 'decorator-shared/views/icons';
import cls from 'decorator-client/src/styles/language-selector.module.css';

export type LanguageSelectorProps = {
availableLanguages: AvailableLanguage[];
availableLanguages: AvailableLanguage[];
localTexts: Texts;
};

export const LanguageSelector = ({
availableLanguages,
availableLanguages,
localTexts
}: LanguageSelectorProps) => html`
<language-selector>
<div class="${clsx(cls.languageSelector, {
[cls.empty]: availableLanguages.length === 0,
})}"
>
<button type="button" class="${cls.button}">
${GlobeIcon({ className: cls.icon })}
<span>
<span lang="nb">${'Språk'}</span>/<span lang="en">Language</span>
</span>
${DownChevronIcon({ className: cls.icon })}
</button>
</div>
</language-selector>
<language-selector>
<nav
class="${clsx(cls.languageSelector, {[cls.empty]: availableLanguages.length === 0})}"
aria-label="${localTexts.language_selector}"
>
<button type="button" class="${cls.button}">
${GlobeIcon({ className: cls.icon })}
<span>
<span lang="nb">${'Språk'}</span>/<span lang="en">Language</span>
</span>
${DownChevronIcon({ className: cls.icon })}
</button>
</nav>
</language-selector>
`;
4 changes: 2 additions & 2 deletions packages/server/src/views/ops-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type OpsMessagesProps = {
};

export const OpsMessages = ({ opsMessages }: OpsMessagesProps) => html`
<div class="${cls.opsMessagesContent} ${utilsCls.contentContainer}">
<section class="${cls.opsMessagesContent} ${utilsCls.contentContainer}">
${opsMessages.map(
({ heading, url, type }) =>
html`<lenke-med-sporing
Expand All @@ -24,5 +24,5 @@ export const OpsMessages = ({ opsMessages }: OpsMessagesProps) => html`
<span>${heading}</span>
</lenke-med-sporing>`,
)}
</div>
</section>
`;
1 change: 1 addition & 0 deletions packages/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type Texts = ClientTexts & {
clear: string;
login: string;
logged_in: string;
language_selector: string;
notifications: string;
notifications_empty_list: string;
notifications_empty_list_description: string;
Expand Down
Loading