@ndla/ui 15.2.0 → 16.1.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 (58) hide show
  1. package/es/Article/ArticleContent.js +2 -0
  2. package/es/FileList/File.js +7 -12
  3. package/es/Filter/FilterButtons.js +13 -13
  4. package/es/NDLAFilm/CategorySelect.js +51 -25
  5. package/es/NDLAFilm/FilmMovieList.js +14 -10
  6. package/es/NDLAFilm/FilmMovieSearch.js +23 -10
  7. package/es/NDLAFilm/FilmSlideshow.js +117 -19
  8. package/es/NDLAFilm/MovieGrid.js +23 -14
  9. package/es/NDLAFilm/NavigationArrow.js +33 -7
  10. package/es/NDLAFilm/SlideshowIndicator.js +27 -11
  11. package/es/NDLAFilm/filmStyles.js +23 -0
  12. package/es/RadioButtonGroup/RadioButtonGroup.js +28 -9
  13. package/es/Resource/resourceComponents.js +17 -9
  14. package/es/TreeStructure/TreeStructure.js +6 -9
  15. package/es/all.css +1 -1
  16. package/lib/Article/ArticleContent.js +3 -0
  17. package/lib/FileList/File.js +10 -14
  18. package/lib/Filter/FilterButtons.js +13 -13
  19. package/lib/Frontpage/FrontpageMultidisciplinarySubject.d.ts +5 -5
  20. package/lib/Frontpage/illustrations/FrontpageIllustrations.d.ts +2 -2
  21. package/lib/MultidisciplinarySubject/Illustrations.d.ts +7 -7
  22. package/lib/NDLAFilm/CategorySelect.js +52 -30
  23. package/lib/NDLAFilm/FilmMovieList.js +17 -13
  24. package/lib/NDLAFilm/FilmMovieSearch.js +29 -17
  25. package/lib/NDLAFilm/FilmSlideshow.js +113 -24
  26. package/lib/NDLAFilm/MovieGrid.js +26 -16
  27. package/lib/NDLAFilm/NavigationArrow.d.ts +5 -1
  28. package/lib/NDLAFilm/NavigationArrow.js +34 -10
  29. package/lib/NDLAFilm/SlideshowIndicator.js +34 -13
  30. package/lib/NDLAFilm/filmStyles.d.ts +8 -0
  31. package/lib/NDLAFilm/filmStyles.js +38 -0
  32. package/lib/RadioButtonGroup/RadioButtonGroup.js +28 -13
  33. package/lib/Resource/resourceComponents.d.ts +2 -2
  34. package/lib/Resource/resourceComponents.js +17 -9
  35. package/lib/Search/ContentTypeResultStyles.d.ts +3 -3
  36. package/lib/SearchTypeResult/ActiveFilterContent.d.ts +1 -1
  37. package/lib/TreeStructure/TreeStructure.js +6 -9
  38. package/lib/all.css +1 -1
  39. package/package.json +7 -7
  40. package/src/Article/ArticleContent.tsx +2 -0
  41. package/src/FileList/File.tsx +8 -11
  42. package/src/Filter/FilterButtons.tsx +3 -4
  43. package/src/NDLAFilm/CategorySelect.tsx +110 -23
  44. package/src/NDLAFilm/FilmMovieList.tsx +13 -11
  45. package/src/NDLAFilm/FilmMovieSearch.tsx +45 -14
  46. package/src/NDLAFilm/FilmSlideshow.tsx +186 -25
  47. package/src/NDLAFilm/MovieGrid.tsx +33 -25
  48. package/src/NDLAFilm/NavigationArrow.tsx +76 -10
  49. package/src/NDLAFilm/SlideshowIndicator.tsx +53 -11
  50. package/src/NDLAFilm/component.film-movielist.scss +0 -46
  51. package/src/NDLAFilm/filmStyles.ts +33 -0
  52. package/src/RadioButtonGroup/RadioButtonGroup.tsx +82 -11
  53. package/src/Resource/resourceComponents.tsx +1 -3
  54. package/src/TreeStructure/TreeStructure.tsx +5 -11
  55. package/src/main.scss +0 -3
  56. package/src/NDLAFilm/component.film-moviesearch.scss +0 -127
  57. package/src/NDLAFilm/component.film-slideshow.scss +0 -258
  58. package/src/RadioButtonGroup/component.radio-button-group.scss +0 -67
