@ndla/ui 32.1.1 → 33.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 (92) hide show
  1. package/es/Frontpage/FrontpageAllSubjects.js +9 -17
  2. package/es/Frontpage/FrontpageFilm.js +5 -4
  3. package/es/Frontpage/FrontpageMultidisciplinarySubject.js +10 -8
  4. package/es/Frontpage/FrontpageToolbox.js +7 -5
  5. package/es/InfoWidget/InfoWidget.js +10 -8
  6. package/es/RelatedArticleList/RelatedArticleList.js +3 -1
  7. package/es/SearchTypeResult/components/ItemTopicHeader.js +4 -4
  8. package/es/SectionHeading/SectionHeading.js +12 -18
  9. package/es/Subject/Subject.js +15 -12
  10. package/es/Subject/SubjectAbout.js +11 -9
  11. package/es/Subject/SubjectArchive.js +13 -11
  12. package/es/Subject/SubjectCarousel.js +7 -5
  13. package/es/Subject/SubjectLinks.js +6 -4
  14. package/es/Subject/SubjectNewContent.js +11 -9
  15. package/es/Subject/SubjectShortcuts.js +7 -5
  16. package/es/Subject/SubjectSocial.js +5 -3
  17. package/es/locale/messages-en.js +3 -2
  18. package/es/locale/messages-nb.js +3 -2
  19. package/es/locale/messages-nn.js +3 -2
  20. package/es/locale/messages-se.js +3 -2
  21. package/es/locale/messages-sma.js +3 -2
  22. package/es/model/SubjectCategories.js +2 -1
  23. package/lib/Frontpage/FrontpageAllSubjects.d.ts +0 -2
  24. package/lib/Frontpage/FrontpageAllSubjects.js +9 -17
  25. package/lib/Frontpage/FrontpageFilm.js +5 -4
  26. package/lib/Frontpage/FrontpageMultidisciplinarySubject.d.ts +3 -1
  27. package/lib/Frontpage/FrontpageMultidisciplinarySubject.js +10 -8
  28. package/lib/Frontpage/FrontpageToolbox.d.ts +3 -1
  29. package/lib/Frontpage/FrontpageToolbox.js +7 -5
  30. package/lib/InfoWidget/InfoWidget.d.ts +3 -1
  31. package/lib/InfoWidget/InfoWidget.js +10 -8
  32. package/lib/RelatedArticleList/RelatedArticleList.d.ts +3 -1
  33. package/lib/RelatedArticleList/RelatedArticleList.js +3 -1
  34. package/lib/SearchTypeResult/components/ItemTopicHeader.js +4 -4
  35. package/lib/SectionHeading/SectionHeading.d.ts +3 -1
  36. package/lib/SectionHeading/SectionHeading.js +12 -18
  37. package/lib/Subject/Subject.d.ts +6 -2
  38. package/lib/Subject/Subject.js +15 -12
  39. package/lib/Subject/SubjectAbout.d.ts +3 -1
  40. package/lib/Subject/SubjectAbout.js +11 -9
  41. package/lib/Subject/SubjectArchive.d.ts +2 -0
  42. package/lib/Subject/SubjectArchive.js +13 -11
  43. package/lib/Subject/SubjectCarousel.d.ts +3 -1
  44. package/lib/Subject/SubjectCarousel.js +7 -5
  45. package/lib/Subject/SubjectLinks.d.ts +3 -1
  46. package/lib/Subject/SubjectLinks.js +6 -4
  47. package/lib/Subject/SubjectNewContent.d.ts +3 -1
  48. package/lib/Subject/SubjectNewContent.js +11 -9
  49. package/lib/Subject/SubjectShortcuts.d.ts +2 -0
  50. package/lib/Subject/SubjectShortcuts.js +7 -5
  51. package/lib/Subject/SubjectSocial.d.ts +7 -3
  52. package/lib/Subject/SubjectSocial.js +5 -3
  53. package/lib/locale/messages-en.d.ts +3 -1
  54. package/lib/locale/messages-en.js +3 -2
  55. package/lib/locale/messages-nb.d.ts +3 -1
  56. package/lib/locale/messages-nb.js +3 -2
  57. package/lib/locale/messages-nn.d.ts +3 -1
  58. package/lib/locale/messages-nn.js +3 -2
  59. package/lib/locale/messages-se.d.ts +3 -1
  60. package/lib/locale/messages-se.js +3 -2
  61. package/lib/locale/messages-sma.d.ts +3 -1
  62. package/lib/locale/messages-sma.js +3 -2
  63. package/lib/model/SubjectCategories.d.ts +2 -1
  64. package/lib/model/SubjectCategories.js +5 -3
  65. package/lib/types.d.ts +1 -0
  66. package/package.json +2 -2
  67. package/src/Frontpage/FrontpageAllSubjects.tsx +2 -14
  68. package/src/Frontpage/FrontpageFilm.tsx +3 -1
  69. package/src/Frontpage/FrontpageMultidisciplinarySubject.tsx +6 -2
  70. package/src/Frontpage/FrontpageToolbox.tsx +6 -2
  71. package/src/InfoWidget/InfoWidget.tsx +6 -2
  72. package/src/MyNdla/Resource/Folder.stories.mdx +52 -0
  73. package/src/RelatedArticleList/RelatedArticleList.tsx +6 -2
  74. package/src/Resource/BlockResource.stories.mdx +58 -0
  75. package/src/Resource/Resource.stories.mdx +58 -0
  76. package/src/SearchTypeResult/components/ItemTopicHeader.tsx +1 -0
  77. package/src/SectionHeading/SectionHeading.tsx +15 -20
  78. package/src/Subject/Subject.tsx +10 -2
  79. package/src/Subject/SubjectAbout.tsx +6 -2
  80. package/src/Subject/SubjectArchive.tsx +13 -2
  81. package/src/Subject/SubjectCarousel.tsx +10 -2
  82. package/src/Subject/SubjectLinks.tsx +4 -2
  83. package/src/Subject/SubjectNewContent.tsx +4 -2
  84. package/src/Subject/SubjectShortcuts.tsx +4 -2
  85. package/src/Subject/SubjectSocial.tsx +9 -2
  86. package/src/locale/messages-en.ts +4 -2
  87. package/src/locale/messages-nb.ts +4 -2
  88. package/src/locale/messages-nn.ts +4 -2
  89. package/src/locale/messages-se.ts +4 -2
  90. package/src/locale/messages-sma.ts +4 -2
  91. package/src/model/SubjectCategories.ts +2 -1
  92. package/src/types.ts +2 -0
