@helsenorge/designsystem-react 7.2.0 → 7.2.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/CHANGELOG.md +17 -0
- package/components/AnchorLink/AnchorLink.stories.d.ts +1 -0
- package/components/Avatar/Avatar.stories.d.ts +2 -0
- package/components/Badge/Badge.stories.d.ts +2 -0
- package/components/Button/Button.js +21 -21
- package/components/Button/Button.js.map +1 -1
- package/components/Checkbox/Checkbox.stories.d.ts +1 -0
- package/components/Close/Close.stories.d.ts +1 -0
- package/components/DictionaryTrigger/DictionaryTrigger.stories.d.ts +1 -0
- package/components/Dropdown/Dropdown.stories.d.ts +1 -0
- package/components/Duolist/Duolist.stories.d.ts +1 -0
- package/components/Duolist/styles.module.scss +19 -19
- package/components/EmptyState/EmptyState.stories.d.ts +1 -0
- package/components/Expander/Expander.stories.d.ts +1 -0
- package/components/Expander/styles.module.scss +13 -13
- package/components/ExpanderHierarchy/ExpanderHierarchy.stories.d.ts +1 -0
- package/components/ExpanderList/ExpanderList.stories.d.ts +2 -0
- package/components/FormGroup/FormGroup.stories.d.ts +1 -0
- package/components/FormLayout/FormLayout.stories.d.ts +1 -0
- package/components/HelpBubble/HelpBubble.stories.d.ts +1 -0
- package/components/HelpPanel/HelpPanel.stories.d.ts +1 -0
- package/components/HelpQuestion/HelpQuestion.stories.d.ts +1 -0
- package/components/HighlightBox/HighlightBox.stories.d.ts +1 -0
- package/components/HorizontalScroll/styles.module.scss +2 -0
- package/components/Icon/Icon.stories.d.ts +1 -0
- package/components/Illustration/Illustration.stories.d.ts +1 -0
- package/components/Illustration/Illustrations.stories.d.ts +1 -0
- package/components/Input/Input.stories.d.ts +1 -0
- package/components/Label/Label.stories.d.ts +1 -0
- package/components/LazyIcon/LazyIcon.stories.d.ts +1 -0
- package/components/LazyIllustration/LazyIllustration.stories.d.ts +1 -0
- package/components/LinkList/LinkList.stories.d.ts +2 -0
- package/components/List/styles.module.scss +6 -0
- package/components/Loader/Loader.stories.d.ts +1 -0
- package/components/Logo/Logo.stories.d.ts +1 -0
- package/components/NotificationPanel/NotificationPanel.stories.d.ts +1 -0
- package/components/Panel/Panel.stories.d.ts +1 -0
- package/components/PanelList/PanelList.stories.d.ts +1 -0
- package/components/PopMenu/PopMenu.stories.d.ts +1 -0
- package/components/PopMenu/styles.module.scss +7 -8
- package/components/PopOver/styles.module.scss +4 -4
- package/components/PromoPanel/PromoPanel.stories.d.ts +1 -0
- package/components/RadioButton/RadioButton.stories.d.ts +1 -0
- package/components/Select/Select.stories.d.ts +1 -0
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -0
- package/components/SharingStatus/SharingStatus.stories.d.ts +1 -0
- package/components/Slider/Slider.stories.d.ts +1 -0
- package/components/Spacer/Spacer.stories.d.ts +1 -0
- package/components/StatusDot/StatusDot.stories.d.ts +1 -0
- package/components/Step/Step.stories.d.ts +1 -0
- package/components/StepButtons/StepButtons.stories.d.ts +1 -0
- package/components/Stepper/Stepper.stories.d.ts +1 -0
- package/components/Table/Table.stories.d.ts +1 -0
- package/components/Tag/Tag.stories.d.ts +1 -0
- package/components/TagList/TagList.stories.d.ts +1 -0
- package/components/Textarea/Textarea.stories.d.ts +1 -0
- package/components/Tile/Tile.stories.d.ts +2 -0
- package/components/Title/Title.stories.d.ts +1 -0
- package/components/Tooltip/Tooltip.stories.d.ts +1 -0
- package/components/Trigger/Trigger.stories.d.ts +1 -0
- package/components/Validation/Validation.stories.d.ts +2 -1
- package/docs/index.d.ts +1 -0
- package/docs/index.js +9 -4
- package/docs/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [7.2.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.1.0&targetVersion=GTv7.2.0) (2024-04-19)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- knappen i dropdown skal ikke være fluid
|
|
6
|
+
([a3abe2b](https://github.com/helsenorge/designsystem/commit/a3abe2bf5a57e62302b5e4f1a1f1b609452effd0)), closes
|
|
7
|
+
[#323389](https://github.com/helsenorge/designsystem/issues/323389)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- bruk supernova-sjekk som funker i ff
|
|
12
|
+
([afae2a9](https://github.com/helsenorge/designsystem/commit/afae2a90d9e453be054016b5922aa378500f91cc))
|
|
13
|
+
- oppdater sjekk for om vi er i superNova
|
|
14
|
+
([b20a776](https://github.com/helsenorge/designsystem/commit/b20a776f293953d78ccab6e40d687bab67676a28))
|
|
15
|
+
- oppdater sjekk for om vi er i superNova
|
|
16
|
+
([167d572](https://github.com/helsenorge/designsystem/commit/167d572261a91fd60a8c432d4d990356a610115f))
|
|
17
|
+
|
|
1
18
|
## [7.1.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv7.0.0&targetVersion=GTv7.1.0) (2024-04-17)
|
|
2
19
|
|
|
3
20
|
### Features
|
|
@@ -5,6 +5,7 @@ declare const meta: {
|
|
|
5
5
|
component: React.ForwardRefExoticComponent<import("./AnchorLink").AnchorLinkProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
6
6
|
parameters: {
|
|
7
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
8
9
|
description: {
|
|
9
10
|
component: string;
|
|
10
11
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
import { AvatarSize } from './Avatar';
|
|
3
4
|
declare const meta: {
|
|
@@ -5,6 +6,7 @@ declare const meta: {
|
|
|
5
6
|
component: import("./Avatar").AvatarType;
|
|
6
7
|
parameters: {
|
|
7
8
|
docs: {
|
|
9
|
+
page: () => React.JSX.Element;
|
|
8
10
|
description: {
|
|
9
11
|
component: string;
|
|
10
12
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import("./Badge").BadgeType;
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
7
9
|
description: {
|
|
8
10
|
component: string;
|
|
9
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import o, { useRef as lt, useEffect as ct } from "react";
|
|
2
|
-
import
|
|
2
|
+
import d from "classnames";
|
|
3
3
|
import { Icon as it } from "../Icon/Icon.js";
|
|
4
4
|
import { AnalyticsId as $, IconSize as v } from "../../constants.js";
|
|
5
5
|
import { useBreakpoint as ut } from "../../hooks/useBreakpoint.js";
|
|
@@ -7,16 +7,16 @@ import { useHover as D } from "../../hooks/useHover.js";
|
|
|
7
7
|
import { useIcons as mt } from "../../hooks/useIcons.js";
|
|
8
8
|
import { getColor as i } from "../../theme/currys/color.js";
|
|
9
9
|
import { breakpoints as bt } from "../../theme/grid.js";
|
|
10
|
-
import { isTest as
|
|
10
|
+
import { isTest as dt, isProd as pt } from "../../utils/environment.js";
|
|
11
11
|
import ft from "../Icons/ArrowRight.js";
|
|
12
12
|
import t from "../Button/styles.module.scss";
|
|
13
|
-
const ht = (e, r, n,
|
|
13
|
+
const ht = (e, r, n, p, a, g) => g && n ? !a || e ? i("neutral", r ? 500 : 700) : i("white") : n ? !a || e ? i("neutral", 500) : `${i("white")}b3` : e && !a || !e && a ? "white" : p === "normal" ? i("blueberry", 600) : i("cherry", 500), N = (e, r) => r && e ? v.Small : e ? v.Medium : v.XSmall, gt = (e, r, n) => {
|
|
14
14
|
if (n && e && (r === void 0 || r === ""))
|
|
15
15
|
throw new Error("Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav");
|
|
16
16
|
}, _t = o.forwardRef(function(r, n) {
|
|
17
17
|
const {
|
|
18
|
-
ariaLabel:
|
|
19
|
-
id:
|
|
18
|
+
ariaLabel: p,
|
|
19
|
+
id: a,
|
|
20
20
|
children: g,
|
|
21
21
|
wrapperClassName: O,
|
|
22
22
|
className: X,
|
|
@@ -37,11 +37,11 @@ const ht = (e, r, n, d, s, g) => g && n ? !s || e ? i("neutral", r ? 500 : 700)
|
|
|
37
37
|
target: U,
|
|
38
38
|
type: J = "button",
|
|
39
39
|
...F
|
|
40
|
-
} = r, [u, m, H] = mt(o.Children.toArray(g)), { hoverRef: L, isHovered: K } = w === "button" ? D(n) : D(n), Q = lt(null),
|
|
40
|
+
} = r, [u, m, H] = mt(o.Children.toArray(g)), { hoverRef: L, isHovered: K } = w === "button" ? D(n) : D(n), Q = lt(null), s = !!(u || m) && !H, M = u && (m || _) && !s, y = j === "ondark", h = ut() < bt.md, P = B === "destructive" && !f, Y = I === "outline", l = I === "borderless", T = ht(I === "fill", l, f, B, y, h), C = _ === "icon" && !l, b = q === "large" && !P && !l, Z = _ === "accessibility-character" && !A && !u && !m && !C && l, tt = { ...F }, V = d(
|
|
41
41
|
t["button-wrapper"],
|
|
42
42
|
{ [t["button-wrapper--fluid"]]: A || R },
|
|
43
43
|
O
|
|
44
|
-
), ot =
|
|
44
|
+
), ot = d(
|
|
45
45
|
t.button,
|
|
46
46
|
{
|
|
47
47
|
[t["button--destructive"]]: P,
|
|
@@ -49,36 +49,36 @@ const ht = (e, r, n, d, s, g) => g && n ? !s || e ? i("neutral", r ? 500 : 700)
|
|
|
49
49
|
[t["button--large"]]: b,
|
|
50
50
|
[t["button--outline"]]: Y,
|
|
51
51
|
[t["button--borderless"]]: l,
|
|
52
|
-
[t["button--left-icon"]]: u && !
|
|
53
|
-
[t["button--right-icon"]]: m && !
|
|
52
|
+
[t["button--left-icon"]]: u && !s,
|
|
53
|
+
[t["button--right-icon"]]: m && !s,
|
|
54
54
|
[t["button--both-icons"]]: M,
|
|
55
|
-
[t["button--only-icon"]]:
|
|
55
|
+
[t["button--only-icon"]]: s,
|
|
56
56
|
[t["button--arrow"]]: C,
|
|
57
57
|
[t["button--on-dark"]]: y
|
|
58
58
|
},
|
|
59
59
|
X
|
|
60
|
-
), et =
|
|
60
|
+
), et = d(t.button__text, {
|
|
61
61
|
[t["button__text--ellipsis"]]: R
|
|
62
|
-
}), rt =
|
|
62
|
+
}), rt = d(t.diagonal, {
|
|
63
63
|
[t["diagonal--on-dark"]]: y
|
|
64
64
|
});
|
|
65
65
|
ct(() => {
|
|
66
|
-
gt(
|
|
66
|
+
gt(s, p, !dt() && !pt());
|
|
67
67
|
}, []);
|
|
68
|
-
const k = (c,
|
|
69
|
-
size:
|
|
68
|
+
const k = (c, at, st) => c ? o.cloneElement(c, {
|
|
69
|
+
size: at,
|
|
70
70
|
color: c != null && c.props.color ? c.props.color : T,
|
|
71
71
|
isHovered: K,
|
|
72
|
-
className:
|
|
73
|
-
}) : null, nt = () => /* @__PURE__ */ o.createElement("span", { className: et, ref: Q }, f && l && /* @__PURE__ */ o.createElement("span", { className: rt }, /* @__PURE__ */ o.createElement("span", { className: t.diagonal__line })), /* @__PURE__ */ o.createElement("span", null,
|
|
72
|
+
className: st
|
|
73
|
+
}) : null, nt = () => /* @__PURE__ */ o.createElement("span", { className: et, ref: Q }, f && l && /* @__PURE__ */ o.createElement("span", { className: rt }, /* @__PURE__ */ o.createElement("span", { className: t.diagonal__line })), /* @__PURE__ */ o.createElement("span", null, s ? p : H)), W = () => /* @__PURE__ */ o.createElement("span", { className: ot }, k(u, N(b, h), s ? void 0 : t["button__left-icon"]), nt(), C ? k(
|
|
74
74
|
/* @__PURE__ */ o.createElement(it, { svgIcon: ft }),
|
|
75
75
|
N(b, h),
|
|
76
|
-
|
|
77
|
-
) : k(m, N(b, h), t["button__right-icon"]), Z && /* @__PURE__ */ o.createElement("span", { style: { color: T }, className: t["button__right-unicode-arrow"] }, " →"));
|
|
76
|
+
d(t.button__arrow, { [t["button__arrow--both-icons"]]: M })
|
|
77
|
+
) : k(m, N(b, h), t["button__right-icon"]), Z && /* @__PURE__ */ o.createElement("span", { style: { color: T }, className: t["button__right-unicode-arrow"], "aria-hidden": !0 }, " →"));
|
|
78
78
|
return /* @__PURE__ */ o.createElement(o.Fragment, null, w === "button" && /* @__PURE__ */ o.createElement(
|
|
79
79
|
"button",
|
|
80
80
|
{
|
|
81
|
-
id:
|
|
81
|
+
id: a,
|
|
82
82
|
onBlur: E,
|
|
83
83
|
onClick: x,
|
|
84
84
|
disabled: f,
|
|
@@ -94,7 +94,7 @@ const ht = (e, r, n, d, s, g) => g && n ? !s || e ? i("neutral", r ? 500 : 700)
|
|
|
94
94
|
), w === "a" && /* @__PURE__ */ o.createElement(
|
|
95
95
|
"a",
|
|
96
96
|
{
|
|
97
|
-
id:
|
|
97
|
+
id: a,
|
|
98
98
|
onBlur: E,
|
|
99
99
|
onClick: x,
|
|
100
100
|
"data-testid": z,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconSize } from './../Icon';\nimport { HTMLButtonProps, HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { BaseIconElement, useIcons } from '../../hooks/useIcons';\nimport { getColor } from '../../theme/currys/color';\nimport { breakpoints } from '../../theme/grid';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonMode = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\nexport type ButtonArrows = 'icon' | 'accessibility-character';\n\nexport interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: ButtonArrows;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n mode?: ButtonMode;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean): void => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button = React.forwardRef(function ButtonForwardedRef(\n props: ButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>\n) {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n mode = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n ...restProps\n } = props;\n\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { hoverRef, isHovered } =\n htmlMarkup === 'button'\n ? useHover<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>)\n : useHover<HTMLAnchorElement>(ref as React.RefObject<HTMLAnchorElement>);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = mode === 'ondark';\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, mobile);\n const hasArrow = arrow === 'icon' && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const hasUURightArrow = arrow === 'accessibility-character' && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(buttonStyles['button__text'], {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n });\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (iconElement: BaseIconElement | null, iconSize: number, iconClassName?: string): BaseIconElement | null => {\n return iconElement\n ? React.cloneElement(iconElement, {\n size: iconSize,\n color: iconElement?.props.color ? iconElement.props.color : iconColor,\n isHovered,\n className: iconClassName,\n })\n : null;\n };\n\n const renderButtonContent = (): JSX.Element => {\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): JSX.Element => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, mobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(\n <Icon svgIcon={ArrowRight} />,\n getLargeIconSize(large, mobile),\n classNames(buttonStyles['button__arrow'], { [buttonStyles['button__arrow--both-icons']]: bothIcons })\n )\n : renderIcon(rightIcon, getLargeIconSize(large, mobile), buttonStyles['button__right-icon'])}\n {hasUURightArrow && (\n <span style={{ color: iconColor }} className={buttonStyles['button__right-unicode-arrow']}>\n {' →'}\n </span>\n )}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={hoverRef as React.ForwardedRef<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={hoverRef as React.ForwardedRef<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n});\n\nexport default Button;\n"],"names":["getIconColor","fill","borderless","disabled","concept","ondark","mobile","getColor","getLargeIconSize","large","IconSize","checkOnlyIconAria","onlyIcon","ariaLabel","devEnv","Button","React","props","ref","id","children","wrapperClassName","className","arrow","ellipsis","fluid","htmlMarkup","mode","onBlur","onClick","size","variant","href","tabIndex","testId","target","type","restProps","leftIcon","rightIcon","restChildren","useIcons","hoverRef","isHovered","useHover","buttonContentRef","useRef","bothIcons","onDark","useBreakpoint","breakpoints","destructive","outlineVariant","borderlessVariant","iconColor","hasArrow","hasUURightArrow","rest","buttonWrapperClasses","classNames","buttonStyles","buttonClasses","buttonTextClasses","diagonalClasses","useEffect","isTest","isProd","renderIcon","iconElement","iconSize","iconClassName","renderButtonContent","renderbuttonContentWrapper","Icon","ArrowRight","AnalyticsId","Button$1"],"mappings":";;;;;;;;;;;;AA8DA,MAAMA,KAAe,CACnBC,GACAC,GACAC,GACAC,GACAC,GACAC,MAEIA,KAAUH,IACL,CAACE,KAAUJ,IAAOM,EAAS,WAAYL,IAAmB,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C,GAAOH,CAAM,GAAGsD,EAAa,oBAAoB,CAAC,GAC5FJ,qCACE,QAAK,EAAA,OAAO,EAAE,OAAOF,EAAU,GAAG,WAAWM,EAAa,6BAA6B,KACrF,KACH,CAEJ;AAIA,SAAA5C,gBAAAA,EAAA,cAAAA,EAAA,UAAA,MACGU,MAAe,YACdV,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAAG;AAAA,MACA,QAAAS;AAAA,MACA,SAAAC;AAAA,MACA,UAAA1B;AAAA,MACA,eAAa+B;AAAA,MACb,oBAAkByC,EAAY;AAAA,MAC9B,WAAWjB;AAAA,MACX,KAAKhB;AAAA,MACL,UAAAT;AAAA,MACA,MAAAG;AAAA,MACC,GAAGqB;AAAA,IAAA;AAAA,IAEHe,EAA2B;AAAA,EAAA,GAG/B9C,MAAe,OACdV,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAAG;AAAA,MACA,QAAAS;AAAA,MACA,SAAAC;AAAA,MACA,eAAaK;AAAA,MACb,oBAAkByC,EAAY;AAAA,MAC9B,WAAWjB;AAAA,MACX,MAAA1B;AAAA,MACA,QAAAG;AAAA,MACA,KAAKA,MAAW,WAAW,wBAAwBlB,EAAM;AAAA,MACzD,KAAKyB;AAAA,MACL,UAAAT;AAAA,MACC,GAAGI;AAAA,IAAA;AAAA,IAEHmC,EAA2B;AAAA,EAAA,CAGlC;AAEJ,CAAC,GAEDI,KAAe7D;"}
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import React, { AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconSize } from './../Icon';\nimport { HTMLButtonProps, HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { BaseIconElement, useIcons } from '../../hooks/useIcons';\nimport { getColor } from '../../theme/currys/color';\nimport { breakpoints } from '../../theme/grid';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonMode = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\nexport type ButtonArrows = 'icon' | 'accessibility-character';\n\nexport interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: ButtonArrows;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n mode?: ButtonMode;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean): void => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button = React.forwardRef(function ButtonForwardedRef(\n props: ButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>\n) {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n mode = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n ...restProps\n } = props;\n\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { hoverRef, isHovered } =\n htmlMarkup === 'button'\n ? useHover<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>)\n : useHover<HTMLAnchorElement>(ref as React.RefObject<HTMLAnchorElement>);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = mode === 'ondark';\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, mobile);\n const hasArrow = arrow === 'icon' && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const hasUURightArrow = arrow === 'accessibility-character' && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(buttonStyles['button__text'], {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n });\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (iconElement: BaseIconElement | null, iconSize: number, iconClassName?: string): BaseIconElement | null => {\n return iconElement\n ? React.cloneElement(iconElement, {\n size: iconSize,\n color: iconElement?.props.color ? iconElement.props.color : iconColor,\n isHovered,\n className: iconClassName,\n })\n : null;\n };\n\n const renderButtonContent = (): JSX.Element => {\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): JSX.Element => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, mobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(\n <Icon svgIcon={ArrowRight} />,\n getLargeIconSize(large, mobile),\n classNames(buttonStyles['button__arrow'], { [buttonStyles['button__arrow--both-icons']]: bothIcons })\n )\n : renderIcon(rightIcon, getLargeIconSize(large, mobile), buttonStyles['button__right-icon'])}\n {hasUURightArrow && (\n <span style={{ color: iconColor }} className={buttonStyles['button__right-unicode-arrow']} aria-hidden>\n {' →'}\n </span>\n )}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={hoverRef as React.ForwardedRef<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={hoverRef as React.ForwardedRef<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n});\n\nexport default Button;\n"],"names":["getIconColor","fill","borderless","disabled","concept","ondark","mobile","getColor","getLargeIconSize","large","IconSize","checkOnlyIconAria","onlyIcon","ariaLabel","devEnv","Button","React","props","ref","id","children","wrapperClassName","className","arrow","ellipsis","fluid","htmlMarkup","mode","onBlur","onClick","size","variant","href","tabIndex","testId","target","type","restProps","leftIcon","rightIcon","restChildren","useIcons","hoverRef","isHovered","useHover","buttonContentRef","useRef","bothIcons","onDark","useBreakpoint","breakpoints","destructive","outlineVariant","borderlessVariant","iconColor","hasArrow","hasUURightArrow","rest","buttonWrapperClasses","classNames","buttonStyles","buttonClasses","buttonTextClasses","diagonalClasses","useEffect","isTest","isProd","renderIcon","iconElement","iconSize","iconClassName","renderButtonContent","renderbuttonContentWrapper","Icon","ArrowRight","AnalyticsId","Button$1"],"mappings":";;;;;;;;;;;;AA8DA,MAAMA,KAAe,CACnBC,GACAC,GACAC,GACAC,GACAC,GACAC,MAEIA,KAAUH,IACL,CAACE,KAAUJ,IAAOM,EAAS,WAAYL,IAAmB,MAAN,GAAS,IAAIK,EAAS,OAAO,IAEtFJ,IACK,CAACE,KAAUJ,IAAOM,EAAS,WAAW,GAAG,IAAI,GAAGA,EAAS,OAAO,CAAC,OAErEN,KAAQ,CAACI,KAAY,CAACJ,KAAQI,IAC1B,UAGFD,MAAY,WAAWG,EAAS,aAAa,GAAG,IAAIA,EAAS,UAAU,GAAG,GAE7EC,IAAmB,CAACC,GAAgBH,MACpCA,KAAUG,IAAcC,EAAS,QACjCD,IAAcC,EAAS,SACpBA,EAAS,QAGZC,KAAoB,CAACC,GAAmBC,GAA+BC,MAA0B;AACrG,MAAIA,KAAUF,MAAaC,MAAc,UAAaA,MAAc;AAC5D,UAAA,IAAI,MAAM,yEAAyE;AAE7F,GAEME,KAASC,EAAM,WAAW,SAC9BC,GACAC,GACA;AACM,QAAA;AAAA,IACJ,WAAAL;AAAA,IACA,IAAAM;AAAA,IACA,UAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAnB,IAAU;AAAA,IACV,UAAAD,IAAW;AAAA,IACX,UAAAqB,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,YAAAC,IAAa;AAAA,IACb,MAAAC,IAAO;AAAA,IACP,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,SA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;AAAA,MACC,GAAGI;AAAA,IAAA;AAAA,IAEHmC,EAA2B;AAAA,EAAA,CAGlC;AAEJ,CAAC,GAEDI,KAAe7D;"}
|
|
@@ -25,25 +25,6 @@
|
|
|
25
25
|
font-size: $font-size-md;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
&__dt,
|
|
29
|
-
&__dd {
|
|
30
|
-
line-height: $lineheight-size-md;
|
|
31
|
-
padding-bottom: getSpacer(2xs);
|
|
32
|
-
|
|
33
|
-
&:last-of-type {
|
|
34
|
-
padding-bottom: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&--bold {
|
|
38
|
-
font-weight: 600;
|
|
39
|
-
line-height: $lineheight-size-sm;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&--non-formatted {
|
|
43
|
-
display: inline;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
28
|
&__dt {
|
|
48
29
|
padding-right: getSpacer(l);
|
|
49
30
|
|
|
@@ -64,6 +45,25 @@
|
|
|
64
45
|
margin-inline-start: 0;
|
|
65
46
|
}
|
|
66
47
|
|
|
48
|
+
&__dt,
|
|
49
|
+
&__dd {
|
|
50
|
+
line-height: $lineheight-size-md;
|
|
51
|
+
padding-bottom: getSpacer(2xs);
|
|
52
|
+
|
|
53
|
+
&:last-of-type {
|
|
54
|
+
padding-bottom: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--bold {
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
line-height: $lineheight-size-sm;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&--non-formatted {
|
|
63
|
+
display: inline;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
67
|
&--line &__dt,
|
|
68
68
|
&--line &__dd {
|
|
69
69
|
padding-top: getSpacer(2xs);
|
|
@@ -34,6 +34,19 @@
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
&__button,
|
|
38
|
+
&__trigger {
|
|
39
|
+
&--sticky {
|
|
40
|
+
position: fixed;
|
|
41
|
+
top: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&--absolute {
|
|
45
|
+
position: absolute;
|
|
46
|
+
bottom: 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
&__button {
|
|
38
51
|
position: relative;
|
|
39
52
|
padding-right: getSpacer(s);
|
|
@@ -134,19 +147,6 @@
|
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
|
|
137
|
-
&__button,
|
|
138
|
-
&__trigger {
|
|
139
|
-
&--sticky {
|
|
140
|
-
position: fixed;
|
|
141
|
-
top: 0;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
&--absolute {
|
|
145
|
-
position: absolute;
|
|
146
|
-
bottom: 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
150
|
&__content {
|
|
151
151
|
$content: &;
|
|
152
152
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import("./ExpanderList").ExpanderListCompound;
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
7
9
|
description: {
|
|
8
10
|
component: string;
|
|
9
11
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import("./LinkList").CompoundComponent;
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
7
9
|
description: {
|
|
8
10
|
component: string;
|
|
9
11
|
};
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
> #{$list}__item {
|
|
22
22
|
> #{$list}--bullet {
|
|
23
|
+
// for å beholde utseende disables warning på whitespace her
|
|
24
|
+
/* stylelint-disable-next-line no-irregular-whitespace */
|
|
23
25
|
list-style-type: '⬥ ';
|
|
24
26
|
|
|
25
27
|
> #{$list}__item {
|
|
@@ -28,6 +30,8 @@
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
> #{$list}--bullet {
|
|
33
|
+
// for å beholde utseende disables warning på whitespace her
|
|
34
|
+
/* stylelint-disable-next-line no-irregular-whitespace */
|
|
31
35
|
list-style-type: '– ';
|
|
32
36
|
}
|
|
33
37
|
}
|
|
@@ -38,6 +42,8 @@
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
&--dashed {
|
|
45
|
+
// for å beholde utseende disables warning på whitespace her
|
|
46
|
+
/* stylelint-disable-next-line no-irregular-whitespace */
|
|
41
47
|
list-style-type: '– ';
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
box-shadow: none;
|
|
19
19
|
outline: none;
|
|
20
20
|
}
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
html :focus > .pop-menu-button {
|
|
24
|
+
box-shadow: none;
|
|
25
|
+
border: solid;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
:focus > .pop-menu-button:hover {
|
|
28
|
+
.pop-menu-button :focus > .pop-menu-button {
|
|
29
29
|
box-shadow: none;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// overrides
|
|
33
|
+
:focus > .pop-menu-button:hover {
|
|
33
34
|
box-shadow: none;
|
|
34
|
-
border: solid;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.pop-menu-button--on-white {
|
|
@@ -108,7 +108,6 @@ html :focus > .pop-menu-button {
|
|
|
108
108
|
|
|
109
109
|
.pop-menu__pop-over {
|
|
110
110
|
width: 20.875rem;
|
|
111
|
-
width: 26.125rem;
|
|
112
111
|
border: 0.125rem solid rgb(24 128 151);
|
|
113
112
|
box-shadow: 0 0 0.3125rem 0 rgb(0 0 0 / 50%);
|
|
114
113
|
|
|
@@ -20,10 +20,6 @@
|
|
|
20
20
|
z-index: 3;
|
|
21
21
|
visibility: hidden;
|
|
22
22
|
|
|
23
|
-
& + &__arrow {
|
|
24
|
-
visibility: hidden;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
23
|
&--visible {
|
|
28
24
|
visibility: visible;
|
|
29
25
|
|
|
@@ -65,4 +61,8 @@
|
|
|
65
61
|
filter: drop-shadow(0 0.2rem 0 var(--drop-shadow-color));
|
|
66
62
|
}
|
|
67
63
|
}
|
|
64
|
+
|
|
65
|
+
& + &__arrow {
|
|
66
|
+
visibility: hidden;
|
|
67
|
+
}
|
|
68
68
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react';
|
|
2
3
|
declare const meta: {
|
|
3
4
|
title: string;
|
|
4
5
|
component: import("./Tile").TileCompound;
|
|
5
6
|
parameters: {
|
|
6
7
|
docs: {
|
|
8
|
+
page: () => React.JSX.Element;
|
|
7
9
|
description: {
|
|
8
10
|
component: string;
|
|
9
11
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { StoryObj } from '@storybook/react';
|
|
3
3
|
import { FormSize } from '../../constants';
|
|
4
4
|
declare const meta: {
|
|
@@ -6,6 +6,7 @@ declare const meta: {
|
|
|
6
6
|
component: (props: import("../FormExample/FormExample").FormExampleProps) => JSX.Element;
|
|
7
7
|
parameters: {
|
|
8
8
|
docs: {
|
|
9
|
+
page: () => React.JSX.Element;
|
|
9
10
|
description: {
|
|
10
11
|
component: string;
|
|
11
12
|
markdown: string;
|
package/docs/index.d.ts
CHANGED
package/docs/index.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import "../node_modules/@storybook/addon-docs/dist/chunk-HLWAVYOI.js";
|
|
3
|
-
import { ArgTypes as n, Title as
|
|
4
|
-
const
|
|
3
|
+
import { ArgTypes as n, Title as o, Subtitle as l, Description as i, Primary as c, Stories as s } from "../node_modules/@storybook/blocks/dist/index.js";
|
|
4
|
+
const m = () => (window.location != window.parent.location ? document.referrer : document.location.href).startsWith("https://frankenstein.helsenorge.design") || window.location.search.includes("isSupernova"), w = (t) => {
|
|
5
|
+
if (m())
|
|
6
|
+
return /* @__PURE__ */ e.createElement(n, { of: t.component });
|
|
7
|
+
const r = new URLSearchParams(window.location.search), a = `${window.location.pathname}?id=${r.get("id")}&viewMode=docs`;
|
|
8
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between" } }, /* @__PURE__ */ e.createElement(o, null), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("a", { target: "_blank", href: a, rel: "noreferrer" }, "Åpne i ny fane"))), /* @__PURE__ */ e.createElement(l, null), /* @__PURE__ */ e.createElement(i, null), /* @__PURE__ */ e.createElement(c, null), /* @__PURE__ */ e.createElement(n, { of: t.component }), !t.hideStories && /* @__PURE__ */ e.createElement(s, null));
|
|
9
|
+
};
|
|
5
10
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
w as default,
|
|
12
|
+
m as isSupernova
|
|
8
13
|
};
|
|
9
14
|
//# sourceMappingURL=index.js.map
|
package/docs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/docs/index.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Title, Subtitle, Description, Primary, ArgTypes, Stories } from '@storybook/addon-docs';\n\ninterface DocsProps<T> {\n component: T;\n}\n\nexport const isSupernova = (): boolean => {\n const url = window.location != window.parent.location ? document.referrer : document.location.href;\n return url.startsWith('https://frankenstein.helsenorge.design') || window.location.search.includes('isSupernova');\n};\n\nconst Docs = <T,>(props: DocsProps<T>): React.JSX.Element => {\n if (isSupernova()) {\n return <ArgTypes of={props.component} />;\n }\n\n return (\n <>\n <Title />\n <Subtitle />\n <Description />\n <Primary />\n <ArgTypes of={props.component} />\n <Stories
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/docs/index.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Title, Subtitle, Description, Primary, ArgTypes, Stories } from '@storybook/addon-docs';\n\ninterface DocsProps<T> {\n component: T;\n hideStories?: boolean;\n}\n\nexport const isSupernova = (): boolean => {\n const url = window.location != window.parent.location ? document.referrer : document.location.href;\n return url.startsWith('https://frankenstein.helsenorge.design') || window.location.search.includes('isSupernova');\n};\n\nconst Docs = <T,>(props: DocsProps<T>): React.JSX.Element => {\n if (isSupernova()) {\n return <ArgTypes of={props.component} />;\n }\n\n const searchParams = new URLSearchParams(window.location.search);\n const newWindowUrl = `${window.location.pathname}?id=${searchParams.get('id')}&viewMode=docs`;\n\n return (\n <>\n <div style={{ display: 'flex', justifyContent: 'space-between' }}>\n <Title />\n <div>\n <a target=\"_blank\" href={newWindowUrl} rel=\"noreferrer\">\n {'Åpne i ny fane'}\n </a>\n </div>\n </div>\n <Subtitle />\n <Description />\n <Primary />\n <ArgTypes of={props.component} />\n {!props.hideStories && <Stories />}\n </>\n );\n};\n\nexport default Docs;\n"],"names":["isSupernova","Docs","props","React","ArgTypes","searchParams","newWindowUrl","Title","Subtitle","Description","Primary","Stories"],"mappings":";;;AASO,MAAMA,IAAc,OACb,OAAO,YAAY,OAAO,OAAO,WAAW,SAAS,WAAW,SAAS,SAAS,MACnF,WAAW,wCAAwC,KAAK,OAAO,SAAS,OAAO,SAAS,aAAa,GAG5GC,IAAO,CAAKC,MAA2C;AAC3D,MAAIF;AACF,WAAQ,gBAAAG,EAAA,cAAAC,GAAA,EAAS,IAAIF,EAAM,UAAW,CAAA;AAGxC,QAAMG,IAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACzDC,IAAe,GAAG,OAAO,SAAS,QAAQ,OAAOD,EAAa,IAAI,IAAI,CAAC;AAG3E,SAAA,gBAAAF,EAAA,cAAAA,EAAA,UAAA,sCACG,OAAI,EAAA,OAAO,EAAE,SAAS,QAAQ,gBAAgB,kBAAgB,mCAC5DI,GAAM,IAAA,mCACN,OACC,MAAA,gBAAAJ,EAAA,cAAC,OAAE,QAAO,UAAS,MAAMG,GAAc,KAAI,aAAA,GACxC,gBACH,CACF,CACF,GACC,gBAAAH,EAAA,cAAAK,GAAA,IAAS,GACT,gBAAAL,EAAA,cAAAM,GAAA,IAAY,GACb,gBAAAN,EAAA,cAACO,GAAQ,IAAA,mCACRN,GAAS,EAAA,IAAIF,EAAM,UAAW,CAAA,GAC9B,CAACA,EAAM,eAAgB,gBAAAC,EAAA,cAAAQ,GAAA,IAAQ,CAClC;AAEJ;"}
|