@ndla/ui 36.0.1 → 37.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.
Files changed (188) hide show
  1. package/es/Article/Article.js +7 -13
  2. package/es/Article/ArticleByline.js +79 -123
  3. package/es/Article/ArticleFootNotes.js +16 -11
  4. package/es/AudioPlayer/AudioPlayer.js +33 -35
  5. package/es/AudioPlayer/initAudioPlayers.js +6 -1
  6. package/es/BlogPost/BlogPost.js +4 -4
  7. package/es/CampaignBlock/CampaignBlock.js +77 -0
  8. package/es/CampaignBlock/index.js +9 -0
  9. package/es/ContactBlock/ContactBlock.js +63 -39
  10. package/es/Embed/AudioEmbed.js +44 -188
  11. package/es/Embed/BrightcoveEmbed.js +27 -123
  12. package/es/Embed/ConceptEmbed.js +53 -75
  13. package/es/Embed/EmbedErrorPlaceholder.js +41 -0
  14. package/es/Embed/ExternalEmbed.js +5 -12
  15. package/es/Embed/H5pEmbed.js +4 -14
  16. package/es/Embed/IframeEmbed.js +4 -4
  17. package/es/Embed/ImageEmbed.js +41 -153
  18. package/es/Embed/conceptComponents.js +62 -228
  19. package/es/Embed/types.js +1 -0
  20. package/es/KeyFigure/KeyFigure.js +57 -0
  21. package/es/{KeyPerformanceIndicator → KeyFigure}/index.js +1 -1
  22. package/es/LicenseByline/EmbedByline.js +115 -0
  23. package/es/LicenseByline/LicenseDescription.js +39 -0
  24. package/es/LicenseByline/LicenseLink.js +36 -0
  25. package/es/LicenseByline/index.js +1 -0
  26. package/es/List/OrderedList.js +48 -0
  27. package/es/List/UnOrderedList.js +36 -0
  28. package/es/List/index.js +10 -0
  29. package/es/Navigation/NavigationBox.js +41 -48
  30. package/es/Navigation/NavigationHeading.js +18 -29
  31. package/es/Notion/Notion.js +5 -5
  32. package/es/Resource/resourceComponents.js +12 -11
  33. package/es/Typography/Heading.js +38 -0
  34. package/es/Typography/index.js +9 -0
  35. package/es/all.css +1 -1
  36. package/es/index.js +4 -2
  37. package/es/locale/messages-en.js +13 -2
  38. package/es/locale/messages-nb.js +13 -2
  39. package/es/locale/messages-nn.js +13 -2
  40. package/es/locale/messages-se.js +13 -2
  41. package/es/locale/messages-sma.js +13 -2
  42. package/es/model/ContentType.js +7 -1
  43. package/lib/Article/Article.d.ts +1 -3
  44. package/lib/Article/Article.js +7 -13
  45. package/lib/Article/ArticleByline.d.ts +3 -5
  46. package/lib/Article/ArticleByline.js +83 -126
  47. package/lib/Article/ArticleFootNotes.js +16 -11
  48. package/lib/AudioPlayer/AudioPlayer.d.ts +1 -2
  49. package/lib/AudioPlayer/AudioPlayer.js +33 -36
  50. package/lib/AudioPlayer/initAudioPlayers.d.ts +1 -0
  51. package/lib/AudioPlayer/initAudioPlayers.js +9 -3
  52. package/lib/BlogPost/BlogPost.js +4 -4
  53. package/lib/CampaignBlock/CampaignBlock.d.ts +31 -0
  54. package/lib/CampaignBlock/CampaignBlock.js +82 -0
  55. package/lib/CampaignBlock/index.d.ts +8 -0
  56. package/lib/CampaignBlock/index.js +13 -0
  57. package/lib/ContactBlock/ContactBlock.js +63 -39
  58. package/lib/Embed/AudioEmbed.d.ts +3 -2
  59. package/lib/Embed/AudioEmbed.js +53 -192
  60. package/lib/Embed/BrightcoveEmbed.d.ts +3 -1
  61. package/lib/Embed/BrightcoveEmbed.js +27 -122
  62. package/lib/Embed/ConceptEmbed.d.ts +7 -2
  63. package/lib/Embed/ConceptEmbed.js +51 -73
  64. package/lib/Embed/EmbedErrorPlaceholder.d.ts +17 -0
  65. package/lib/Embed/EmbedErrorPlaceholder.js +48 -0
  66. package/lib/Embed/ExternalEmbed.js +5 -11
  67. package/lib/Embed/H5pEmbed.js +4 -13
  68. package/lib/Embed/IframeEmbed.d.ts +2 -2
  69. package/lib/Embed/IframeEmbed.js +4 -4
  70. package/lib/Embed/ImageEmbed.d.ts +3 -10
  71. package/lib/Embed/ImageEmbed.js +48 -161
  72. package/lib/Embed/conceptComponents.d.ts +4 -2
  73. package/lib/Embed/conceptComponents.js +67 -231
  74. package/lib/Embed/index.d.ts +1 -0
  75. package/lib/Embed/types.d.ts +14 -0
  76. package/lib/Embed/types.js +5 -0
  77. package/lib/KeyFigure/KeyFigure.d.ts +10 -0
  78. package/lib/KeyFigure/KeyFigure.js +62 -0
  79. package/lib/KeyFigure/index.d.ts +1 -0
  80. package/lib/KeyFigure/index.js +13 -0
  81. package/lib/LicenseByline/EmbedByline.d.ts +51 -0
  82. package/lib/LicenseByline/EmbedByline.js +120 -0
  83. package/lib/LicenseByline/LicenseDescription.d.ts +14 -0
  84. package/lib/LicenseByline/LicenseDescription.js +44 -0
  85. package/lib/LicenseByline/LicenseLink.d.ts +14 -0
  86. package/lib/LicenseByline/LicenseLink.js +44 -0
  87. package/lib/LicenseByline/index.d.ts +1 -0
  88. package/lib/LicenseByline/index.js +13 -0
  89. package/lib/List/OrderedList.d.ts +15 -0
  90. package/lib/List/OrderedList.js +56 -0
  91. package/lib/List/UnOrderedList.d.ts +10 -0
  92. package/lib/List/UnOrderedList.js +43 -0
  93. package/lib/List/index.d.ts +9 -0
  94. package/lib/List/index.js +20 -0
  95. package/lib/Navigation/NavigationBox.js +40 -47
  96. package/lib/Navigation/NavigationHeading.js +17 -28
  97. package/lib/Notion/Notion.js +5 -5
  98. package/lib/Resource/resourceComponents.js +12 -11
  99. package/lib/Typography/Heading.d.ts +26 -0
  100. package/lib/Typography/Heading.js +45 -0
  101. package/lib/Typography/index.d.ts +8 -0
  102. package/lib/Typography/index.js +13 -0
  103. package/lib/all.css +1 -1
  104. package/lib/index.d.ts +4 -1
  105. package/lib/index.js +23 -3
  106. package/lib/locale/messages-en.d.ts +11 -0
  107. package/lib/locale/messages-en.js +13 -2
  108. package/lib/locale/messages-nb.d.ts +11 -0
  109. package/lib/locale/messages-nb.js +13 -2
  110. package/lib/locale/messages-nn.d.ts +11 -0
  111. package/lib/locale/messages-nn.js +13 -2
  112. package/lib/locale/messages-se.d.ts +11 -0
  113. package/lib/locale/messages-se.js +13 -2
  114. package/lib/locale/messages-sma.d.ts +11 -0
  115. package/lib/locale/messages-sma.js +13 -2
  116. package/lib/model/ContentType.d.ts +1 -0
  117. package/lib/model/ContentType.js +9 -2
  118. package/package.json +15 -15
  119. package/src/Article/Article.tsx +1 -8
  120. package/src/Article/ArticleByline.tsx +78 -127
  121. package/src/Article/ArticleFootNotes.tsx +33 -10
  122. package/src/Article/component.article.scss +1 -52
  123. package/src/Article/component.footnotes.scss +2 -2
  124. package/src/Aside/component.aside.scss +3 -3
  125. package/src/AudioPlayer/AudioPlayer.tsx +11 -24
  126. package/src/AudioPlayer/initAudioPlayers.tsx +7 -2
  127. package/src/BlogPost/BlogPost.tsx +0 -4
  128. package/src/CampaignBlock/CampaignBlock.stories.tsx +63 -0
  129. package/src/CampaignBlock/CampaignBlock.tsx +99 -0
  130. package/src/CampaignBlock/index.ts +9 -0
  131. package/src/ContactBlock/ContactBlock.tsx +27 -19
  132. package/src/ContactBlock/Contactblock.stories.tsx +0 -1
  133. package/src/Dialog/component.dialog.scss +4 -5
  134. package/src/Embed/AudioEmbed.stories.tsx +5 -3
  135. package/src/Embed/AudioEmbed.tsx +45 -192
  136. package/src/Embed/BrightcoveEmbed.stories.tsx +5 -1
  137. package/src/Embed/BrightcoveEmbed.tsx +20 -95
  138. package/src/Embed/ConceptEmbed.stories.tsx +5 -0
  139. package/src/Embed/ConceptEmbed.tsx +43 -54
  140. package/src/Embed/EmbedErrorPlaceholder.tsx +59 -0
  141. package/src/Embed/ExternalEmbed.stories.tsx +86 -0
  142. package/src/Embed/ExternalEmbed.tsx +3 -8
  143. package/src/Embed/H5pEmbed.stories.tsx +92 -0
  144. package/src/Embed/H5pEmbed.tsx +2 -10
  145. package/src/Embed/IframeEmbed.stories.tsx +130 -0
  146. package/src/Embed/IframeEmbed.tsx +3 -3
  147. package/src/Embed/ImageEmbed.stories.tsx +3 -1
  148. package/src/Embed/ImageEmbed.tsx +21 -116
  149. package/src/Embed/conceptComponents.tsx +67 -257
  150. package/src/Embed/index.ts +1 -0
  151. package/src/Embed/types.ts +12 -0
  152. package/src/FactBox/component.factbox.scss +3 -3
  153. package/src/Figure/component.figure-license.scss +4 -4
  154. package/src/Figure/component.figure.scss +1 -1
  155. package/src/KeyFigure/KeyFigure.stories.tsx +36 -0
  156. package/src/{KeyPerformanceIndicator/KeyPerformanceIndicator.tsx → KeyFigure/KeyFigure.tsx} +9 -7
  157. package/src/{KeyPerformanceIndicator → KeyFigure}/index.ts +1 -1
  158. package/src/LicenseByline/EmbedByline.stories.tsx +83 -0
  159. package/src/LicenseByline/EmbedByline.tsx +165 -0
  160. package/src/LicenseByline/LicenseDescription.tsx +43 -0
  161. package/src/LicenseByline/LicenseLink.tsx +42 -0
  162. package/src/LicenseByline/index.tsx +1 -0
  163. package/src/List/OrderedList.tsx +115 -0
  164. package/src/List/UnOrderedList.tsx +49 -0
  165. package/src/List/index.ts +10 -0
  166. package/src/MediaList/component.medialist.scss +2 -2
  167. package/src/Navigation/NavigationBox.tsx +10 -14
  168. package/src/Navigation/NavigationHeading.tsx +15 -24
  169. package/src/Notion/Notion.tsx +1 -1
  170. package/src/RelatedArticleList/component.related-articles.scss +3 -13
  171. package/src/Resource/resourceComponents.tsx +4 -2
  172. package/src/Table/component.tables.scss +0 -46
  173. package/src/Translation/component.translation.scss +3 -5
  174. package/src/Typography/Heading.tsx +96 -0
  175. package/src/Typography/index.ts +9 -0
  176. package/src/index.ts +5 -1
  177. package/src/locale/messages-en.ts +11 -0
  178. package/src/locale/messages-nb.ts +11 -0
  179. package/src/locale/messages-nn.ts +11 -0
  180. package/src/locale/messages-se.ts +11 -0
  181. package/src/locale/messages-sma.ts +11 -0
  182. package/src/model/ContentType.ts +7 -0
  183. package/es/KeyPerformanceIndicator/KeyPerformanceIndicator.js +0 -57
  184. package/lib/KeyPerformanceIndicator/KeyPerformanceIndicator.d.ts +0 -8
  185. package/lib/KeyPerformanceIndicator/KeyPerformanceIndicator.js +0 -62
  186. package/lib/KeyPerformanceIndicator/index.d.ts +0 -1
  187. package/lib/KeyPerformanceIndicator/index.js +0 -13
  188. package/src/KeyPerformanceIndicator/KeyPerformanceIndicator.stories.tsx +0 -79
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Copyright (c) 2023-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 { ReactNode } from 'react';
10
+ import { useTranslation } from 'react-i18next';
11
+ import styled from '@emotion/styled';
12
+ import { breakpoints, colors, fonts, misc, mq, spacing } from '@ndla/core';
13
+ import { getLicenseByAbbreviation, getLicenseCredits } from '@ndla/licenses';
14
+ import { ICopyright as ImageCopyright } from '@ndla/types-backend/image-api';
15
+ import { ICopyright as AudioCopyright } from '@ndla/types-backend/audio-api';
16
+ import { ICopyright as ConceptCopyright } from '@ndla/types-backend/concept-api';
17
+ import { BrightcoveCopyright } from '@ndla/types-embed';
18
+ import { WarningOutline } from '@ndla/icons/common';
19
+ import LicenseLink from './LicenseLink';
20
+ import LicenseDescription from './LicenseDescription';
21
+
22
+ interface BaseProps {
23
+ topRounded?: boolean;
24
+ bottomRounded?: boolean;
25
+ description?: string;
26
+ children?: ReactNode;
27
+ visibleAlt?: string;
28
+ error?: true | false;
29
+ first?: boolean;
30
+ }
31
+
32
+ export interface EmbedBylineErrorProps extends BaseProps {
33
+ type: EmbedBylineTypeProps['type'] | 'h5p' | 'external';
34
+ error: true;
35
+ }
36
+
37
+ interface ImageProps extends BaseProps {
38
+ type: 'image';
39
+ copyright: ImageCopyright;
40
+ }
41
+
42
+ interface BrightcoveProps extends BaseProps {
43
+ type: 'video';
44
+ copyright: BrightcoveCopyright;
45
+ }
46
+
47
+ interface AudioProps extends BaseProps {
48
+ type: 'audio';
49
+ copyright: AudioCopyright;
50
+ }
51
+
52
+ interface PodcastProps extends BaseProps {
53
+ type: 'podcast';
54
+ copyright: AudioCopyright;
55
+ }
56
+
57
+ interface ConceptProps extends BaseProps {
58
+ type: 'concept';
59
+ copyright: ConceptCopyright;
60
+ }
61
+
62
+ export type EmbedBylineTypeProps = ImageProps | BrightcoveProps | AudioProps | PodcastProps | ConceptProps;
63
+
64
+ type Props = EmbedBylineTypeProps | EmbedBylineErrorProps;
65
+
66
+ export type LicenseType = ReturnType<typeof getLicenseByAbbreviation>;
67
+
68
+ const BylineWrapper = styled.div`
69
+ display: flex;
70
+ flex-direction: column;
71
+ gap: ${spacing.small};
72
+ font-family: ${fonts.sans};
73
+ ${fonts.sizes('18px', '24px')};
74
+ background-color: ${colors.brand.lightest};
75
+ padding: ${spacing.nsmall} ${spacing.normal};
76
+ border: 1px solid ${colors.brand.tertiary};
77
+ border-top: none;
78
+
79
+ &[data-top-rounded='true'] {
80
+ border-top-right-radius: ${misc.borderRadius};
81
+ border-top-left-radius: ${misc.borderRadius};
82
+ }
83
+
84
+ &[data-bottom-rounded='true'] {
85
+ border-bottom-right-radius: ${misc.borderRadius};
86
+ border-bottom-left-radius: ${misc.borderRadius};
87
+ }
88
+
89
+ &[data-error='true'] {
90
+ border: none;
91
+ background-color: ${colors.support.redLightest};
92
+ }
93
+ &[data-first='true'] {
94
+ border-top: 1px solid ${colors.brand.tertiary};
95
+ }
96
+ `;
97
+
98
+ const RightsWrapper = styled.div`
99
+ display: flex;
100
+ align-items: center;
101
+ gap: ${spacing.nsmall};
102
+
103
+ ${mq.range({ until: breakpoints.tablet })} {
104
+ align-items: flex-start;
105
+ gap: ${spacing.xsmall};
106
+ flex-direction: column;
107
+ }
108
+ `;
109
+
110
+ const StyledSpan = styled.span`
111
+ font-style: italic;
112
+ color: grey;
113
+ `;
114
+
115
+ const LicenseInformationWrapper = styled.div`
116
+ flex: 1;
117
+ `;
118
+
119
+ const EmbedByline = ({
120
+ type,
121
+ topRounded,
122
+ bottomRounded,
123
+ description,
124
+ children,
125
+ visibleAlt,
126
+ first = true,
127
+ ...props
128
+ }: Props) => {
129
+ const { t, i18n } = useTranslation();
130
+ const strippedDescription = description?.trim();
131
+
132
+ if (props.error) {
133
+ const typeString = type === 'h5p' ? 'H5P' : t(`embed.type.${type}`).toLowerCase();
134
+ return (
135
+ <BylineWrapper data-top-rounded={topRounded} data-bottom-rounded={bottomRounded} data-error={true}>
136
+ <LicenseDescription description={t('embed.embedError', { type: typeString })} icon={<WarningOutline />} />
137
+ </BylineWrapper>
138
+ );
139
+ }
140
+
141
+ const { copyright } = props;
142
+
143
+ const license = getLicenseByAbbreviation(copyright.license?.license ?? '', i18n.language);
144
+ const authors = getLicenseCredits(copyright);
145
+ const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];
146
+
147
+ return (
148
+ <BylineWrapper data-top-rounded={topRounded} data-bottom-rounded={bottomRounded} data-first={first}>
149
+ {!!strippedDescription?.length && description && <LicenseDescription description={description} />}
150
+ {visibleAlt ? <StyledSpan>{`Alt: ${visibleAlt}`}</StyledSpan> : null}
151
+ <RightsWrapper>
152
+ <LicenseLink license={license} asLink={!!license.url.length} />
153
+ <LicenseInformationWrapper>
154
+ <span>
155
+ <b>{t(`embed.type.${type}`)}: </b>
156
+ {captionAuthors.map((author) => author.name).join(', ')}
157
+ </span>
158
+ </LicenseInformationWrapper>
159
+ {children}
160
+ </RightsWrapper>
161
+ </BylineWrapper>
162
+ );
163
+ };
164
+
165
+ export default EmbedByline;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Copyright (c) 2023-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 styled from '@emotion/styled';
10
+ import { colors, spacing } from '@ndla/core';
11
+ import { ReactNode } from 'react';
12
+
13
+ interface Props {
14
+ description: string;
15
+ icon?: ReactNode;
16
+ }
17
+
18
+ const StyledParagraph = styled.p`
19
+ margin: 0;
20
+ `;
21
+
22
+ const StyledFigCaption = styled.figcaption`
23
+ display: flex;
24
+ gap: ${spacing.small};
25
+ align-items: center;
26
+ background: unset;
27
+ padding: unset;
28
+ font-size: unset;
29
+ color: unset;
30
+ padding-bottom: ${spacing.xsmall};
31
+ border-bottom: inherit;
32
+ `;
33
+
34
+ const LicenseDescription = ({ description, icon }: Props) => {
35
+ return (
36
+ <StyledFigCaption>
37
+ {icon}
38
+ <StyledParagraph>{description}</StyledParagraph>
39
+ </StyledFigCaption>
40
+ );
41
+ };
42
+
43
+ export default LicenseDescription;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2023-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 styled from '@emotion/styled';
10
+ import SafeLink from '@ndla/safelink';
11
+ import { colors, fonts } from '@ndla/core';
12
+ import { LicenseType } from './EmbedByline';
13
+
14
+ interface Props {
15
+ license: LicenseType;
16
+ asLink?: boolean;
17
+ }
18
+
19
+ const StyledSafeLink = styled(SafeLink)`
20
+ color: ${colors.brand.primary};
21
+ font-weight: ${fonts.weight.bold};
22
+ text-decoration: underline;
23
+ box-shadow: none;
24
+ &:hover,
25
+ &:focus-within {
26
+ text-decoration: none;
27
+ }
28
+ `;
29
+
30
+ const StyledSpan = styled.span`
31
+ font-weight: ${fonts.weight.bold};
32
+ `;
33
+
34
+ const LicenseLink = ({ license, asLink = true }: Props) => {
35
+ if (asLink) {
36
+ return <StyledSafeLink to={license.url}>{license.abbreviation}</StyledSafeLink>;
37
+ } else {
38
+ return <StyledSpan>{license.abbreviation}</StyledSpan>;
39
+ }
40
+ };
41
+
42
+ export default LicenseLink;
@@ -0,0 +1 @@
1
+ export { default as EmbedByline } from './EmbedByline';
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright (c) 2022-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 styled from '@emotion/styled';
10
+ import { fonts, spacing, spacingUnit } from '@ndla/core';
11
+ import { forwardRef, HTMLAttributes } from 'react';
12
+
13
+ export const generateListResets = () => {
14
+ let styles = '';
15
+ for (let $i = 0; $i < 50; $i++) {
16
+ styles += `
17
+ ol.ol-reset-${$i} { counter-reset: item ${$i - 1} }
18
+ `;
19
+ }
20
+
21
+ return styles;
22
+ };
23
+
24
+ const listSpacing = {
25
+ xlarge: `${spacingUnit * 2.5}px`,
26
+ xxlarge: `${spacingUnit * 3}px`,
27
+ };
28
+
29
+ const StyledOl = styled.ol`
30
+ margin-top: 0;
31
+ margin-left: 0;
32
+ ${fonts.sizes('18px', '29px')};
33
+ list-style-type: none;
34
+
35
+ // Child ordered lists
36
+ ol {
37
+ padding-left: ${spacing.normal};
38
+ }
39
+ // List item
40
+ li {
41
+ margin-top: ${spacing.normal};
42
+ }
43
+
44
+ &[data-type='letters'] {
45
+ counter-reset: item 0;
46
+ > li {
47
+ counter-increment: item;
48
+ &:before {
49
+ position: absolute;
50
+ transform: translateX(-100%);
51
+ content: counter(item, upper-alpha) '.';
52
+ padding-right: 0.25em;
53
+ }
54
+
55
+ > ol[data-type='letters'] {
56
+ > li:before {
57
+ content: counter(item, lower-alpha) '.';
58
+ }
59
+ ol[data-type='letters'] {
60
+ padding-left: ${spacing.normal};
61
+ > li:before {
62
+ content: counter(item, lower-roman) '.';
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
+ &:not([data-type='letters']) {
70
+ counter-reset: item 0;
71
+ > li {
72
+ counter-increment: item;
73
+ &:before {
74
+ position: absolute;
75
+ transform: translateX(-100%);
76
+ padding-right: 0.25em;
77
+ content: counters(item, '.') '.';
78
+ }
79
+
80
+ > ol:not([data-type='letters']) {
81
+ padding-left: ${spacing.medium};
82
+ > li {
83
+ > ol:not([data-type='letters']) {
84
+ padding-left: ${spacing.large};
85
+ > li {
86
+ > ol:not([data-type='letters']) {
87
+ padding-left: ${listSpacing.xlarge};
88
+ ol:not([data-type='letters']) {
89
+ padding-left: ${listSpacing.xxlarge};
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ // List reset classes
99
+ ${generateListResets()}
100
+ `;
101
+
102
+ interface Props extends HTMLAttributes<HTMLOListElement> {
103
+ type?: 'letters';
104
+ start?: number;
105
+ }
106
+
107
+ const OrderedList = forwardRef<HTMLOListElement, Props>(({ type, children, ...rest }, ref) => {
108
+ return (
109
+ <StyledOl data-type={type} ref={ref} {...rest}>
110
+ {children}
111
+ </StyledOl>
112
+ );
113
+ });
114
+
115
+ export default OrderedList;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) 2022-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 styled from '@emotion/styled';
10
+ import { colors, fonts, spacing } from '@ndla/core';
11
+ import { forwardRef, HTMLAttributes } from 'react';
12
+ import { generateListResets } from './OrderedList';
13
+
14
+ const StyledUl = styled.ul`
15
+ > li {
16
+ ::marker {
17
+ color: ${colors.brand.secondary};
18
+ }
19
+ }
20
+ ul {
21
+ list-style-image: none;
22
+ padding-left: ${spacing.mediumlarge};
23
+ }
24
+ margin-top: 0;
25
+ margin-left: 0;
26
+ ${fonts.sizes('18px', '29px')};
27
+
28
+ // List item
29
+ li {
30
+ margin-top: ${spacing.normal};
31
+ }
32
+
33
+ // Child unordered lists
34
+ ul {
35
+ padding-left: ${spacing.nsmall};
36
+ }
37
+ // List reset classes
38
+ ${generateListResets()}
39
+ `;
40
+
41
+ const UnOrderedList = forwardRef<HTMLUListElement, HTMLAttributes<HTMLUListElement>>(({ children, ...rest }, ref) => {
42
+ return (
43
+ <StyledUl ref={ref} {...rest}>
44
+ {children}
45
+ </StyledUl>
46
+ );
47
+ });
48
+
49
+ export default UnOrderedList;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2022-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
+ export { default as OrderedList } from './OrderedList';
10
+ export { default as UnOrderedList } from './UnOrderedList';
@@ -28,7 +28,7 @@
28
28
  }
