@ndla/ui 36.0.2 → 37.0.1

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 (174) 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/ContentTypeBadge/ContentTypeBadge.js +27 -6
  7. package/es/Embed/AudioEmbed.js +44 -188
  8. package/es/Embed/BrightcoveEmbed.js +32 -127
  9. package/es/Embed/ConceptEmbed.js +53 -75
  10. package/es/Embed/EmbedErrorPlaceholder.js +41 -0
  11. package/es/Embed/ExternalEmbed.js +5 -12
  12. package/es/Embed/H5pEmbed.js +5 -15
  13. package/es/Embed/IframeEmbed.js +4 -4
  14. package/es/Embed/ImageEmbed.js +41 -153
  15. package/es/Embed/RelatedContentEmbed.js +3 -3
  16. package/es/Embed/conceptComponents.js +62 -228
  17. package/es/Embed/types.js +1 -0
  18. package/es/KeyFigure/KeyFigure.js +57 -0
  19. package/es/{KeyPerformanceIndicator → KeyFigure}/index.js +1 -1
  20. package/es/LicenseByline/EmbedByline.js +33 -8
  21. package/es/LicenseByline/LicenseDescription.js +16 -14
  22. package/es/List/OrderedList.js +48 -0
  23. package/es/List/UnOrderedList.js +36 -0
  24. package/es/List/index.js +10 -0
  25. package/es/Navigation/NavigationBox.js +41 -48
  26. package/es/Navigation/NavigationHeading.js +18 -29
  27. package/es/Notion/Notion.js +5 -5
  28. package/es/Resource/ListResource.js +9 -9
  29. package/es/Resource/resourceComponents.js +12 -11
  30. package/es/Typography/Heading.js +38 -0
  31. package/es/Typography/index.js +9 -0
  32. package/es/all.css +1 -1
  33. package/es/index.js +4 -2
  34. package/es/locale/messages-en.js +6 -2
  35. package/es/locale/messages-nb.js +6 -2
  36. package/es/locale/messages-nn.js +6 -2
  37. package/es/locale/messages-se.js +6 -2
  38. package/es/locale/messages-sma.js +6 -2
  39. package/es/model/ContentType.js +7 -1
  40. package/lib/Article/Article.d.ts +1 -3
  41. package/lib/Article/Article.js +7 -13
  42. package/lib/Article/ArticleByline.d.ts +3 -5
  43. package/lib/Article/ArticleByline.js +83 -126
  44. package/lib/Article/ArticleFootNotes.js +16 -11
  45. package/lib/AudioPlayer/AudioPlayer.d.ts +1 -2
  46. package/lib/AudioPlayer/AudioPlayer.js +33 -36
  47. package/lib/AudioPlayer/initAudioPlayers.d.ts +1 -0
  48. package/lib/AudioPlayer/initAudioPlayers.js +9 -3
  49. package/lib/ContentTypeBadge/ContentTypeBadge.js +27 -6
  50. package/lib/Embed/AudioEmbed.d.ts +3 -2
  51. package/lib/Embed/AudioEmbed.js +53 -192
  52. package/lib/Embed/BrightcoveEmbed.d.ts +3 -1
  53. package/lib/Embed/BrightcoveEmbed.js +32 -126
  54. package/lib/Embed/ConceptEmbed.d.ts +7 -2
  55. package/lib/Embed/ConceptEmbed.js +51 -73
  56. package/lib/Embed/EmbedErrorPlaceholder.d.ts +17 -0
  57. package/lib/Embed/EmbedErrorPlaceholder.js +48 -0
  58. package/lib/Embed/ExternalEmbed.js +5 -11
  59. package/lib/Embed/H5pEmbed.js +5 -14
  60. package/lib/Embed/IframeEmbed.d.ts +2 -2
  61. package/lib/Embed/IframeEmbed.js +4 -4
  62. package/lib/Embed/ImageEmbed.d.ts +3 -10
  63. package/lib/Embed/ImageEmbed.js +48 -161
  64. package/lib/Embed/RelatedContentEmbed.js +3 -3
  65. package/lib/Embed/conceptComponents.d.ts +4 -2
  66. package/lib/Embed/conceptComponents.js +67 -231
  67. package/lib/Embed/index.d.ts +1 -0
  68. package/lib/Embed/types.d.ts +14 -0
  69. package/lib/Embed/types.js +5 -0
  70. package/lib/KeyFigure/KeyFigure.d.ts +10 -0
  71. package/lib/KeyFigure/KeyFigure.js +62 -0
  72. package/lib/KeyFigure/index.d.ts +1 -0
  73. package/lib/KeyFigure/index.js +13 -0
  74. package/lib/LicenseByline/EmbedByline.d.ts +10 -2
  75. package/lib/LicenseByline/EmbedByline.js +32 -7
  76. package/lib/LicenseByline/LicenseDescription.d.ts +3 -1
  77. package/lib/LicenseByline/LicenseDescription.js +14 -13
  78. package/lib/List/OrderedList.d.ts +15 -0
  79. package/lib/List/OrderedList.js +56 -0
  80. package/lib/List/UnOrderedList.d.ts +10 -0
  81. package/lib/List/UnOrderedList.js +43 -0
  82. package/lib/List/index.d.ts +9 -0
  83. package/lib/List/index.js +20 -0
  84. package/lib/Navigation/NavigationBox.js +40 -47
  85. package/lib/Navigation/NavigationHeading.js +17 -28
  86. package/lib/Notion/Notion.js +5 -5
  87. package/lib/Resource/ListResource.js +8 -8
  88. package/lib/Resource/resourceComponents.js +12 -11
  89. package/lib/Typography/Heading.d.ts +26 -0
  90. package/lib/Typography/Heading.js +45 -0
  91. package/lib/Typography/index.d.ts +8 -0
  92. package/lib/Typography/index.js +13 -0
  93. package/lib/all.css +1 -1
  94. package/lib/index.d.ts +4 -1
  95. package/lib/index.js +23 -3
  96. package/lib/locale/messages-en.d.ts +4 -0
  97. package/lib/locale/messages-en.js +6 -2
  98. package/lib/locale/messages-nb.d.ts +4 -0
  99. package/lib/locale/messages-nb.js +6 -2
  100. package/lib/locale/messages-nn.d.ts +4 -0
  101. package/lib/locale/messages-nn.js +6 -2
  102. package/lib/locale/messages-se.d.ts +4 -0
  103. package/lib/locale/messages-se.js +6 -2
  104. package/lib/locale/messages-sma.d.ts +4 -0
  105. package/lib/locale/messages-sma.js +6 -2
  106. package/lib/model/ContentType.d.ts +1 -0
  107. package/lib/model/ContentType.js +9 -2
  108. package/package.json +15 -15
  109. package/src/Article/Article.tsx +1 -8
  110. package/src/Article/ArticleByline.tsx +78 -127
  111. package/src/Article/ArticleFootNotes.tsx +33 -10
  112. package/src/Article/component.article.scss +1 -52
  113. package/src/Article/component.footnotes.scss +2 -2
  114. package/src/Aside/component.aside.scss +3 -3
  115. package/src/AudioPlayer/AudioPlayer.tsx +11 -24
  116. package/src/AudioPlayer/initAudioPlayers.tsx +7 -2
  117. package/src/ContentTypeBadge/ContentTypeBadge.tsx +29 -6
  118. package/src/ContentTypeBadge/component.content-type-badge.scss +9 -3
  119. package/src/Dialog/component.dialog.scss +4 -5
  120. package/src/Embed/AudioEmbed.stories.tsx +5 -3
  121. package/src/Embed/AudioEmbed.tsx +45 -192
  122. package/src/Embed/BrightcoveEmbed.stories.tsx +5 -1
  123. package/src/Embed/BrightcoveEmbed.tsx +24 -98
  124. package/src/Embed/ConceptEmbed.stories.tsx +5 -0
  125. package/src/Embed/ConceptEmbed.tsx +43 -54
  126. package/src/Embed/EmbedErrorPlaceholder.tsx +59 -0
  127. package/src/Embed/ExternalEmbed.stories.tsx +86 -0
  128. package/src/Embed/ExternalEmbed.tsx +3 -8
  129. package/src/Embed/H5pEmbed.stories.tsx +92 -0
  130. package/src/Embed/H5pEmbed.tsx +3 -11
  131. package/src/Embed/IframeEmbed.stories.tsx +130 -0
  132. package/src/Embed/IframeEmbed.tsx +3 -3
  133. package/src/Embed/ImageEmbed.stories.tsx +3 -1
  134. package/src/Embed/ImageEmbed.tsx +21 -116
  135. package/src/Embed/RelatedContentEmbed.tsx +3 -1
  136. package/src/Embed/conceptComponents.tsx +67 -257
  137. package/src/Embed/index.ts +1 -0
  138. package/src/Embed/types.ts +12 -0
  139. package/src/FactBox/component.factbox.scss +3 -3
  140. package/src/Figure/component.figure-license.scss +4 -4
  141. package/src/Figure/component.figure.scss +1 -1
  142. package/src/KeyFigure/KeyFigure.stories.tsx +36 -0
  143. package/src/{KeyPerformanceIndicator/KeyPerformanceIndicator.tsx → KeyFigure/KeyFigure.tsx} +9 -7
  144. package/src/{KeyPerformanceIndicator → KeyFigure}/index.ts +1 -1
  145. package/src/LicenseByline/EmbedByline.stories.tsx +1 -0
  146. package/src/LicenseByline/EmbedByline.tsx +57 -9
  147. package/src/LicenseByline/LicenseDescription.tsx +9 -3
  148. package/src/List/OrderedList.tsx +115 -0
  149. package/src/List/UnOrderedList.tsx +49 -0
  150. package/src/List/index.ts +10 -0
  151. package/src/MediaList/component.medialist.scss +2 -2
  152. package/src/Navigation/NavigationBox.tsx +10 -14
  153. package/src/Navigation/NavigationHeading.tsx +15 -24
  154. package/src/Notion/Notion.tsx +1 -1
  155. package/src/RelatedArticleList/component.related-articles.scss +3 -13
  156. package/src/Resource/ListResource.tsx +6 -2
  157. package/src/Resource/resourceComponents.tsx +4 -2
  158. package/src/Table/component.tables.scss +0 -46
  159. package/src/Translation/component.translation.scss +3 -5
  160. package/src/Typography/Heading.tsx +96 -0
  161. package/src/Typography/index.ts +9 -0
  162. package/src/index.ts +5 -1
  163. package/src/locale/messages-en.ts +4 -0
  164. package/src/locale/messages-nb.ts +4 -0
  165. package/src/locale/messages-nn.ts +4 -0
  166. package/src/locale/messages-se.ts +4 -0
  167. package/src/locale/messages-sma.ts +4 -0
  168. package/src/model/ContentType.ts +7 -0
  169. package/es/KeyPerformanceIndicator/KeyPerformanceIndicator.js +0 -57
  170. package/lib/KeyPerformanceIndicator/KeyPerformanceIndicator.d.ts +0 -8
  171. package/lib/KeyPerformanceIndicator/KeyPerformanceIndicator.js +0 -62
  172. package/lib/KeyPerformanceIndicator/index.d.ts +0 -1
  173. package/lib/KeyPerformanceIndicator/index.js +0 -13
  174. package/src/KeyPerformanceIndicator/KeyPerformanceIndicator.stories.tsx +0 -79
