@ndla/ui 56.0.34-alpha.0 → 56.0.36-alpha.0

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.
Files changed (78) hide show
  1. package/dist/panda.buildinfo.json +8 -20
  2. package/dist/styles.css +20 -64
  3. package/es/CampaignBlock/CampaignBlock.js +36 -47
  4. package/es/Embed/CodeEmbed.js +6 -2
  5. package/es/Embed/ConceptEmbed.js +1 -0
  6. package/es/Embed/EmbedErrorPlaceholder.js +8 -9
  7. package/es/Layout/index.js +1 -3
  8. package/es/index.js +1 -2
  9. package/es/locale/messages-en.js +2 -1
  10. package/es/locale/messages-nb.js +2 -1
  11. package/es/locale/messages-nn.js +2 -1
  12. package/es/locale/messages-se.js +2 -1
  13. package/es/locale/messages-sma.js +2 -1
  14. package/lib/CampaignBlock/CampaignBlock.d.ts +4 -2
  15. package/lib/CampaignBlock/CampaignBlock.js +35 -46
  16. package/lib/Embed/CodeEmbed.js +7 -2
  17. package/lib/Embed/ConceptEmbed.js +1 -0
  18. package/lib/Embed/EmbedErrorPlaceholder.js +7 -8
  19. package/lib/Layout/index.d.ts +0 -2
  20. package/lib/Layout/index.js +1 -11
  21. package/lib/LicenseByline/EmbedByline.d.ts +1 -1
  22. package/lib/index.d.ts +1 -3
  23. package/lib/index.js +1 -14
  24. package/lib/locale/messages-en.d.ts +1 -0
  25. package/lib/locale/messages-en.js +2 -1
  26. package/lib/locale/messages-nb.d.ts +1 -0
  27. package/lib/locale/messages-nb.js +2 -1
  28. package/lib/locale/messages-nn.d.ts +1 -0
  29. package/lib/locale/messages-nn.js +2 -1
  30. package/lib/locale/messages-se.d.ts +1 -0
  31. package/lib/locale/messages-se.js +2 -1
  32. package/lib/locale/messages-sma.d.ts +1 -0
  33. package/lib/locale/messages-sma.js +2 -1
  34. package/package.json +6 -6
  35. package/src/CampaignBlock/CampaignBlock.tsx +43 -44
  36. package/src/ContentTypeHero/ContentTypeHero.stories.tsx +3 -4
  37. package/src/Embed/AudioEmbed.stories.tsx +3 -3
  38. package/src/Embed/BrightcoveEmbed.stories.tsx +3 -3
  39. package/src/Embed/CodeEmbed.tsx +5 -2
  40. package/src/Embed/ConceptEmbed.stories.tsx +3 -3
  41. package/src/Embed/ConceptEmbed.tsx +1 -0
  42. package/src/Embed/EmbedErrorPlaceholder.tsx +8 -9
  43. package/src/Embed/ExternalEmbed.stories.tsx +3 -3
  44. package/src/Embed/H5pEmbed.stories.tsx +3 -3
  45. package/src/Embed/IframeEmbed.stories.tsx +3 -3
  46. package/src/Embed/ImageEmbed.stories.tsx +3 -4
  47. package/src/Embed/RelatedContentEmbed.stories.tsx +3 -3
  48. package/src/Embed/UuDisclaimerEmbed.stories.tsx +3 -4
  49. package/src/Grid/Grid.stories.tsx +4 -3
  50. package/src/Layout/index.ts +0 -4
  51. package/src/LicenseByline/EmbedByline.tsx +1 -1
  52. package/src/index.ts +1 -4
  53. package/src/locale/messages-en.ts +1 -0
  54. package/src/locale/messages-nb.ts +1 -0
  55. package/src/locale/messages-nn.ts +1 -0
  56. package/src/locale/messages-se.ts +1 -0
  57. package/src/locale/messages-sma.ts +1 -0
  58. package/es/Layout/LayoutItem.js +0 -35
  59. package/es/TreeStructure/TreeStructure.js +0 -318
  60. package/es/TreeStructure/helperFunctions.js +0 -29
  61. package/es/TreeStructure/index.js +0 -9
  62. package/es/TreeStructure/types.js +0 -1
  63. package/lib/Layout/LayoutItem.d.ts +0 -11
  64. package/lib/Layout/LayoutItem.js +0 -40
  65. package/lib/TreeStructure/TreeStructure.d.ts +0 -22
  66. package/lib/TreeStructure/TreeStructure.js +0 -325
  67. package/lib/TreeStructure/helperFunctions.d.ts +0 -9
  68. package/lib/TreeStructure/helperFunctions.js +0 -36
  69. package/lib/TreeStructure/index.d.ts +0 -9
  70. package/lib/TreeStructure/index.js +0 -12
  71. package/lib/TreeStructure/types.d.ts +0 -15
  72. package/lib/TreeStructure/types.js +0 -5
  73. package/src/Layout/LayoutItem.tsx +0 -36
  74. package/src/TreeStructure/TreeStructure.stories.tsx +0 -282
  75. package/src/TreeStructure/TreeStructure.tsx +0 -354
  76. package/src/TreeStructure/helperFunctions.ts +0 -18
  77. package/src/TreeStructure/index.ts +0 -10
  78. package/src/TreeStructure/types.ts +0 -22
