@ndla/ui 52.0.0 → 53.0.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.
- package/es/Article/Article.js +110 -117
- package/es/Article/ArticleHeaderWrapper.js +14 -9
- package/es/all.css +1 -1
- package/es/index.js +0 -1
- package/es/locale/messages-en.js +3 -0
- package/es/locale/messages-nb.js +3 -0
- package/es/locale/messages-nn.js +3 -0
- package/es/locale/messages-se.js +3 -0
- package/es/locale/messages-sma.js +3 -0
- package/lib/Article/Article.d.ts +4 -5
- package/lib/Article/Article.js +108 -115
- package/lib/Article/ArticleHeaderWrapper.js +14 -9
- package/lib/Article/index.d.ts +1 -0
- package/lib/all.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -25
- package/lib/locale/messages-en.d.ts +3 -0
- package/lib/locale/messages-en.js +3 -0
- package/lib/locale/messages-nb.d.ts +3 -0
- package/lib/locale/messages-nb.js +3 -0
- package/lib/locale/messages-nn.d.ts +3 -0
- package/lib/locale/messages-nn.js +3 -0
- package/lib/locale/messages-se.d.ts +3 -0
- package/lib/locale/messages-se.js +3 -0
- package/lib/locale/messages-sma.d.ts +3 -0
- package/lib/locale/messages-sma.js +3 -0
- package/package.json +2 -3
- package/src/Article/Article.tsx +177 -113
- package/src/Article/ArticleHeaderWrapper.tsx +16 -9
- package/src/Article/index.ts +2 -0
- package/src/all.scss +2 -3
- package/src/index.ts +2 -2
- package/src/locale/messages-en.ts +3 -0
- package/src/locale/messages-nb.ts +3 -0
- package/src/locale/messages-nn.ts +3 -0
- package/src/locale/messages-se.ts +3 -0
- package/src/locale/messages-sma.ts +3 -0
- package/es/Article/ArticleNotions.js +0 -90
- package/es/Masthead/Masthead.js +0 -62
- package/es/Masthead/SkipToMainContent.js +0 -30
- package/es/Masthead/index.js +0 -13
- package/es/Masthead/utils.js +0 -38
- package/lib/Article/ArticleNotions.d.ts +0 -14
- package/lib/Article/ArticleNotions.js +0 -96
- package/lib/Masthead/Masthead.d.ts +0 -23
- package/lib/Masthead/Masthead.js +0 -68
- package/lib/Masthead/SkipToMainContent.d.ts +0 -12
- package/lib/Masthead/SkipToMainContent.js +0 -37
- package/lib/Masthead/index.d.ts +0 -12
- package/lib/Masthead/index.js +0 -36
- package/lib/Masthead/utils.d.ts +0 -11
- package/lib/Masthead/utils.js +0 -46
- package/src/Article/ArticleNotions.tsx +0 -139
- package/src/Article/component.article.scss +0 -149
- package/src/Masthead/Masthead.tsx +0 -100
- package/src/Masthead/SkipToMainContent.tsx +0 -54
- package/src/Masthead/index.ts +0 -16
- package/src/Masthead/utils.ts +0 -45
- package/src/main.scss +0 -4
package/lib/index.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export { default as FramedContent } from "./FramedContent";
|
|
|
10
10
|
export { ConceptNotionV2, ImageEmbed, getCrop, getFocalPoint, AudioEmbed, H5pEmbed, ExternalEmbed, IframeEmbed, FootnoteEmbed, BrightcoveEmbed, ContentLinkEmbed, RelatedContentEmbed, ConceptEmbed, ConceptListEmbed, UnknownEmbed, InlineConcept, BlockConcept, UuDisclaimerEmbed, CopyrightEmbed, CodeEmbed, } from "./Embed";
|
|
11
11
|
export { LicenseLink } from "./LicenseByline";
|
|
12
12
|
export { ArticleByline, ArticleFootNotes, ArticleIntroduction, ArticleTitle, ArticleWrapper, ArticleHeaderWrapper, default as Article, ArticleParagraph, } from "./Article";
|
|
13
|
+
export type { ArticleModifier } from "./Article";
|
|
13
14
|
export { getPossiblyRelativeUrl } from "./utils/relativeUrl";
|
|
14
15
|
export { default as Table, TableStyling } from "./Table";
|
|
15
|
-
export { default as Masthead, getMastheadHeight, useMastheadHeight, SkipToMainContent } from "./Masthead";
|
|
16
16
|
export { default as ContentLoader } from "./ContentLoader";
|
|
17
17
|
export { default as RelatedArticleList, RelatedArticle } from "./RelatedArticleList";
|
|
18
18
|
export { ErrorResourceAccessDenied, default as ErrorMessage } from "./ErrorMessage";
|
package/lib/index.js
CHANGED
|
@@ -477,12 +477,6 @@ Object.defineProperty(exports, "Logo", {
|
|
|
477
477
|
return _Logo.default;
|
|
478
478
|
}
|
|
479
479
|
});
|
|
480
|
-
Object.defineProperty(exports, "Masthead", {
|
|
481
|
-
enumerable: true,
|
|
482
|
-
get: function () {
|
|
483
|
-
return _Masthead.default;
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
480
|
Object.defineProperty(exports, "MediaList", {
|
|
487
481
|
enumerable: true,
|
|
488
482
|
get: function () {
|
|
@@ -627,12 +621,6 @@ Object.defineProperty(exports, "SearchResultSleeve", {
|
|
|
627
621
|
return _SearchResultSleeve.default;
|
|
628
622
|
}
|
|
629
623
|
});
|
|
630
|
-
Object.defineProperty(exports, "SkipToMainContent", {
|
|
631
|
-
enumerable: true,
|
|
632
|
-
get: function () {
|
|
633
|
-
return _Masthead.SkipToMainContent;
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
624
|
Object.defineProperty(exports, "SnackbarProvider", {
|
|
637
625
|
enumerable: true,
|
|
638
626
|
get: function () {
|
|
@@ -765,12 +753,6 @@ Object.defineProperty(exports, "getFocalPoint", {
|
|
|
765
753
|
return _Embed.getFocalPoint;
|
|
766
754
|
}
|
|
767
755
|
});
|
|
768
|
-
Object.defineProperty(exports, "getMastheadHeight", {
|
|
769
|
-
enumerable: true,
|
|
770
|
-
get: function () {
|
|
771
|
-
return _Masthead.getMastheadHeight;
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
756
|
Object.defineProperty(exports, "getPossiblyRelativeUrl", {
|
|
775
757
|
enumerable: true,
|
|
776
758
|
get: function () {
|
|
@@ -825,12 +807,6 @@ Object.defineProperty(exports, "resourceTypeColor", {
|
|
|
825
807
|
return _resourceTypeColor.default;
|
|
826
808
|
}
|
|
827
809
|
});
|
|
828
|
-
Object.defineProperty(exports, "useMastheadHeight", {
|
|
829
|
-
enumerable: true,
|
|
830
|
-
get: function () {
|
|
831
|
-
return _Masthead.useMastheadHeight;
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
810
|
Object.defineProperty(exports, "useSnack", {
|
|
835
811
|
enumerable: true,
|
|
836
812
|
get: function () {
|
|
@@ -844,7 +820,6 @@ var _LicenseByline = require("./LicenseByline");
|
|
|
844
820
|
var _Article = _interopRequireWildcard(require("./Article"));
|
|
845
821
|
var _relativeUrl = require("./utils/relativeUrl");
|
|
846
822
|
var _Table = _interopRequireWildcard(require("./Table"));
|
|
847
|
-
var _Masthead = _interopRequireWildcard(require("./Masthead"));
|
|
848
823
|
var _ContentLoader = _interopRequireDefault(require("./ContentLoader"));
|
|
849
824
|
var _RelatedArticleList = _interopRequireWildcard(require("./RelatedArticleList"));
|
|
850
825
|
var _ErrorMessage = _interopRequireWildcard(require("./ErrorMessage"));
|
|
@@ -524,8 +524,10 @@ declare const messages: {
|
|
|
524
524
|
};
|
|
525
525
|
contentTypes: {
|
|
526
526
|
all: string;
|
|
527
|
+
article: string;
|
|
527
528
|
subject: string;
|
|
528
529
|
"topic-article": string;
|
|
530
|
+
learningpath: string;
|
|
529
531
|
"learning-path": string;
|
|
530
532
|
"subject-material": string;
|
|
531
533
|
"tasks-and-activities": string;
|
|
@@ -912,6 +914,7 @@ declare const messages: {
|
|
|
912
914
|
onDragEndMissingOver: string;
|
|
913
915
|
onDragCancel: string;
|
|
914
916
|
dragHandle: string;
|
|
917
|
+
professional: string;
|
|
915
918
|
sharedWarning: string;
|
|
916
919
|
sharing: {
|
|
917
920
|
share: string;
|
|
@@ -541,8 +541,10 @@ const messages = {
|
|
|
541
541
|
},
|
|
542
542
|
contentTypes: {
|
|
543
543
|
all: "All",
|
|
544
|
+
article: "Article",
|
|
544
545
|
subject: "Subject",
|
|
545
546
|
"topic-article": "Topic article",
|
|
547
|
+
learningpath: "Learning path",
|
|
546
548
|
"learning-path": "Learning path",
|
|
547
549
|
"subject-material": "Subject material",
|
|
548
550
|
"tasks-and-activities": "Task and activities",
|
|
@@ -929,6 +931,7 @@ const messages = {
|
|
|
929
931
|
onDragEndMissingOver: "The folder {{name}} was dropped",
|
|
930
932
|
onDragCancel: "Dragging was cancelled. The folder {{name}} was dropped",
|
|
931
933
|
dragHandle: "Drag the folder {{name}}",
|
|
934
|
+
professional: "a professional",
|
|
932
935
|
sharedWarning: "Name and description will be visible for everyone you share the folder with",
|
|
933
936
|
sharing: {
|
|
934
937
|
share: "Share folder",
|
|
@@ -524,8 +524,10 @@ declare const messages: {
|
|
|
524
524
|
};
|
|
525
525
|
contentTypes: {
|
|
526
526
|
all: string;
|
|
527
|
+
article: string;
|
|
527
528
|
subject: string;
|
|
528
529
|
"topic-article": string;
|
|
530
|
+
learningpath: string;
|
|
529
531
|
"learning-path": string;
|
|
530
532
|
"subject-material": string;
|
|
531
533
|
"tasks-and-activities": string;
|
|
@@ -912,6 +914,7 @@ declare const messages: {
|
|
|
912
914
|
onDragEndMissingOver: string;
|
|
913
915
|
onDragCancel: string;
|
|
914
916
|
dragHandle: string;
|
|
917
|
+
professional: string;
|
|
915
918
|
sharedWarning: string;
|
|
916
919
|
sharing: {
|
|
917
920
|
share: string;
|
|
@@ -541,8 +541,10 @@ const messages = {
|
|
|
541
541
|
},
|
|
542
542
|
contentTypes: {
|
|
543
543
|
all: "Alle",
|
|
544
|
+
article: "Artikkel",
|
|
544
545
|
subject: "Fag",
|
|
545
546
|
"topic-article": "Emne",
|
|
547
|
+
learningpath: "Læringssti",
|
|
546
548
|
"learning-path": "Læringssti",
|
|
547
549
|
"subject-material": "Fagstoff",
|
|
548
550
|
"tasks-and-activities": "Oppgaver og aktiviteter",
|
|
@@ -929,6 +931,7 @@ const messages = {
|
|
|
929
931
|
onDragEndMissingOver: "Mappen {{name}} ble sluppet",
|
|
930
932
|
onDragCancel: "Flytting avbrutt. Mappen {{name}} ble sluppet",
|
|
931
933
|
dragHandle: "Sorter mappen {{name}}",
|
|
934
|
+
professional: "en fagperson",
|
|
932
935
|
sharedWarning: "Navn og beskrivelse blir synlig for alle du deler mappen med.",
|
|
933
936
|
sharing: {
|
|
934
937
|
share: "Del mappe",
|
|
@@ -524,8 +524,10 @@ declare const messages: {
|
|
|
524
524
|
};
|
|
525
525
|
contentTypes: {
|
|
526
526
|
all: string;
|
|
527
|
+
article: string;
|
|
527
528
|
subject: string;
|
|
528
529
|
"topic-article": string;
|
|
530
|
+
learningpath: string;
|
|
529
531
|
"learning-path": string;
|
|
530
532
|
"subject-material": string;
|
|
531
533
|
"tasks-and-activities": string;
|
|
@@ -912,6 +914,7 @@ declare const messages: {
|
|
|
912
914
|
onDragEndMissingOver: string;
|
|
913
915
|
onDragCancel: string;
|
|
914
916
|
dragHandle: string;
|
|
917
|
+
professional: string;
|
|
915
918
|
sharedWarning: string;
|
|
916
919
|
sharing: {
|
|
917
920
|
share: string;
|
|
@@ -541,8 +541,10 @@ const messages = {
|
|
|
541
541
|
},
|
|
542
542
|
contentTypes: {
|
|
543
543
|
all: "Alle",
|
|
544
|
+
article: "Artikkel",
|
|
544
545
|
subject: "Fag",
|
|
545
546
|
"topic-article": "Emne",
|
|
547
|
+
learningpath: "Læringssti",
|
|
546
548
|
"learning-path": "Læringssti",
|
|
547
549
|
"subject-material": "Fagstoff",
|
|
548
550
|
"tasks-and-activities": "Oppgåver og aktivitetar",
|
|
@@ -929,6 +931,7 @@ const messages = {
|
|
|
929
931
|
onDragEndMissingOver: "Mappa blei sleppt",
|
|
930
932
|
onDragCancel: "Flytting avbrutt. Mappa {{name}} blei sleppt",
|
|
931
933
|
dragHandle: "Sorter mappa {{name}}",
|
|
934
|
+
professional: "ein fagperson",
|
|
932
935
|
sharedWarning: "Namn og beskriving blir synleg for alle du deler mappa med.",
|
|
933
936
|
sharing: {
|
|
934
937
|
share: "Del mappe",
|
|
@@ -524,8 +524,10 @@ declare const messages: {
|
|
|
524
524
|
};
|
|
525
525
|
contentTypes: {
|
|
526
526
|
all: string;
|
|
527
|
+
article: string;
|
|
527
528
|
subject: string;
|
|
528
529
|
"topic-article": string;
|
|
530
|
+
learningpath: string;
|
|
529
531
|
"learning-path": string;
|
|
530
532
|
"subject-material": string;
|
|
531
533
|
"tasks-and-activities": string;
|
|
@@ -912,6 +914,7 @@ declare const messages: {
|
|
|
912
914
|
onDragEndMissingOver: string;
|
|
913
915
|
onDragCancel: string;
|
|
914
916
|
dragHandle: string;
|
|
917
|
+
professional: string;
|
|
915
918
|
sharedWarning: string;
|
|
916
919
|
sharing: {
|
|
917
920
|
share: string;
|
|
@@ -541,8 +541,10 @@ const messages = {
|
|
|
541
541
|
},
|
|
542
542
|
contentTypes: {
|
|
543
543
|
all: "Buot",
|
|
544
|
+
article: "Artikkel",
|
|
544
545
|
subject: "Fága",
|
|
545
546
|
"topic-article": "Fáddá",
|
|
547
|
+
learningpath: "Oahppanbálggis",
|
|
546
548
|
"learning-path": "Oahppanbálggis",
|
|
547
549
|
"subject-material": "Fágaávdnasat",
|
|
548
550
|
"tasks-and-activities": "Bihtát ja doaimmat",
|
|
@@ -929,6 +931,7 @@ const messages = {
|
|
|
929
931
|
onDragEndMissingOver: "Mappen {{name}} ble sluppet",
|
|
930
932
|
onDragCancel: "Flytting avbrutt. Mappen {{name}} ble sluppet",
|
|
931
933
|
dragHandle: "Sorter mappen {{name}}",
|
|
934
|
+
professional: "en fagperson",
|
|
932
935
|
sharedWarning: "Navn og beskrivelse blir synlig for alle du deler mappen med.",
|
|
933
936
|
sharing: {
|
|
934
937
|
share: "Del mappe",
|
|
@@ -524,8 +524,10 @@ declare const messages: {
|
|
|
524
524
|
};
|
|
525
525
|
contentTypes: {
|
|
526
526
|
all: string;
|
|
527
|
+
article: string;
|
|
527
528
|
subject: string;
|
|
528
529
|
"topic-article": string;
|
|
530
|
+
learningpath: string;
|
|
529
531
|
"learning-path": string;
|
|
530
532
|
"subject-material": string;
|
|
531
533
|
"tasks-and-activities": string;
|
|
@@ -912,6 +914,7 @@ declare const messages: {
|
|
|
912
914
|
onDragEndMissingOver: string;
|
|
913
915
|
onDragCancel: string;
|
|
914
916
|
dragHandle: string;
|
|
917
|
+
professional: string;
|
|
915
918
|
sharedWarning: string;
|
|
916
919
|
sharing: {
|
|
917
920
|
share: string;
|
|
@@ -541,8 +541,10 @@ const messages = {
|
|
|
541
541
|
},
|
|
542
542
|
contentTypes: {
|
|
543
543
|
all: "Alle",
|
|
544
|
+
article: "Artikkel",
|
|
544
545
|
subject: "Faagem",
|
|
545
546
|
"topic-article": "Teema",
|
|
547
|
+
learningpath: "Lïeremebaalka",
|
|
546
548
|
"learning-path": "Lïeremebaalka",
|
|
547
549
|
"subject-material": "Faage-aamhtese",
|
|
548
550
|
"tasks-and-activities": "Laavenjassh jïh darjomh",
|
|
@@ -929,6 +931,7 @@ const messages = {
|
|
|
929
931
|
onDragEndMissingOver: "Mappen {{name}} ble sluppet",
|
|
930
932
|
onDragCancel: "Flytting avbrutt. Mappen {{name}} ble sluppet",
|
|
931
933
|
dragHandle: "Sorter mappen {{name}}",
|
|
934
|
+
professional: "en fagperson",
|
|
932
935
|
sharedWarning: "Navn og beskrivelse blir synlig for alle du deler mappen med.",
|
|
933
936
|
sharing: {
|
|
934
937
|
share: "Del mappe",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "53.0.0",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"html-react-parser": "^5.1.8",
|
|
52
52
|
"i18next-browser-languagedetector": "^7.1.0",
|
|
53
53
|
"lodash.throttle": "^4.1.1",
|
|
54
|
-
"react-bem-helper": "1.4.1",
|
|
55
54
|
"react-device-detect": "^2.2.3",
|
|
56
55
|
"react-select": "^5.8.0",
|
|
57
56
|
"react-swipeable": "^7.0.0"
|
|
@@ -77,5 +76,5 @@
|
|
|
77
76
|
"publishConfig": {
|
|
78
77
|
"access": "public"
|
|
79
78
|
},
|
|
80
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "fe4060794eb3eafc6231ef802b7f44df65155467"
|
|
81
80
|
}
|
package/src/Article/Article.tsx
CHANGED
|
@@ -6,37 +6,139 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ReactNode,
|
|
10
|
-
import
|
|
9
|
+
import { ReactNode, forwardRef, ComponentPropsWithRef, useMemo, CSSProperties } from "react";
|
|
10
|
+
import { SerializedStyles, css } from "@emotion/react";
|
|
11
11
|
import styled from "@emotion/styled";
|
|
12
12
|
|
|
13
|
-
import { spacing, mq, breakpoints } from "@ndla/core";
|
|
14
|
-
import { useIntersectionObserver } from "@ndla/hooks";
|
|
13
|
+
import { spacing, mq, breakpoints, fonts, colors, spacingUnit } from "@ndla/core";
|
|
15
14
|
import { Heading, Text } from "@ndla/typography";
|
|
16
|
-
import { resizeObserver } from "@ndla/util";
|
|
17
15
|
import ArticleByline from "./ArticleByline";
|
|
18
16
|
import ArticleHeaderWrapper from "./ArticleHeaderWrapper";
|
|
19
|
-
import ArticleNotions from "./ArticleNotions";
|
|
20
17
|
import LayoutItem from "../Layout";
|
|
21
18
|
import MessageBox from "../Messages/MessageBox";
|
|
22
19
|
import { Article as ArticleType } from "../types";
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
export type ArticleModifier =
|
|
22
|
+
| "clean"
|
|
23
|
+
| "in-topic"
|
|
24
|
+
| "subject-material"
|
|
25
|
+
| "assessment-resources"
|
|
26
|
+
| "tasks-and-activities"
|
|
27
|
+
| "concept"
|
|
28
|
+
| "source-material";
|
|
28
29
|
|
|
29
30
|
interface ArticleWrapperProps extends ComponentPropsWithRef<"article"> {
|
|
30
|
-
modifier?:
|
|
31
|
+
modifier?: ArticleModifier;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const StyledArticle = styled.article`
|
|
35
|
+
font-family: ${fonts.serif};
|
|
36
|
+
background: ${colors.white};
|
|
37
|
+
margin-top: ${spacing.large};
|
|
38
|
+
margin-right: auto;
|
|
39
|
+
margin-bottom: ${spacing.normal};
|
|
40
|
+
margin-left: auto;
|
|
41
|
+
overflow-wrap: break-word;
|
|
42
|
+
${fonts.sizes("18px", "29px")};
|
|
43
|
+
position: relative;
|
|
44
|
+
|
|
45
|
+
mjx-stretchy-v > mjx-ext > mjx-c {
|
|
46
|
+
transform: scaleY(100) translateY(0.075em);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
> section > p {
|
|
50
|
+
&:not([class]) {
|
|
51
|
+
margin-bottom: 29px;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
${mq.range({ from: breakpoints.tablet })} {
|
|
56
|
+
${fonts.sizes("18px", "29px")}; //This is probably not needed, but it's here to be sure.
|
|
57
|
+
|
|
58
|
+
> section > p {
|
|
59
|
+
&:not([class]) {
|
|
60
|
+
margin-bottom: 35px;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
padding: 0 ${spacing.normal} ${spacing.normal};
|
|
64
|
+
margin-bottom: ${spacing.large};
|
|
65
|
+
margin-top: -${spacingUnit * 6}px;
|
|
66
|
+
padding-top: ${spacing.xlarge};
|
|
67
|
+
}
|
|
68
|
+
${mq.range({ from: breakpoints.desktop })} {
|
|
69
|
+
padding-bottom: ${spacing.large};
|
|
70
|
+
margin-bottom: ${spacing.large};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&::after {
|
|
74
|
+
content: "";
|
|
75
|
+
display: table;
|
|
76
|
+
clear: both;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
p {
|
|
80
|
+
margin-top: 0;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
// Make sure to wrap modifiers in & {} to avoid specificity issues
|
|
85
|
+
const articleModifiers: Partial<Record<ArticleModifier, SerializedStyles>> = {
|
|
86
|
+
clean: css`
|
|
87
|
+
& {
|
|
88
|
+
margin-top: ${spacing.normal} !important;
|
|
89
|
+
padding: ${spacing.small} !important;
|
|
90
|
+
${mq.range({ from: breakpoints.tablet })} {
|
|
91
|
+
padding: 0 !important;
|
|
92
|
+
}
|
|
93
|
+
border: none;
|
|
94
|
+
}
|
|
95
|
+
`,
|
|
96
|
+
"in-topic": css`
|
|
97
|
+
& {
|
|
98
|
+
margin-top: 0 !important;
|
|
99
|
+
padding: 0 !important;
|
|
100
|
+
padding-left: ${spacing.medium} !important;
|
|
101
|
+
}
|
|
102
|
+
`,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const borderCss = css`
|
|
106
|
+
${mq.range({ from: breakpoints.tablet })} {
|
|
107
|
+
border: 2px solid var(--color);
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
export const ArticleWrapper = forwardRef<HTMLElement, ArticleWrapperProps>(({ children, modifier, ...rest }, ref) => {
|
|
112
|
+
const borderColor = useMemo(() => {
|
|
113
|
+
let color = undefined;
|
|
114
|
+
if (modifier === "subject-material") {
|
|
115
|
+
color = colors.subjectMaterial.light;
|
|
116
|
+
} else if (modifier === "assessment-resources") {
|
|
117
|
+
color = colors.assessmentResource.background;
|
|
118
|
+
} else if (modifier === "tasks-and-activities") {
|
|
119
|
+
color = colors.tasksAndActivities.background;
|
|
120
|
+
} else if (modifier === "concept") {
|
|
121
|
+
color = colors.concept.light;
|
|
122
|
+
} else if (modifier === "source-material") {
|
|
123
|
+
color = colors.sourceMaterial.light;
|
|
124
|
+
}
|
|
125
|
+
if (color) {
|
|
126
|
+
return { "--color": color } as CSSProperties;
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}, [modifier]);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<StyledArticle
|
|
133
|
+
css={[borderColor ? borderCss : undefined, modifier ? articleModifiers[modifier] : undefined]}
|
|
134
|
+
style={borderColor}
|
|
135
|
+
{...rest}
|
|
136
|
+
ref={ref}
|
|
137
|
+
>
|
|
36
138
|
{children}
|
|
37
|
-
</
|
|
38
|
-
)
|
|
39
|
-
);
|
|
139
|
+
</StyledArticle>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
40
142
|
|
|
41
143
|
type ArticleTitleProps = {
|
|
42
144
|
icon?: ReactNode;
|
|
@@ -46,28 +148,40 @@ type ArticleTitleProps = {
|
|
|
46
148
|
lang?: string;
|
|
47
149
|
};
|
|
48
150
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let labelView = null;
|
|
151
|
+
const TitleLabelText = styled(Text)`
|
|
152
|
+
color: #757575;
|
|
153
|
+
text-transform: uppercase;
|
|
154
|
+
font-family: ${fonts.sans};
|
|
155
|
+
`;
|
|
56
156
|
|
|
57
|
-
|
|
58
|
-
|
|
157
|
+
const ArticleTitleWrapper = styled.div`
|
|
158
|
+
display: flex;
|
|
159
|
+
gap: ${spacing.normal};
|
|
160
|
+
align-items: flex-start;
|
|
161
|
+
h1 {
|
|
162
|
+
overflow-wrap: anywhere;
|
|
59
163
|
}
|
|
164
|
+
padding-bottom: ${spacing.medium};
|
|
165
|
+
[data-badge] {
|
|
166
|
+
flex-shrink: 0;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
60
169
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
170
|
+
export const ArticleTitle = ({ children, icon, label, id, lang }: ArticleTitleProps) => (
|
|
171
|
+
<ArticleTitleWrapper>
|
|
172
|
+
{icon}
|
|
173
|
+
<hgroup>
|
|
174
|
+
{!!label && (
|
|
175
|
+
<TitleLabelText textStyle="meta-text-medium" margin="none">
|
|
176
|
+
{label}
|
|
177
|
+
</TitleLabelText>
|
|
178
|
+
)}
|
|
179
|
+
<Heading element="h1" margin="none" headingStyle="h1-resource" id={id} tabIndex={-1} lang={lang}>
|
|
66
180
|
{children}
|
|
67
181
|
</Heading>
|
|
68
|
-
</
|
|
69
|
-
|
|
70
|
-
|
|
182
|
+
</hgroup>
|
|
183
|
+
</ArticleTitleWrapper>
|
|
184
|
+
);
|
|
71
185
|
|
|
72
186
|
type ArticleIntroductionProps = {
|
|
73
187
|
children: ReactNode;
|
|
@@ -107,29 +221,15 @@ type Props = {
|
|
|
107
221
|
article: ArticleType;
|
|
108
222
|
icon?: ReactNode;
|
|
109
223
|
licenseBox?: ReactNode;
|
|
110
|
-
modifier?:
|
|
224
|
+
modifier?: ArticleModifier;
|
|
111
225
|
children?: ReactNode;
|
|
112
226
|
messages: Messages;
|
|
113
|
-
contentTransformed?: boolean;
|
|
114
227
|
messageBoxLinks?: [];
|
|
115
228
|
competenceGoals?: ReactNode;
|
|
116
229
|
id: string;
|
|
117
|
-
notions?: ReactNode;
|
|
118
230
|
lang?: string;
|
|
119
231
|
};
|
|
120
232
|
|
|
121
|
-
const getArticleContent = (content: any, contentTransformed?: boolean) => {
|
|
122
|
-
if (contentTransformed) {
|
|
123
|
-
return content;
|
|
124
|
-
}
|
|
125
|
-
switch (typeof content) {
|
|
126
|
-
case "function":
|
|
127
|
-
return content();
|
|
128
|
-
default:
|
|
129
|
-
return content;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
233
|
export const Article = ({
|
|
134
234
|
article,
|
|
135
235
|
icon,
|
|
@@ -140,79 +240,43 @@ export const Article = ({
|
|
|
140
240
|
children,
|
|
141
241
|
competenceGoals,
|
|
142
242
|
id,
|
|
143
|
-
notions,
|
|
144
243
|
heartButton,
|
|
145
|
-
contentTransformed,
|
|
146
244
|
lang,
|
|
147
245
|
}: Props) => {
|
|
148
|
-
const articleRef = useRef<HTMLDivElement>(null);
|
|
149
|
-
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
150
|
-
const { entry } = useIntersectionObserver({
|
|
151
|
-
rootMargin: "400px",
|
|
152
|
-
target: articleRef.current,
|
|
153
|
-
threshold: 0.1,
|
|
154
|
-
});
|
|
155
|
-
const [articlePositionRight, setArticlePositionRight] = useState(0);
|
|
156
|
-
|
|
157
|
-
const showExplainNotions = !!entry?.isIntersecting;
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (wrapperRef?.current) {
|
|
161
|
-
const handler = () => {
|
|
162
|
-
if (wrapperRef?.current) {
|
|
163
|
-
const offset =
|
|
164
|
-
wrapperRef.current.getBoundingClientRect().left + wrapperRef.current.getBoundingClientRect().width;
|
|
165
|
-
setArticlePositionRight(offset);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
handler();
|
|
169
|
-
|
|
170
|
-
return resizeObserver(document.body, handler);
|
|
171
|
-
}
|
|
172
|
-
}, [wrapperRef]);
|
|
173
|
-
|
|
174
246
|
const { title, introduction, published, content, footNotes, copyright } = article;
|
|
175
247
|
|
|
176
248
|
const authors =
|
|
177
249
|
copyright?.creators.length || copyright?.rightsholders.length ? copyright.creators : copyright?.processors;
|
|
178
250
|
|
|
179
251
|
return (
|
|
180
|
-
<
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
{
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
published={published}
|
|
209
|
-
license={copyright?.license?.license ?? ""}
|
|
210
|
-
licenseBox={licenseBox}
|
|
211
|
-
/>
|
|
212
|
-
</LayoutItem>
|
|
213
|
-
<LayoutItem layout="extend">{children}</LayoutItem>
|
|
214
|
-
</ArticleWrapper>
|
|
215
|
-
</div>
|
|
252
|
+
<ArticleWrapper modifier={modifier} data-ndla-article="">
|
|
253
|
+
<LayoutItem layout="center">
|
|
254
|
+
{messages.messageBox && (
|
|
255
|
+
<MSGboxWrapper>
|
|
256
|
+
<MessageBox links={messageBoxLinks}>{messages.messageBox}</MessageBox>
|
|
257
|
+
</MSGboxWrapper>
|
|
258
|
+
)}
|
|
259
|
+
<ArticleHeaderWrapper competenceGoals={competenceGoals}>
|
|
260
|
+
{heartButton ? <ArticleFavoritesButtonWrapper>{heartButton}</ArticleFavoritesButtonWrapper> : null}
|
|
261
|
+
<ArticleTitle id={id} icon={icon} label={messages.label} lang={lang}>
|
|
262
|
+
{title}
|
|
263
|
+
</ArticleTitle>
|
|
264
|
+
<ArticleIntroduction lang={lang}>{introduction}</ArticleIntroduction>
|
|
265
|
+
</ArticleHeaderWrapper>
|
|
266
|
+
</LayoutItem>
|
|
267
|
+
<LayoutItem layout="center">{content}</LayoutItem>
|
|
268
|
+
<LayoutItem layout="center">
|
|
269
|
+
<ArticleByline
|
|
270
|
+
footnotes={footNotes}
|
|
271
|
+
authors={authors}
|
|
272
|
+
suppliers={copyright?.rightsholders}
|
|
273
|
+
published={published}
|
|
274
|
+
license={copyright?.license?.license ?? ""}
|
|
275
|
+
licenseBox={licenseBox}
|
|
276
|
+
/>
|
|
277
|
+
</LayoutItem>
|
|
278
|
+
<LayoutItem layout="extend">{children}</LayoutItem>
|
|
279
|
+
</ArticleWrapper>
|
|
216
280
|
);
|
|
217
281
|
};
|
|
218
282
|
|