@@ -0,0 +1,52 @@
1
+ import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
2
+ import { defaultParameters } from '../../../../designmanual/stories/defaults';
3
+ import { Pencil } from '@ndla/icons/action';
4
+ import { DeleteForever } from '@ndla/icons/editor';
5
+
6
+ import Folder from './Folder';
7
+ import ButtonV2 from '../../../../button/src/ButtonV2';
8
+
9
+ <Meta
10
+ title="Enkle komponenter/Mappe"
11
+ component={Folder}
12
+ parameters={{
13
+ ...defaultParameters,
14
+ docs: {
15
+ inlineStories: true,
16
+ },
17
+ backgrounds: {},
18
+ }}
19
+ argTypes={{
20
+ menuItems: {
21
+ control: false,
22
+ },
23
+ }}
24
+ />
25
+
26
+ export const Template = (args) => <Folder {...args} />;
27
+
28
+ # Mappe
29
+
30
+ <Canvas>
31
+ <Story
32
+ name="Mappe"
33
+ args={{
34
+ id: '3d88300c-1186-47f5-a99a-8ea93fa20981',
35
+ title: 'Dette er min tittel',
36
+ subFolders: 3,
37
+ subResources: 3,
38
+ description: '',
39
+ link: '',
40
+ type: 'list',
41
+ menuItems: [
42
+ { icon: <Pencil />, text: 'Rediger', onClick: () => {} },
43
+ { icon: <DeleteForever />, text: 'Slett', onClick: () => {}, type: 'danger' },
44
+ ],
45
+ }}>
46
+ {Template.bind({})}
47
+ </Story>
48
+ </Canvas>
49
+
50
+ ### Props
51
+
52
+ <ArgsTable story="Mappe" />
@@ -3,6 +3,7 @@ import BEMHelper from 'react-bem-helper';
3
3
  import Button from '@ndla/button';
4
4
  import SafeLink from '@ndla/safelink';
5
5
  import SectionHeading from '../SectionHeading';
6
+ import { HeadingLevel } from '../types';
6
7
 