@@ -31,7 +31,6 @@ const Container = (0, _jsx2.styled)("div", {
31
31
  base: {
32
32
  display: "grid",
33
33
  gridTemplateColumns: "1fr",
34
- gap: "medium",
35
34
  border: "1px solid",
36
35
  borderColor: "stroke.default",
37
36
  backgroundColor: "background.default",
@@ -61,31 +60,20 @@ const Container = (0, _jsx2.styled)("div", {
61
60
  }
62
61
  }
63
62
  }
63
+ },
64
+ background: {
65
+ neutral: {},
66
+ brand1: {
67
+ backgroundColor: "surface.brand.1"
68
+ },
69
+ brand3: {
70
+ backgroundColor: "surface.brand.3"
71
+ }
64
72
  }
65
73
  },
66
74
  defaultVariants: {
67
- imageSide: "left"
68
- }
69
- });
70
- const LinkText = (0, _jsx2.styled)(_primitives.Text, {
71
- base: {
72
- display: "flex",
73
- gap: "xxsmall",
74
- textDecoration: "underline",
75
- _hover: {
76
- textDecoration: "none"
77
- },
78
- paddingBlock: "xsmall",
79
- fontWeight: "bold"
80
- }
81
- });
82
- const LinkHeader = (0, _jsx2.styled)(_primitives.Text, {
83
- base: {
84
- display: "flex",
85
- textDecoration: "underline",
86
- _hover: {
87
- textDecoration: "none"
88
- }
75
+ imageSide: "left",
76
+ background: "neutral"
89
77
  }
90
78
  });
91
79
  const StyledImg = (0, _jsx2.styled)("img", {
@@ -103,7 +91,8 @@ const StyledImg = (0, _jsx2.styled)("img", {
103
91
  tabletWide: {
104
92
  height: "340px"
105
93
  }
106
- }
94
+ },
95
+ backgroundColor: "background.default"
107
96
  }
108
97
  });
