@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "15.2.0",
3
+ "version": "16.1.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,18 +31,18 @@
31
31
  "types"
32
32
  ],
33
33
  "dependencies": {
34
- "@ndla/button": "^2.4.0",
34
+ "@ndla/button": "^2.4.1",
35
35
  "@ndla/carousel": "^1.2.9",
36
36
  "@ndla/core": "^2.1.1",
37
37
  "@ndla/hooks": "^1.1.4",
38
38
  "@ndla/icons": "^1.8.1",
39
- "@ndla/licenses": "^4.1.5",
39
+ "@ndla/licenses": "^5.0.0",
40
40
  "@ndla/modal": "^1.2.10",
41
- "@ndla/notion": "^3.1.12",
42
- "@ndla/safelink": "^2.0.4",
41
+ "@ndla/notion": "^3.1.14",
42
+ "@ndla/safelink": "^2.0.5",
43
43
  "@ndla/switch": "^0.1.5",
44
44
  "@ndla/tabs": "^1.1.8",
45
- "@ndla/tooltip": "^2.0.0",
45
+ "@ndla/tooltip": "^2.1.0",
46
46
  "@ndla/util": "^3.0.0",
47
47
  "@reach/menu-button": "^0.16.2",
48
48
  "@reach/slider": "^0.16.0",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "21186f9391477c1c0507d44fffbc72730793017b"
84
+ "gitHead": "f0ced3947f6cb38fc17be3ba1b914ba21996e4b5"
85
85
  }
@@ -12,6 +12,7 @@ import {
12
12
  removeEventListenerForResize,
13
13
  // @ts-ignore
14
14
  } from '@ndla/article-scripts';
15
+ import { initTooltips } from '@ndla/tooltip';
15
16
  import { initAudioPlayers } from '../AudioPlayer';
16
17
  import { initCopyParagraphButtons } from '../CopyParagraphButton';
17
18
  import { Locale } from '../types';
@@ -26,6 +27,7 @@ const ArticleContent = ({ content, locale, ...rest }: Props) => {
26
27
  initArticleScripts();
27
28
  initAudioPlayers(locale);
28
29
  initCopyParagraphButtons();
30
+ initTooltips();
29
31
  return () => {
30
32
  removeEventListenerForResize();
31
33
  };
@@ -1,7 +1,8 @@
1
- import React from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
1
  import { Download } from '@ndla/icons/common';
4
2
  import SafeLink from '@ndla/safelink';
3
+ import Tooltip from '@ndla/tooltip';
4
+ import React from 'react';
5
+ import BEMHelper from 'react-bem-helper';
5
6
  import { FileFormat, FileType } from './FileList';
6
7
 
7
8
  const classes = BEMHelper('c-file-list');
@@ -16,9 +17,6 @@ const renderFormat = (format: FileFormat, title: string, isPrimary: boolean, id:
16
17
  <span key={format.url}>
17
18
  <Download />
18
19
  <span>{isPrimary ? titleWithFormat : `(${format.fileType.toUpperCase()})`}</span>
19
- <span {...classes('tooltip')} aria-hidden role="tooltip" id={formatId}>
20
- <span {...classes('tooltip-text')}>{format.tooltip}</span>
21
- </span>
22
20
  </span>
23
21
  );
24
22
  }
@@ -32,12 +30,11 @@ const renderFormat = (format: FileFormat, title: string, isPrimary: boolean, id:
32
30
  aria-label={titleWithFormat}
33
31
  aria-describedby={formatId}>
34
32
  <Download />
35
- <span {...classes('link-text')}>
36
- <span>{isPrimary ? titleWithFormat : `(${format.fileType.toUpperCase()})`}</span>
37
- </span>
38
- <span {...classes('tooltip')} aria-hidden role="tooltip" id={formatId}>
39
- <span {...classes('tooltip-text')}>{format.tooltip}</span>
40
- </span>
33
+ <Tooltip tooltip={format.tooltip}>
34
+ <span {...classes('link-text')}>
35
+ <span>{isPrimary ? titleWithFormat : `(${format.fileType.toUpperCase()})`}</span>
36
+ </span>
37
+ </Tooltip>
41
38
  </SafeLink>
42
39
  );
43
40
  };
@@ -24,15 +24,14 @@ const StyledHeading = styled.h3`
24
24
  `;
25
25
 