29
29
 
30
30
  .c-medialist__body {
31
- @include inuit-font-size(14px, 24px);
31
+ @include font-size(14px, 24px);
32
32
  @include mq(tablet) {
33
33
  max-width: 70% !important;
34
34
  }
@@ -143,7 +143,7 @@
143
143
  .c-medialist__title {
144
144
  margin-top: 0;
145
145
  margin-bottom: $spacing--small/2;
146
- @include inuit-font-size(16px);
146
+ @include font-size(16px, 1.5);
147
147
  color: $brand-color;
148
148
  + p {
149
149
  margin-top: 0;
@@ -8,6 +8,7 @@ import { Switch } from '@ndla/switch';
8
8
  import { uuid } from '@ndla/util';
9
9
  import { useTranslation } from 'react-i18next';
10
10
  import { HumanMaleBoard } from '@ndla/icons/common';
11
+ import { Heading } from '../Typography';
11
12
 
12
13
  const StyledWrapper = styled.nav`
13
14
  margin: 20px 0 34px;
@@ -18,19 +19,10 @@ const StyledHeadingWrapper = styled.div`
18
19
  align-items: baseline;
19
20
  `;
20
21
 
21
- type InvertItProps = {
22
- invertedStyle?: boolean;
23
- };
24
-
25
- const StyledHeading = styled.h2<InvertItProps>`
26
- ${fonts.sizes('18px', '32px')};
27
- text-transform: uppercase;
28
- margin: 0 0 10px;
29
- ${(props) =>
30
- props.invertedStyle &&
31
- css`
32
- color: #fff;
33
- `}
22
+ const StyledHeading = styled(Heading)`
23
+ &[data-inverted='true'] {
24
+ color: ${colors.white};
25
+ }
34
26
  `;
35
27
 
36
28
  type listProps = {
@@ -216,7 +208,11 @@ export const NavigationBox = ({
216
208
  return (
217
209
  <StyledWrapper>
218
210
  <StyledHeadingWrapper>
219
- {heading && <StyledHeading invertedStyle={invertedStyle}>{heading}</StyledHeading>}
211
+ {heading && (
212
+ <StyledHeading element="h2" margin="small" headingStyle="list-title" data-inverted={invertedStyle}>
213
+ {heading}
214
+ </StyledHeading>
215
+ )}
220
216
  {hasAdditionalResources && (
221
217
  <Switch
222
218
  id={uuid()}
@@ -1,29 +1,12 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import styled from '@emotion/styled';
3
- import { css } from '@emotion/react';
4
- import { breakpoints, fonts, mq } from '@ndla/core';
3
+ import { breakpoints, colors, fonts, mq } from '@ndla/core';
4
+ import { Heading } from '../Typography';
5
5
 
6
- type InvertItProps = {
7
- invertedStyle?: boolean;
8
- };
9
-
10
- const StyledH1 = styled.h1<InvertItProps>`
11
- ${fonts.sizes('24px', '28px')};
12
- margin: 30px 0 20px 0;
13
- font-weight: ${fonts.weight.bold};
14
- ${mq.range({ from: breakpoints.tablet })} {
15
- margin: 40px 0 22px;
16
- ${fonts.sizes('40px', '48px')};
17
- }
18
- ${mq.range({ from: breakpoints.desktop })} {
19
- margin: 50px 0 24px;
20
- ${fonts.sizes('52px', '65px')};
6
+ const StyledHeading = styled(Heading)`
7
+ &[data-inverted='true'] {
8
+ color: ${colors.white};
21
9
  }
22
- ${(props) =>
23
- props.invertedStyle &&
24
- css`
25
- color: #fff;
26
- `}
27
10
  `;
28
11
  const StyledMainText = styled.span`
29
12
  display: block;
@@ -49,10 +32,18 @@ type Props = {
49
32
  };
50
33
 
51
34
  export const NavigationHeading = ({ subHeading, children, invertedStyle, headingId }: Props) => (
52
- <StyledH1 invertedStyle={invertedStyle} id={headingId} tabIndex={-1}>
35
+ <StyledHeading
36
+ element="h1"
37
+ margin="xlarge"
38
+ headingStyle="h1"
39
+ serif
40
+ data-inverted={invertedStyle}
41
+ id={headingId}
42
+ tabIndex={-1}
43
+ >
53
44
  {subHeading && <StyledSubText>{subHeading}</StyledSubText>}
54
45
  <StyledMainText>{children}</StyledMainText>
55
- </StyledH1>
46
+ </StyledHeading>
56
47
  );
57
48
 
58
49
  export default NavigationHeading;
@@ -83,7 +83,7 @@ const Notion = ({ id, labels = [], text, title, visualElement, imageElement, chi
83
83
  {imageElement}
84
84
  {visualElement}
85
85
  <TextWrapper hasVisualElement={!!(imageElement || visualElement)}>
86
- {parseMarkdown(`**${title}** \u2013 ${text}`, 'body')}
86
+ {parseMarkdown(`**${title.trim()}** \u2013 ${text}`, 'body')}
87
87
  {!!labels.length && (
88
88
  <LabelsContainer>
89
89
  {t('searchPage.resultType.notionLabels')}
@@ -77,15 +77,11 @@
77
77
  }
78
78
 
79
79
  &__title {
80
- @include font-size(18px);
80
+ @include font-size(18px, 1.33);
81
81
  margin: 0 0 $spacing--small 0;
82
82
  font-weight: $font-weight-semibold;
83
83
  display: flex;
84
84
 
85
- @include chinese() {
86
- @include font-size(20px);
87
- }
88
-
89
85
  .c-content-type-badge {
90
86
  flex-shrink: 0;
91
87
  margin-top: 1px;
@@ -93,16 +89,10 @@
93
89
  }
94
90
 
95
91
  &__description {
96
- @include font-size(16px);
97
-
98
- @include chinese() {
99
- @include font-size(18px);
100
- }
92
+ @include font-size(16px, 1.5);
101
93
 
102
94
  span {
103
- @include chinese() {
104
- @include font-size(18px);
105
- }
95
+ @include font-size(16px, 1.5);
106
96
  }
107
97
 
108
98
  margin: 0;
@@ -8,13 +8,15 @@
8
8
 
9
9
  import styled from '@emotion/styled';
10
10
  import { colors, fonts, spacing } from '@ndla/core';
11
- import React, { MouseEvent, ReactNode } from 'react';
11
+ import React, { ReactNode } from 'react';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { MenuButton } from '@ndla/button';
14
14
  import SafeLink from '@ndla/safelink';
15
15
  import { useNavigate } from 'react-router-dom';
16
16
  import { HashTag } from '@ndla/icons/common';
17
17
  import resourceTypeColor from '../utils/resourceTypeColor';
18
+ import { resourceTypeMapping } from '../model/ContentType';
19
+
18
20
  export interface ResourceImageProps {
19
21
  alt: string;
20
22
  src: string;
@@ -196,7 +198,7 @@ export const ResourceTypeList = ({ resourceTypes }: ResourceTypeListProps) => {
196
198
  <StyledResourceTypeList aria-label={t('navigation.topics')}>
197
199
  {resourceTypes.map((resource, i) => (
198
200
  <StyledResourceListElement key={resource.id}>
199
- {resource.name}
201
+ {resourceTypeMapping[resource.id] ? t(`embed.type.${resourceTypeMapping[resource.id]}`) : resource.name}
200
202
  {i !== resourceTypes.length - 1 && <StyledTopicDivider aria-hidden="true">•</StyledTopicDivider>}
201
203
  </StyledResourceListElement>
202
204
  ))}
@@ -83,31 +83,6 @@ article table {
83
83
 
84
84
  // scrolling shadows on left/right
85
85
 
86
- @include chinese() {
87
- th {
88
- @include font-size(18px, 22px);
89
-
90
- @include mq(tablet) {
91
- @include font-size(18px, 30px);
92
- }
93
- }
94
-
95
- thead tr:nth-child(2) th {
96
- @include font-size(16px, 18px);
97
-
98
- @include mq(tablet) {
99
- @include font-size(18px, 26px);
100
- }
101
- }
102
-
103
- td {
104
- @include font-size(16px, 22px);
105
- @include mq(tablet) {
106
- @include font-size(18px, 30px);
107
- }
108
- }
109
- }
110
-
111
86
  &:after,
112
87
  &:before {
113
88
  content: '';
@@ -144,13 +119,6 @@ article table {
144
119
  @include mq(tablet) {
145
120
  @include font-size(16px, 30px);
146
121
  }
147
-
148
- @include chinese() {
149
- @include font-size(18px, 22px);
150
- @include mq(tablet) {
151
- @include font-size(18px, 30px);
152
- }
153
- }
154
122
  }
155
123
 
156
124
  tbody th {
@@ -174,13 +142,6 @@ article table {
174
142
  &:empty {
175
143
  background-color: transparent;
176
144
  }
177
-
178
- @include chinese() {
179
- @include font-size(16px, 18px);
180
- @include mq(tablet) {
181
- @include font-size(18px, 26px);
182
- }
183
- }
184
145
  }
185
146
 
186
147
  td {
@@ -193,13 +154,6 @@ article table {
193
154
  @include font-size(15px, 30px);
194
155
  }
195
156
 
196
- @include chinese() {
197
- @include font-size(16px, 22px);
198
- @include mq(tablet) {
199
- @include font-size(18px, 30px);
200
- }
201
- }
202
-
203
157
  p {
204
158
  line-height: 1.6em;
205
159
  }