109
98
  const ContentWrapper = (0, _jsx2.styled)("div", {
@@ -115,7 +104,8 @@ const ContentWrapper = (0, _jsx2.styled)("div", {
115
104
  alignItems: "flex-start",
116
105
  justifyContent: "center",
117
106
  paddingBlock: "medium",
118
- paddingInline: "medium"
107
+ paddingInline: "medium",
108
+ position: "relative"
119
109
  }
120
110
  });
121
111
  const StyledText = (0, _jsx2.styled)(_primitives.Text, {
@@ -129,19 +119,24 @@ const StyledText = (0, _jsx2.styled)(_primitives.Text, {
129
119
  }
130
120
  }
131
121
  });
132
- const StyledSafeLink = (0, _jsx2.styled)(_safelink.SafeLink, {
122
+ const StyledSafeLinkButton = (0, _jsx2.styled)(_safelink.SafeLinkButton, {
133
123
  base: {
134
- color: "inherit"
124
+ boxShadow: "full",
125
+ border: "1px solid",
126
+ borderColor: "stroke.default"
135
127
  }
136
128
  });
137
- const MaybeLinkText = _ref => {
129
+ const LinkButton = _ref => {
138
130
  let {
139
131
  url,
140
132
  children,
141
133
  path
142
134
  } = _ref;
143
- if (url) return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledSafeLink, {
135
+ if (url) return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledSafeLinkButton, {
144
136
  to: (0, _relativeUrl.getPossiblyRelativeUrl)(url, path),
137
+ target: "_blank",
138
+ variant: "secondary",
139
+ rel: "noopener noreferrer",
145
140
  children: children
146
141
  });
147
142
  return children;
@@ -155,7 +150,8 @@ const CampaignBlock = _ref2 => {
155
150
  headingLevel: InternalHeading = "h2",
156
151
  url,
157
152
  path,
158
- className
153
+ className,
154
+ background
159
155
  } = _ref2;
160
156
  const imageComponent = image && /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledImg, {
161
157
  src: `${image.src}?width=455`,
@@ -163,34 +159,27 @@ const CampaignBlock = _ref2 => {
163
159
  width: 455,
164
160
  alt: image.alt
165
161
  });
166
- const HeaderComponent = url?.url ? LinkHeader : _primitives.Text;
167
162
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
168
163
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
169
164
  className: className,
170
165
  "data-embed-type": "campaign-block",
171
166
  imageSide: imageSide,
167
+ background: background,
172
168
  children: [imageSide === "left" && imageComponent, /*#__PURE__*/(0, _jsxRuntime.jsxs)(ContentWrapper, {
173
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(MaybeLinkText, {
174
- url: url?.url,
175
- path: path,
176
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HeaderComponent, {
177
- asChild: true,
178
- consumeCss: true,
179
- textStyle: "heading.small",
180
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalHeading, {
181
- children: (0, _htmlReactParser.default)(title)
182
- })
169
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.Text, {
170
+ asChild: true,
171
+ consumeCss: true,
172
+ textStyle: "heading.small",
173
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(InternalHeading, {
174
+ children: (0, _htmlReactParser.default)(title)
183
175
  })
184
176
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledText, {
185
177
  textStyle: "body.xlarge",
186
178
  children: (0, _htmlReactParser.default)(description)
187
- }), !!url?.url && /*#__PURE__*/(0, _jsxRuntime.jsx)(MaybeLinkText, {
179
+ }), !!url?.url && /*#__PURE__*/(0, _jsxRuntime.jsxs)(LinkButton, {
188
180
  url: url.url,
189
181
  path: path,
190
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(LinkText, {
191
- textStyle: "body.medium",
192
- children: [(0, _htmlReactParser.default)(url.text ?? ""), /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.ArrowRightLine, {})]
193
- })
182
+ children: [(0, _htmlReactParser.default)(url.text ?? ""), /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.ArrowRightLine, {})]
194
183
  })]
195
184
  }), imageSide !== "left" && imageComponent]
196
185
  })
@@ -11,8 +11,10 @@ var _editor = require("@ndla/icons/editor");
11
11
  var _primitives = require("@ndla/primitives");
12
12
  var _jsx2 = require("@ndla/styled-system/jsx");
13
13
  var _util = require("@ndla/util");
14
+ var _EmbedErrorPlaceholder = _interopRequireDefault(require("./EmbedErrorPlaceholder"));
14
15
  var _CodeBlock = require("../CodeBlock");
15
16
  var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
18
  /**
17
19
  * Copyright (c) 2023-present, NDLA.
18
20
  *
@@ -21,8 +23,6 @@ var _jsxRuntime = require("react/jsx-runtime");
21
23
  *
22
24
  */
23
25
 
24
- // TODO: We need an error state for this
25
-
26
26
  const StyledFigCaption = (0, _jsx2.styled)("figcaption", {
27
27
  base: {
28
28
  textStyle: "label.large",
@@ -61,6 +61,11 @@ const CodeEmbed = _ref => {
61
61
  };
62
62
  }
63
63
  }, [isCopied]);
64
+ if (embed.status === "error") {
65
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
66
+ type: "code"
67
+ });
68
+ }
64
69
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledFigure, {
65
70
  "data-embed-type": "code-block",
66
71
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledFigCaption, {
@@ -47,6 +47,7 @@ const ConceptEmbed = _ref => {
47
47
  });
48
48
  }
