@rikstv/shared-components 3.0.18 → 3.0.20

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # 📖 Changelog
2
2
 
3
+ ## 3.0.20
4
+
5
+ - Refactor `<Panel>` component to [Figma design](https://www.figma.com/design/tHKRyAMB0VrQHZjENOnwNi/Forslag%3A-designsystem-strim-web?m=dev&node-id=415%3A83885) and use CSS modules.
6
+ - rename `variant` to `intent` to mirror `<Alert>`
7
+ - remove `lightBackground` prop
8
+ - allow a string as `heading` (on top of `{ text: string, level: h }`)
9
+ - update used icons
10
+ - styled via `:where(.rds-panel)` for easier overrides. Accepts variables `--panel-color` and `--panel-bg` from outside
11
+ - Add `text-wrap: pretty` to `<Panel>` and `<Alert>` (also add max-width to Alert)
12
+
13
+ ## 3.0.19
14
+
15
+ - Revert remove `breakpoints.scss` since it is sooooo hard to configure custom media queries in NextJs...
16
+
3
17
  ## 3.0.18
4
18
 
5
19
  - ⚠️ (Breaking change) Remove export of `breakpoints.scss` and `rem.scss`
@@ -3,7 +3,7 @@ import { forwardRef as S, useState as o } from "react";
3
3
  import { H as k, B as w } from "../typography/Typography-563b6318.mjs";
4
4
  import "../icons/HeartToggle-54bb18c7.mjs";
5
5
  import { S as y, a as B, b as a, c as T } from "../icons/Icons-2b68875c.mjs";
6
- const R = "_rds-alert--icon_1cbbx_66", E = "_rds-alert--content-title_1cbbx_74", H = "_rds-alert--content_1cbbx_74", O = "_rds-alert--dismiss_1cbbx_100", D = "_dismissed_1cbbx_129", F = "_fade-out_1cbbx_1", t = {
6
+ const R = "_rds-alert--icon_h7b6b_67", E = "_rds-alert--content-title_h7b6b_75", H = "_rds-alert--content_h7b6b_75", O = "_rds-alert--dismiss_h7b6b_108", D = "_dismissed_h7b6b_137", F = "_fade-out_h7b6b_1", t = {
7
7
  rdsAlertIcon: R,
8
8
  rdsAlertContentTitle: E,
9
9
  rdsAlertContent: H,
@@ -17,25 +17,25 @@ const R = "_rds-alert--icon_1cbbx_66", E = "_rds-alert--content-title_1cbbx_74",
17
17
  success: { title: "Vellykket", Icon: T }
18
18
  }, V = S(
19
19
  ({
20
- className: c,
20
+ className: d,
21
21
  intent: r = "warning",
22
22
  variant: l = "filled",
23
- testId: d = "rds-alert",
23
+ testId: c = "rds-alert",
24
24
  heading: m,
25
25
  children: f,
26
26
  dismissible: A = !0,
27
27
  lightBackground: _,
28
28
  onDismissed: e,
29
- LinkToDetails: x,
30
- ...b
29
+ LinkToDetails: b,
30
+ ...h
31
31
  }, v) => {
32
- const [u, n] = o(!1), [j, i] = o(!1), p = ["rds-alert", _ ? "rds-light" : "", u ? t.dismissed : "", c].filter(Boolean).join(" ");
32
+ const [u, n] = o(!1), [j, i] = o(!1), p = ["rds-alert", _ ? "rds-light" : "", u ? t.dismissed : "", d].filter(Boolean).join(" ");
33
33
  if (j)
34
34
  return null;
35
- const C = () => {
35
+ const x = () => {
36
36
  n(!1), i(!1);
37
- }, { title: I, Icon: g } = M[r], h = () => {
38
- i(!0), e == null || e(C);
37
+ }, { title: C, Icon: I } = M[r], g = () => {
38
+ i(!0), e == null || e(x);
39
39
  }, N = A && l !== "inline";
40
40
  return /* @__PURE__ */ s.jsxs(
41
41
  "div",
@@ -44,17 +44,17 @@ const R = "_rds-alert--icon_1cbbx_66", E = "_rds-alert--content-title_1cbbx_74",
44
44
  "aria-live": "polite",
45
45
  ref: v,
46
46
  className: p,
47
- "data-testid": d,
47
+ "data-testid": c,
48
48
  "data-intent": r,
49
49
  "data-variant": l,
50
- onAnimationEnd: h,
51
- ...b,
50
+ onAnimationEnd: g,
51
+ ...h,
52
52
  children: [
53
- /* @__PURE__ */ s.jsx(g, { className: t.rdsAlertIcon }),
53
+ /* @__PURE__ */ s.jsx(I, { className: t.rdsAlertIcon }),
54
54
  /* @__PURE__ */ s.jsxs("div", { className: t.rdsAlertContent, children: [
55
- /* @__PURE__ */ s.jsx(k, { className: t.rdsAlertContentTitle, as: "span", children: m || I }),
55
+ /* @__PURE__ */ s.jsx(k, { className: t.rdsAlertContentTitle, as: "span", children: m || C }),
56
56
  /* @__PURE__ */ s.jsx(w, { children: f }),
57
- x
57
+ b
58
58
  ] }),
59
59
  N && /* @__PURE__ */ s.jsx("div", { className: t.rdsAlertDismiss, children: /* @__PURE__ */ s.jsx("button", { "aria-label": "Avvis varsel", onClick: () => n(!0), children: /* @__PURE__ */ s.jsx(y, {}) }) })
60
60
  ]
@@ -1,3 +1,5 @@
1
+ @use "../core/mixin/breakpoints" as break;
2
+
1
3
  .rds-breadcrumb {
2
4
  --rds-crumb-separator: "/";
3
5
  // --rds-crumb-separator: "›";
@@ -37,7 +39,7 @@
37
39
  // you're most likely to either go all the way back to the start, or back one step, so that's
38
40
  // the ones we show
39
41
  &--truncate {
40
- @media (max-width: 768px) {
42
+ @include break.breakpoint("sm") {
41
43
  // Flip everything to be not visible
42
44
  display: none;
43
45
  &::after {
@@ -0,0 +1,129 @@
1
+ @use "./mixin/breakpoints" as break;
2
+ @use "./mixin/focus" as focus;
3
+
4
+ :root {
5
+ // Spacing
6
+ --rds-spacing--2: 0.125rem;
7
+ --rds-spacing--4: 0.25rem;
8
+ --rds-spacing--8: 0.5rem;
9
+ --rds-spacing--16: 1rem;
10
+ --rds-spacing--24: 1.5rem;
11
+ --rds-spacing--32: 2rem;
12
+ --rds-spacing--40: 2.5rem;
13
+ --rds-spacing--48: 3rem;
14
+ --rds-spacing--64: 4rem;
15
+ --rds-spacing--80: 5rem;
16
+ --rds-spacing--96: 6rem;
17
+
18
+ // Common shadows
19
+ --rds-box-shadow--default: 0px 8px 16px rgba(0, 0, 0, 0.5);
20
+
21
+ // Widths
22
+ --rds-readability-width: 70ch;
23
+ --rds-content-width--default: 1070px;
24
+
25
+ // Gutters
26
+ --rds-gutter--sm: 1rem;
27
+ --rds-gutter--md: 5vw;
28
+ --rds-gutter--lg: 7.5vw;
29
+ --rds-gutter: var(--rds-gutter--sm);
30
+
31
+ @include break.min("sm") {
32
+ --rds-gutter: var(--rds-gutter--md);
33
+ }
34
+
35
+ @include break.min("lg") {
36
+ --rds-gutter: var(--rds-gutter--lg);
37
+ }
38
+ }
39
+
40
+ .rds-gutter {
41
+ margin-inline: var(--rds-gutter);
42
+ }
43
+
44
+ .rds-gutter-padding {
45
+ padding-inline: var(--rds-gutter);
46
+ }
47
+
48
+ .sr-only {
49
+ position: absolute;
50
+ width: 1px;
51
+ height: 1px;
52
+ margin: -1px;
53
+ padding: 0;
54
+ overflow: hidden;
55
+ clip: rect(0, 0, 0, 0);
56
+ border: 0;
57
+ }
58
+
59
+ .with-keyboard-focus {
60
+ @include focus.with-keyboard-focus;
61
+ }
62
+
63
+ .with-keyboard-focus-within {
64
+ @include focus.with-keyboard-focus-within;
65
+ }
66
+
67
+ @font-face {
68
+ font-family: "HALMatex";
69
+ src: url("https://static.rikstv.no/strim/fonts/HALMatexStrim-Medium.woff2") format("woff2"),
70
+ url("https://static.rikstv.no/strim/fonts/HALMatexStrim-Medium.woff") format("woff");
71
+ font-style: normal;
72
+ font-display: swap;
73
+ }
74
+
75
+ @font-face {
76
+ font-family: "HALMatexLight";
77
+ src: url("https://static.rikstv.no/strim/fonts/HALMatexStrim-Light.woff2") format("woff2"),
78
+ url("https://static.rikstv.no/strim/fonts/HALMatexStrim-Light.woff") format("woff");
79
+ font-weight: normal;
80
+ font-style: normal;
81
+ font-display: swap;
82
+ }
83
+
84
+ @font-face {
85
+ font-family: "AvertaRegular";
86
+ src: url("https://static.rikstv.no/strim/fonts/AvertaStandardRegular.woff2") format("woff2"),
87
+ url("https://static.rikstv.no/strim/fonts/hinted-AvertaStd-Regular.woff") format("woff");
88
+ font-weight: 400;
89
+ font-style: normal;
90
+ font-display: swap;
91
+ }
92
+
93
+ @font-face {
94
+ font-family: "AvertaSemibold";
95
+ src: url("https://static.rikstv.no/strim/fonts/AvertaStandardSemibold.woff2") format("woff2"),
96
+ url("https://static.rikstv.no/strim/fonts/hinted-AvertaStd-Semibold.woff") format("woff");
97
+ font-weight: 500;
98
+ font-style: normal;
99
+ font-display: swap;
100
+ }
101
+
102
+ @font-face {
103
+ font-family: "AvertaBold";
104
+ src: url("https://static.rikstv.no/strim/fonts/AvertaStandardBold.woff2") format("woff2"),
105
+ url("https://static.rikstv.no/strim/fonts/hinted-AvertaStd-Bold.woff") format("woff");
106
+ font-weight: 700;
107
+ font-style: normal;
108
+ font-display: swap;
109
+ }
110
+
111
+ /** Custom media breakpoints
112
+ * Requires "postcss-custom-media" in consumer postcss config
113
+ */
114
+ // Max-width
115
+ @custom-media --rds-media-xs (max-width: #{break.$xs});
116
+ @custom-media --rds-media-sm (max-width: #{break.$sm});
117
+ @custom-media --rds-media-md (max-width: #{break.$md});
118
+ @custom-media --rds-media-ml (max-width: #{break.$ml});
119
+ @custom-media --rds-media-lg (max-width: #{break.$lg});
120
+ @custom-media --rds-media-lw (max-width: #{break.$lw});
121
+ @custom-media --rds-media-xl (max-width: #{break.$xl});
122
+ // Min-width
123
+ @custom-media --rds-media-min-xs (min-width: #{break.$xs});
124
+ @custom-media --rds-media-min-sm (min-width: #{break.$sm});
125
+ @custom-media --rds-media-min-md (min-width: #{break.$md});
126
+ @custom-media --rds-media-min-ml (min-width: #{break.$ml});
127
+ @custom-media --rds-media-min-lg (min-width: #{break.$lg});
128
+ @custom-media --rds-media-min-lw (min-width: #{break.$lw});
129
+ @custom-media --rds-media-min-xl (min-width: #{break.$xl});
@@ -0,0 +1,44 @@
1
+ $xs: 568px;
2
+ $sm: 768px;
3
+ $md: 992px;
4
+ $ml: 1024px;
5
+ $lg: 1200px;
6
+ $lw: 1600px;
7
+ $xl: 2400px;
8
+
9
+ $breakpoints: (
10
+ "xs": $xs,
11
+ "sm": $sm,
12
+ "md": $md,
13
+ "ml": $ml,
14
+ "lg": $lg,
15
+ "lw": $lw,
16
+ "xl": $xl,
17
+ ) !default;
18
+
19
+ @mixin breakpoint($breakpoint) {
20
+ // If the key exists in the map
21
+ @if map-has-key($breakpoints, $breakpoint) {
22
+ // Prints a media query based on the value
23
+ @media (max-width: map-get($breakpoints, $breakpoint)) {
24
+ @content;
25
+ }
26
+ }
27
+
28
+ // If the key doesn't exist in the map
29
+ @else {
30
+ @warn 'Unfortunately, no value could be retrieved from `#{$breakpoint}`. ' + 'Available breakpoints are: #{map-keys($breakpoints)}.';
31
+ }
32
+ }
33
+
34
+ @mixin min($breakpoint) {
35
+ // If the key exists in the map
36
+ @if map-has-key($breakpoints, $breakpoint) {
37
+ // Prints a media query based on the value
38
+ @media (min-width: map-get($breakpoints, $breakpoint)) {
39
+ @content;
40
+ }
41
+ } @else {
42
+ @warn 'Unfortunately, no value could be retrieved from `#{$breakpoint}`. ' + 'Available breakpoints are: #{map-keys($breakpoints)}.';
43
+ }
44
+ }
@@ -1,6 +1,7 @@
1
- @import "./core.css";
1
+ @use "./core";
2
+
3
+ // Source of truth: https://www.figma.com/file/eZpToN8EpnZiD9AU2Xc8bN/Global-%2F-Farger?node-id=399%3A0&mode=dev
2
4
 
3
- /* RIKSTV COLORS */
4
5
  .rtv {
5
6
  // RiksTV Red
6
7
  --rikstv-red: #ef4642;
@@ -71,8 +72,6 @@
71
72
  --rikstv-foreground-gray-80: #858585;
72
73
  }
73
74
 
74
- // Source of truth: https://www.figma.com/file/eZpToN8EpnZiD9AU2Xc8bN/Global-%2F-Farger?node-id=399%3A0&mode=dev
75
-
76
75
  // Semantic colors/tags
77
76
  .rtv {
78
77
  // Brand colors
@@ -91,7 +90,7 @@
91
90
  --rds-button-tertiary-hover-bg: var(--rikstv-card-gray);
92
91
 
93
92
  // Panel
94
- --panel-warning2-background-color: var(--rikstv-red-120);
93
+ --panel-warning-bg: var(--rikstv-red-120);
95
94
 
96
95
  // Foreground
97
96
  --rds-foreground-primary: var(--rikstv-white);
@@ -1,6 +1,7 @@
1
- @import "./core.css";
1
+ @use "./core";
2
+
3
+ // Source of truth: https://www.figma.com/file/eZpToN8EpnZiD9AU2Xc8bN/Global-%2F-Farger?node-id=399%3A0&mode=dev
2
4
 
3
- /** STRIM COLORS */
4
5
  .strm {
5
6
  // Yellow
6
7
  --strim-action-yellow: #faed6f;
@@ -48,8 +49,6 @@
48
49
  --strim-error-dark: #d91b4e;
49
50
  }
50
51
 
51
- // Source of truth: https://www.figma.com/file/eZpToN8EpnZiD9AU2Xc8bN/Global-%2F-Farger?node-id=399%3A0&mode=dev
52
-
53
52
  .strm {
54
53
  // ?
55
54
  --stand-up-green: var(--strim-standup-green);
@@ -71,7 +70,7 @@
71
70
  --rds-button-tertiary-hover-bg: var(--strim-thriller-teal);
72
71
 
73
72
  // Panel
74
- --panel-warning2-background-color: var(--strim-action-yellow-60);
73
+ --panel-warning-bg: var(--strim-action-yellow-60);
75
74
 
76
75
  // Foreground
77
76
  --rds-foreground-primary: var(--strim-white);
@@ -0,0 +1,59 @@
1
+ import { j as t } from "../accordion/Accordion-b8669b7e.mjs";
2
+ import { forwardRef as f } from "react";
3
+ import { S as j } from "../typography/Typography-563b6318.mjs";
4
+ import "../icons/HeartToggle-54bb18c7.mjs";
5
+ import { b as c, c as u, a as v } from "../icons/Icons-2b68875c.mjs";
6
+ const g = "_rds-panel_gg8xr_1", N = "_content-and-buttons_gg8xr_33", b = "_content_gg8xr_33", P = "_title_gg8xr_60", y = "_icon_gg8xr_67", A = "_buttons_gg8xr_74", n = {
7
+ rdsPanel: g,
8
+ contentAndButtons: N,
9
+ content: b,
10
+ title: P,
11
+ icon: y,
12
+ buttons: A
13
+ }, S = {
14
+ error: {
15
+ title: "Feil",
16
+ icon: /* @__PURE__ */ t.jsx(c, {})
17
+ },
18
+ info: {
19
+ title: "Informasjon",
20
+ icon: /* @__PURE__ */ t.jsx(c, {})
21
+ },
22
+ success: {
23
+ title: "Vellykket",
24
+ icon: /* @__PURE__ */ t.jsx(u, {})
25
+ },
26
+ warning: {
27
+ title: "Advarsel",
28
+ icon: /* @__PURE__ */ t.jsx(v, {})
29
+ }
30
+ }, k = f(
31
+ ({ className: l = "", intent: o = "info", heading: s, action: e, id: r, children: i, ...a }, x) => {
32
+ const { title: m, icon: _ } = S[o], p = typeof s == "string" ? s : (s == null ? void 0 : s.title) ?? m, d = typeof s == "string" ? "span" : (s == null ? void 0 : s.level) ?? "span";
33
+ return /* @__PURE__ */ t.jsxs(
34
+ "div",
35
+ {
36
+ id: r,
37
+ className: `${n.rdsPanel} ${l}`,
38
+ "data-testid": "rds-panel",
39
+ "data-intent": o,
40
+ ref: x,
41
+ ...a,
42
+ children: [
43
+ /* @__PURE__ */ t.jsx("span", { className: n.icon, children: _ }),
44
+ /* @__PURE__ */ t.jsxs("div", { className: n.contentAndButtons, children: [
45
+ /* @__PURE__ */ t.jsxs("div", { className: n.content, children: [
46
+ /* @__PURE__ */ t.jsx(d, { className: `${n.title} rds-title-4`, children: p }),
47
+ /* @__PURE__ */ t.jsx(j, { children: i })
48
+ ] }),
49
+ e && /* @__PURE__ */ t.jsx("div", { className: n.buttons, children: e })
50
+ ] })
51
+ ]
52
+ }
53
+ );
54
+ }
55
+ );
56
+ k.displayName = "Panel";
57
+ export {
58
+ k as P
59
+ };
@@ -1,14 +1,14 @@
1
1
  import { HTMLAttributes, ReactNode } from "react";
2
+ type Intent = "info" | "warning" | "success" | "error";
2
3
  export interface Props extends HTMLAttributes<HTMLDivElement> {
3
4
  className?: string;
4
- variant?: "info" | "warning" | "warning2" | "error";
5
- id?: string;
6
- lightBackground?: boolean;
7
- heading?: {
8
- text: string;
5
+ /** Defaults to `info`. Controls theme and icon */
6
+ intent?: Intent;
7
+ heading?: string | {
8
+ title: string;
9
9
  level: "h1" | "h2" | "h3" | "h4";
10
10
  };
11
11
  action?: ReactNode;
12
- icon?: "info" | "success";
13
12
  }
14
13
  export declare const Panel: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>;
14
+ export {};
@@ -1,5 +1,6 @@
1
1
  @use "../button/button-shared";
2
2
  @use "../button/button";
3
+ @use "../core/mixin/breakpoints" as break;
3
4
  @use "../core/mixin/focus.scss" as mix;
4
5
 
5
6
  .rds-toggle-button-container:focus-within {
@@ -51,7 +52,7 @@
51
52
  display: none;
52
53
  margin-left: var(--rds-spacing--16);
53
54
 
54
- @media (min-width: 768px) {
55
+ @include break.min("sm") {
55
56
  display: block;
56
57
  }
57
58