7
8
  const classes = new BEMHelper({
8
9
  name: 'related-articles',
@@ -51,13 +52,14 @@ interface Props {
51
52
  showMore: string;
52
53
  showLess: string;
53
54
  };
55
+ headingLevel: HeadingLevel;
54
56
  children?: ReactElement;
55
57
  dangerouslySetInnerHTML?: {
56
58
  __html: string;
57
59
  };
58
60
  articleCount?: number;
59
61
  }
60
- const RelatedArticleList = ({ messages, children, articleCount, dangerouslySetInnerHTML }: Props) => {
62
+ const RelatedArticleList = ({ messages, children, articleCount, dangerouslySetInnerHTML, headingLevel }: Props) => {
61
63
  const clonedChildren =
62
64
  !dangerouslySetInnerHTML && children
63
65
  ? Children.map(children, (article, i) =>
@@ -70,7 +72,9 @@ const RelatedArticleList = ({ messages, children, articleCount, dangerouslySetIn
70
72
 
71
73
  return (
72
74
  <section {...classes('')}>
73
- <SectionHeading className={classes('component-title').className}>{messages.title}</SectionHeading>
75
+ <SectionHeading headingLevel={headingLevel} className={classes('component-title').className}>
76
+ {messages.title}
77
+ </SectionHeading>
74
78
  <div {...classes('articles')} dangerouslySetInnerHTML={dangerouslySetInnerHTML}>
75
79
  {clonedChildren}
76
80
  </div>
@@ -0,0 +1,58 @@
1
+ import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
2
+ import { defaultParameters } from '../../../designmanual/stories/defaults';
3
+ import { Pencil } from '@ndla/icons/action';
4
+ import { DeleteForever } from '@ndla/icons/editor';
5
+
6
+ import BlockResource from './BlockResource';
7
+
8
+ <Meta
9
+ title="Enkle komponenter/Ressurser/BlockResource"
10
+ component={BlockResource}
11
+ parameters={{
12
+ ...defaultParameters,
13
+ docs: {
14
+ inlineStories: true,
15
+ },
16
+ backgrounds: {},
17
+ }}
18
+ argTypes={{
19
+ resourceImage: {
20
+ control: false,
21
+ },
22
+ resourceTypes: {
23
+ control: false,
24
+ },
25
+ headingLevel: {
26
+ control: false,
27
+ },
28
+ menuItems: {
29
+ control: false,
30
+ },
31
+ }}
32
+ />
33
+
34
+ export const Template = (args) => <BlockResource {...args} />;
35
+
36
+ # Blokkressurs
37
+
38
+ <Canvas>
39
+ <Story
40
+ name="BlockResource"
41
+ args={{
42
+ id: '1234',
43
+ link: '',
44
+ title: 'Tittel til ressurs',
45
+ resourceImage: {
46
+ src: '',
47
+ alt: '',
48
+ },
49
+ resourceTypes: [{ id: 'urn:resourcetype:learningPath', name: 'Læringssti' }],
50
+ tags: ['tag', 'tag', 'tag', 'tag'],
51
+ }}>
52
+ {Template.bind({})}
53
+ </Story>
54
+ </Canvas>
55
+
56
+ ### Props
57
+
58
+ <ArgsTable story="BlockResource" />
@@ -0,0 +1,58 @@
1
+ import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs';
2
+ import { defaultParameters } from '../../../designmanual/stories/defaults';
3
+ import { Pencil } from '@ndla/icons/action';
4
+ import { DeleteForever } from '@ndla/icons/editor';
5
+
6
+ import ListResource from './ListResource';
7
+
8
+ <Meta
9
+ title="Enkle komponenter/Ressurser/ListResource"
10
+ component={ListResource}
11
+ parameters={{
12
+ ...defaultParameters,
13
+ docs: {
14
+ inlineStories: true,
15
+ },
16
+ backgrounds: {},
17
+ }}
18
+ argTypes={{
19
+ resourceImage: {
20
+ control: false,
21
+ },
22
+ resourceTypes: {
23
+ control: false,
24
+ },
25
+ headingLevel: {
26
+ control: false,
27
+ },
28
+ menuItems: {
29
+ control: false,
30
+ },
31
+ }}
32
+ />
33
+
34
+ export const Template = (args) => <ListResource {...args} />;
35
+
36
+ # Standard ressurs
37
+
38
+ <Canvas>
39
+ <Story
40
+ name="ListResource"
41
+ args={{
42
+ id: '1234',
43
+ link: '',
44
+ title: 'Tittel til ressurs',
45
+ resourceImage: {
46
+ src: '',
47
+ alt: '',
48
+ },
49
+ resourceTypes: [{ id: 'urn:resourcetype:learningPath', name: 'Læringssti' }],
50
+ tags: ['tag', 'tag', 'tag', 'tag'],
51
+ }}>
52
+ {Template.bind({})}
53
+ </Story>
54
+ </Canvas>
55
+
56
+ ### Props
57
+
58
+ <ArgsTable story="ListResource" />
@@ -54,6 +54,7 @@ const TopicHeaderVisualElementWrapper = styled.div`
54
54
  align-items: center;
55
55
  overflow: hidden;
56
56
  border-radius: 50%;
57
+ -webkit-mask-image: -webkit-radial-gradient(white, black);
57
58
  `;
58
59
 
59
60
  const TopicHeaderImage = styled.img`
@@ -1,13 +1,9 @@
1
1
  import React, { ElementType, ReactNode } from 'react';
2
2
  import { css } from '@emotion/react';
3
3
  import { breakpoints, fonts, mq, spacing } from '@ndla/core';
4
- import styled from '@emotion/styled';
4
+ import { HeadingLevel } from '../types';
5
5
 
6
- interface StyledWrapperProps {
7
- large?: boolean;
8
- }
9
-
10
- const StyledWrapper = styled.h2<StyledWrapperProps>`
6
+ const headingStyle = css`
11
7
  font-weight: ${fonts.weight.bold};
12
8
  text-transform: uppercase;
13
9
  letter-spacing: 0.05em;
@@ -15,31 +11,30 @@ const StyledWrapper = styled.h2<StyledWrapperProps>`
15
11
  ${mq.range({ from: breakpoints.tablet })} {
16
12
  ${fonts.sizes('20px', '26px')};
17
13
  }
18
- ${(p) =>
19
- p.large &&
20
- css`
21
- margin: 0 0 ${spacing.small} 0;
22
- ${fonts.sizes('16px', '32px')};
23
- ${mq.range({ from: breakpoints.tablet })} {
24
- ${fonts.sizes('22px')};
25
- }
26
- `};
27
14
  `;
28
15
 
29
- const LargeStyledWrapper = StyledWrapper.withComponent('h1');
16
+ const largeHeadingStyle = css`
17
+ margin: 0 0 ${spacing.small} 0;
18
+ ${fonts.sizes('16px', '32px')};
19
+ ${mq.range({ from: breakpoints.tablet })} {
20
+ ${fonts.sizes('22px')};
21
+ }
22
+ `;
30
23
 
31
24
  interface Props {
32
25
  children: ReactNode;
33
26
  large?: boolean;
34
27
  className?: string;
28
+ headingLevel: HeadingLevel;
35
29
  }
36
30
 
37
- const SectionHeading = ({ children, large = false, className }: Props) => {
38
- const Wrapper: ElementType = large ? LargeStyledWrapper : StyledWrapper;
31
+ const SectionHeading = ({ children, large = false, className, headingLevel = 'h2' }: Props) => {
32
+ const Element: ElementType = headingLevel;
33
+ const styles = large ? [headingStyle, largeHeadingStyle] : [headingStyle];
39
34
  return (
40
- <Wrapper large={large} className={className}>
35
+ <Element css={styles} className={className}>
41
36
  {children}
42
- </Wrapper>
37
+ </Element>
43
38
  );
44
39
  };
45
40
 
@@ -3,6 +3,7 @@ import styled from '@emotion/styled';
3
3
  import { css } from '@emotion/react';
4
4
  import { breakpoints, colors, mq, spacing, spacingUnit } from '@ndla/core';
5
5
  import SectionHeading from '../SectionHeading';
6
+ import { HeadingLevel } from '../types';
6
7
 
7
8
  const SubjectContentWrapper = styled.div`
8
9
  ${mq.range({ from: breakpoints.tablet })} {
@@ -190,6 +191,13 @@ const StyledSectionHeading = styled(SectionHeading)`
190
191
  }
191
192
  `;
192
193
 
193
- export const SubjectSectionTitle = ({ children }: { children: ReactNode }) => (
194
- <StyledSectionHeading large>{children}</StyledSectionHeading>
194
+ interface SubjectSectionTitleProps {
195
+ headingLevel: HeadingLevel;
196
+ children: ReactNode;
197
+ }
198
+
199
+ export const SubjectSectionTitle = ({ children, headingLevel = 'h2' }: SubjectSectionTitleProps) => (
200
+ <StyledSectionHeading large headingLevel={headingLevel}>
201
+ {children}
202
+ </StyledSectionHeading>
195
203
  );
@@ -3,6 +3,7 @@ import { css } from '@emotion/react';
3
3
  import styled from '@emotion/styled';
4
4
  import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
5
5
  import SectionHeading from '../SectionHeading';
6
+ import { HeadingLevel } from '../types';
6
7
 
7
8
  interface Props {
8
9
  fixedWidth?: boolean;
@@ -10,6 +11,7 @@ interface Props {
10
11
  media: ReactNode;
11
12
  heading: string;
12
13
  description: string;
14
+ headingLevel: HeadingLevel;
13
15
  }
14
16
 
15
17
  interface SubjectAboutSectionProps {
@@ -98,9 +100,11 @@ const StyledDescription = styled.p`
98
100
  ${fonts.sizes('16px', '26px')};
99
101
  `;
100
102
 
101
- const SubjectAbout = ({ fixedWidth = false, media, heading, description, wide = false }: Props) => (
103
+ const SubjectAbout = ({ fixedWidth = false, media, heading, description, wide = false, headingLevel }: Props) => (
102
104
  <SubjectAboutSection wide={wide} fixedWidth={fixedWidth}>
103
- <StyledSectionHeading large>{heading}</StyledSectionHeading>
105
+ <StyledSectionHeading headingLevel={headingLevel} large>
106
+ {heading}
107
+ </StyledSectionHeading>
104
108
  <MediaWrapper>{media}</MediaWrapper>
105
109
  <StyledContent>
106
110
  <StyledMainHeading>{heading}</StyledMainHeading>
@@ -5,6 +5,7 @@ import { Cross } from '@ndla/icons/action';
5
5
  import { breakpoints, colors, fonts, mq, spacing, utils } from '@ndla/core';
6
6
  import SafeLink from '@ndla/safelink';
7
7
  import SectionHeading from '../SectionHeading';
8
+ import { HeadingLevel } from '../types';
8
9
 
9
10
  interface Props {
10
11
  featuringArticle: {
@@ -13,6 +14,7 @@ interface Props {
13
14
  description: string;
14
15
  url: string;
15
16
  };
17
+ headingLevel: HeadingLevel;
16
18
  archiveArticles: { url: string; heading: string }[];
17
19
  sectionHeading: string;
18
20
  fixedWidth?: boolean;
@@ -155,7 +157,14 @@ class SubjectArchive extends Component<Props, State> {
155
157
  }
156
158
 
157
159
  render() {
158
- const { fixedWidth = false, featuringArticle, messages, sectionHeading, archiveArticles } = this.props;
160
+ const {
161
+ fixedWidth = false,
162
+ headingLevel,
163
+ featuringArticle,
164
+ messages,
165
+ sectionHeading,
166
+ archiveArticles,
167
+ } = this.props;
159
168
 
160
169
  const archiveId = 'subject-archive';
161
170
 
@@ -183,7 +192,9 @@ class SubjectArchive extends Component<Props, State> {
183
192
 
184
193
  return (
185
194
  <SubjectArchiveSection animate={!!this.state.minHeight} fixedWidth={fixedWidth} ref={this.wrapperRef}>
186
- <StyledSectionHeading large>{sectionHeading}</StyledSectionHeading>
195
+ <StyledSectionHeading headingLevel={headingLevel} large>
196
+ {sectionHeading}
197
+ </StyledSectionHeading>
187
198
  <ArchiveWrapper>
188
199
  {section}
189
200
  <ArchiveButon
@@ -7,6 +7,7 @@ import { breakpoints, mq, spacing, spacingUnit } from '@ndla/core';
7
7
  import { SafeLinkProps } from '@ndla/safelink';
8
8
  import { ContentCard } from '../index';
9
9
  import { SubjectSectionTitle } from './Subject';
10
+ import { HeadingLevel } from '../types';
10
11
 
11
12
  interface Props {
12
13
  subjects?: {
@@ -17,6 +18,7 @@ interface Props {
17
18
  image?: string | undefined | null;
18
19
  toLinkProps: () => SafeLinkProps;
19
20
  }[];
21
+ headingLevel: HeadingLevel;
20
22
  title?: string;
21
23
  narrowScreen?: boolean;
22
24
  wideScreen?: boolean;
@@ -59,7 +61,13 @@ const StyledSubjectSectionTitle = styled(SubjectSectionTitle)`
59
61
  }
60
62
  `;
61
63
 
62
- const SubjectCarousel = ({ subjects = [], title = '', narrowScreen = false, wideScreen = false }: Props) => {
64
+ const SubjectCarousel = ({
65
+ subjects = [],
66
+ title = '',
67
+ narrowScreen = false,
68
+ wideScreen = false,
69
+ headingLevel,
70
+ }: Props) => {
63
71
  const { t } = useTranslation();
64
72
  return (
65
73
  <StyledSection narrowScreen={narrowScreen} wideScreen={wideScreen}>
@@ -124,7 +132,7 @@ const SubjectCarousel = ({ subjects = [], title = '', narrowScreen = false, wide
124
132
  itemsLength={subjects?.length ?? 0}>
125
133
  {(autoSizedProps) => (
126
134
  <>
127
- <StyledSubjectSectionTitle>{title}</StyledSubjectSectionTitle>
135
+ <StyledSubjectSectionTitle headingLevel={headingLevel}>{title}</StyledSubjectSectionTitle>
128
136
  <Carousel
129
137
  {...autoSizedProps}
130
138
  disableScroll={(autoSizedProps?.columnsPrSlide ?? 0) >= subjects.length}
@@ -4,6 +4,7 @@ import { spacing } from '@ndla/core';
4
4
  import SafeLink, { SafeLinkProps } from '@ndla/safelink';
5
5
 
6
6
  import { SubjectSectionTitle } from './Subject';
7
+ import { HeadingLevel } from '../types';
7
8
 
8
9
  const SubjectLinksSection = styled.section`
9
10
  margin-bottom: ${spacing.large};
@@ -20,6 +21,7 @@ const SubjectLinksList = styled.ul`
20
21
  `;
21
22
 
22
23
  interface Props {
24
+ headingLevel: HeadingLevel;
23
25
  links: {
24
26
  toLinkProps: () => SafeLinkProps;
25
27
  text: string;
@@ -27,9 +29,9 @@ interface Props {
27
29
  heading: string;
28
30
  }
29
31
 
30
- const SubjectLinks = ({ links, heading }: Props) => (
32
+ const SubjectLinks = ({ links, heading, headingLevel }: Props) => (
31
33
  <SubjectLinksSection>
32
- <StyledSubjectSectionTitle>{heading}</StyledSubjectSectionTitle>
34
+ <StyledSubjectSectionTitle headingLevel={headingLevel}>{heading}</StyledSubjectSectionTitle>
33
35
  <nav>
34
36
  <SubjectLinksList>
35
37
  {links.map((link) => (
@@ -4,8 +4,10 @@ import SafeLink from '@ndla/safelink';
4
4
  import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
5
5
  import ContentTypeBadge from '../ContentTypeBadge';
6
6
  import { SubjectSectionTitle } from './Subject';
7
+ import { HeadingLevel } from '../types';
7
8
 
8
9
  interface Props {
10
+ headingLevel: HeadingLevel;
9
11
  heading: string;
10
12
  content: {
11
13
  name: string;
@@ -86,9 +88,9 @@ const StyledSafeLink = styled(SafeLink)`
86
88
  }
87
89
  `;
88
90
 
89
- const SubjectNewContent = ({ heading, content }: Props) => (
91
+ const SubjectNewContent = ({ heading, content, headingLevel }: Props) => (
90
92
  <StyledSection>
91
- <StyledSubjectSectionTitle>{heading}</StyledSubjectSectionTitle>
93
+ <StyledSubjectSectionTitle headingLevel={headingLevel}>{heading}</StyledSubjectSectionTitle>
92
94
  <nav>
93
95
  <StyledUl>
94
96
  {content.map((item, index) => (
@@ -6,6 +6,7 @@ import { Forward } from '@ndla/icons/common';
6
6
  import SafeLink from '@ndla/safelink';
7
7
  import { SubjectSectionTitle } from './Subject';
8
8
  import Fade from '../Animation/Fade';
9
+ import { HeadingLevel } from '../types';
9
10
 
10
11
  const SubjectShortcutsSection = styled.section`
11
12
  margin-bottom: ${spacing.large};
@@ -69,6 +70,7 @@ interface Props {
69
70
  url: string;
70
71
  text: string;
71
72
  }[];
73
+ headingLevel: HeadingLevel;
72
74
  messages: {
73
75
  heading: string;
74
76
  showMore: string;
@@ -102,7 +104,7 @@ class SubjectShortcuts extends Component<Props, State> {
102
104
  }
103
105
 
104
106
  render() {
105
- const { links, messages, defaultVisableCount } = this.props;
107
+ const { links, messages, defaultVisableCount, headingLevel } = this.props;
106
108
  const id = 'subject-shortcut';
107
109
 
108
110
  const showExpand = defaultVisableCount < links.length;
@@ -128,7 +130,7 @@ class SubjectShortcuts extends Component<Props, State> {
128
130
  }
129
131
  return (
130
132
  <SubjectShortcutsSection>
131
- <SubjectSectionTitle>{messages.heading}</SubjectSectionTitle>
133
+ <SubjectSectionTitle headingLevel={headingLevel}>{messages.heading}</SubjectSectionTitle>
132
134
  <nav id={id}>
133
135
  <StyledTransitionGroup component="ul">
134
136
  {filteredLinks.map((link) => (
@@ -1,6 +1,7 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { breakpoints, mq, spacing } from '@ndla/core';
3
3
  import React, { ReactNode } from 'react';
4
+ import { HeadingLevel } from '../types';
4
5
  import { SubjectSectionTitle } from './Subject';
5
6
 
6
7
  const StyledSubjectSocialContent = styled.div`
@@ -21,9 +22,15 @@ const StyledSection = styled.section`
21
22
  }
22
23
  `;
23
24
 
24
- export const SubjectSocialSection = ({ children, title = '' }: { children: ReactNode; title?: string }) => (
25
+ interface SubjectSocialSectionProps {
26
+ children: ReactNode;
27
+ title?: string;
28
+ headingLevel: HeadingLevel;
29
+ }
30
+
31
+ export const SubjectSocialSection = ({ children, title = '', headingLevel }: SubjectSocialSectionProps) => (
25
32
  <StyledSection>
26
- <SubjectSectionTitle>{title}</SubjectSectionTitle>
33
+ <SubjectSectionTitle headingLevel={headingLevel}>{title}</SubjectSectionTitle>
27
34
  {children}
28
35
  </StyledSection>
29
36
  );
@@ -110,12 +110,13 @@ const messages = {
110
110
  [subjectCategories.ACTIVE_SUBJECTS]: 'Active',
111
111
  [subjectCategories.ARCHIVE_SUBJECTS]: 'Expired',
112
112
  [subjectCategories.BETA_SUBJECTS]: 'Revised',
113
- [subjectTypes.RESOURCE_COLLECTION]: 'Other resources',
113
+ [subjectCategories.OTHER]: 'Other resources',
114
+ [subjectTypes.RESOURCE_COLLECTION]: 'Resource collections',
114
115
  },
115
116
  subjectTypes: {
116
117
  [subjectTypes.BETA_SUBJECT]: 'Betafag',
117
- [subjectTypes.SUBJECT]: 'Subject',
118
118
  [subjectTypes.RESOURCE_COLLECTION]: 'Resource collection',
119
+ [subjectTypes.SUBJECT]: 'Subject',
119
120
  },
120
121
  searchPage: {
121
122
  noHits: 'Your search - {{query}} - did not match any articles. ',
@@ -327,6 +328,7 @@ const messages = {
327
328
  },
328
329
  },
329
330
  menu: {
331
+ goToMainMenu: 'Go to main menu',
330
332
  close: 'Close',
331
333
  goTo: 'Go to',
332
334
  search: 'Search',
@@ -110,12 +110,13 @@ const messages = {
110
110
  [subjectCategories.ACTIVE_SUBJECTS]: 'Aktive',
111
111
  [subjectCategories.ARCHIVE_SUBJECTS]: 'Utgåtte',
112
112
  [subjectCategories.BETA_SUBJECTS]: 'Kommende',
113
- [subjectTypes.RESOURCE_COLLECTION]: 'Andre ressurser',
113
+ [subjectCategories.OTHER]: 'Andre ressurser',
114
+ [subjectTypes.RESOURCE_COLLECTION]: 'Ressurssamlinger',
114
115
  },
115
116
  subjectTypes: {
116
117
  [subjectTypes.BETA_SUBJECT]: 'Betafag',
117
- [subjectTypes.SUBJECT]: 'Fag',
118
118
  [subjectTypes.RESOURCE_COLLECTION]: 'Ressurssamling',
119
+ [subjectTypes.SUBJECT]: 'Fag',
119
120
  },
120
121
  searchPage: {
121
122
  noHits: 'Ingen artikler samsvarte med søket ditt på: {{query}}',
@@ -326,6 +327,7 @@ const messages = {
326
327
  },
327
328
  },
328
329
  menu: {
330
+ goToMainMenu: 'Gå til hovedmeny',
329
331
  close: 'Lukk',
330
332
  goTo: 'Gå til',
331
333
  search: 'Søk',
@@ -110,12 +110,13 @@ const messages = {
110
110
  [subjectCategories.ACTIVE_SUBJECTS]: 'Aktive',
111
111
  [subjectCategories.ARCHIVE_SUBJECTS]: 'Utgåtte',
112
112
  [subjectCategories.BETA_SUBJECTS]: 'Kommande',
113
- [subjectTypes.RESOURCE_COLLECTION]: 'Andre ressursar',
113
+ [subjectCategories.OTHER]: 'Andre ressursar',
114
+ [subjectTypes.RESOURCE_COLLECTION]: 'Ressurssamlingar',
114
115
  },
115
116
  subjectTypes: {
116
117
  [subjectTypes.BETA_SUBJECT]: 'Betafag',
117
- [subjectTypes.SUBJECT]: 'Fag',
118
118
  [subjectTypes.RESOURCE_COLLECTION]: 'Ressurssamling',
119
+ [subjectTypes.SUBJECT]: 'Fag',
119
120
  },
120
121
  searchPage: {
121
122
  noHits: 'Ingen artiklar samsvarte med søket ditt på: {{query}}',
@@ -326,6 +327,7 @@ const messages = {
326
327
  },
327
328
  },
328
329
  menu: {
330
+ goToMainMenu: 'Gå til hovedmeny',
329
331
  close: 'Lukk',
330
332
  goTo: 'Gå til',
331
333
  search: 'Søk',
@@ -110,12 +110,13 @@ const messages = {
110
110
  [subjectCategories.ACTIVE_SUBJECTS]: 'Doaimmas',
111
111
  [subjectCategories.ARCHIVE_SUBJECTS]: 'Ii doaimmas šat',
112
112
  [subjectCategories.BETA_SUBJECTS]: 'Boahttevaš',
113
- [subjectTypes.RESOURCE_COLLECTION]: 'Eará resurssat',
113
+ [subjectCategories.OTHER]: 'Eará resurssat',
114
+ [subjectTypes.RESOURCE_COLLECTION]: 'Resursačoakkáldat',
114
115
  },
115
116
  subjectTypes: {
116
117
  [subjectTypes.BETA_SUBJECT]: 'Betafága',
117
- [subjectTypes.SUBJECT]: 'Fága',
118
118
  [subjectTypes.RESOURCE_COLLECTION]: 'Resursačoakkáldat',
119
+ [subjectTypes.SUBJECT]: 'Fága',
119
120
  },
120
121
  searchPage: {
121
122
  noHits: 'Ii oktage artihkal heiven du ohcamii: {{query}}',
@@ -327,6 +328,7 @@ const messages = {
327
328
  },
328
329
  },
329
330
  menu: {
331
+ goToMainMenu: 'Gå til hovedmeny',
330
332
  close: 'Govčča',
331
333
  goTo: 'Mana deike',
332
334
  search: 'Oza',
@@ -110,12 +110,13 @@ const messages = {
110
110
  [subjectCategories.ACTIVE_SUBJECTS]: 'Aktive',
111
111
  [subjectCategories.ARCHIVE_SUBJECTS]: 'Utgåtte',
112
112
  [subjectCategories.BETA_SUBJECTS]: 'Kommende',
113
- [subjectTypes.RESOURCE_COLLECTION]: 'Andre ressurser',
113
+ [subjectCategories.OTHER]: 'Andre ressurser',
114
+ [subjectTypes.RESOURCE_COLLECTION]: 'Ressurssamlinger',
114
115
  },
115
116
  subjectTypes: {
116
117
  [subjectTypes.BETA_SUBJECT]: 'Betafag',
117
- [subjectTypes.SUBJECT]: 'Fag',
118
118
  [subjectTypes.RESOURCE_COLLECTION]: 'Ressurssamling',
119
+ [subjectTypes.SUBJECT]: 'Fag',
119
120
  },
120
121
  searchPage: {
121
122
  noHits: 'Ingen artikler samsvarte med søket ditt på: {{query}}',
@@ -326,6 +327,7 @@ const messages = {
326
327
  },
327
328
  },
328
329
  menu: {
330
+ goToMainMenu: 'Gå til hovedmeny',
329
331
  close: 'Lukk',
330
332
  goTo: 'Gå til',
331
333
  search: 'Søk',
@@ -7,5 +7,6 @@
7
7
  */
8
8
 
9
9
  export const ACTIVE_SUBJECTS = 'active';
10
- export const BETA_SUBJECTS = 'beta';
11
10
  export const ARCHIVE_SUBJECTS = 'archive';
11
+ export const BETA_SUBJECTS = 'beta';
12
+ export const OTHER = 'otherResources';
package/src/types.ts CHANGED
@@ -120,3 +120,5 @@ export type NotionMedia = {
120
120
  type: 'video' | 'other';
121
121
  element: ReactNode;
122
122
  };
123
+
124
+ export type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5';