49
49
  if (embed.status === "error") {
50
+ // TODO: This could be either concept or gloss. We don't know if it errors out. :)
50
51
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmbedErrorPlaceholder.default, {
51
52
  type: "gloss"
52
53
  });
@@ -22,16 +22,15 @@ const ErrorPlaceholder = (0, _jsx2.styled)("div", {
22
22
  display: "flex",
23
23
  alignItems: "center",
24
24
  justifyContent: "center",
25
- backgroundColor: "surface.disabled",
25
+ background: "background.subtle",
26
26
  height: "surface.xsmall",
27
+ border: "1px solid",
28
+ borderColor: "stroke.default",
27
29
  borderRadius: "xsmall",
28
30
  "& svg": {
29
- fill: "text.subtle",
30
- height: "90%",
31
- width: "90%"
32
- },
33
- "&[data-embed-type='audio']": {
34
- height: "surface.3xsmall"
31
+ height: "5xlarge",
32
+ width: "5xlarge",
33
+ fill: "stroke.default"
35
34
  }
36
35
  }
37
36
  });
@@ -55,7 +54,7 @@ const EmbedErrorPlaceholder = _ref => {
55
54
  "data-embed-type": type,
56
55
  children: [children ?? /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorPlaceholder, {
57
56
  "data-embed-type": type,
58
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.AlertLine, {})
57
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.Report, {})
59
58
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LicenseByline.EmbedByline, {
60
59
  error: true,
61
60
  type: type
@@ -5,7 +5,5 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import LayoutItem from "./LayoutItem";
9
8
  export { default as OneColumn } from "./OneColumn";
10
9
  export { default as PageContainer } from "./PageContainer";
11
- export default LayoutItem;
@@ -15,16 +15,6 @@ Object.defineProperty(exports, "PageContainer", {
15
15
  return _PageContainer.default;
16
16
  }
17
17
  });
18
- exports.default = void 0;
19
- var _LayoutItem = _interopRequireDefault(require("./LayoutItem"));
20
18
  var _OneColumn = _interopRequireDefault(require("./OneColumn"));
21
19
  var _PageContainer = _interopRequireDefault(require("./PageContainer"));
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
- /**
24
- * Copyright (c) 2016-present, NDLA.
25
- *
26
- * This source code is licensed under the GPLv3 license found in the
27
- * LICENSE file in the root directory of this source tree.
28
- *
29
- */
30
- var _default = exports.default = _LayoutItem.default;
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -20,7 +20,7 @@ interface BaseProps {
20
20
  hideCopyright?: boolean;
21
21
  }
22
22
  export interface EmbedBylineErrorProps extends BaseProps {
23
- type: EmbedBylineTypeProps["type"] | "h5p" | "external";
23
+ type: EmbedBylineTypeProps["type"] | "h5p" | "external" | "code";
24
24
  error: true;
25
25
  }
26
26
  interface ImageProps extends BaseProps {
package/lib/index.d.ts CHANGED
@@ -28,14 +28,12 @@ export { default as messagesSMA } from "./locale/messages-sma";
28
28
  export { default as Breadcrumb, HomeBreadcrumb } from "./Breadcrumb";
29
29
  export type { SimpleBreadcrumbItem, IndexedBreadcrumbItem } from "./Breadcrumb";
30
30
  export { i18nInstance, formatNestedMessages, useTagsInputTranslations, useTagSelectorTranslations, useComboboxTranslations, usePaginationTranslations, useAudioSearchTranslations, useImageSearchTranslations, useVideoSearchTranslations, } from "./i18n";
31
- export { default as LayoutItem, OneColumn, PageContainer } from "./Layout";
31
+ export { OneColumn, PageContainer } from "./Layout";
32
32
  export { default as ContentTypeBadge, SubjectMaterialBadge, TasksAndActivitiesBadge, AssessmentResourcesBadge, LearningPathBadge, SubjectBadge, SourceMaterialBadge, ConceptBadge, } from "./ContentTypeBadge";
33
33
  export type { ContentTypeBadgeProps, ContentType } from "./ContentTypeBadge/ContentTypeBadgeNew";
34
34
  export { ContentTypeBadge as ContentTypeBadgeNew, contentTypeToBadgeVariantMap, } from "./ContentTypeBadge/ContentTypeBadgeNew";
35
35
  export { default as CopyParagraphButton } from "./CopyParagraphButton";
36
36
  export { TagSelectorRoot, TagSelectorLabel, TagSelectorItemInput, TagSelectorTrigger, TagSelectorControl, TagSelectorClearTrigger, TagSelectorInputBase, TagSelectorInput, } from "./TagSelector/TagSelector";
37
- export { TreeStructure } from "./TreeStructure";
38
- export type { TreeStructureProps } from "./TreeStructure";
39
37
  export { BlogPostV2 } from "./BlogPost";
40
38
  export { KeyFigure } from "./KeyFigure";
41
39
  export { ContactBlock, contactBlockBackgrounds } from "./ContactBlock";
package/lib/index.js CHANGED
@@ -321,12 +321,6 @@ Object.defineProperty(exports, "KeyFigure", {
321
321
  return _KeyFigure.KeyFigure;
322
322
  }
323
323
  });
324
- Object.defineProperty(exports, "LayoutItem", {
325
- enumerable: true,
326
- get: function () {
327
- return _Layout.default;
328
- }
329
- });
330
324
  Object.defineProperty(exports, "LearningPathBadge", {
331
325
  enumerable: true,
332
326
  get: function () {
@@ -465,12 +459,6 @@ Object.defineProperty(exports, "TasksAndActivitiesBadge", {
465
459
  return _ContentTypeBadge.TasksAndActivitiesBadge;
466
460
  }
467
461
  });
468
- Object.defineProperty(exports, "TreeStructure", {
469
- enumerable: true,
470
- get: function () {
471
- return _TreeStructure.TreeStructure;
472
- }
473
- });
474
462
  Object.defineProperty(exports, "UnknownEmbed", {
475
463
  enumerable: true,
476
464
  get: function () {
@@ -642,12 +630,11 @@ var _messagesSe = _interopRequireDefault(require("./locale/messages-se"));
642
630
  var _messagesSma = _interopRequireDefault(require("./locale/messages-sma"));
643
631
  var _Breadcrumb = _interopRequireWildcard(require("./Breadcrumb"));
644
632
  var _i18n = require("./i18n");
645
- var _Layout = _interopRequireWildcard(require("./Layout"));
633
+ var _Layout = require("./Layout");
646
634
  var _ContentTypeBadge = _interopRequireWildcard(require("./ContentTypeBadge"));
647
635
  var _ContentTypeBadgeNew = require("./ContentTypeBadge/ContentTypeBadgeNew");
648
636
  var _CopyParagraphButton = _interopRequireDefault(require("./CopyParagraphButton"));
649
637
  var _TagSelector = require("./TagSelector/TagSelector");
650
- var _TreeStructure = require("./TreeStructure");
651
638
  var _BlogPost = require("./BlogPost");
652
639
  var _KeyFigure = require("./KeyFigure");
653
640
  var _ContactBlock = require("./ContactBlock");
@@ -1384,6 +1384,7 @@ declare const messages: {
1384
1384
  external: string;
1385
1385
  gloss: string;
1386
1386
  copyright: string;
1387
+ code: string;
1387
1388
  };
1388
1389
  };
1389
1390
  gloss: {
@@ -1400,7 +1400,8 @@ const messages = {
1400
1400
  h5p: "H5P",
1401
1401
  external: "External resource",
1402
1402
  gloss: "Gloss",
1403
- copyright: "Text"
1403
+ copyright: "Text",
1404
+ code: "Code block"
1404
1405
  }
1405
1406
  },
1406
1407
  gloss: {
@@ -1384,6 +1384,7 @@ declare const messages: {
1384
1384
  external: string;
1385
1385
  gloss: string;
1386
1386
  copyright: string;
1387
+ code: string;
1387
1388
  };
1388
1389
  };
1389
1390
  gloss: {
@@ -1400,7 +1400,8 @@ const messages = {
1400
1400
  h5p: "H5P",
1401
1401
  external: "Ekstern ressurs",
1402
1402
  gloss: "Glose",
1403
- copyright: "Tekst"
1403
+ copyright: "Tekst",
1404
+ code: "Kodeblokk"
1404
1405
  }
1405
1406
  },
1406
1407
  gloss: {
@@ -1384,6 +1384,7 @@ declare const messages: {
1384
1384
  external: string;
1385
1385
  gloss: string;
1386
1386
  copyright: string;
1387
+ code: string;
1387
1388
  };
1388
1389
  };
1389
1390
  gloss: {
@@ -1400,7 +1400,8 @@ const messages = {
1400
1400
  h5p: "H5P",
1401
1401
  external: "Ekstern ressurs",
1402
1402
  gloss: "Glose",
1403
- copyright: "Tekst"
1403
+ copyright: "Tekst",
1404
+ code: "Kodeblokk"
1404
1405
  }
1405
1406
  },
1406
1407
  gloss: {
@@ -1384,6 +1384,7 @@ declare const messages: {
1384
1384
  external: string;
1385
1385
  gloss: string;
1386
1386
  copyright: string;
1387
+ code: string;
1387
1388
  };
1388
1389
  };
1389
1390
  gloss: {
@@ -1400,7 +1400,8 @@ const messages = {
1400
1400
  h5p: "H5P",
1401
1401
  external: "Olgguldas resursa",
1402
1402
  gloss: "Glose",
1403
- copyright: "Tekst"
1403
+ copyright: "Tekst",
1404
+ code: "Kodeblokk"
1404
1405
  }
1405
1406
  },
1406
1407
  gloss: {
@@ -1384,6 +1384,7 @@ declare const messages: {
1384
1384
  external: string;
1385
1385
  gloss: string;
1386
1386
  copyright: string;
1387
+ code: string;
1387
1388
  };
1388
1389
  };
1389
1390
  gloss: {
@@ -1400,7 +1400,8 @@ const messages = {
1400
1400
  h5p: "H5P",
1401
1401
  external: "Ekstern ressurs",
1402
1402
  gloss: "Glosa",
1403
- copyright: "Tekst"
1403
+ copyright: "Tekst",
1404
+ code: "Kodeblokk"
1404
1405
  }
1405
1406
  },
1406
1407
  gloss: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "56.0.34-alpha.0",
3
+ "version": "56.0.36-alpha.0",
4
4
  "description": "UI component library for NDLA",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -33,10 +33,10 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@ndla/core": "^5.0.2",
36
- "@ndla/icons": "^8.0.23-alpha.0",
36
+ "@ndla/icons": "^8.0.25-alpha.0",
37
37
  "@ndla/licenses": "^8.0.3-alpha.0",
38
- "@ndla/primitives": "^1.0.31-alpha.0",
39
- "@ndla/safelink": "^7.0.31-alpha.0",
38
+ "@ndla/primitives": "^1.0.33-alpha.0",
39
+ "@ndla/safelink": "^7.0.33-alpha.0",
40
40
  "@ndla/styled-system": "^0.0.22",
41
41
  "@ndla/util": "^5.0.0-alpha.0",
42
42
  "html-react-parser": "^5.1.8",
@@ -50,7 +50,7 @@
50
50
  "react-router-dom": "> 6.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@ndla/preset-panda": "^0.0.33",
53
+ "@ndla/preset-panda": "^0.0.34",
54
54
  "@ndla/types-backend": "^0.2.86",
55
55
  "@ndla/types-embed": "^5.0.3-alpha.0",
56
56
  "@pandacss/dev": "^0.46.0"
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "bedff84c8034cb9016d300a3d270d14a49accfff"
61
+ "gitHead": "183d252ef9c40520099fadd2ee6a48e46eb1c71e"
62
62
  }
@@ -10,8 +10,9 @@ import parse from "html-react-parser";
10
10
  import { ReactNode } from "react";
11
11
  import { ArrowRightLine } from "@ndla/icons/common";
12
12
  import { Text } from "@ndla/primitives";
13
- import { SafeLink } from "@ndla/safelink";
13
+ import { SafeLinkButton } from "@ndla/safelink";
14
14
  import { styled } from "@ndla/styled-system/jsx";
15
+ import { CampaignBlockEmbedData } from "@ndla/types-embed";
15
16
  import { HeadingLevel } from "../types";
16
17
  import { getPossiblyRelativeUrl } from "../utils/relativeUrl";
17
18
 
@@ -29,9 +30,10 @@ interface Props {
29
30
  text?: string;
30
31
  };
31
32
  image?: Image;
32
- imageSide?: "left" | "right";
33
+ imageSide?: CampaignBlockEmbedData["imageSide"];
33
34
  className?: string;
34
35
  path?: string;
36
+ background?: CampaignBlockEmbedData["background"];
35
37
  }
36
38
 
37
39
  const Wrapper = styled("div", {
@@ -46,7 +48,6 @@ const Container = styled("div", {
46
48
  base: {
47
49
  display: "grid",
48
50
  gridTemplateColumns: "1fr",
49
- gap: "medium",
50
51
  border: "1px solid",
51
52
  borderColor: "stroke.default",
52
53
  backgroundColor: "background.default",
@@ -77,32 +78,19 @@ const Container = styled("div", {
77
78
  },
78
79
  },
79
80
  },
81
+ background: {
82
+ neutral: {},
83
+ brand1: {
84
+ backgroundColor: "surface.brand.1",
85
+ },
86
+ brand3: {
87
+ backgroundColor: "surface.brand.3",
88
+ },
89
+ },
80
90
  },
81
91
  defaultVariants: {
82
92
  imageSide: "left",
83
- },
84
- });
85
-
86
- const LinkText = styled(Text, {
87
- base: {
88
- display: "flex",
89
- gap: "xxsmall",
90
- textDecoration: "underline",
91
- _hover: {
92
- textDecoration: "none",
93
- },
94
- paddingBlock: "xsmall",
95
- fontWeight: "bold",
96
- },
97
- });
98
-
99
- const LinkHeader = styled(Text, {
100
- base: {
101
- display: "flex",
102
- textDecoration: "underline",
103
- _hover: {
104
- textDecoration: "none",
105
- },
93
+ background: "neutral",
106
94
  },
107
95
  });
108
96
 
@@ -122,6 +110,7 @@ const StyledImg = styled("img", {
122
110
  height: "340px",
123
111
  },
124
112
  },
113
+ backgroundColor: "background.default",
125
114
  },
126
115
  });
127
116
 
@@ -135,6 +124,7 @@ const ContentWrapper = styled("div", {
135
124
  justifyContent: "center",
136
125
  paddingBlock: "medium",
137
126
  paddingInline: "medium",
127
+ position: "relative",
138
128
  },
139
129
  });