26
26
  const StyledButtonsWrapper = styled.div`
27
- display: flex;
28
- flex-wrap: nowrap;
29
- position: relative;
27
+ display: inline-flex;
28
+ flex-wrap: wrap;
30
29
  `;
31
30
 
32
31
  const StyledButtonElementWrapper = styled.div`
33
32
  margin: 0 ${spacing.xsmall} ${spacing.xsmall} 0;
34
33
  break-inside: avoid;
35
- flex: 1 0 auto;
34
+ flex-shrink: 0;
36
35
  `;
37
36
 
38
37
  const StyledList = styled.ul`
@@ -1,14 +1,109 @@
1
1
  import React, { Component } from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
2
  import FocusTrapReact from 'focus-trap-react';
3
+ import styled from '@emotion/styled';
4
+ import { keyframes } from '@emotion/core';
5
+ import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
4
6
  import { ChevronDown } from '@ndla/icons/common';
5
7
  import { WithTranslation, withTranslation } from 'react-i18next';
6
8
  import { MovieResourceType } from './types';
7
9
 
8
- const classes = new BEMHelper({
9
- name: 'film-moviesearch',
10
- prefix: 'c-',
11
- });
10
+ const zoomInSelect = keyframes`
11
+ 0% {
12
+ display: none;
13
+ opacity: 0;
14
+ }
15
+ 1% {
16
+ display: flex;
17
+ transform: scale3d(0.95, 0.95, 0.95);
18
+ opacity: 0;
19
+ }
20
+ 100% {
21
+ opacity: 1;
22
+ transform: scale3d(1, 1, 1);
23
+ }
24
+ `;
25
+
26
+ const DropdownContainer = styled.div`
27
+ position: relative;
28
+ margin: 0 0 ${spacing.normal};
29
+ `;
30
+
31
+ const DropdownButton = styled.button`
32
+ border-radius: 4px;
33
+ ${fonts.sizes('22px', '26px')};
34
+ border: 0;
35
+ text-transform: uppercase;
36
+ background: ${colors.ndlaFilm.filmColorBright};
37
+ color: ${colors.white};
38
+ padding: ${spacing.small} ${spacing.nsmall};
39
+ font-weight: ${fonts.weight.semibold};
40
+ display: flex;
41
+ align-items: center;
42
+ text-align: left;
43
+ justify-content: space-between;
44
+ width: 100%;
45
+ letter-spacing: 0.05em;
46
+ ${mq.range({ from: breakpoints.tablet })} {
47
+ padding: ${spacing.small} ${spacing.normal};
48
+ }
49
+ div:first-child {
50
+ ${mq.range({ until: breakpoints.tablet })} {
51
+ display: flex;
52
+ flex-direction: column;
53
+ small {
54
+ padding: 0;
55
+ }
56
+ }
57
+ }
58
+ small {
59
+ text-transform: none;
60
+ padding-left: ${spacing.small};
61
+ font-weight: normal;
62
+ }
63
+ `;
64
+
65
+ interface DropdownWrapperProps {
66
+ offsetDropdown: number;
67
+ }
68
+
69
+ const DropdownWrapper = styled.div<DropdownWrapperProps>`
70
+ top: -${(props) => props.offsetDropdown * 52 + 13}px;
71
+ ${DropdownButton} {
72
+ border-radius: 0;
73
+ text-transform: 0;
74
+ letter-spacing: 0;
75
+ }
76
+ display: flex;
77
+ flex-direction: column;
78
+ padding: $spacing--small 0;
79
+ background: ${colors.brand.lighter};
80
+ border-radius: 4px;
81
+ left: 0;
82
+ right: 0;
83
+ animation: ${zoomInSelect} 200ms ease;
84
+ box-shadow: 0 0 30px rgba(${colors.black}, 0.6);
85
+ position: absolute;
86
+ z-index: 9999;
87
+ button,
88
+ a {
89
+ color: ${colors.text.primary};
90
+ border: 0;
91
+ outline: 0;
92
+ text-align: left;
93
+ background: transparent;
94
+ padding: ${spacing.small};
95
+ padding-left: ${spacing.normal};
96
+ font-weight: ${fonts.weight.semibold};
97
+ text-decoration: none;
98
+ box-shadow: none;
99
+ transition: background 200ms ease;
100
+ &:hover,
101
+ &:focus {
102
+ color: ${colors.brand.primary};
103
+ background: rgba(0, 0, 0, 0.2);
104
+ }
105
+ }
106
+ `;
12
107
 
13
108
  interface Props extends WithTranslation {
14
109
  resourceTypes: MovieResourceType[];
@@ -66,12 +161,11 @@ class CategorySelect extends Component<Props, State> {
66
161
  : 0;
67
162
 
68
163
  return (
69
- <div {...classes('dropdown-container', '', 'u-12/12')}>
70
- <button
164
+ <DropdownContainer className="u-12/12">
165
+ <DropdownButton
71
166
  aria-expanded={!resourceTypesIsOpen}
72
167
  aria-controls="selectCategory"
73
168
  type="button"
74
- {...classes('dropdown-button', 'toggleButton')}
75
169
  tabIndex={resourceTypesIsOpen ? -1 : 0}
76
170
  onClick={this.openSelect}>
77
171
  <div>
@@ -83,7 +177,7 @@ class CategorySelect extends Component<Props, State> {
83
177
  <div>
84
178
  <ChevronDown className="c-icon--22" />
85
179
  </div>
86
- </button>
180
+ </DropdownButton>
87
181
  {resourceTypesIsOpen && (
88
182
  <FocusTrapReact
89
183
  active={resourceTypesIsOpen}
@@ -94,32 +188,25 @@ class CategorySelect extends Component<Props, State> {
94
188
  clickOutsideDeactivates: true,
95
189
  escapeDeactivates: true,
96
190
  }}>
97
- <div id="selectCategory" {...classes('dropdown-wrapper')} style={{ top: `-${offsetDropDown * 52 + 13}px` }}>
98
- <button
99
- aria-controls={ariaControlId}
100
- type="button"
101
- onClick={() => this.onSelect()}
102
- {...classes('dropdown-button')}>
191
+ <DropdownWrapper id="selectCategory" offsetDropdown={offsetDropDown}>
192
+ <DropdownButton aria-controls={ariaControlId} type="button" onClick={() => this.onSelect()}>
103
193
  <span>{t('ndlaFilm.search.categoryFromNdla')}</span>
104
- </button>
194
+ </DropdownButton>
105
195
  {resourceTypes.map((resourceType) => (
106
- <button
196
+ <DropdownButton
107
197
  aria-controls={ariaControlId}
108
198
  type="button"
109
199
  ref={(el) => this.createRef(el, resourceType.id)}
110
200
  onClick={() => this.onSelect(resourceType.id)}
111
- {...classes('dropdown-button', {
112
- selected: !!resourceTypeSelected && resourceTypeSelected.id === resourceType.id,
113
- })}
114
201
  data-id={resourceType.id}
115
202
  key={resourceType.id}>
116
203
  <span>{resourceType.name}</span>
117
- </button>
204
+ </DropdownButton>
118
205
  ))}
119
- </div>
206
+ </DropdownWrapper>
120
207
  </FocusTrapReact>
121
208
  )}
122
- </div>
209
+ </DropdownContainer>
123
210
  );
124
211
  }
125
212
  }
@@ -6,15 +6,12 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import BEMHelper from 'react-bem-helper';
10
9
  import { Carousel, CalculatedCarouselProps } from '@ndla/carousel';
10
+ import styled from '@emotion/styled';
11
+ import { breakpoints, mq, spacing } from '@ndla/core';
11
12
  import FilmContentCard from './FilmContentCard';
12
13
  import { MovieResourceType, MovieType } from './types';
13
-
14
- const classes = new BEMHelper({
15
- name: 'film-movielist',
16
- prefix: 'c-',
17
- });
14
+ import { StyledHeadingH1 } from './filmStyles';
18
15
 
19
16
  interface Props {
20
17
  movies: MovieType[];
@@ -26,6 +23,13 @@ interface Props {
26
23
  resizeThumbnailImages?: boolean;
27
24
  }
28
25
 
26
+ const StyledSection = styled.section`
27
+ margin-bottom: ${spacing.normal};
28
+ ${mq.range({ from: breakpoints.tablet })} {
29
+ margin-bottom: ${spacing.large};
30
+ }
31
+ `;
32
+
29
33
  const FilmMovieList = ({
30
34
  name,
31
35
  movies = [],
@@ -35,10 +39,8 @@ const FilmMovieList = ({
35
39
  autoSizedProps,
36
40
  resizeThumbnailImages,
37
41
  }: Props) => (
38
- <section {...classes()}>
39
- <h1 {...classes('heading')} style={{ marginLeft: `${autoSizedProps.margin}px` }}>
40
- {name}
41
- </h1>
42
+ <StyledSection>
43
+ <StyledHeadingH1 marginLeft={autoSizedProps.margin}>{name}</StyledHeadingH1>
42
44
  <Carousel
43
45
  disableScroll={false}
44
46
  slideBackwardsLabel={slideBackwardsLabel}
@@ -56,7 +58,7 @@ const FilmMovieList = ({
56
58
  ))}
57
59
  {...autoSizedProps}
58
60
  />
59
- </section>
61
+ </StyledSection>
60
62
  );
61
63
 
62
64
  export default FilmMovieList;
@@ -7,22 +7,53 @@
7
7
  */
8
8
 
9
9
  import React from 'react';
10
- import BEMHelper from 'react-bem-helper';
11
10
  import SafeLink from '@ndla/safelink';
12
11
  import { useTranslation } from 'react-i18next';
12
+ import styled from '@emotion/styled';
13
+ import { spacing, mq, breakpoints, colors } from '@ndla/core';
13
14
  import CategorySelect from './CategorySelect';
14
15
  import { MovieResourceType } from './types';
15
16
  import { OneColumn } from '..';
17
+ import { StyledHeadingH2 } from './filmStyles';
16
18
 
17
- const classes = new BEMHelper({
18
- name: 'film-moviesearch',
19
- prefix: 'c-',
20
- });
19
+ const FilmMovieSearchContainer = styled.div`
20
+ margin: ${spacing.normal} 0 ${spacing.large};
21
+ `;
21
22
 
22
- const classesMovieList = new BEMHelper({
23
- name: 'film-movielist',
24
- prefix: 'c-',
25
- });
23
+ const TopicNavigation = styled.div`
24
+ margin: ${spacing.normal} 0;
25
+ ${mq.range({ from: breakpoints.tablet })} {
26
+ display: flex;
27
+ align-items: flex-start;
28
+ padding: 0 ${spacing.normal};
29
+ }
30
+ ul {
31
+ list-style-type: none;
32
+ list-style-image: none;
33
+ display: flex;
34
+ align-items: flex-start;
35
+ flex-wrap: wrap;
36
+ padding: 0;
37
+ margin: ${spacing.small} 0;
38
+ ${mq.range({ from: breakpoints.tablet })} {
39
+ padding-left: ${spacing.normal};
40
+ }
41
+ li {
42
+ padding: 0;
43
+ width: 100%;
44
+ ${mq.range({ from: breakpoints.tablet })} {
45
+ width: 50%;
46
+ }
47
+ a {
48
+ color: #fff;
49
+ &:hover,
50
+ &:focus {
51
+ color: ${colors.brand.light};
52
+ }
53
+ }
54
+ }
55
+ }
56
+ `;
26
57
 
27
58
  interface Props {
28
59
  topics?: { id: string; path: string; name: string }[];
@@ -41,10 +72,10 @@ const FilmMovieSearch = ({
41
72
  }: Props) => {
42
73
  const { t } = useTranslation();
43
74
  return (
44
- <div {...classes('')}>
75
+ <FilmMovieSearchContainer>
45
76
  <OneColumn>
46
- <div {...classes('topic-navigation')}>
47
- <h2 {...classesMovieList('heading', '', 'u-12/12 u-4/12@tablet')}>{t('ndlaFilm.subjectsInMovies')}:</h2>
77
+ <TopicNavigation>
78
+ <StyledHeadingH2 className="u-12/12 u-4/12@tablet">{t('ndlaFilm.subjectsInMovies')}:</StyledHeadingH2>
48
79
  <nav className="u-12/12 u-8/12@tablet">
49
80
  <ul>
50
81
  {topics.map((topic) => (
@@ -56,7 +87,7 @@ const FilmMovieSearch = ({
56
87
  ))}
57
88
  </ul>
58
89
  </nav>
59
- </div>
90
+ </TopicNavigation>
60
91
  <CategorySelect
61
92
  onChangeResourceType={onChangeResourceType}
62
93
  resourceTypes={resourceTypes}
@@ -64,7 +95,7 @@ const FilmMovieSearch = ({
64
95
  ariaControlId={ariaControlId}
65
96
  />
66
97
  </OneColumn>
67
- </div>
98
+ </FilmMovieSearchContainer>
68
99
  );
69
100
  };
70
101