@@ -7,10 +7,9 @@
7
7
  */
8
8
 
9
9
  import React, { Fragment, Component, ChangeEvent } from 'react';
10
- import BEMHelper from 'react-bem-helper';
10
+ import styled from '@emotion/styled';
11
11
  import { uuid } from '@ndla/util';
12
-
13
- const classes = BEMHelper('c-radio-button-group');
12
+ import { spacing, fonts, colors } from '@ndla/core';
14
13
 
15
14
  interface Props {
16
15
  selected?: string;
@@ -28,6 +27,81 @@ interface State {
28
27
  selected: string;
29
28
  }
30
29
 
30
+ const RadioButtonGroupWrapper = styled.div`
31
+ padding: ${spacing.small} 0;
32
+ font-family: ${fonts.sans};
33
+ display: flex;
34
+ align-items: center;
35
+ `;
36
+
37
+ const RadioButtonGroupLabelHeading = styled.h1`
38
+ ${fonts.sizes('16px', '20px')};
39
+ margin: 0 ${spacing.normal} 0 0;
40
+ font-weight: 600;
41
+ `;
42
+
43
+ const RadioButtonGroupLabel = styled.label`
44
+ ${fonts.sizes('16px', '28px')};
45
+ color: ${colors.brand.primary};
46
+ align-items: center;
47
+ display: inline-flex;
48
+ &:before {
49
+ content: '';
50
+ margin-right: ${spacing.small};
51
+ width: 20px;
52
+ height: 20px;
53
+ border-radius: 100%;
54
+ border: 2px solid ${colors.brand.tertiary};
55
+ transition: 200ms border-color ease;
56
+ }
57
+ &:after {
58
+ content: '';
59
+ background: transparent;
60
+ width: 10px;
61
+ height: 10px;
62
+ border-radius: 100%;
63
+ position: absolute;
64
+ transform: translateX(5px) scale(0, 0);
65
+ transition: 200ms all ease;
66
+ }
67
+ &:not(:last-child) {
68
+ margin-right: ${spacing.medium};
69
+ }
70
+ `;
71
+
72
+ const RadioButtonGroupInput = styled.input`
73
+ opacity: 0;
74
+ position: absolute;
75
+ width: auto;
76
+ &:hover + ${RadioButtonGroupLabel} {
77
+ outline: 1px dotted #212121;
78
+ outline: -webkit-focus-ring-color auto 5px;
79
+ &:after {
80
+ transform: translateX(5px) scale(1, 1);
81
+ background: ${colors.brand.tertiary};
82
+ }
83
+ }
84
+ // emotion does not seem to support several selectors combined with targeting another emotion component
85
+ // so we duplicate the css for :hover and :focus.
86
+ &:focus + ${RadioButtonGroupLabel} {
87
+ outline: 1px dotted #212121;
88
+ outline: -webkit-focus-ring-color auto 5px;
89
+ &:after {
90
+ transform: translateX(5px) scale(1, 1);
91
+ background: ${colors.brand.tertiary};
92
+ }
93
+ }
94
+ &:checked + ${RadioButtonGroupLabel} {
95
+ &:before {
96
+ border-color: ${colors.brand.primary};
97
+ }
98
+ &:after {
99
+ transform: translateX(5px) scale(1, 1);
100
+ background: ${colors.brand.primary};
101
+ }
102
+ }
103
+ `;
104
+
31
105
  class RadioButtonGroup extends Component<Props, State> {
32
106
  private readonly uuid?: string;
33
107
  constructor(props: Props) {
@@ -49,14 +123,13 @@ class RadioButtonGroup extends Component<Props, State> {
49
123
  render() {
50
124
  return (
51
125
  <section>
52
- <div role="radiogroup" {...classes('wrapper')}>
53
- {this.props.label && <h1 {...classes('label-heading')}>{this.props.label}</h1>}
126
+ <RadioButtonGroupWrapper role="radiogroup">
127
+ {this.props.label && <RadioButtonGroupLabelHeading>{this.props.label}</RadioButtonGroupLabelHeading>}
54
128
  {this.props.options.map((option) => {
55
129
  const id = this.uuid ? `${this.uuid}_${option.value}` : option.value;
56
130
  return (
57
131
  <Fragment key={option.value}>
58
- <input
59
- {...classes('input')}
132
+ <RadioButtonGroupInput
60
133
  disabled={option.disabled}
61
134
  aria-checked={this.state.selected === option.value}
62
135
  checked={this.state.selected === option.value}
@@ -66,13 +139,11 @@ class RadioButtonGroup extends Component<Props, State> {
66
139
  name={id}
67
140
  onChange={this.handleOnChange}
68
141
  />
69
- <label htmlFor={id} {...classes('label')}>
70
- {option.title}
71
- </label>
142
+ <RadioButtonGroupLabel htmlFor={id}>{option.title}</RadioButtonGroupLabel>
72
143
  </Fragment>
73
144
  );
74
145
  })}
75
- </div>
146
+ </RadioButtonGroupWrapper>
76
147
  </section>
77
148
  );
78
149
  }
@@ -17,10 +17,8 @@ export interface ResourceImageProps {
17
17
  src: string;
18
18
  }
19
19
 
20
- export const ResourceTitle = styled.h2`
21
- ${fonts.sizes(18)};
20
+ export const ResourceTitle = styled.h3`
22
21
  min-width: 50px;
23
- font-weight: ${fonts.weight.bold};
24
22
  margin: 0;
25
23
  flex: 1;
26
24
  overflow: hidden;
@@ -8,7 +8,7 @@
8
8
 
9
9
  import React, { useEffect, useState, useRef, useMemo } from 'react';
10
10
  import { uuid } from '@ndla/util';
11
- import Button from '@ndla/button';
11
+ import { AddButton } from '@ndla/button';
12
12
  import Tooltip from '@ndla/tooltip';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import styled from '@emotion/styled';
@@ -118,9 +118,6 @@ const TreeStructure = ({
118
118
  setFocusedFolderId(id);
119
119
  };
120
120
 
121
- const disableAddFolderButton =
122
- markedFolderId === undefined || getPathOfFolder(data, markedFolderId).length >= MAX_LEVEL_FOR_FOLDERS;
123
-
124
121
  return (
125
122
  <div
126
123
  ref={treestructureRef}
@@ -163,17 +160,14 @@ const TreeStructure = ({
163
160
  tooltip={t('myNdla.newFolderUnder', {
164
161
  folderName: getFolderName(data, markedFolderId),
165
162
  })}>
166
- <Button
167
- size="small"
168
- light
169
- disabled={disableAddFolderButton}
163
+ <AddButton
164
+ aria-label={t('myNdla.newFolder')}
170
165
  onClick={() => {
171
166
  const paths = getPathOfFolder(data, markedFolderId || '');
172
167
  const idPaths = getIdPathsOfFolder(data, markedFolderId || '');
173
168
  setNewFolder({ idPaths, parentId: paths[paths.length - 1] });
174
- }}>
175
- {t('myNdla.newFolder')}
176
- </Button>
169
+ }}
170
+ />
177
171
  </Tooltip>
178
172
  </AddFolderWrapper>
179
173
  )}
package/src/main.scss CHANGED
@@ -40,7 +40,4 @@
40
40
  @import 'FileList/component.file-list';
41
41
  @import 'SectionHeading/component.section-heading';
42
42
  @import 'AuthorInfo/component.author-info';
43
- @import 'RadioButtonGroup/component.radio-button-group';
44
- @import 'NDLAFilm/component.film-slideshow';
45
43
  @import 'NDLAFilm/component.film-movielist';
46
- @import 'NDLAFilm/component.film-moviesearch';
@@ -1,127 +0,0 @@
1
- .c-film-moviesearch {
2
- margin: $spacing 0 $spacing--large;
3
- &__topic-navigation {
4
- margin: $spacing 0;
5
- @include mq(tablet) {
6
- display: flex;
7
- align-items: flex-start;
8
- padding: 0 $spacing;
9
- }
10
- ul {
11
- list-style-type: none;
12
- list-style-image: none;
13
- display: flex;
14
- align-items: flex-start;
15
- flex-wrap: wrap;
16
- padding: 0;
17
- margin: $spacing--small 0;
18
- @include mq(tablet) {
19
- padding-left: $spacing;
20
- }
21
- li {
22
- padding: 0;
23
- width: 100%;
24
- @include mq(tablet) {
25
- width: 50%;
26
- }
27
- a {
28
- color: #fff;
29
- &:hover,
30
- &:focus {
31
- color: $brand-color--light;
32
- }
33
- }
34
- }
35
- }
36
- }
37
- &__dropdown-button {
38
- border-radius: $border-radius;
39
- @include font-size(22px, 26px);
40
- border: 0;
41
- text-transform: uppercase;
42
- background: $film-color-bright;
43
- color: #fff;
44
- padding: $spacing--small $spacing--small * 1.5;
45
- font-weight: $font-weight-semibold;
46
- display: flex;
47
- align-items: center;
48
- text-align: left;
49
- justify-content: space-between;
50
- width: 100%;
51
- letter-spacing: 0.05em;
52
- @include mq(tablet) {
53
- padding: $spacing--small $spacing;
54
- }
55
- div:first-child {
56
- @include mq($until: tablet) {
57
- display: flex;
58
- flex-direction: column;
59
- small {
60
- padding: 0;
61
- }
62
- }
63
- }
64
- small {
65
- text-transform: none;
66
- padding-left: $spacing--small;
67
- font-weight: normal;
68
- }
69
- }
70
- &__dropdown-container {
71
- position: relative;
72
- margin: 0 0 $spacing;
73
- }
74
- &__dropdown-wrapper {
75
- .c-film-moviesearch__dropdown-button {
76
- border-radius: 0;
77
- text-transform: none;
78
- letter-spacing: 0;
79
- }
80
- display: flex;
81
- flex-direction: column;
82
- padding: $spacing--small 0;
83
- background: #deebf6;
84
- border-radius: $border-radius;
85
- left: 0;
86
- right: 0;
87
- animation: zoomInSelect 200ms ease;
88
- box-shadow: 0 0 30px rgba($black, 0.6);
89
- position: absolute;
90
- z-index: 9999;
91
- button,
92
- a {
93
- color: $primary-color;
94
- border: 0;
95
- outline: 0;
96
- text-align: left;
97
- background: transparent;
98
- padding: $spacing--small;
99
- padding-left: $spacing;
100
- font-weight: $font-weight-semibold;
101
- text-decoration: none;
102
- box-shadow: none;
103
- transition: background 200ms ease;
104
- &:hover,
105
- &:focus {
106
- color: $brand-color;
107
- background: rgba(0, 0, 0, 0.2);
108
- }
109
- }
110
- }
111
- }
112
-
113
- @keyframes zoomInSelect {
114
- 0% {
115
- display: none;
116
- opacity: 0;
117
- }
118
- 1% {
119
- display: flex;
120
- transform: scale3d(0.95, 0.95, 0.95);
121
- opacity: 0;
122
- }
123
- 100% {
124
- opacity: 1;
125
- transform: scale3d(1, 1, 1);
126
- }
127
- }
@@ -1,258 +0,0 @@
1
- .c-film-slideshow {
2
- &:hover {
3
- .c-film-slideshow__navigation-arrows {
4
- opacity: 1;
5
- transform: translate(0, 0);
6
- }
7
- }
8
- &__navigation-arrows {
9
- opacity: 0;
10
- transition: transform 800ms ease, opacity 800ms ease;
11
- display: flex;
12
- justify-content: center;
13
- flex-direction: column;
14
- position: absolute;
15
- align-items: center;
16
- z-index: 2;
17
- height: 70vw;
18
- @include mq(tablet) {
19
- height: 60vw;
20
- }
21
- @include mq(desktop) {
22
- height: 55vw;
23
- }
24
- @include mq(wide) {
25
- height: 40vw;
26
- }
27
- @include mq(ultraWide) {
28
- height: 36vw;
29
- }
30
- transform: translate($spacing--small / 2, 0);
31
- .c-icon {
32
- fill: #fff;
33
- width: 52px;
34
- height: 52px;
35
- @include mq(desktop) {
36
- width: 78px;
37
- height: 78px;
38
- }
39
- opacity: 0.7;
40
- transition: transform 400ms ease, opacity 400ms ease;
41
- }
42
- button {
43
- padding: $spacing 0;
44
- border-radius: $border-radius;
45
- outline: none;
46
- background: transparent;
47
- color: #fff;
48
- border: 0;
49
- &:hover,
50
- &:focus {
51
- .c-icon {
52
- opacity: 1;
53
- }
54
- background: rgba(0, 0, 0, 0.1);
55
- }
56
- }
57
- &--right {
58
- right: 0;
59
- transform: translate(-$spacing--small / 2, 0);
60
- }
61
- }
62
- &__slide-link-wrapper {
63
- margin: 0 auto;
64
- display: flex;
65
- justify-content: flex-start;
66
- align-items: flex-end;
67
- position: absolute;
68
- z-index: 2;
69
- height: 100vw;
70
- width: 100%;
71
- @include mq(mobileWide) {
72
- height: 100vw;
73
- }
74
- @include mq(tablet) {
75
- height: 75vw;
76
- }
77
- @include mq(desktop) {
78
- height: 55vw;
79
- }
80
- @include mq(wide) {
81
- height: 40vw;
82
- }
83
- @include mq(ultraWide) {
84
- height: 36vw;
85
- }
86
- }
87
- &__item-wrapper {
88
- display: flex;
89
- box-shadow: none;
90
- &--text {
91
- display: flex;
92
- transition: all 400ms ease;
93
- @include mq(mobileWide) {
94
- padding-bottom: $spacing--medium;
95
- }
96
- @include mq(tablet) {
97
- padding-bottom: $spacing--large;
98
- }
99
- @include mq(desktop) {
100
- padding-bottom: $spacing--large * 1.5;
101
- }
102
- &:hover {
103
- h1 {
104
- text-decoration: underline;
105
- }
106
- }
107
- &.out {
108
- opacity: 0;
109
- }
110
- &:not(.out) {
111
- animation: fadeInBottomFixed 600ms ease;
112
- }
113
- }
114
- }
115
- &__item {
116
- width: 100vw;
117
- height: 100vw;
118
- /* aspect ratios */
119
- @include mq(mobileWide) {
120
- height: 100vw;
121
- }
122
- @include mq(tablet) {
123
- height: 75vw;
124
- }
125
- @include mq(desktop) {
126
- height: 55vw;
127
- }
128
- @include mq(wide) {
129
- height: 40vw;
130
- }
131
- @include mq(ultraWide) {
132
- height: 36vw;
133
- }
134
- background-color: '#222';
135
- background-size: cover;
136
- background-position-x: center;
137
- background-position-y: center;
138
- border: 0;
139
- position: relative;
140
- &:before {
141
- content: '';
142
- opacity: 0.4;
143
- background: #091a2a;
144
- top: 0;
145
- left: 0;
146
- bottom: 0;
147
- right: 0;
148
- position: absolute;
149
- z-index: 1;
150
- }
151
- &--fade-over {
152
- position: absolute;
153
- z-index: 1;
154
- animation: fadeIn 400ms ease;
155
- }
156
- }
157
- &__slide-info {
158
- border: 0;
159
- background: none;
160
- background-color: rgba(3, 23, 43, 0.7);
161
- border-radius: $border-radius;
162
- padding: $spacing--medium $spacing--medium $spacing--medium $spacing;
163
- margin: 0 -20px;
164
- width: 100vw;
165
- @include mq(mobileWide) {
166
- margin: 0;
167
- width: 100%;
168
- padding: $spacing--medium $spacing--large * 2 $spacing--medium $spacing;
169
- }
170
- h1 {
171
- @include font-size(22px, 30px);
172
- color: $white;
173
- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
174
- margin: 0;
175
- font-weight: $font-weight-semibold;
176
- @include mq(mobileWide) {
177
- margin: 0 0 $spacing--small;
178
- @include font-size(26px, 30px);
179
- }
180
- @include mq(tablet) {
181
- @include font-size(40px, 44px);
182
- }
183
- @include mq(desktop) {
184
- @include font-size(48px, 54px);
185
- }
186
- }
187
-
188
- p {
189
- color: #fff;
190
- display: inline-block;
191
- margin: 0;
192
- padding: 0;
193
- border-radius: $border-radius;
194
- @include font-size(12px, 18px);
195
- @include mq(mobileWide) {
196
- @include font-size(15px, 20px);
197
- }
198
- @include mq(tablet) {
199
- @include font-size(18px, 24px);
200
- }
201
- @include mq(wide) {
202
- @include font-size(20px, 32px);
203
- }
204
- }
205
- }
206
- &__indicator-wrapper {
207
- display: flex;
208
- align-items: center;
209
- justify-content: center;
210
- margin: $spacing--small 0;
211
- @include mq(mobileWide) {
212
- margin: $spacing 0;
213
- }
214
- &--isMobile {
215
- pointer-events: none;
216
- }
217
- }
218
- &__indicator-dot {
219
- border: 0;
220
- display: flex;
221
- justify-content: center;
222
- background: transparent;
223
- span {
224
- background: $film-color-bright;
225
- transition: background 100ms ease;
226
- height: 8px;
227
- width: 8px;
228
- @include mq(mobileWide) {
229
- height: 10px;
230
- width: 10px;
231
- }
232
- @include mq(tablet) {
233
- height: $spacing--small;
234
- width: $spacing--small;
235
- }
236
- border-radius: 100%;
237
- }
238
- padding: $spacing--small / 2;
239
- @include mq(tablet) {
240
- padding: $spacing--small;
241
- }
242
- &:hover,
243
- &:focus,
244
- &--active {
245
- span {
246
- background: #fff;
247
- }
248
- }
249
- }
250
- &__slideshow {
251
- background: rgba(255, 255, 255, 0.08);
252
- margin-bottom: $spacing--large * 4;
253
- display: flex;
254
- align-items: center;
255
- justify-content: center;
256
- height: 40vw;
257
- }
258
- }
@@ -1,67 +0,0 @@
1
- .c-radio-button-group {
2
- &__wrapper {
3
- padding: $spacing--small 0;
4
- font-family: $font;
5
- display: flex;
6
- align-items: center;
7
- flex-flow: flow;
8
- }
9
- &__label-heading {
10
- @include font-size(16px, 20px);
11
- margin: 0 $spacing 0 0;
12
- font-weight: 600;
13
- }
14
- &__label {
15
- @include font-size(16px, 28px, $important: true);
16
- color: $brand-color;
17
- align-items: center;
18
- display: inline-flex;
19
- &:before {
20
- content: "";
21
- margin-right: $spacing--small;
22
- width: 20px;
23
- height: 20px;
24
- border-radius: 100%;
25
- border: 2px solid $brand-color--tertiary;
26
- transition: 200ms border-color ease;
27
- }
28
- &:after {
29
- content: "";
30
- background: transparent;
31
- width: 10px;
32
- height: 10px;
33
- border-radius: 100%;
34
- position: absolute;
35
- transform: translateX(5px) scale(0, 0);
36
- transition: 200ms all ease;
37
- }
38
- &:not(:last-child) {
39
- margin-right: $spacing--medium;
40
- }
41
- }
42
- &__input {
43
- opacity: 0;
44
- position: absolute;
45
- width: auto;
46
- &:hover, &:focus {
47
- + .c-radio-button-group__label {
48
- @include restore-outline();
49
- &:after {
50
- transform: translateX(5px) scale(1, 1);
51
- background: $brand-color--tertiary;
52
- }
53
- }
54
- }
55
- &:checked {
56
- + .c-radio-button-group__label {
57
- &:before {
58
- border-color: $brand-color;
59
- }
60
- &:after {
61
- transform: translateX(5px) scale(1, 1);
62
- background: $brand-color;
63
- }
64
- }
65
- }
66
- }
67
- }