140
130
 
@@ -150,20 +140,32 @@ const StyledText = styled(Text, {
150
140
  },
151
141
  });
152
142
 
153
- interface MaybeLinkTextProps {
143
+ interface LinkButtonProps {
154
144
  url?: string;
155
145
  path?: string;
156
146
  children: ReactNode;
157
147
  }
158
148
 
159
- const StyledSafeLink = styled(SafeLink, {
149
+ const StyledSafeLinkButton = styled(SafeLinkButton, {
160
150
  base: {
161
- color: "inherit",
151
+ boxShadow: "full",
152
+ border: "1px solid",
153
+ borderColor: "stroke.default",
162
154
  },
163
155
  });
164
156
 
165
- const MaybeLinkText = ({ url, children, path }: MaybeLinkTextProps) => {
166
- if (url) return <StyledSafeLink to={getPossiblyRelativeUrl(url, path)}>{children}</StyledSafeLink>;
157
+ const LinkButton = ({ url, children, path }: LinkButtonProps) => {
158
+ if (url)
159
+ return (
160
+ <StyledSafeLinkButton
161
+ to={getPossiblyRelativeUrl(url, path)}
162
+ target="_blank"
163
+ variant="secondary"
164
+ rel="noopener noreferrer"
165
+ >
166
+ {children}
167
+ </StyledSafeLinkButton>
168
+ );
167
169
  return children;
168
170
  };
169
171
 
@@ -176,27 +178,24 @@ const CampaignBlock = ({
176
178
  url,
177
179
  path,
178
180
  className,
181
+ background,
179
182
  }: Props) => {
180
183
  const imageComponent = image && <StyledImg src={`${image.src}?width=455`} height={340} width={455} alt={image.alt} />;
181
- const HeaderComponent = url?.url ? LinkHeader : Text;
184
+
182
185
  return (
183
186
  <Wrapper>
184
- <Container className={className} data-embed-type="campaign-block" imageSide={imageSide}>
187
+ <Container className={className} data-embed-type="campaign-block" imageSide={imageSide} background={background}>
185
188
  {imageSide === "left" && imageComponent}
186
189
  <ContentWrapper>
187
- <MaybeLinkText url={url?.url} path={path}>
188
- <HeaderComponent asChild consumeCss textStyle="heading.small">
189
- <InternalHeading>{parse(title)}</InternalHeading>
190
- </HeaderComponent>
191
- </MaybeLinkText>
190
+ <Text asChild consumeCss textStyle="heading.small">
191
+ <InternalHeading>{parse(title)}</InternalHeading>
192
+ </Text>
192
193
  <StyledText textStyle="body.xlarge">{parse(description)}</StyledText>
193
194
  {!!url?.url && (
194
- <MaybeLinkText url={url.url} path={path}>
195
- <LinkText textStyle="body.medium">
196
- {parse(url.text ?? "")}
197
- <ArrowRightLine />
198
- </LinkText>
199
- </MaybeLinkText>
195
+ <LinkButton url={url.url} path={path}>
196
+ {parse(url.text ?? "")}
197
+ <ArrowRightLine />
198
+ </LinkButton>
200
199
  )}
201
200
  </ContentWrapper>
202
201
  {imageSide !== "left" && imageComponent}
@@ -7,10 +7,9 @@
7
7
  */
8
8
 
9
9
  import { Meta, StoryFn } from "@storybook/react";
10
- import { HeroBackground, HeroContent, Text } from "@ndla/primitives";
10
+ import { HeroBackground, HeroContent, PageContent, Text } from "@ndla/primitives";
11
11
  import { styled } from "@ndla/styled-system/jsx";
12
12
  import { ContentTypeHero } from "./ContentTypeHero";
13
- import { OneColumn } from "../Layout";
14
13
 
15
14
  /**
16
15
  * A thin wrapper around the `Hero` component that automatically assigns a variant based on the provided content type
@@ -31,7 +30,7 @@ export default {
31
30
  export const HeroStory: StoryFn<typeof ContentTypeHero> = ({ ...args }) => (
32
31
  <ContentTypeHero {...args}>
33
32
  <HeroBackground />
34
- <OneColumn>
33
+ <PageContent>
35
34
  <HeroContent>Hello</HeroContent>
36
35
 
37
36
  <styled.div css={{ background: "surface.default", padding: "medium" }}>
@@ -69,7 +68,7 @@ export const HeroStory: StoryFn<typeof ContentTypeHero> = ({ ...args }) => (
69
68
  faucibus ac ut mauris. Fusce facilisis at erat a dignissim.
70
69
  </Text>
71
70
  </styled.div>
72
- </OneColumn>
71
+ </PageContent>
73
72
  </ContentTypeHero>
74
73
  );
75
74