@@ -7,7 +7,7 @@ $padding-bottom: 17px;
7
7
  overflow: hidden;
8
8
  padding-bottom: $padding-bottom;
9
9
 
10
- @include inuit-font-size(16px);
10
+ @include font-size(16px, 1.5);
11
11
 
12
12
  &__content {
13
13
  position: relative;
@@ -148,7 +148,7 @@ $padding-bottom: 17px;
148
148
  border-bottom: 2px solid $brand-color;
149
149
  margin-top: 0;
150
150
  margin-bottom: $spacing;
151
- @include inuit-font-size(22px, 34px);
151
+ @include font-size(22px, 34px);
152
152
  font-weight: $font-weight-bold;
153
153
  position: relative;
154
154
  z-index: 2;
@@ -159,7 +159,7 @@ $padding-bottom: 17px;
159
159
  h4,
160
160
  h5 {
161
161
  display: block;
162
- @include inuit-font-size(16px);
162
+ @include font-size(16px, 1.5);
163
163
  letter-spacing: 0.1em;
164
164
  margin-top: $spacing;
165
165
  margin-bottom: $spacing--small;
@@ -7,7 +7,7 @@
7
7
  **/
8
8
 
9
9
  .c-figure-license {
10
- @include font-size(16px);
10
+ @include font-size(16px, 1.5);
11
11
  font-family: $font-serif;
12
12
  }
13
13
 
@@ -57,7 +57,7 @@
57
57
  background: transparent;
58
58
  border: none;
59
59
  color: $brand-color;
60
- @include font-size(20px);
60
+ @include font-size(18px, 1.33);
61
61
  font-weight: $font-weight-normal;
62
62
  z-index: 9;
63
63
  cursor: pointer;
@@ -71,7 +71,7 @@
71
71
 
72
72
  .c-figure-license__title {
73
73
  margin: 0 0 $spacing--small;
74
- @include inuit-font-size(18px);
74
+ @include font-size(18px, 1.33);
75
75
  color: $brand-color;
76
76
  }
77
77
  .c-figure-license--fullscreen {
@@ -84,7 +84,7 @@
84
84
  }
85
85
 
86
86
  .c-figure-license__image-title {
87
- @include inuit-font-size(28px);
87
+ @include font-size(28px, 30px);
88
88
  margin: $spacing 0 0;
89
89
  text-align: left;
90
90
  }
@@ -154,7 +154,7 @@
154
154
  margin-bottom: $spacing--small;
155
155
  font-family: $font;
156
156
  color: $primary-color;
157
- @include inuit-font-size(16px, 24px);
157
+ @include font-size(16px, 24px);
158
158
  @include mq($from: tablet) {
159
159
  flex: 2;
160
160
  margin-bottom: $spacing--small;
@@ -0,0 +1,36 @@
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 React from 'react';
10
+ import { Meta, StoryFn } from '@storybook/react';
11
+ import { defaultParameters } from '../../../../stories/defaults';
12
+ import KeyFigure from './KeyFigure';
13
+
14
+ export default {
15
+ title: 'Enkle komponenter/Nøkkeltall',
16
+ component: KeyFigure,
17
+ tags: ['autodocs'],
18
+ parameters: {
19
+ ...defaultParameters,
20
+ layout: 'centered',
21
+ },
22
+ args: {
23
+ title: '500',
24
+ subtitle: 'TVERRFAGLIGE RESSURSER',
25
+ image: {
26
+ alt: 'Nøkkeltall tverrfaglig',
27
+ src: 'https://api.test.ndla.no/image-api/raw/wMowCjRg.svg',
28
+ },
29
+ },
30
+ } as Meta<typeof KeyFigure>;
31
+
32
+ export const KeyFigureStory: StoryFn<typeof KeyFigure> = ({ ...args }) => {
33
+ return <KeyFigure {...args} />;
34
+ };
35
+
36
+ KeyFigureStory.storyName = 'Nøkkeltall';
@@ -8,7 +8,6 @@
8
8
 
9
9
  import styled from '@emotion/styled';
10
10
  import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
11
- import { IImageMetaInformationV3 } from '@ndla/types-backend/build/image-api';
12
11
 
13
12
  const ContentWrapper = styled.div`
14
13
  display: flex;
@@ -48,19 +47,22 @@ const SubTitleWrapper = styled.div`
48
47
  `;
49
48
 
50
49
  interface Props {
51
- image?: IImageMetaInformationV3;
50
+ image?: {
51
+ src?: string;
52
+ alt?: string;
53
+ };
52
54
  title: string;
53
- subTitle: string;
55
+ subtitle: string;
54
56
  }
55
57
 
56
- const KeyPerformanceIndicator = ({ image, title, subTitle }: Props) => {
58
+ const KeyFigure = ({ image, title, subtitle }: Props) => {
57
59
  return (
58
60
  <ContentWrapper>
59
- <StyledImage src={image?.image.imageUrl} alt={image?.alttext.alttext} />
61
+ <StyledImage src={image?.src} alt={image?.alt} />
60
62
  <TitleWrapper>{title}</TitleWrapper>
61
- <SubTitleWrapper>{subTitle}</SubTitleWrapper>
63
+ <SubTitleWrapper>{subtitle}</SubTitleWrapper>
62
64
  </ContentWrapper>
63
65
  );
64
66
  };
65
67
 
66
- export default KeyPerformanceIndicator;
68
+ export default KeyFigure;
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- export { default as KeyPerformanceIndicator } from './KeyPerformanceIndicator';
9
+ export { default as KeyFigure } from './KeyFigure';
@@ -36,6 +36,7 @@ export default {
36
36
  },
37
37
  args: {
38
38
  topRounded: true,
39
+ bottomRounded: true,
39
40
  visibleAlt: 'Synlig alt-tekst kan legges her, eller fjernes helt',
40
41
  type: 'image',
41
42
  children: (
@@ -9,20 +9,29 @@
9
9
  import { ReactNode } from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import styled from '@emotion/styled';
12
- import { breakpoints, colors, misc, mq, spacing } from '@ndla/core';
12
+ import { breakpoints, colors, fonts, misc, mq, spacing } from '@ndla/core';
13
13
  import { getLicenseByAbbreviation, getLicenseCredits } from '@ndla/licenses';
14
14
  import { ICopyright as ImageCopyright } from '@ndla/types-backend/image-api';
15
15
  import { ICopyright as AudioCopyright } from '@ndla/types-backend/audio-api';
16
16
  import { ICopyright as ConceptCopyright } from '@ndla/types-backend/concept-api';
17
17
  import { BrightcoveCopyright } from '@ndla/types-embed';
18
+ import { WarningOutline } from '@ndla/icons/common';
18
19
  import LicenseLink from './LicenseLink';
19
20
  import LicenseDescription from './LicenseDescription';
20
21
 
21
22
  interface BaseProps {
22
23
  topRounded?: boolean;
24
+ bottomRounded?: boolean;
23
25
  description?: string;
24
26
  children?: ReactNode;
25
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;
26
35
  }
27
36
 
28
37
  interface ImageProps extends BaseProps {
@@ -50,7 +59,9 @@ interface ConceptProps extends BaseProps {
50
59
  copyright: ConceptCopyright;
51
60
  }
52
61
 
53
- type Props = ImageProps | BrightcoveProps | AudioProps | PodcastProps | ConceptProps;
62
+ export type EmbedBylineTypeProps = ImageProps | BrightcoveProps | AudioProps | PodcastProps | ConceptProps;
63
+
64
+ type Props = EmbedBylineTypeProps | EmbedBylineErrorProps;
54
65
 
55
66
  export type LicenseType = ReturnType<typeof getLicenseByAbbreviation>;
56
67
 
@@ -58,14 +69,29 @@ const BylineWrapper = styled.div`
58
69
  display: flex;
59
70
  flex-direction: column;
60
71
  gap: ${spacing.small};
72
+ font-family: ${fonts.sans};
73
+ ${fonts.sizes('18px', '24px')};
61
74
  background-color: ${colors.brand.lightest};
62
- padding: ${spacing.small} ${spacing.normal};
75
+ padding: ${spacing.nsmall} ${spacing.normal};
63
76
  border: 1px solid ${colors.brand.tertiary};
64
- border-bottom-right-radius: ${misc.borderRadius};
65
- border-bottom-left-radius: ${misc.borderRadius};
77
+ border-top: none;
66
78
 
67
79
  &[data-top-rounded='true'] {
68
- border-radius: ${misc.borderRadius};
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};
69
95
  }
70
96
  `;
71
97
 
@@ -90,15 +116,37 @@ const LicenseInformationWrapper = styled.div`
90
116
  flex: 1;
91
117
  `;
92
118
 
93
- const EmbedByline = ({ type, topRounded, description, copyright, children, visibleAlt }: Props) => {
119
+ const EmbedByline = ({
120
+ type,
121
+ topRounded,
122
+ bottomRounded,
123
+ description,
124
+ children,
125
+ visibleAlt,
126
+ first = true,
127
+ ...props
128
+ }: Props) => {
94
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
+
95
143
  const license = getLicenseByAbbreviation(copyright.license?.license ?? '', i18n.language);
96
144
  const authors = getLicenseCredits(copyright);
97
145
  const captionAuthors = Object.values(authors).find((i) => i.length > 0) ?? [];
98
146
 
99
147
  return (
100
- <BylineWrapper data-top-rounded={topRounded}>
101
- {!!description && <LicenseDescription description={description} />}
148
+ <BylineWrapper data-top-rounded={topRounded} data-bottom-rounded={bottomRounded} data-first={first}>
149
+ {!!strippedDescription?.length && description && <LicenseDescription description={description} />}
102
150
  {visibleAlt ? <StyledSpan>{`Alt: ${visibleAlt}`}</StyledSpan> : null}
103
151
  <RightsWrapper>
104
152
  <LicenseLink license={license} asLink={!!license.url.length} />
@@ -8,27 +8,33 @@
8
8
 
9
9
  import styled from '@emotion/styled';
10
10
  import { colors, spacing } from '@ndla/core';
11
+ import { ReactNode } from 'react';
11
12
 
12
13
  interface Props {
13
14
  description: string;
15
+ icon?: ReactNode;
14
16
  }
15
17
 
16
18
  const StyledParagraph = styled.p`
17
19
  margin: 0;
18
- padding-bottom: ${spacing.xsmall};
19
- border-bottom: 1px solid ${colors.brand.tertiary};
20
20
  `;
21
21
 
22
22
  const StyledFigCaption = styled.figcaption`
23
+ display: flex;
24
+ gap: ${spacing.small};
25
+ align-items: center;
23
26
  background: unset;
24
27
  padding: unset;
25
28
  font-size: unset;
26
29
  color: unset;
30
+ padding-bottom: ${spacing.xsmall};
31
+ border-bottom: inherit;
27
32
  `;
28
33
 
29
- const LicenseDescription = ({ description }: Props) => {
34
+ const LicenseDescription = ({ description, icon }: Props) => {
30
35
  return (
31
36
  <StyledFigCaption>
37
+ {icon}
32
38
  <StyledParagraph>{description}</StyledParagraph>
33
39
  </StyledFigCaption>
34
40
  );
@@ -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;
@@ -22,7 +22,7 @@ import {
22
22
  } from './resourceComponents';
23
23
  import ContentLoader from '../ContentLoader';
24
24
  import ContentTypeBadge from '../ContentTypeBadge';
25
- import { contentTypeMapping } from '../model/ContentType';
25
+ import { contentTypeMapping, resourceTypeMapping } from '../model/ContentType';
26
26
  import { SettingsMenu } from '../MyNdla';
27
27
 
28
28
  const ListResourceWrapper = styled.div`
@@ -229,7 +229,11 @@ const ListResource = ({
229
229
  resourceImage={resourceImage}
230
230
  loading={isLoading}
231
231
  type={imageType}
232
- contentType={contentTypeMapping[firstContentType] ?? contentTypeMapping['default']}
232
+ contentType={
233
+ contentTypeMapping[firstContentType] ??
234
+ resourceTypeMapping[firstContentType] ??
235
+ contentTypeMapping['default']
236
+ }
233
237
  />
234
238
  </ImageWrapper>
235
239
  <TopicAndTitleWrapper>