@ndla/ui 33.0.5 → 33.0.7

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 (102) hide show
  1. package/es/Footer/FooterPrivacy.js +19 -8
  2. package/es/Image/Image.js +5 -5
  3. package/es/Image/ImageLink.js +5 -5
  4. package/es/ResourcesWrapper/ResourcesTopicTitle.js +63 -31
  5. package/es/ResourcesWrapper/ResourcesWrapper.js +12 -16
  6. package/es/ResourcesWrapper/index.js +0 -1
  7. package/es/SearchTypeResult/SearchItemList.js +11 -11
  8. package/es/Subject/Subject.js +15 -21
  9. package/es/Subject/index.js +1 -6
  10. package/es/all.css +1 -1
  11. package/es/index.js +2 -3
  12. package/es/locale/messages-en.js +1 -1
  13. package/es/locale/messages-nb.js +2 -2
  14. package/es/locale/messages-nn.js +1 -1
  15. package/es/locale/messages-se.js +1 -1
  16. package/es/locale/messages-sma.js +1 -1
  17. package/lib/Footer/FooterPrivacy.js +17 -8
  18. package/lib/Image/Image.js +5 -5
  19. package/lib/Image/ImageLink.js +5 -5
  20. package/lib/ResourcesWrapper/ResourcesTopicTitle.js +62 -30
  21. package/lib/ResourcesWrapper/ResourcesWrapper.d.ts +4 -6
  22. package/lib/ResourcesWrapper/ResourcesWrapper.js +13 -17
  23. package/lib/ResourcesWrapper/index.d.ts +0 -1
  24. package/lib/ResourcesWrapper/index.js +0 -7
  25. package/lib/SearchTypeResult/SearchItemList.js +11 -11
  26. package/lib/Subject/Subject.d.ts +0 -3
  27. package/lib/Subject/Subject.js +16 -23
  28. package/lib/Subject/index.d.ts +1 -6
  29. package/lib/Subject/index.js +0 -41
  30. package/lib/all.css +1 -1
  31. package/lib/index.d.ts +2 -3
  32. package/lib/index.js +0 -57
  33. package/lib/locale/messages-en.js +1 -1
  34. package/lib/locale/messages-nb.js +2 -2
  35. package/lib/locale/messages-nn.js +1 -1
  36. package/lib/locale/messages-se.js +1 -1
  37. package/lib/locale/messages-sma.js +1 -1
  38. package/package.json +6 -6
  39. package/src/Footer/FooterPrivacy.tsx +14 -5
  40. package/src/Image/Image.tsx +0 -2
  41. package/src/Image/ImageLink.tsx +0 -2
  42. package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +0 -6
  43. package/src/LetterFilter/LetterFilter.stories.tsx +1 -1
  44. package/src/MyNdla/Resource/Folder.stories.mdx +1 -1
  45. package/src/Resource/BlockResource.stories.mdx +1 -1
  46. package/src/Resource/Resource.stories.mdx +1 -1
  47. package/src/ResourcesWrapper/ResourcesTopicTitle.tsx +118 -15
  48. package/src/ResourcesWrapper/ResourcesWrapper.tsx +14 -13
  49. package/src/ResourcesWrapper/index.ts +0 -1
  50. package/src/SearchTypeResult/SearchItemList.tsx +1 -0
  51. package/src/Subject/Subject.tsx +0 -4
  52. package/src/Subject/index.ts +0 -6
  53. package/src/index.ts +1 -9
  54. package/src/locale/messages-en.ts +1 -1
  55. package/src/locale/messages-nb.ts +2 -2
  56. package/src/locale/messages-nn.ts +1 -1
  57. package/src/locale/messages-se.ts +1 -1
  58. package/src/locale/messages-sma.ts +1 -1
  59. package/src/main.scss +0 -2
  60. package/es/ResourcesWrapper/ResourcesTitle.js +0 -28
  61. package/es/Subject/SubjectAbout.js +0 -81
  62. package/es/Subject/SubjectArchive.js +0 -203
  63. package/es/Subject/SubjectLinks.js +0 -53
  64. package/es/Subject/SubjectShortcuts.js +0 -136
  65. package/es/TopicIntroductionList/TopicIntroduction.js +0 -90
  66. package/es/TopicIntroductionList/TopicIntroductionList.js +0 -68
  67. package/es/TopicIntroductionList/TopicIntroductionShortcuts.js +0 -86
  68. package/es/TopicIntroductionList/TopicShortcutItem.js +0 -43
  69. package/es/TopicIntroductionList/index.js +0 -10
  70. package/lib/ResourcesWrapper/ResourcesTitle.d.ts +0 -13
  71. package/lib/ResourcesWrapper/ResourcesTitle.js +0 -27
  72. package/lib/Subject/SubjectAbout.d.ts +0 -12
  73. package/lib/Subject/SubjectAbout.js +0 -88
  74. package/lib/Subject/SubjectArchive.d.ts +0 -32
  75. package/lib/Subject/SubjectArchive.js +0 -211
  76. package/lib/Subject/SubjectLinks.d.ts +0 -12
  77. package/lib/Subject/SubjectLinks.js +0 -60
  78. package/lib/Subject/SubjectShortcuts.d.ts +0 -34
  79. package/lib/Subject/SubjectShortcuts.js +0 -137
  80. package/lib/TopicIntroductionList/TopicIntroduction.d.ts +0 -21
  81. package/lib/TopicIntroductionList/TopicIntroduction.js +0 -97
  82. package/lib/TopicIntroductionList/TopicIntroductionList.d.ts +0 -35
  83. package/lib/TopicIntroductionList/TopicIntroductionList.js +0 -67
  84. package/lib/TopicIntroductionList/TopicIntroductionShortcuts.d.ts +0 -8
  85. package/lib/TopicIntroductionList/TopicIntroductionShortcuts.js +0 -96
  86. package/lib/TopicIntroductionList/TopicShortcutItem.d.ts +0 -6
  87. package/lib/TopicIntroductionList/TopicShortcutItem.js +0 -50
  88. package/lib/TopicIntroductionList/index.d.ts +0 -9
  89. package/lib/TopicIntroductionList/index.js +0 -17
  90. package/src/ResourcesWrapper/ResourcesTitle.tsx +0 -23
  91. package/src/ResourcesWrapper/component.resources.scss +0 -216
  92. package/src/Subject/SubjectAbout.tsx +0 -116
  93. package/src/Subject/SubjectArchive.tsx +0 -221
  94. package/src/Subject/SubjectLinks.tsx +0 -47
  95. package/src/Subject/SubjectShortcuts.tsx +0 -158
  96. package/src/TopicIntroductionList/TopicIntroduction.tsx +0 -100
  97. package/src/TopicIntroductionList/TopicIntroductionList.tsx +0 -93
  98. package/src/TopicIntroductionList/TopicIntroductionShortcuts.tsx +0 -71
  99. package/src/TopicIntroductionList/TopicShortcutItem.tsx +0 -29
  100. package/src/TopicIntroductionList/component.topic-introduction.scss +0 -111
  101. package/src/TopicIntroductionList/component.topic-shortcuts.scss +0 -90
  102. package/src/TopicIntroductionList/index.ts +0 -11
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
9
- var _tooltip = _interopRequireDefault(require("@ndla/tooltip"));
10
- var _safelink = _interopRequireDefault(require("@ndla/safelink"));
11
- var _reactI18next = require("react-i18next");
12
- var _ContentTypeBadge = _interopRequireDefault(require("../ContentTypeBadge"));
13
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
- var classes = new _reactBemHelper["default"]({
19
- name: 'topic-shortcuts',
20
- prefix: 'c-'
21
- });
22
- var ShortcutItem = function ShortcutItem(_ref) {
23
- var _ref$shortcut = _ref.shortcut,
24
- id = _ref$shortcut.id,
25
- tooltip = _ref$shortcut.tooltip,
26
- contentType = _ref$shortcut.contentType,
27
- url = _ref$shortcut.url,
28
- count = _ref$shortcut.count;
29
- var _useTranslation = (0, _reactI18next.useTranslation)(),
30
- t = _useTranslation.t;
31
- return (0, _jsxRuntime.jsx)(_tooltip["default"], {
32
- id: "shortcut-tooltip-".concat(id),
33
- tooltip: t('resource.shortcutsTooltip', {
34
- count: count
35
- }),
36
- children: (0, _jsxRuntime.jsxs)(_safelink["default"], _objectSpread(_objectSpread({}, classes('item-link')), {}, {
37
- "aria-label": tooltip,
38
- to: url,
39
- children: [(0, _jsxRuntime.jsx)(_ContentTypeBadge["default"], {
40
- type: contentType,
41
- size: "x-small",
42
- background: true
43
- }), (0, _jsxRuntime.jsx)("span", _objectSpread(_objectSpread({}, classes('count')), {}, {
44
- children: count
45
- }))]
46
- }))
47
- });
48
- };
49
- var _default = ShortcutItem;
50
- exports["default"] = _default;
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) 2018-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
- import TopicIntroductionList from './TopicIntroductionList';
9
- export default TopicIntroductionList;
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _TopicIntroductionList = _interopRequireDefault(require("./TopicIntroductionList"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9
- /**
10
- * Copyright (c) 2018-present, NDLA.
11
- *
12
- * This source code is licensed under the GPLv3 license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- *
15
- */
16
- var _default = _TopicIntroductionList["default"];
17
- exports["default"] = _default;
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-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, { ReactNode } from 'react';
10
- import { classes } from './ResourcesWrapper';
11
- import { SubjectBadge } from '../ContentTypeBadge';
12
-
13
- interface Props {
14
- children: ReactNode;
15
- }
16
- const ResourceTitle = ({ children }: Props) => (
17
- <div {...classes('title-wrapper')}>
18
- <SubjectBadge size="large" background />
19
- <h1 {...classes('title')}>{children}</h1>
20
- </div>
21
- );
22
-
23
- export default ResourceTitle;
@@ -1,216 +0,0 @@
1
- /**
2
- ** RESOURCES
3
- ** Wrapper for resources, titles for resource types
4
- **/
5
-
6
- .c-resources {
7
- padding-top: $spacing;
8
- padding-bottom: $spacing;
9
-
10
- .c-filter__list--float-right {
11
- flex-grow: 1;
12
- justify-content: flex-end;
13
- }
14
- .c-filter__text {
15
- white-space: nowrap;
16
- }
17
-
18
- &__topic-title-icon {
19
- color: $brand-color;
20
- flex-grow: 1;
21
- justify-content: flex-end;
22
- border: 0;
23
- outline: 0;
24
- background: transparent;
25
- // dual coloured icon..
26
- .HelpCircleDual-background {
27
- fill: $brand-color--light;
28
- }
29
- .HelpCircleDual-symbol {
30
- fill: $brand-color--dark;
31
- }
32
- &:hover,
33
- &:focus {
34
- .HelpCircleDual-background {
35
- fill: $brand-color;
36
- }
37
- .HelpCircleDual-symbol {
38
- fill: #fff;
39
- }
40
- }
41
- &--invertedStyle {
42
- .HelpCircleDual-background {
43
- fill: #fff;
44
- }
45
- .HelpCircleDual-symbol {
46
- fill: $brand-color;
47
- }
48
- &:hover,
49
- &:focus {
50
- .HelpCircleDual-background {
51
- fill: #fff;
52
- }
53
- .HelpCircleDual-symbol {
54
- fill: $brand-color;
55
- }
56
- }
57
- }
58
- }
59
-
60
- &__title {
61
- display: block;
62
- @include inuit-font-size(16px, 18px);
63
- font-weight: $font-weight-bold;
64
- text-transform: uppercase;
65
- letter-spacing: 0.05em;
66
- margin: 0;
67
- }
68
-
69
- &__title-wrapper {
70
- display: flex;
71
- align-items: center;
72
- padding-bottom: $spacing--small / 2;
73
- margin-top: $spacing--medium;
74
-
75
- .c-content-type-badge {
76
- display: none;
77
- margin-right: $spacing--medium + 2px;
78
- }
79
- }
80
-
81
- &__topic-title-wrapper {
82
- display: inline-flex;
83
- flex-flow: wrap;
84
- align-items: center;
85
- margin-top: $spacing--large;
86
- padding-bottom: $spacing--small;
87
- width: 100%;
88
- flex-direction: row;
89
- justify-content: space-between;
90
- align-items: center;
91
- &--invertedStyle {
92
- color: #fff;
93
- }
94
- > div {
95
- display: inline-flex;
96
- flex-wrap: wrap;
97
- align-items: center;
98
- .c-filter__list {
99
- width: auto;
100
- }
101
- .c-filter__item {
102
- margin-right: $spacing--small / 2;
103
- }
104
- &:last-child {
105
- padding: $spacing--small / 2 0;
106
- }
107
- }
108
- @include mq($until: mobileWide) {
109
- .c-filter__list--filter-single-checkbox {
110
- margin-top: $spacing--small !important;
111
- }
112
- .c-filter__list + div {
113
- display: none;
114
- }
115
- > div {
116
- display: block;
117
- }
118
- }
119
- @include mq($until: tablet) {
120
- display: block;
121
- }
122
- }
123
-
124
- .c-resources__topic-title-icon {
125
- padding-right: 0;
126
- }
127
-
128
- &__topic-title-label {
129
- font-family: $font;
130
- @include font-size(18px, 24px);
131
- font-weight: $font-weight-bold;
132
- text-transform: uppercase;
133
- letter-spacing: 0.05em;
134
- margin: 0 $spacing--small / 2 0 0;
135
- @include mq(tablet) {
136
- margin-right: $spacing--small;
137
- @include font-size(20px, 26px);
138
- }
139
- }
140
-
141
- &__topic-title {
142
- font-weight: $font-weight-normal;
143
- @include font-size(18px, 24px);
144
- @include mq(tablet) {
145
- @include font-size(20px, 26px);
146
- }
147
- margin: 0;
148
- &--single {
149
- font-weight: $font-weight-bold;
150
- text-transform: uppercase;
151
- }
152
- }
153
-
154
- &__topic-title-link {
155
- color: $brand-color;
156
- }
157
-
158
- &__topic-filter-wrapper {
159
- display: flex;
160
- width: 100%;
161
- @include mq(tablet) {
162
- width: auto;
163
- flex-grow: 1;
164
- background: green;
165
- }
166
- }
167
-
168
- &--subjectPage {
169
- padding-top: 0;
170
- padding-bottom: 0;
171
-
172
- .c-resources {
173
- &__title-wrapper {
174
- margin-top: 0;
175
-
176
- .c-content-type-badge {
177
- display: none;
178
-
179
- @include mq(tablet) {
180
- display: inline-flex;
181
- }
182
- }
183
- }
184
-
185
- &__content {
186
- @include mq(tablet) {
187
- margin-left: $spacing--medium + $spacing--large;
188
- }
189
- }
190
-
191
- &__title {
192
- @include inuit-font-size(16px, 32px);
193
-
194
- @include mq(tablet) {
195
- @include inuit-font-size(22px, 32px);
196
- }
197
- }
198
-
199
- &__title-wrapper {
200
- margin-left: $spacing;
201
- margin-right: $spacing;
202
-
203
- @include mq(tablet) {
204
- margin-left: 0;
205
- margin-right: 0;
206
- }
207
- }
208
- }
209
-
210
- .c-topic-introduction__list {
211
- @include mq($until: tablet) {
212
- padding: 0 $spacing;
213
- }
214
- }
215
- }
216
- }
@@ -1,116 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { css } from '@emotion/react';
3
- import styled from '@emotion/styled';
4
- import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
5
- import SectionHeading from '../SectionHeading';
6
- import { HeadingLevel } from '../types';
7
-
8
- interface Props {
9
- fixedWidth?: boolean;
10
- wide?: boolean;
11
- media: ReactNode;
12
- heading: string;
13
- description: string;
14
- headingLevel: HeadingLevel;
15
- }
16
-
17
- interface SubjectAboutSectionProps {
18
- fixedWidth: boolean;
19
- wide: boolean;
20
- }
21
-
22
- const SubjectAboutSection = styled.section<SubjectAboutSectionProps>`
23
- margin-bottom: ${spacing.large};
24
- max-width: ${(p) => p.fixedWidth && '350px'};
25
-
26
- ${(p) =>
27
- p.wide &&
28
- css`
29
- margin: 40px 0;
30
- ${mq.range({ from: breakpoints.tablet })} {
31
- display: flex;
32
- margin: 80px 0;
33
- }
34
- `};
35
- ${mq.range({ from: breakpoints.tablet })} {
36
- border: 1px solid ${colors.brand.greyLight};
37
- }
38
- `;
39
-
40
- const StyledSectionHeading = styled(SectionHeading)`
41
- margin: 0 0 ${spacing.small} 0;
42
- ${mq.range({ from: breakpoints.tablet })} {
43
- display: none;
44
- }
45
- `;
46
-
47
- interface MediaWrapperProps {
48
- wide?: boolean;
49
- }
50
-
51
- const MediaWrapper = styled.div<MediaWrapperProps>`
52
- width: 100%;
53
- display: flex;
54
- justify-content: center;
55
- align-items: center;
56
- text-align: center;
57
- & > *,
58
- img {
59
- width: 100%;
60
- }
61
- ${mq.range({ from: breakpoints.tablet })} {
62
- width: 50%;
63
- min-width: 50%;
64
- }
65
- ${mq.range({ from: breakpoints.desktop })} {
66
- width: 40%;
67
- min-width: 40%;
68
- }
69
- ${(p) =>
70
- p.wide &&
71
- css`
72
- margin: 40px 0;
73
- ${mq.range({ from: breakpoints.tablet })} {
74
- display: flex;
75
- margin: 80px 0;
76
- }
77
- `};
78
- `;
79
-
80
- const StyledContent = styled.div`
81
- padding: ${spacing.small} 0 0 0;
82
- ${mq.range({ from: breakpoints.tablet })} {
83
- padding: ${spacing.normal};
84
- }
85
- `;
86
-
87
- const StyledMainHeading = styled.h1`
88
- margin: 0 0 ${spacing.small} 0;
89
- ${fonts.sizes('14px', '32px')};
90
- text-transform: uppercase;
91
- font-weight: ${fonts.weight.bold};
92
- display: none;
93
- ${mq.range({ from: breakpoints.tablet })} {
94
- display: block;
95
- }
96
- `;
97
-
98
- const StyledDescription = styled.p`
99
- margin: 0;
100
- ${fonts.sizes('16px', '26px')};
101
- `;
102
-
103
- const SubjectAbout = ({ fixedWidth = false, media, heading, description, wide = false, headingLevel }: Props) => (
104
- <SubjectAboutSection wide={wide} fixedWidth={fixedWidth}>
105
- <StyledSectionHeading headingLevel={headingLevel} large>
106
- {heading}
107
- </StyledSectionHeading>
108
- <MediaWrapper>{media}</MediaWrapper>
109
- <StyledContent>
110
- <StyledMainHeading>{heading}</StyledMainHeading>
111
- <StyledDescription>{description}</StyledDescription>
112
- </StyledContent>
113
- </SubjectAboutSection>
114
- );
115
-
116
- export default SubjectAbout;
@@ -1,221 +0,0 @@
1
- import React, { ReactNode, Component, createRef, RefObject } from 'react';
2
- import styled from '@emotion/styled';
3
- import { Forward } from '@ndla/icons/common';
4
- import { Cross } from '@ndla/icons/action';
5
- import { breakpoints, colors, fonts, mq, spacing, utils } from '@ndla/core';
6
- import SafeLink from '@ndla/safelink';
7
- import SectionHeading from '../SectionHeading';
8
- import { HeadingLevel } from '../types';
9
-
10
- interface Props {
11
- featuringArticle: {
12
- media: ReactNode;
13
- heading: string;
14
- description: string;
15
- url: string;
16
- };
17
- headingLevel: HeadingLevel;
18
- archiveArticles: { url: string; heading: string }[];
19
- sectionHeading: string;
20
- fixedWidth?: boolean;
21
- messages: { archive: string; close: string };
22
- }
23
-
24
- interface State {
25
- archiveOpen: boolean;
26
- minHeight: number | null;
27
- }
28
-
29
- interface SubjectArchiveSectionProps {
30
- fixedWidth: boolean;
31
- animate: boolean;
32
- }
33
-
34
- const ArchiveWrapper = styled.div`
35
- display: flex;
36
- flex-flow: column;
37
- `;
38
-
39
- const StyledSectionHeading = styled(SectionHeading)`
40
- margin: 0 0 ${spacing.small} 0;
41
- ${mq.range({ from: breakpoints.tablet })} {
42
- ${utils.visuallyHidden};
43
- }
44
- `;
45
-
46
- const ArchiveButon = styled.button`
47
- display: inline-flex;
48
- align-items: center;
49
- cursor: pointer;
50
- margin: ${spacing.small} 0 0 0;
51
- padding: ${spacing.xsmall} 0;
52
- border: 0;
53
- color: ${colors.brand.primary};
54
- ${fonts.sizes('16px', '24px')};
55
- font-weight: ${fonts.weight.semibold};
56
- ${mq.range({ from: breakpoints.tablet })} {
57
- margin: ${spacing.xsmall} ${spacing.normal} ${spacing.normal};
58
- }
59
- c-icon {
60
- width: 18px;
61
- height: 18px;
62
- margin-right: ${spacing.small};
63
- }
64
- `;
65
-
66
- interface StyledNavProps {
67
- animate: boolean;
68
- }
69
- const StyledNav = styled.nav<StyledNavProps>`
70
- padding: 0;
71
- animation: ${(p) => p.animate && 'fadeIn 0.3s ease-in-out'};
72
- ${mq.range({ from: breakpoints.tablet })} {
73
- padding: ${spacing.large} ${spacing.large} 0 ${spacing.large};
74
- }
75
- `;
76
-
77
- const StyledArchiveList = styled.ul`
78
- list-style: none;
79
- margin: 0;
80
- padding: 0;
81
-
82
- li {
83
- ${fonts.sizes('16px', '24px')};
84
- margin-bottom: ${spacing.small};
85
- }
86
- `;
87
-
88
- const MediaWrapper = styled.div`
89
- width: 100%;
90
- & > * {
91
- width: 100%;
92
- }
93
- `;
94
-
95
- const StyledContent = styled.div`
96
- padding: ${spacing.small} 0 0 0;
97
- ${mq.range({ from: breakpoints.tablet })} {
98
- padding: ${spacing.normal};
99
- }
100
- `;
101
-
102
- const StyledHeading = styled.h1`
103
- ${fonts.sizes('20px', '32px')};
104
- margin: 0 0 ${spacing.small} 0;
105
- flex: 0 0 auto;
106
- `;
107
-
108
- const StyledDescription = styled.p`
109
- margin: 0;
110
- ${fonts.sizes('16px', '26px')}
111
- `;
112
-
113
- const SubjectArchiveSection = styled.section<SubjectArchiveSectionProps>`
114
- margin-bottom: ${spacing.large};
115
- display: flex;
116
- flex-direction: column;
117
- max-width: ${(p) => p.fixedWidth && '350px'};
118
- animation: ${(p) => p.animate && 'fadeIn 0.3s ease-in-out'};
119
-
120
- ${mq.range({ from: breakpoints.tablet })} {
121
- border: 1px solid ${colors.brand.greyLight};
122
- }
123
- `;
124
-
125
- interface FeaturingSectionProps {
126
- animate: boolean;
127
- }
128
- const FeaturingSection = styled.section<FeaturingSectionProps>`
129
- animation: ${(p) => p.animate && 'fadeIn 0.3s ease-in-out'};
130
- `;
131
-
132
- class SubjectArchive extends Component<Props, State> {
133
- wrapperRef: RefObject<HTMLElement> | null = createRef<HTMLElement>();
134
- constructor(props: Props) {
135
- super(props);
136
- this.state = {
137
- archiveOpen: false,
138
- minHeight: null,
139
- };
140
-
141
- this.handleToggleArchive = this.handleToggleArchive.bind(this);
142
- }
143
-
144
- handleToggleArchive() {
145
- this.setState((prevState) => {
146
- const newState: State = {
147
- archiveOpen: !prevState.archiveOpen,
148
- minHeight: null,
149
- };
150
-
151
- if (!prevState.minHeight) {
152
- newState.minHeight = this.wrapperRef?.current?.offsetHeight ?? null;
153
- }
154
-
155
- return newState;
156
- });
157
- }
158
-
159
- render() {
160
- const {
161
- fixedWidth = false,
162
- headingLevel,
163
- featuringArticle,
164
- messages,
165
- sectionHeading,
166
- archiveArticles,
167
- } = this.props;
168
-
169
- const archiveId = 'subject-archive';
170
-
171
- const section = this.state.archiveOpen ? (
172
- <StyledNav id={archiveId} animate={!!this.state.minHeight}>
173
- <StyledArchiveList>
174
- {archiveArticles.map((article) => (
175
- <li key={article.heading}>
176
- <SafeLink to={article.url}>{article.heading}</SafeLink>
177
- </li>
178
- ))}
179
- </StyledArchiveList>
180
- </StyledNav>
181
- ) : (
182
- <FeaturingSection animate={!!this.state.minHeight}>
183
- <MediaWrapper>{featuringArticle.media}</MediaWrapper>
184
- <StyledContent>
185
- <StyledHeading>
186
- <SafeLink to={featuringArticle.url}>{featuringArticle.heading}</SafeLink>
187
- </StyledHeading>
188
- <StyledDescription>{featuringArticle.description}</StyledDescription>
189
- </StyledContent>
190
- </FeaturingSection>
191
- );
192
-
193
- return (
194
- <SubjectArchiveSection animate={!!this.state.minHeight} fixedWidth={fixedWidth} ref={this.wrapperRef}>
195
- <StyledSectionHeading headingLevel={headingLevel} large>
196
- {sectionHeading}
197
- </StyledSectionHeading>
198
- <ArchiveWrapper>
199
- {section}
200
- <ArchiveButon
201
- type="button"
202
- aria-expanded={this.state.archiveOpen}
203
- aria-controls={archiveId}
204
- onClick={this.handleToggleArchive}>
205
- {this.state.archiveOpen ? (
206
- <>
207
- <Cross /> <span>{messages.close}</span>
208
- </>
209
- ) : (
210
- <>
211
- <Forward /> <span>{messages.archive}</span>
212
- </>
213
- )}
214
- </ArchiveButon>
215
- </ArchiveWrapper>
216
- </SubjectArchiveSection>
217
- );
218
- }
219
- }
220
-
221
- export default SubjectArchive;
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import styled from '@emotion/styled';
3
- import { spacing } from '@ndla/core';
4
- import SafeLink, { SafeLinkProps } from '@ndla/safelink';
5
-
6
- import { SubjectSectionTitle } from './Subject';
7
- import { HeadingLevel } from '../types';
8
-
9
- const SubjectLinksSection = styled.section`
10
- margin-bottom: ${spacing.large};
11
- `;
12
-
13
- const StyledSubjectSectionTitle = styled(SubjectSectionTitle)`
14
- margin: 0 0 ${spacing.small} 0;
15
- `;
16
-
17
- const SubjectLinksList = styled.ul`
18
- margin: 0;
19
- padding: 0;
20
- list-style: none;
21
- `;
22
-
23
- interface Props {
24
- headingLevel: HeadingLevel;
25
- links: {
26
- toLinkProps: () => SafeLinkProps;
27
- text: string;
28
- }[];
29
- heading: string;
30
- }
31
-
32
- const SubjectLinks = ({ links, heading, headingLevel }: Props) => (
33
- <SubjectLinksSection>
34
- <StyledSubjectSectionTitle headingLevel={headingLevel}>{heading}</StyledSubjectSectionTitle>
35
- <nav>
36
- <SubjectLinksList>
37
- {links.map((link) => (
38
- <li key={link.toLinkProps().to.toString()}>
39
- <SafeLink {...link.toLinkProps()}>{link.text}</SafeLink>
40
- </li>
41
- ))}
42
- </SubjectLinksList>
43
- </nav>
44
- </SubjectLinksSection>
45
- );
46
-
47
- export default SubjectLinks;