@norges-domstoler/dds-components 13.7.0 → 13.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AppShell/AppShell.d.ts +29 -4
- package/dist/cjs/components/AppShell/AppShell.stories.d.ts +9 -4
- package/dist/cjs/components/AppShell/AppShell.tokens.d.ts +16 -0
- package/dist/cjs/components/AppShell/AppShellContext.d.ts +10 -0
- package/dist/cjs/components/AppShell/Navigation/EmbeteIcon.d.ts +7 -0
- package/dist/cjs/components/AppShell/Navigation/Navigation.d.ts +6 -1
- package/dist/cjs/components/AppShell/Navigation/NavigationItem.d.ts +5 -2
- package/dist/cjs/components/AppShell/Navigation/NavigationLogo.d.ts +3 -0
- package/dist/cjs/components/AppShell/Navigation/TopBar.d.ts +23 -0
- package/dist/cjs/components/Button/Button.d.ts +1 -1
- package/dist/cjs/components/Button/Button.stories.d.ts +1 -1
- package/dist/cjs/components/Button/Button.types.d.ts +2 -2
- package/dist/cjs/index.js +1824 -1605
- package/dist/components/AppShell/AppShell.d.ts +29 -4
- package/dist/components/AppShell/AppShell.js +42 -20
- package/dist/components/AppShell/AppShell.stories.d.ts +9 -4
- package/dist/components/AppShell/AppShell.tokens.d.ts +16 -0
- package/dist/components/AppShell/AppShell.tokens.js +16 -3
- package/dist/components/AppShell/AppShellContext.d.ts +10 -0
- package/dist/components/AppShell/AppShellContext.js +27 -0
- package/dist/components/AppShell/Navigation/EmbeteIcon.d.ts +7 -0
- package/dist/components/AppShell/Navigation/EmbeteIcon.js +21 -0
- package/dist/components/AppShell/Navigation/Navigation.d.ts +6 -1
- package/dist/components/AppShell/Navigation/Navigation.js +83 -37
- package/dist/components/AppShell/Navigation/NavigationItem.d.ts +5 -2
- package/dist/components/AppShell/Navigation/NavigationItem.js +13 -3
- package/dist/components/AppShell/Navigation/NavigationLogo.d.ts +3 -0
- package/dist/components/AppShell/Navigation/NavigationLogo.js +34 -0
- package/dist/components/AppShell/Navigation/TopBar.d.ts +23 -0
- package/dist/components/AppShell/Navigation/TopBar.js +78 -0
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.stories.d.ts +1 -1
- package/dist/components/Button/Button.types.d.ts +2 -2
- package/package.json +2 -1
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
|
+
import { User } from './Navigation/TopBar';
|
|
3
|
+
import { OverflowMenuProps } from '../OverflowMenu';
|
|
4
|
+
import { Environment } from '@norges-domstoler/development-utils';
|
|
2
5
|
export type AppShellProps = PropsWithChildren<{
|
|
3
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Versjon på appen på formatet 0.0.0
|
|
8
|
+
*/
|
|
4
9
|
version?: string;
|
|
5
10
|
navigation: AppShellNavigationProps;
|
|
11
|
+
/**
|
|
12
|
+
* Den innloggede brukeren.
|
|
13
|
+
*/
|
|
14
|
+
user: User;
|
|
15
|
+
/**
|
|
16
|
+
* Menyvalg som skal vises i OverflowMenu knyttet til "bruker"-knappen.
|
|
17
|
+
*/
|
|
18
|
+
userMenuItems?: OverflowMenuProps['items'];
|
|
19
|
+
/**
|
|
20
|
+
* `environment` brukes for å vise en banner øverst i appen som viser hvilket miljø du er i.
|
|
21
|
+
* Når environment er undefined eller `"PROD"` så vises ikke banneret.
|
|
22
|
+
*/
|
|
23
|
+
environment?: Environment;
|
|
6
24
|
}>;
|
|
7
25
|
export type AppShellNavigationProps = {
|
|
8
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Interne lenker i navigasjonen.
|
|
28
|
+
*/
|
|
9
29
|
internal?: ReactElement[];
|
|
10
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Eksterne lenker i navigasjonen.
|
|
32
|
+
*/
|
|
11
33
|
external?: ReactElement[];
|
|
12
34
|
};
|
|
13
|
-
export declare const AppShell:
|
|
35
|
+
export declare const AppShell: {
|
|
36
|
+
({ children, version, navigation: { internal, external }, user, userMenuItems, environment, }: AppShellProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
@@ -1,34 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { appShellTokens } from './AppShell.tokens.js';
|
|
4
4
|
import { Navigation } from './Navigation/Navigation.js';
|
|
5
|
+
import { ENVIRONMENT_BANNER_HEIGHT, EnvironmentBanner } from '@norges-domstoler/development-utils';
|
|
6
|
+
import { AppShellContextProvider } from './AppShellContext.js';
|
|
5
7
|
|
|
6
8
|
var AppShellContainer = styled.div.withConfig({
|
|
7
9
|
displayName: "AppShell__AppShellContainer",
|
|
8
10
|
componentId: "sc-1c8yu5p-0"
|
|
9
|
-
})(["display:flex;flex-direction:row;"]);
|
|
11
|
+
})(["display:flex;flex-direction:column;@media (min-width:", "){flex-direction:row;}"], appShellTokens.navigation.mobile.breakpoint);
|
|
10
12
|
var MainContent = styled.main.withConfig({
|
|
11
13
|
displayName: "AppShell__MainContent",
|
|
12
14
|
componentId: "sc-1c8yu5p-1"
|
|
13
|
-
})(["min-width:calc(100vw - ", ");max-width:calc(100vw - ", ");"], appShellTokens.navigation.
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
})(["min-height:calc(100vh - ", ");margin-top:", ";@media (min-width:", "){min-height:unset;margin-top:", ";margin-left:", ";min-width:calc(100vw - ", ");max-width:calc(100vw - ", ");}"], appShellTokens.navigation.topBar.height, function (_ref) {
|
|
16
|
+
var environmentBannerActive = _ref.environmentBannerActive;
|
|
17
|
+
return environmentBannerActive ? "calc(".concat(ENVIRONMENT_BANNER_HEIGHT, " + ").concat(appShellTokens.navigation.topBar.height, ")") : appShellTokens.navigation.topBar.height;
|
|
18
|
+
}, appShellTokens.navigation.mobile.breakpoint, function (_ref2) {
|
|
19
|
+
var environmentBannerActive = _ref2.environmentBannerActive;
|
|
20
|
+
return environmentBannerActive ? ENVIRONMENT_BANNER_HEIGHT : 0;
|
|
21
|
+
}, appShellTokens.navigation.width, appShellTokens.navigation.width, appShellTokens.navigation.width);
|
|
22
|
+
var AppShell = function AppShell(_ref3) {
|
|
23
|
+
var children = _ref3.children,
|
|
24
|
+
_ref3$version = _ref3.version,
|
|
25
|
+
version = _ref3$version === void 0 ? '' : _ref3$version,
|
|
26
|
+
_ref3$navigation = _ref3.navigation,
|
|
27
|
+
_ref3$navigation$inte = _ref3$navigation.internal,
|
|
28
|
+
internal = _ref3$navigation$inte === void 0 ? [] : _ref3$navigation$inte,
|
|
29
|
+
_ref3$navigation$exte = _ref3$navigation.external,
|
|
30
|
+
external = _ref3$navigation$exte === void 0 ? [] : _ref3$navigation$exte,
|
|
31
|
+
user = _ref3.user,
|
|
32
|
+
userMenuItems = _ref3.userMenuItems,
|
|
33
|
+
_ref3$environment = _ref3.environment,
|
|
34
|
+
environment = _ref3$environment === void 0 ? 'PROD' : _ref3$environment;
|
|
35
|
+
var environmentBannerActive = environment !== 'PROD';
|
|
36
|
+
return jsx(AppShellContextProvider, {
|
|
37
|
+
children: jsxs(AppShellContainer, {
|
|
38
|
+
children: [jsx(EnvironmentBanner, {
|
|
39
|
+
environment: environment
|
|
40
|
+
}), jsx(Navigation, {
|
|
41
|
+
user: user,
|
|
42
|
+
userMenuItems: userMenuItems,
|
|
43
|
+
version: version,
|
|
44
|
+
internal: internal,
|
|
45
|
+
external: external,
|
|
46
|
+
environmentBannerActive: environmentBannerActive
|
|
47
|
+
}), jsx(MainContent, {
|
|
48
|
+
environmentBannerActive: environmentBannerActive,
|
|
49
|
+
children: children
|
|
50
|
+
})]
|
|
51
|
+
})
|
|
31
52
|
});
|
|
32
53
|
};
|
|
54
|
+
AppShell.displayName = 'AppShell';
|
|
33
55
|
|
|
34
56
|
export { AppShell };
|
|
@@ -2,11 +2,14 @@ import { ComponentProps } from 'react';
|
|
|
2
2
|
import { AppShell } from '.';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
|
-
component:
|
|
5
|
+
component: {
|
|
6
|
+
({ children, version, navigation: { internal, external }, user, userMenuItems, environment, }: import("./AppShell").AppShellProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
displayName: string;
|
|
8
|
+
} & {
|
|
6
9
|
NavItem: {
|
|
7
|
-
<T extends import("@norges-domstoler/dds-core").As = "a">({ as: _as, active, icon, external, children, ...rest }: import("react").PropsWithoutRef<ComponentProps<T>> & {
|
|
10
|
+
<T extends import("@norges-domstoler/dds-core").As = "a">({ as: _as, active, icon, external, children, onClick: propOnClick, ...rest }: import("react").PropsWithoutRef<ComponentProps<T>> & {
|
|
8
11
|
as?: T | undefined;
|
|
9
|
-
} & ({
|
|
12
|
+
} & (({
|
|
10
13
|
icon: import("@norges-domstoler/dds-icons").SvgIcon;
|
|
11
14
|
active?: boolean | undefined;
|
|
12
15
|
external?: false | undefined;
|
|
@@ -14,10 +17,12 @@ declare const _default: {
|
|
|
14
17
|
external: true;
|
|
15
18
|
active?: false | undefined;
|
|
16
19
|
icon?: undefined;
|
|
20
|
+
}) & {
|
|
21
|
+
onClick?: import("react").MouseEventHandler | undefined;
|
|
17
22
|
})): import("react/jsx-runtime").JSX.Element;
|
|
18
23
|
displayName: string;
|
|
19
24
|
};
|
|
20
25
|
};
|
|
21
26
|
};
|
|
22
27
|
export default _default;
|
|
23
|
-
export declare const Default: (args: ComponentProps<typeof AppShell
|
|
28
|
+
export declare const Default: (args: Partial<ComponentProps<typeof AppShell>>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -35,6 +35,14 @@ export declare const appShellTokens: {
|
|
|
35
35
|
color: string;
|
|
36
36
|
logo: {
|
|
37
37
|
fontWeight: number;
|
|
38
|
+
small: {
|
|
39
|
+
fontWeight: number;
|
|
40
|
+
lineHeight: any;
|
|
41
|
+
fontSize: string;
|
|
42
|
+
letterSpacing: any;
|
|
43
|
+
fontFamily: any;
|
|
44
|
+
fontStyle: any;
|
|
45
|
+
};
|
|
38
46
|
lineHeight: any;
|
|
39
47
|
fontSize: string;
|
|
40
48
|
letterSpacing: any;
|
|
@@ -50,6 +58,12 @@ export declare const appShellTokens: {
|
|
|
50
58
|
fontStyle: any;
|
|
51
59
|
};
|
|
52
60
|
};
|
|
61
|
+
topBar: {
|
|
62
|
+
padding: string;
|
|
63
|
+
height: string;
|
|
64
|
+
buttonTextColor: string;
|
|
65
|
+
gap: string;
|
|
66
|
+
};
|
|
53
67
|
color: string;
|
|
54
68
|
backgroundColor: string;
|
|
55
69
|
gap: string;
|
|
@@ -57,6 +71,7 @@ export declare const appShellTokens: {
|
|
|
57
71
|
padding: string;
|
|
58
72
|
width: string;
|
|
59
73
|
mobile: {
|
|
74
|
+
breakpoint: string;
|
|
60
75
|
iconColors: string;
|
|
61
76
|
};
|
|
62
77
|
};
|
|
@@ -64,5 +79,6 @@ export declare const appShellTokens: {
|
|
|
64
79
|
gap: string;
|
|
65
80
|
textColor: string;
|
|
66
81
|
backgroundColor: string;
|
|
82
|
+
borderRadius: string;
|
|
67
83
|
};
|
|
68
84
|
};
|
|
@@ -3,7 +3,8 @@ import { ddsBaseTokens } from '@norges-domstoler/dds-design-tokens';
|
|
|
3
3
|
var colors = ddsBaseTokens.colors,
|
|
4
4
|
spacing = ddsBaseTokens.spacing,
|
|
5
5
|
fontPackages = ddsBaseTokens.fontPackages,
|
|
6
|
-
borderRadius = ddsBaseTokens.borderRadius
|
|
6
|
+
borderRadius = ddsBaseTokens.borderRadius,
|
|
7
|
+
breakpoints = ddsBaseTokens.breakpoints;
|
|
7
8
|
var navigationItems = {
|
|
8
9
|
gap: spacing.SizesDdsSpacingLocalX05,
|
|
9
10
|
item: Object.assign(Object.assign({}, fontPackages.body_sans_02.base), {
|
|
@@ -25,13 +26,23 @@ var logoAndVersion = {
|
|
|
25
26
|
padding: '36px 24px',
|
|
26
27
|
color: colors.DdsColorNeutralsWhite,
|
|
27
28
|
logo: Object.assign(Object.assign({}, fontPackages.heading_sans_05.base), {
|
|
28
|
-
fontWeight: 700
|
|
29
|
+
fontWeight: 700,
|
|
30
|
+
small: Object.assign(Object.assign({}, fontPackages.heading_sans_03.base), {
|
|
31
|
+
fontWeight: 600
|
|
32
|
+
})
|
|
29
33
|
}),
|
|
30
34
|
version: Object.assign({}, fontPackages.supportingStyle_tiny_01.base)
|
|
31
35
|
};
|
|
36
|
+
var topBar = {
|
|
37
|
+
padding: spacing.SizesDdsSpacingLocalX025,
|
|
38
|
+
height: "calc(".concat(spacing.SizesDdsSpacingLayoutX3, " + 2 * ").concat(spacing.SizesDdsSpacingLocalX025, ")"),
|
|
39
|
+
buttonTextColor: colors.DdsColorNeutralsGray3,
|
|
40
|
+
gap: spacing.SizesDdsSpacingLocalX025
|
|
41
|
+
};
|
|
32
42
|
var navigation = {
|
|
33
43
|
navigationItems: navigationItems,
|
|
34
44
|
logoAndVersion: logoAndVersion,
|
|
45
|
+
topBar: topBar,
|
|
35
46
|
color: colors.DdsColorNeutralsGray1,
|
|
36
47
|
backgroundColor: colors.DdsColorPrimaryBase,
|
|
37
48
|
gap: spacing.SizesDdsSpacingLocalX05,
|
|
@@ -39,13 +50,15 @@ var navigation = {
|
|
|
39
50
|
padding: spacing.SizesDdsSpacingLocalX1,
|
|
40
51
|
width: '264px',
|
|
41
52
|
mobile: {
|
|
53
|
+
breakpoint: breakpoints.DdsBreakpointSm,
|
|
42
54
|
iconColors: colors.DdsColorNeutralsGray3
|
|
43
55
|
}
|
|
44
56
|
};
|
|
45
57
|
var floatingActionButtons = {
|
|
46
58
|
gap: spacing.SizesDdsSpacingLocalX1,
|
|
47
59
|
textColor: colors.DdsColorNeutralsGray7,
|
|
48
|
-
backgroundColor: colors.
|
|
60
|
+
backgroundColor: colors.DdsColorNeutralsWhite,
|
|
61
|
+
borderRadius: borderRadius.RadiiDdsBorderRadius3Radius
|
|
49
62
|
};
|
|
50
63
|
var appShellTokens = {
|
|
51
64
|
navigation: navigation,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode, type SetStateAction, type Dispatch } from 'react';
|
|
2
|
+
type AppShellContextValues = {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
5
|
+
};
|
|
6
|
+
export declare const AppShellContextProvider: ({ children, }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const useAppShellContext: () => AppShellContextValues;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useContext, createContext } from 'react';
|
|
4
|
+
|
|
5
|
+
var AppShellContext = /*#__PURE__*/createContext({
|
|
6
|
+
isOpen: false,
|
|
7
|
+
setOpen: function setOpen() {}
|
|
8
|
+
});
|
|
9
|
+
var AppShellContextProvider = function AppShellContextProvider(_ref) {
|
|
10
|
+
var children = _ref.children;
|
|
11
|
+
var _useState = useState(false),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
isOpen = _useState2[0],
|
|
14
|
+
setOpen = _useState2[1];
|
|
15
|
+
return jsx(AppShellContext.Provider, {
|
|
16
|
+
value: {
|
|
17
|
+
isOpen: isOpen,
|
|
18
|
+
setOpen: setOpen
|
|
19
|
+
},
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var useAppShellContext = function useAppShellContext() {
|
|
24
|
+
return useContext(AppShellContext);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { AppShellContextProvider, useAppShellContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SvgProps } from '@norges-domstoler/dds-icons';
|
|
2
|
+
export type EmbeteType = 'jordskifterett' | 'tingrett' | 'lagmannsrett' | 'høyesterett';
|
|
3
|
+
type EmbeteIconProps = {
|
|
4
|
+
type?: EmbeteType;
|
|
5
|
+
} & SvgProps;
|
|
6
|
+
export declare const EmbeteIcon: ({ type, ...rest }: EmbeteIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { PersonIcon, LagmannsrettIcon, TingrettIcon, JordskifterettIcon } from '@norges-domstoler/dds-icons';
|
|
4
|
+
|
|
5
|
+
var EmbeteIcon = function EmbeteIcon(_a) {
|
|
6
|
+
var type = _a.type,
|
|
7
|
+
rest = __rest(_a, ["type"]);
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'jordskifterett':
|
|
10
|
+
return jsx(JordskifterettIcon, Object.assign({}, rest));
|
|
11
|
+
case 'tingrett':
|
|
12
|
+
return jsx(TingrettIcon, Object.assign({}, rest));
|
|
13
|
+
case 'lagmannsrett':
|
|
14
|
+
return jsx(LagmannsrettIcon, Object.assign({}, rest));
|
|
15
|
+
case 'høyesterett':
|
|
16
|
+
case undefined:
|
|
17
|
+
return jsx(PersonIcon, Object.assign({}, rest));
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { EmbeteIcon };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
+
import { User } from './TopBar';
|
|
3
|
+
import { OverflowMenuProps } from '../../OverflowMenu';
|
|
2
4
|
export declare const NavigationItems: import("styled-components").StyledComponent<"nav", any, {}, never>;
|
|
3
5
|
export type NavigationProps = {
|
|
4
6
|
version: string;
|
|
5
7
|
internal: ReactElement[];
|
|
6
8
|
external: ReactElement[];
|
|
9
|
+
user: User;
|
|
10
|
+
userMenuItems?: OverflowMenuProps['items'];
|
|
11
|
+
environmentBannerActive: boolean;
|
|
7
12
|
};
|
|
8
|
-
export declare const Navigation: ({ version, internal, external, }: NavigationProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const Navigation: ({ version, user, userMenuItems, internal, external, environmentBannerActive, }: NavigationProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,65 +1,111 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Children } from 'react';
|
|
2
|
+
import { useEffect, Children } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { appShellTokens } from '../AppShell.tokens.js';
|
|
5
5
|
import { Divider } from '../../Divider/Divider.js';
|
|
6
6
|
import { NavigationItem } from './NavigationItem.js';
|
|
7
|
+
import { TopBar } from './TopBar.js';
|
|
8
|
+
import { NavigationLogo } from './NavigationLogo.js';
|
|
9
|
+
import { ENVIRONMENT_BANNER_HEIGHT } from '@norges-domstoler/development-utils';
|
|
10
|
+
import { useAppShellContext } from '../AppShellContext.js';
|
|
7
11
|
|
|
8
12
|
var navTokens = appShellTokens.navigation;
|
|
9
13
|
var Sidebar = styled.div.withConfig({
|
|
10
14
|
displayName: "Navigation__Sidebar",
|
|
11
15
|
componentId: "sc-twhp5c-0"
|
|
12
|
-
})(["display:flex;flex-direction:column;height:100vh
|
|
16
|
+
})(["display:flex;flex-direction:column;height:calc(100vh - ", ");width:100vw;padding:", ";color:", ";background-color:", ";box-sizing:border-box;position:fixed;top:", ";left:0;right:0;bottom:0;z-index:100;transition:transform 0.2s ease-in-out,opacity 0.2s ease-in-out;transform:translateX(", ");opacity:", ";@media (min-width:", "){height:", ";top:", ";width:", ";position:fixed;transform:translateX(0);opacity:1;}"], navTokens.topBar.height, navTokens.padding, navTokens.color, navTokens.backgroundColor, function (_ref) {
|
|
17
|
+
var environmentBannerActive = _ref.environmentBannerActive;
|
|
18
|
+
return environmentBannerActive ? "calc(".concat(ENVIRONMENT_BANNER_HEIGHT, " + ").concat(navTokens.topBar.height, ")") : navTokens.topBar.height;
|
|
19
|
+
}, function (_ref2) {
|
|
20
|
+
var isOpen = _ref2.isOpen;
|
|
21
|
+
return isOpen ? '0' : '-100%';
|
|
22
|
+
}, function (_ref3) {
|
|
23
|
+
var isOpen = _ref3.isOpen;
|
|
24
|
+
return isOpen ? '1' : '0';
|
|
25
|
+
}, navTokens.mobile.breakpoint, function (_ref4) {
|
|
26
|
+
var environmentBannerActive = _ref4.environmentBannerActive;
|
|
27
|
+
return environmentBannerActive ? "calc(100vh - ".concat(ENVIRONMENT_BANNER_HEIGHT, ")") : '100vh';
|
|
28
|
+
}, function (_ref5) {
|
|
29
|
+
var environmentBannerActive = _ref5.environmentBannerActive;
|
|
30
|
+
return environmentBannerActive ? ENVIRONMENT_BANNER_HEIGHT : 0;
|
|
31
|
+
}, navTokens.width);
|
|
13
32
|
var LogoAndVersionContainer = styled.div.withConfig({
|
|
14
33
|
displayName: "Navigation__LogoAndVersionContainer",
|
|
15
34
|
componentId: "sc-twhp5c-1"
|
|
16
|
-
})(["display:flex;flex-direction:column;color:", ";padding:", ";"], navTokens.logoAndVersion.color, navTokens.logoAndVersion.padding);
|
|
17
|
-
var Logo = styled.a.withConfig({
|
|
18
|
-
displayName: "Navigation__Logo",
|
|
19
|
-
componentId: "sc-twhp5c-2"
|
|
20
|
-
})(["font-size:", ";font-style:", ";font-family:", ";font-weight:", ";line-height:", ";letter-spacing:", ";text-align:middle;"], navTokens.logoAndVersion.logo.fontSize, navTokens.logoAndVersion.logo.fontStyle, navTokens.logoAndVersion.logo.fontFamily, navTokens.logoAndVersion.logo.fontWeight, navTokens.logoAndVersion.logo.lineHeight, navTokens.logoAndVersion.logo.letterSpacing);
|
|
35
|
+
})(["display:none;@media (min-width:", "){display:flex;flex-direction:column;color:", ";padding:", ";}"], navTokens.mobile.breakpoint, navTokens.logoAndVersion.color, navTokens.logoAndVersion.padding);
|
|
21
36
|
var Version = styled.span.withConfig({
|
|
22
37
|
displayName: "Navigation__Version",
|
|
23
|
-
componentId: "sc-twhp5c-
|
|
38
|
+
componentId: "sc-twhp5c-2"
|
|
24
39
|
})(["font-size:", ";font-style:", ";font-family:", ";font-weight:", ";line-height:", ";letter-spacing:", ";"], navTokens.logoAndVersion.version.fontSize, navTokens.logoAndVersion.version.fontStyle, navTokens.logoAndVersion.version.fontFamily, navTokens.logoAndVersion.version.fontWeight, navTokens.logoAndVersion.version.lineHeight, navTokens.logoAndVersion.version.letterSpacing);
|
|
25
40
|
var NavigationItems = styled.nav.withConfig({
|
|
26
41
|
displayName: "Navigation__NavigationItems",
|
|
27
|
-
componentId: "sc-twhp5c-
|
|
42
|
+
componentId: "sc-twhp5c-3"
|
|
28
43
|
})(["display:flex;flex-direction:column;gap:", ";"], navTokens.navigationItems.gap);
|
|
29
44
|
var DividerWrapper = styled.div.withConfig({
|
|
30
45
|
displayName: "Navigation__DividerWrapper",
|
|
31
|
-
componentId: "sc-twhp5c-
|
|
46
|
+
componentId: "sc-twhp5c-4"
|
|
32
47
|
})(["padding-left:", ";padding-right:", ";"], navTokens.navigationItems.item.padding, navTokens.navigationItems.item.padding);
|
|
33
48
|
var StyledDivider = styled(Divider).withConfig({
|
|
34
49
|
displayName: "Navigation__StyledDivider",
|
|
35
|
-
componentId: "sc-twhp5c-
|
|
50
|
+
componentId: "sc-twhp5c-5"
|
|
36
51
|
})(["border-color:", ";"], navTokens.dividerColor);
|
|
37
|
-
var Navigation = function Navigation(
|
|
38
|
-
var version =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
var Navigation = function Navigation(_ref6) {
|
|
53
|
+
var version = _ref6.version,
|
|
54
|
+
user = _ref6.user,
|
|
55
|
+
userMenuItems = _ref6.userMenuItems,
|
|
56
|
+
internal = _ref6.internal,
|
|
57
|
+
external = _ref6.external,
|
|
58
|
+
environmentBannerActive = _ref6.environmentBannerActive;
|
|
59
|
+
var _useAppShellContext = useAppShellContext(),
|
|
60
|
+
isOpen = _useAppShellContext.isOpen,
|
|
61
|
+
setOpen = _useAppShellContext.setOpen;
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
var listener = function listener(event) {
|
|
64
|
+
if (event.key === 'o') {
|
|
65
|
+
setOpen(function (prev) {
|
|
66
|
+
return !prev;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener('keypress', listener);
|
|
71
|
+
return function () {
|
|
72
|
+
return window.removeEventListener('keypress', listener);
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
return jsxs("div", {
|
|
76
|
+
children: [jsx(TopBar, {
|
|
77
|
+
user: user,
|
|
78
|
+
userMenuItems: userMenuItems,
|
|
79
|
+
isNavigationOpen: isOpen,
|
|
80
|
+
onNavigationOpenChange: function onNavigationOpenChange(newOpen) {
|
|
81
|
+
return setOpen(newOpen);
|
|
82
|
+
},
|
|
83
|
+
environmentBannerActive: environmentBannerActive
|
|
84
|
+
}), jsxs(Sidebar, {
|
|
85
|
+
isOpen: isOpen,
|
|
86
|
+
environmentBannerActive: environmentBannerActive,
|
|
87
|
+
children: [jsxs(LogoAndVersionContainer, {
|
|
88
|
+
children: [jsx(NavigationLogo, {
|
|
89
|
+
children: "Lovisa"
|
|
90
|
+
}), version !== '' && jsxs(Version, {
|
|
91
|
+
children: ["v ", version]
|
|
92
|
+
})]
|
|
93
|
+
}), jsxs(NavigationItems, {
|
|
94
|
+
children: [Children.map(internal, function (item) {
|
|
95
|
+
if (item.type !== NavigationItem) {
|
|
96
|
+
console.warn("Du bruker en React-komponent som ikke er tillat i AppShell-internal. Du kan kun bruke AppShell.NavItem i AppShell-internal.");
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
return item;
|
|
100
|
+
}), external.length > 0 && jsx(DividerWrapper, {
|
|
101
|
+
children: jsx(StyledDivider, {})
|
|
102
|
+
}), Children.map(external, function (item) {
|
|
103
|
+
if (item.type !== NavigationItem) {
|
|
104
|
+
console.warn('Du bruker en React-komponent som ikke er tillat i AppShell-external. Du kan kun bruke AppShell.NavItem i AppShell-external.');
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return item;
|
|
108
|
+
})]
|
|
63
109
|
})]
|
|
64
110
|
})]
|
|
65
111
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type PropsOf, type As } from '@norges-domstoler/dds-core';
|
|
2
2
|
import { SvgIcon } from '@norges-domstoler/dds-icons';
|
|
3
|
-
type
|
|
3
|
+
import { type MouseEventHandler } from 'react';
|
|
4
|
+
type BaseNavigationItemProps = ({
|
|
4
5
|
icon: SvgIcon;
|
|
5
6
|
active?: boolean;
|
|
6
7
|
external?: undefined | false;
|
|
@@ -8,10 +9,12 @@ type BaseNavigationItemProps = {
|
|
|
8
9
|
external: true;
|
|
9
10
|
active?: undefined | false;
|
|
10
11
|
icon?: undefined;
|
|
12
|
+
}) & {
|
|
13
|
+
onClick?: MouseEventHandler;
|
|
11
14
|
};
|
|
12
15
|
type NavigationItemProps<T extends As = 'a'> = PropsOf<T> & BaseNavigationItemProps;
|
|
13
16
|
export declare const NavigationItem: {
|
|
14
|
-
<T extends As = "a">({ as: _as, active, icon, external, children, ...rest }: NavigationItemProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
<T extends As = "a">({ as: _as, active, icon, external, children, onClick: propOnClick, ...rest }: NavigationItemProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
displayName: string;
|
|
16
19
|
};
|
|
17
20
|
export {};
|
|
@@ -3,6 +3,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Icon, OpenExternalIcon, ChevronRightIcon } from '@norges-domstoler/dds-icons';
|
|
5
5
|
import { appShellTokens } from '../AppShell.tokens.js';
|
|
6
|
+
import { useAppShellContext } from '../AppShellContext.js';
|
|
6
7
|
|
|
7
8
|
var navTokens = appShellTokens.navigation;
|
|
8
9
|
var navItemTokens = navTokens.navigationItems.item;
|
|
@@ -25,7 +26,7 @@ var BaseLink = styled.a.withConfig({
|
|
|
25
26
|
var InternalNavItem = styled(BaseLink).withConfig({
|
|
26
27
|
displayName: "NavigationItem__InternalNavItem",
|
|
27
28
|
componentId: "sc-8k2l5g-4"
|
|
28
|
-
})(["display:grid;align-items:center;grid-template-areas:'icon text chevron';grid-template-columns:min-content 1fr min-content
|
|
29
|
+
})(["display:grid;align-items:center;grid-template-areas:'icon text chevron';grid-template-columns:min-content 1fr min-content;&.active ", "{opacity:1;}"], ChevronContainer);
|
|
29
30
|
var ExternalNavItem = styled(BaseLink).withConfig({
|
|
30
31
|
displayName: "NavigationItem__ExternalNavItem",
|
|
31
32
|
componentId: "sc-8k2l5g-5"
|
|
@@ -36,12 +37,20 @@ var NavigationItem = function NavigationItem(_a) {
|
|
|
36
37
|
icon = _a.icon,
|
|
37
38
|
external = _a.external,
|
|
38
39
|
children = _a.children,
|
|
39
|
-
|
|
40
|
+
propOnClick = _a.onClick,
|
|
41
|
+
rest = __rest(_a, ["as", "active", "icon", "external", "children", "onClick"]);
|
|
42
|
+
var _useAppShellContext = useAppShellContext(),
|
|
43
|
+
setOpen = _useAppShellContext.setOpen;
|
|
40
44
|
var Comp = _as !== null && _as !== void 0 ? _as : 'a';
|
|
45
|
+
var onClick = function onClick(e) {
|
|
46
|
+
propOnClick === null || propOnClick === void 0 ? void 0 : propOnClick(e);
|
|
47
|
+
setOpen(false);
|
|
48
|
+
};
|
|
41
49
|
if (external) {
|
|
42
50
|
return jsxs(ExternalNavItem, Object.assign({
|
|
43
51
|
as: Comp
|
|
44
52
|
}, rest, {
|
|
53
|
+
onClick: onClick,
|
|
45
54
|
children: [children, jsx(Icon, {
|
|
46
55
|
icon: OpenExternalIcon,
|
|
47
56
|
iconSize: "inherit"
|
|
@@ -51,7 +60,8 @@ var NavigationItem = function NavigationItem(_a) {
|
|
|
51
60
|
return jsxs(InternalNavItem, Object.assign({
|
|
52
61
|
as: Comp
|
|
53
62
|
}, rest, {
|
|
54
|
-
|
|
63
|
+
onClick: onClick,
|
|
64
|
+
className: [active ? 'active' : '', rest.className].join(' '),
|
|
55
65
|
children: [jsx(IconContainer, {
|
|
56
66
|
children: icon && jsx(Icon, {
|
|
57
67
|
icon: icon
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { appShellTokens } from '../AppShell.tokens.js';
|
|
3
|
+
|
|
4
|
+
var navTokens = appShellTokens.navigation;
|
|
5
|
+
var fontPackage = function fontPackage(small) {
|
|
6
|
+
if (small) {
|
|
7
|
+
return navTokens.logoAndVersion.logo.small;
|
|
8
|
+
}
|
|
9
|
+
return navTokens.logoAndVersion.logo;
|
|
10
|
+
};
|
|
11
|
+
var NavigationLogo = styled.a.withConfig({
|
|
12
|
+
displayName: "NavigationLogo",
|
|
13
|
+
componentId: "sc-17higny-0"
|
|
14
|
+
})(["font-size:", ";font-style:", ";font-family:", ";font-weight:", ";line-height:", ";letter-spacing:", ";text-align:middle;"], function (_ref) {
|
|
15
|
+
var small = _ref.small;
|
|
16
|
+
return fontPackage(small).fontSize;
|
|
17
|
+
}, function (_ref2) {
|
|
18
|
+
var small = _ref2.small;
|
|
19
|
+
return fontPackage(small).fontStyle;
|
|
20
|
+
}, function (_ref3) {
|
|
21
|
+
var small = _ref3.small;
|
|
22
|
+
return fontPackage(small).fontFamily;
|
|
23
|
+
}, function (_ref4) {
|
|
24
|
+
var small = _ref4.small;
|
|
25
|
+
return fontPackage(small).fontWeight;
|
|
26
|
+
}, function (_ref5) {
|
|
27
|
+
var small = _ref5.small;
|
|
28
|
+
return fontPackage(small).lineHeight;
|
|
29
|
+
}, function (_ref6) {
|
|
30
|
+
var small = _ref6.small;
|
|
31
|
+
return fontPackage(small).letterSpacing;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export { NavigationLogo };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EmbeteType } from './EmbeteIcon';
|
|
2
|
+
import { OverflowMenuProps } from '../../OverflowMenu';
|
|
3
|
+
type TopBarProps = {
|
|
4
|
+
user: User;
|
|
5
|
+
userMenuItems?: OverflowMenuProps['items'];
|
|
6
|
+
isNavigationOpen: boolean;
|
|
7
|
+
onNavigationOpenChange: (isOpen: boolean) => void;
|
|
8
|
+
environmentBannerActive: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type User = {
|
|
11
|
+
/**Brukerens fulle navn (for- og etternavn). */
|
|
12
|
+
name: string;
|
|
13
|
+
/**Det aktive embetet til brukeren. */
|
|
14
|
+
embete: Embete;
|
|
15
|
+
};
|
|
16
|
+
export type Embete = {
|
|
17
|
+
/**Navnet på embetet. */
|
|
18
|
+
name: string;
|
|
19
|
+
/**Hvilken instans embetet er. */
|
|
20
|
+
type: EmbeteType;
|
|
21
|
+
};
|
|
22
|
+
export declare const TopBar: ({ user, userMenuItems, isNavigationOpen, onNavigationOpenChange, environmentBannerActive, }: TopBarProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|