@ndla/ui 56.0.36-alpha.0 → 56.0.37-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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { forwardRef } from "react";
10
+ import { BlockQuote } from "@ndla/primitives";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const contentTypeToVariantMapping = {
13
+ "subject-material": "brand1",
14
+ "source-material": "brand1",
15
+ concept: "brand1",
16
+ "tasks-and-activities": "brand2",
17
+ "assessment-resources": "brand2"
18
+ };
19
+ export const ContentTypeBlockQuote = /*#__PURE__*/forwardRef((_ref, ref) => {
20
+ let {
21
+ variant,
22
+ contentType,
23
+ ...props
24
+ } = _ref;
25
+ return /*#__PURE__*/_jsx(BlockQuote, {
26
+ ...props,
27
+ variant: variant === "colored" && contentType ? contentTypeToVariantMapping[contentType] : undefined,
28
+ ref: ref
29
+ });
30
+ });
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { forwardRef } from "react";
10
+ import { FramedContent } from "@ndla/primitives";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const contentTypeToVariantMapping = {
13
+ "subject-material": "brand1",
14
+ "source-material": "brand1",
15
+ concept: "brand1",
16
+ "tasks-and-activities": "brand2",
17
+ "assessment-resources": "brand2"
18
+ };
19
+ export const ContentTypeFramedContent = /*#__PURE__*/forwardRef((_ref, ref) => {
20
+ let {
21
+ variant = "neutral",
22
+ contentType,
23
+ ...props
24
+ } = _ref;
25
+ return /*#__PURE__*/_jsx(FramedContent, {
26
+ ...props,
27
+ colorTheme: variant === "colored" && contentType ? contentTypeToVariantMapping[contentType] : undefined,
28
+ ref: ref
29
+ });
30
+ });
package/es/index.js CHANGED
@@ -33,6 +33,8 @@ export { i18nInstance, formatNestedMessages, useTagsInputTranslations, useTagSel
33
33
  export { OneColumn, PageContainer } from "./Layout";
34
34
  export { default as ContentTypeBadge, SubjectMaterialBadge, TasksAndActivitiesBadge, AssessmentResourcesBadge, LearningPathBadge, SubjectBadge, SourceMaterialBadge, ConceptBadge } from "./ContentTypeBadge";
35
35
  export { ContentTypeBadge as ContentTypeBadgeNew, contentTypeToBadgeVariantMap } from "./ContentTypeBadge/ContentTypeBadgeNew";
36
+ export { ContentTypeBlockQuote } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
37
+ export { ContentTypeFramedContent } from "./ContentTypeFramedContent/ContentTypeFramedContent";
36
38
  export { default as CopyParagraphButton } from "./CopyParagraphButton";
37
39
  export { TagSelectorRoot, TagSelectorLabel, TagSelectorItemInput, TagSelectorTrigger, TagSelectorControl, TagSelectorClearTrigger, TagSelectorInputBase, TagSelectorInput } from "./TagSelector/TagSelector";
38
40
  export { BlogPostV2 } from "./BlogPost";
@@ -11,6 +11,7 @@ import * as contentTypes from "../model/ContentType";
11
11
  export interface ContentTypeBadgeProps extends Omit<BadgeProps, "colorTheme"> {
12
12
  contentType: ContentType | undefined;
13
13
  }
14
- export type ContentType = typeof contentTypes.SUBJECT_MATERIAL | typeof contentTypes.TASKS_AND_ACTIVITIES | typeof contentTypes.ASSESSMENT_RESOURCES | typeof contentTypes.SUBJECT | typeof contentTypes.SOURCE_MATERIAL | typeof contentTypes.LEARNING_PATH | typeof contentTypes.TOPIC | typeof contentTypes.MULTIDISCIPLINARY | typeof contentTypes.CONCEPT | typeof contentTypes.EXTERNAL | typeof contentTypes.IMAGE | typeof contentTypes.AUDIO | typeof contentTypes.VIDEO | typeof contentTypes.MISSING | typeof contentTypes.PODCAST | (string & {});
14
+ export type StrictContentType = typeof contentTypes.SUBJECT_MATERIAL | typeof contentTypes.TASKS_AND_ACTIVITIES | typeof contentTypes.ASSESSMENT_RESOURCES | typeof contentTypes.SUBJECT | typeof contentTypes.SOURCE_MATERIAL | typeof contentTypes.LEARNING_PATH | typeof contentTypes.TOPIC | typeof contentTypes.MULTIDISCIPLINARY | typeof contentTypes.CONCEPT | typeof contentTypes.EXTERNAL | typeof contentTypes.IMAGE | typeof contentTypes.AUDIO | typeof contentTypes.VIDEO | typeof contentTypes.MISSING | typeof contentTypes.PODCAST;
15
+ export type ContentType = StrictContentType | (string & {});
15
16
  export declare const contentTypeToBadgeVariantMap: Record<ContentType, BadgeVariant>;
16
17
  export declare const ContentTypeBadge: import("react").ForwardRefExoticComponent<ContentTypeBadgeProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ import { BlockQuoteProps } from "@ndla/primitives";
10
+ import { ContentType } from "../ContentTypeBadge/ContentTypeBadgeNew";
11
+ export type ContentTypeBlockQuoteVariant = "colored" | "neutral";
12
+ interface Props extends Omit<BlockQuoteProps, "variant"> {
13
+ variant?: ContentTypeBlockQuoteVariant;
14
+ contentType?: ContentType;
15
+ }
16
+ export declare const ContentTypeBlockQuote: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLQuoteElement>>;
17
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ContentTypeBlockQuote = void 0;
7
+ var _react = require("react");
8
+ var _primitives = require("@ndla/primitives");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ /**
11
+ * Copyright (c) 2024-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const contentTypeToVariantMapping = {
19
+ "subject-material": "brand1",
20
+ "source-material": "brand1",
21
+ concept: "brand1",
22
+ "tasks-and-activities": "brand2",
23
+ "assessment-resources": "brand2"
24
+ };
25
+ const ContentTypeBlockQuote = exports.ContentTypeBlockQuote = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
26
+ let {
27
+ variant,
28
+ contentType,
29
+ ...props
30
+ } = _ref;
31
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.BlockQuote, {
32
+ ...props,
33
+ variant: variant === "colored" && contentType ? contentTypeToVariantMapping[contentType] : undefined,
34
+ ref: ref
35
+ });
36
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ import { FramedContentProps } from "@ndla/primitives";
10
+ import { ContentType } from "..";
11
+ export type ContentTypeFramedContentVariant = "colored" | "neutral";
12
+ interface Props extends FramedContentProps {
13
+ variant?: ContentTypeFramedContentVariant;
14
+ contentType?: ContentType;
15
+ }
16
+ export declare const ContentTypeFramedContent: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<HTMLDivElement>>;
17
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ContentTypeFramedContent = void 0;
7
+ var _react = require("react");
8
+ var _primitives = require("@ndla/primitives");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ /**
11
+ * Copyright (c) 2024-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const contentTypeToVariantMapping = {
19
+ "subject-material": "brand1",
20
+ "source-material": "brand1",
21
+ concept: "brand1",
22
+ "tasks-and-activities": "brand2",
23
+ "assessment-resources": "brand2"
24
+ };
25
+ const ContentTypeFramedContent = exports.ContentTypeFramedContent = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
26
+ let {
27
+ variant = "neutral",
28
+ contentType,
29
+ ...props
30
+ } = _ref;
31
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.FramedContent, {
32
+ ...props,
33
+ colorTheme: variant === "colored" && contentType ? contentTypeToVariantMapping[contentType] : undefined,
34
+ ref: ref
35
+ });
36
+ });
package/lib/index.d.ts CHANGED
@@ -30,8 +30,12 @@ export type { SimpleBreadcrumbItem, IndexedBreadcrumbItem } from "./Breadcrumb";
30
30
  export { i18nInstance, formatNestedMessages, useTagsInputTranslations, useTagSelectorTranslations, useComboboxTranslations, usePaginationTranslations, useAudioSearchTranslations, useImageSearchTranslations, useVideoSearchTranslations, } from "./i18n";
31
31
  export { OneColumn, PageContainer } from "./Layout";
32
32
  export { default as ContentTypeBadge, SubjectMaterialBadge, TasksAndActivitiesBadge, AssessmentResourcesBadge, LearningPathBadge, SubjectBadge, SourceMaterialBadge, ConceptBadge, } from "./ContentTypeBadge";
33
- export type { ContentTypeBadgeProps, ContentType } from "./ContentTypeBadge/ContentTypeBadgeNew";
33
+ export type { ContentTypeBadgeProps, StrictContentType, ContentType } from "./ContentTypeBadge/ContentTypeBadgeNew";
34
34
  export { ContentTypeBadge as ContentTypeBadgeNew, contentTypeToBadgeVariantMap, } from "./ContentTypeBadge/ContentTypeBadgeNew";
35
+ export { ContentTypeBlockQuote } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
36
+ export { type ContentTypeBlockQuoteVariant } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
37
+ export { ContentTypeFramedContent } from "./ContentTypeFramedContent/ContentTypeFramedContent";
38
+ export { type ContentTypeFramedContentVariant } from "./ContentTypeFramedContent/ContentTypeFramedContent";
35
39
  export { default as CopyParagraphButton } from "./CopyParagraphButton";
36
40
  export { TagSelectorRoot, TagSelectorLabel, TagSelectorItemInput, TagSelectorTrigger, TagSelectorControl, TagSelectorClearTrigger, TagSelectorInputBase, TagSelectorInput, } from "./TagSelector/TagSelector";
37
41
  export { BlogPostV2 } from "./BlogPost";
package/lib/index.js CHANGED
@@ -171,6 +171,18 @@ Object.defineProperty(exports, "ContentTypeBadgeNew", {
171
171
  return _ContentTypeBadgeNew.ContentTypeBadge;
172
172
  }
173
173
  });
174
+ Object.defineProperty(exports, "ContentTypeBlockQuote", {
175
+ enumerable: true,
176
+ get: function () {
177
+ return _ContentTypeBlockQuote.ContentTypeBlockQuote;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "ContentTypeFramedContent", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _ContentTypeFramedContent.ContentTypeFramedContent;
184
+ }
185
+ });
174
186
  Object.defineProperty(exports, "ContentTypeHero", {
175
187
  enumerable: true,
176
188
  get: function () {
@@ -633,6 +645,8 @@ var _i18n = require("./i18n");
633
645
  var _Layout = require("./Layout");
634
646
  var _ContentTypeBadge = _interopRequireWildcard(require("./ContentTypeBadge"));
635
647
  var _ContentTypeBadgeNew = require("./ContentTypeBadge/ContentTypeBadgeNew");
648
+ var _ContentTypeBlockQuote = require("./ContentTypeBlockQuote/ContentTypeBlockQuote");
649
+ var _ContentTypeFramedContent = require("./ContentTypeFramedContent/ContentTypeFramedContent");
636
650
  var _CopyParagraphButton = _interopRequireDefault(require("./CopyParagraphButton"));
637
651
  var _TagSelector = require("./TagSelector/TagSelector");
638
652
  var _BlogPost = require("./BlogPost");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "56.0.36-alpha.0",
3
+ "version": "56.0.37-alpha.0",
4
4
  "description": "UI component library for NDLA",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -33,11 +33,11 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@ndla/core": "^5.0.2",
36
- "@ndla/icons": "^8.0.25-alpha.0",
36
+ "@ndla/icons": "^8.0.26-alpha.0",
37
37
  "@ndla/licenses": "^8.0.3-alpha.0",
38
- "@ndla/primitives": "^1.0.33-alpha.0",
39
- "@ndla/safelink": "^7.0.33-alpha.0",
40
- "@ndla/styled-system": "^0.0.22",
38
+ "@ndla/primitives": "^1.0.34-alpha.0",
39
+ "@ndla/safelink": "^7.0.34-alpha.0",
40
+ "@ndla/styled-system": "^0.0.23",
41
41
  "@ndla/util": "^5.0.0-alpha.0",
42
42
  "html-react-parser": "^5.1.8",
43
43
  "i18next-browser-languagedetector": "^7.1.0"
@@ -50,7 +50,7 @@
50
50
  "react-router-dom": "> 6.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@ndla/preset-panda": "^0.0.34",
53
+ "@ndla/preset-panda": "^0.0.35",
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": "183d252ef9c40520099fadd2ee6a48e46eb1c71e"
61
+ "gitHead": "5bad5d1659659f8f6a1a8cb790d43fdbbfcdedbc"
62
62
  }
@@ -15,7 +15,7 @@ export interface ContentTypeBadgeProps extends Omit<BadgeProps, "colorTheme"> {
15
15
  contentType: ContentType | undefined;
16
16
  }
17
17
 
18
- export type ContentType =
18
+ export type StrictContentType =
19
19
  | typeof contentTypes.SUBJECT_MATERIAL
20
20
  | typeof contentTypes.TASKS_AND_ACTIVITIES
21
21
  | typeof contentTypes.ASSESSMENT_RESOURCES
@@ -30,7 +30,10 @@ export type ContentType =
30
30
  | typeof contentTypes.AUDIO
31
31
  | typeof contentTypes.VIDEO
32
32
  | typeof contentTypes.MISSING
33
- | typeof contentTypes.PODCAST
33
+ | typeof contentTypes.PODCAST;
34
+
35
+ export type ContentType =
36
+ | StrictContentType
34
37
  // This allows for us to fallback to string without getting a ts error, while still keeping intellisense
35
38
  | (string & {});
36
39
 
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { forwardRef } from "react";
10
+ import { BlockQuote, BlockQuoteProps, BlockQuoteVariantProps } from "@ndla/primitives";
11
+ import { ContentType } from "../ContentTypeBadge/ContentTypeBadgeNew";
12
+
13
+ export type ContentTypeBlockQuoteVariant = "colored" | "neutral";
14
+
15
+ const contentTypeToVariantMapping = {
16
+ "subject-material": "brand1",
17
+ "source-material": "brand1",
18
+ concept: "brand1",
19
+ "tasks-and-activities": "brand2",
20
+ "assessment-resources": "brand2",
21
+ } as Record<ContentType, NonNullable<BlockQuoteVariantProps>["variant"]>;
22
+
23
+ interface Props extends Omit<BlockQuoteProps, "variant"> {
24
+ variant?: ContentTypeBlockQuoteVariant;
25
+ contentType?: ContentType;
26
+ }
27
+
28
+ export const ContentTypeBlockQuote = forwardRef<HTMLQuoteElement, Props>(({ variant, contentType, ...props }, ref) => {
29
+ return (
30
+ <BlockQuote
31
+ {...props}
32
+ variant={variant === "colored" && contentType ? contentTypeToVariantMapping[contentType] : undefined}
33
+ ref={ref}
34
+ />
35
+ );
36
+ });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { forwardRef } from "react";
10
+ import { FramedContent, FramedContentProps, FramedContentVariantProps } from "@ndla/primitives";
11
+ import { ContentType } from "..";
12
+
13
+ const contentTypeToVariantMapping = {
14
+ "subject-material": "brand1",
15
+ "source-material": "brand1",
16
+ concept: "brand1",
17
+ "tasks-and-activities": "brand2",
18
+ "assessment-resources": "brand2",
19
+ } as Record<ContentType, NonNullable<FramedContentVariantProps>["colorTheme"]>;
20
+
21
+ export type ContentTypeFramedContentVariant = "colored" | "neutral";
22
+
23
+ interface Props extends FramedContentProps {
24
+ variant?: ContentTypeFramedContentVariant;
25
+ contentType?: ContentType;
26
+ }
27
+
28
+ export const ContentTypeFramedContent = forwardRef<HTMLDivElement, Props>(
29
+ ({ variant = "neutral", contentType, ...props }, ref) => {
30
+ return (
31
+ <FramedContent
32
+ {...props}
33
+ colorTheme={variant === "colored" && contentType ? contentTypeToVariantMapping[contentType] : undefined}
34
+ ref={ref}
35
+ />
36
+ );
37
+ },
38
+ );
package/src/index.ts CHANGED
@@ -103,12 +103,18 @@ export {
103
103
  ConceptBadge,
104
104
  } from "./ContentTypeBadge";
105
105
 
106
- export type { ContentTypeBadgeProps, ContentType } from "./ContentTypeBadge/ContentTypeBadgeNew";
106
+ export type { ContentTypeBadgeProps, StrictContentType, ContentType } from "./ContentTypeBadge/ContentTypeBadgeNew";
107
107
  export {
108
108
  ContentTypeBadge as ContentTypeBadgeNew,
109
109
  contentTypeToBadgeVariantMap,
110
110
  } from "./ContentTypeBadge/ContentTypeBadgeNew";
111
111
 
112
+ export { ContentTypeBlockQuote } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
113
+ export { type ContentTypeBlockQuoteVariant } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
114
+
115
+ export { ContentTypeFramedContent } from "./ContentTypeFramedContent/ContentTypeFramedContent";
116
+ export { type ContentTypeFramedContentVariant } from "./ContentTypeFramedContent/ContentTypeFramedContent";
117
+
112
118
  export { default as CopyParagraphButton } from "./CopyParagraphButton";
113
119
 
114
120
  export {