@ndla/ui 23.0.0 → 24.0.0

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 (95) hide show
  1. package/es/Article/ArticleAuthorContent.js +2 -4
  2. package/es/AuthorInfo/AuthorInfo.js +29 -16
  3. package/es/ContentCard/ContentCard.js +66 -25
  4. package/es/FileList/File.js +34 -8
  5. package/es/FileList/FileList.js +29 -3
  6. package/es/InfoBox/InfoBox.js +10 -3
  7. package/es/InfoWidget/InfoWidget.js +67 -22
  8. package/es/Portrait/Portrait.js +19 -13
  9. package/es/Search/ActiveFilterContent.js +4 -14
  10. package/es/Search/ActiveFilters.js +8 -19
  11. package/es/Search/SearchField.js +31 -52
  12. package/es/Search/SearchResult.js +113 -136
  13. package/es/Search/ToggleSearchButton.js +34 -43
  14. package/es/Search/index.js +2 -8
  15. package/es/all.css +1 -1
  16. package/es/index-javascript.js +0 -1
  17. package/es/index.js +2 -1
  18. package/lib/Article/ArticleAuthorContent.js +9 -4
  19. package/lib/AuthorInfo/AuthorInfo.d.ts +1 -11
  20. package/lib/AuthorInfo/AuthorInfo.js +36 -20
  21. package/lib/ContentCard/ContentCard.d.ts +1 -15
  22. package/lib/ContentCard/ContentCard.js +60 -28
  23. package/lib/FileList/File.js +36 -12
  24. package/lib/FileList/FileList.js +28 -5
  25. package/lib/InfoBox/InfoBox.js +11 -4
  26. package/lib/InfoWidget/InfoWidget.js +61 -25
  27. package/lib/Portrait/Portrait.js +19 -14
  28. package/lib/Search/ActiveFilterContent.d.ts +13 -0
  29. package/lib/Search/ActiveFilterContent.js +4 -15
  30. package/lib/Search/ActiveFilters.d.ts +13 -0
  31. package/lib/Search/ActiveFilters.js +8 -20
  32. package/lib/Search/SearchField.d.ts +19 -0
  33. package/lib/Search/SearchField.js +32 -56
  34. package/lib/Search/SearchResult.d.ts +36 -0
  35. package/lib/Search/SearchResult.js +116 -159
  36. package/lib/Search/ToggleSearchButton.d.ts +16 -0
  37. package/lib/Search/ToggleSearchButton.js +36 -46
  38. package/lib/Search/index.d.ts +12 -0
  39. package/lib/Search/index.js +0 -54
  40. package/lib/SearchTypeResult/SearchTypeHeader.d.ts +1 -1
  41. package/lib/all.css +1 -1
  42. package/lib/index-javascript.js +0 -74
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.js +38 -1
  45. package/package.json +5 -5
  46. package/src/Article/ArticleAuthorContent.tsx +1 -1
  47. package/src/AuthorInfo/AuthorInfo.tsx +53 -19
  48. package/src/ContentCard/ContentCard.tsx +127 -35
  49. package/src/FileList/File.tsx +47 -17
  50. package/src/FileList/FileList.tsx +37 -8
  51. package/src/InfoBox/InfoBox.tsx +24 -4
  52. package/src/InfoWidget/InfoWidget.tsx +83 -34
  53. package/src/Portrait/Portrait.tsx +25 -10
  54. package/src/Search/{ActiveFilterContent.jsx → ActiveFilterContent.tsx} +11 -12
  55. package/src/Search/{ActiveFilters.jsx → ActiveFilters.tsx} +20 -17
  56. package/src/Search/{SearchField.jsx → SearchField.tsx} +58 -68
  57. package/src/Search/SearchResult.tsx +360 -0
  58. package/src/Search/ToggleSearchButton.tsx +73 -0
  59. package/src/Search/component.search.scss +0 -4
  60. package/src/Search/index.ts +16 -0
  61. package/src/all.scss +0 -1
  62. package/src/index-javascript.js +0 -15
  63. package/src/index.ts +2 -0
  64. package/src/main.scss +0 -6
  65. package/es/Search/SearchFilter.js +0 -72
  66. package/es/Search/SearchFilterList.js +0 -115
  67. package/es/Search/SearchOverlay.js +0 -39
  68. package/es/Search/SearchPage.js +0 -178
  69. package/es/Search/SearchPopoverFilter.js +0 -152
  70. package/es/Search/SearchResultAuthor.js +0 -51
  71. package/lib/Search/SearchFilter.js +0 -88
  72. package/lib/Search/SearchFilterList.js +0 -137
  73. package/lib/Search/SearchOverlay.js +0 -62
  74. package/lib/Search/SearchPage.js +0 -207
  75. package/lib/Search/SearchPopoverFilter.js +0 -172
  76. package/lib/Search/SearchResultAuthor.js +0 -60
  77. package/src/AuthorInfo/component.author-info.scss +0 -54
  78. package/src/ContentCard/component.content-card.scss +0 -109
  79. package/src/FileList/component.file-list.scss +0 -102
  80. package/src/InfoBox/component.info-box.scss +0 -21
  81. package/src/InfoWidget/component.info-widget.scss +0 -52
  82. package/src/Portrait/component.portrait.scss +0 -29
  83. package/src/Search/SearchFilter.jsx +0 -82
  84. package/src/Search/SearchFilterList.jsx +0 -110
  85. package/src/Search/SearchOverlay.jsx +0 -38
  86. package/src/Search/SearchPage.jsx +0 -178
  87. package/src/Search/SearchPopoverFilter.jsx +0 -109
  88. package/src/Search/SearchResult.jsx +0 -239
  89. package/src/Search/SearchResultAuthor.jsx +0 -54
  90. package/src/Search/ToggleSearchButton.jsx +0 -64
  91. package/src/Search/component.search-filter.scss +0 -67
  92. package/src/Search/component.search-overlay.scss +0 -103
  93. package/src/Search/component.search-page.scss +0 -125
  94. package/src/Search/component.search-result-author.scss +0 -65
  95. package/src/Search/index.js +0 -34
@@ -23,78 +23,6 @@ Object.defineProperty(exports, "FilterButtons", {
23
23
  return _Filter.FilterButtons;
24
24
  }
25
25
  });
26
- Object.defineProperty(exports, "SearchOverlay", {
27
- enumerable: true,
28
- get: function get() {
29
- return _Search.SearchOverlay;
30
- }
31
- });
32
- Object.defineProperty(exports, "SearchField", {
33
- enumerable: true,
34
- get: function get() {
35
- return _Search.SearchField;
36
- }
37
- });
38
- Object.defineProperty(exports, "SearchPage", {
39
- enumerable: true,
40
- get: function get() {
41
- return _Search.SearchPage;
42
- }
43
- });
44
- Object.defineProperty(exports, "SearchResult", {
45
- enumerable: true,
46
- get: function get() {
47
- return _Search.SearchResult;
48
- }
49
- });
50
- Object.defineProperty(exports, "SearchResultAuthor", {
51
- enumerable: true,
52
- get: function get() {
53
- return _Search.SearchResultAuthor;
54
- }
55
- });
56
- Object.defineProperty(exports, "SearchResultList", {
57
- enumerable: true,
58
- get: function get() {
59
- return _Search.SearchResultList;
60
- }
61
- });
62
- Object.defineProperty(exports, "SearchResultItem", {
63
- enumerable: true,
64
- get: function get() {
65
- return _Search.SearchResultItem;
66
- }
67
- });
68
- Object.defineProperty(exports, "SearchFilter", {
69
- enumerable: true,
70
- get: function get() {
71
- return _Search.SearchFilter;
72
- }
73
- });
74
- Object.defineProperty(exports, "SearchFilterList", {
75
- enumerable: true,
76
- get: function get() {
77
- return _Search.SearchFilterList;
78
- }
79
- });
80
- Object.defineProperty(exports, "SearchPopoverFilter", {
81
- enumerable: true,
82
- get: function get() {
83
- return _Search.SearchPopoverFilter;
84
- }
85
- });
86
- Object.defineProperty(exports, "ActiveFilters", {
87
- enumerable: true,
88
- get: function get() {
89
- return _Search.ActiveFilters;
90
- }
91
- });
92
- Object.defineProperty(exports, "ToggleSearchButton", {
93
- enumerable: true,
94
- get: function get() {
95
- return _Search.ToggleSearchButton;
96
- }
97
- });
98
26
  Object.defineProperty(exports, "TopicIntroductionList", {
99
27
  enumerable: true,
100
28
  get: function get() {
@@ -146,8 +74,6 @@ Object.defineProperty(exports, "CompetenceGoalsDialog", {
146
74
 
147
75
  var _Filter = require("./Filter");
148
76
 
149
- var _Search = require("./Search");
150
-
151
77
  var _TopicIntroductionList = _interopRequireDefault(require("./TopicIntroductionList"));
152
78
 
153
79
  var _TopicMenu = _interopRequireWildcard(require("./TopicMenu"));
package/lib/index.d.ts CHANGED
@@ -89,3 +89,4 @@ export type { Snack, SnackContext } from './SnackBar';
89
89
  export { InfoBlock } from './InfoBlock';
90
90
  export { TreeStructure } from './TreeStructure';
91
91
  export type { FolderType, TreeStructureProps, TreeStructureMenuProps } from './TreeStructure';
92
+ export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
package/lib/index.js CHANGED
@@ -188,7 +188,12 @@ var _exportNames = {
188
188
  BaseSnack: true,
189
189
  DefaultSnackbar: true,
190
190
  InfoBlock: true,
191
- TreeStructure: true
191
+ TreeStructure: true,
192
+ SearchField: true,
193
+ SearchResultList: true,
194
+ SearchResultItem: true,
195
+ ActiveFilters: true,
196
+ ToggleSearchButton: true
192
197
  };
193
198
  Object.defineProperty(exports, "ArticleByline", {
194
199
  enumerable: true,
@@ -1288,6 +1293,36 @@ Object.defineProperty(exports, "TreeStructure", {
1288
1293
  return _TreeStructure.TreeStructure;
1289
1294
  }
1290
1295
  });
1296
+ Object.defineProperty(exports, "SearchField", {
1297
+ enumerable: true,
1298
+ get: function get() {
1299
+ return _Search.SearchField;
1300
+ }
1301
+ });
1302
+ Object.defineProperty(exports, "SearchResultList", {
1303
+ enumerable: true,
1304
+ get: function get() {
1305
+ return _Search.SearchResultList;
1306
+ }
1307
+ });
1308
+ Object.defineProperty(exports, "SearchResultItem", {
1309
+ enumerable: true,
1310
+ get: function get() {
1311
+ return _Search.SearchResultItem;
1312
+ }
1313
+ });
1314
+ Object.defineProperty(exports, "ActiveFilters", {
1315
+ enumerable: true,
1316
+ get: function get() {
1317
+ return _Search.ActiveFilters;
1318
+ }
1319
+ });
1320
+ Object.defineProperty(exports, "ToggleSearchButton", {
1321
+ enumerable: true,
1322
+ get: function get() {
1323
+ return _Search.ToggleSearchButton;
1324
+ }
1325
+ });
1291
1326
 
1292
1327
  var _indexJavascript = require("./index-javascript");
1293
1328
 
@@ -1440,6 +1475,8 @@ var _InfoBlock = require("./InfoBlock");
1440
1475
 
1441
1476
  var _TreeStructure = require("./TreeStructure");
1442
1477
 
1478
+ var _Search = require("./Search");
1479
+
1443
1480
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1444
1481
 
1445
1482
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "23.0.0",
3
+ "version": "24.0.0",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -38,13 +38,13 @@
38
38
  "@ndla/forms": "^3.1.4",
39
39
  "@ndla/hooks": "^1.1.5",
40
40
  "@ndla/icons": "^1.11.4",
41
- "@ndla/licenses": "^5.0.7",
41
+ "@ndla/licenses": "^5.0.8",
42
42
  "@ndla/modal": "^1.2.18",
43
- "@ndla/notion": "^3.1.30",
43
+ "@ndla/notion": "^3.1.31",
44
44
  "@ndla/safelink": "^2.2.7",
45
45
  "@ndla/switch": "^0.1.11",
46
46
  "@ndla/tabs": "^1.1.15",
47
- "@ndla/tooltip": "^2.1.6",
47
+ "@ndla/tooltip": "^2.2.0",
48
48
  "@ndla/types-learningpath-api": "^0.0.12",
49
49
  "@ndla/util": "^3.0.1",
50
50
  "@reach/menu-button": "^0.16.2",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "2f0095b2f2c730ff16d8c71fa8e867db87607c66"
88
+ "gitHead": "5ae8101f78ef46929de137ecbdd3275a5ef72649"
89
89
  }
@@ -78,7 +78,7 @@ const ArticleAuthorContent = ({ showAuthor, authors, onSelectAuthor }: Props) =>
78
78
  return (
79
79
  <div {...classes()}>
80
80
  <div {...classes('author-info')}>
81
- {image && <Portrait src={image} alt={name} {...classes('portrait')} />}
81
+ {image && <Portrait src={image} alt={name} />}
82
82
  <section>
83
83
  <h1>{name}</h1>
84
84
  <hr />
@@ -7,16 +7,11 @@
7
7
  */
8
8
 
9
9
  import React from 'react';
10
- import PropTypes from 'prop-types';
11
- import BEMHelper from 'react-bem-helper';
10
+ import styled from '@emotion/styled';
12
11
  import SafeLink from '@ndla/safelink';
12
+ import { breakpoints, fonts, mq, spacing } from '@ndla/core';
13
13
  import Portrait from '../Portrait';
14
14
 
15
- const classes = new BEMHelper({
16
- name: 'author-info',
17
- prefix: 'c-',
18
- });
19
-
20
15
  interface Props {
21
16
  authorName: string;
22
17
  authorRole: string;
@@ -25,24 +20,63 @@ interface Props {
25
20
  image?: string;
26
21
  }
27
22
 
23
+ const AuthorInfoSection = styled.section`
24
+ display: flex;
25
+ align-items: flex-start;
26
+ padding-bottom: ${spacing.large};
27
+ font-family: ${fonts.sans};
28
+ p,
29
+ a {
30
+ margin: 0;
31
+ ${mq.range({ until: breakpoints.tablet })} {
32
+ ${fonts.sizes('14px', '22px')};
33
+ }
34
+ }
35
+ `;
36
+
37
+ const StyledPortrait = styled(Portrait)`
38
+ margin-right: ${spacing.large};
39
+ ${mq.range({ until: breakpoints.desktop })} {
40
+ margin-right: ${spacing.medium};
41
+ width: 7rem;
42
+ height: 7rem;
43
+ span {
44
+ width: 7rem;
45
+ height: 7rem;
46
+ }
47
+ }
48
+ ${mq.range({ until: breakpoints.desktop })} {
49
+ margin-right: ${spacing.small};
50
+ width: 4rem;
51
+ height: 4rem;
52
+ span {
53
+ width: 4rem;
54
+ height: 4rem;
55
+ }
56
+ } ;
57
+ `;
58
+
59
+ const StyledHeading = styled.h1`
60
+ margin: 0 0 ${spacing.small};
61
+ ${mq.range({ until: breakpoints.desktop })} {
62
+ ${fonts.sizes('22px', '22px')};
63
+ }
64
+ ${mq.range({ until: breakpoints.tablet })} {
65
+ ${fonts.sizes('18px', '18px')};
66
+ margin-bottom: ${spacing.xsmall};
67
+ }
68
+ `;
69
+
28
70
  const AuthorInfo = ({ authorName, authorRole, email, image, phone }: Props) => (
29
- <section {...classes('')}>
30
- {image && <Portrait src={image} alt={authorName} modifier="large" {...classes('portrait-image')} />}
71
+ <AuthorInfoSection>
72
+ {image && <StyledPortrait src={image} alt={authorName} modifier="large" />}
31
73
  <div>
32
- <h1 {...classes('heading')}>{authorName}</h1>
74
+ <StyledHeading>{authorName}</StyledHeading>
33
75
  <p>{authorRole}</p>
34
76
  {phone && <p>{phone}</p>}
35
77
  {email && <SafeLink to={`mailto:${email}`}>{email}</SafeLink>}
36
78
  </div>
37
- </section>
79
+ </AuthorInfoSection>
38
80
  );
39
81
 
40
- AuthorInfo.propTypes = {
41
- authorName: PropTypes.string.isRequired,
42
- authorRole: PropTypes.string.isRequired,
43
- phone: PropTypes.string,
44
- email: PropTypes.string,
45
- image: PropTypes.string,
46
- };
47
-
48
82
  export default AuthorInfo;
@@ -1,11 +1,123 @@
1
1
  import React from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
- import PropTypes from 'prop-types';
2
+ import styled from '@emotion/styled';
4
3
  import { Play } from '@ndla/icons/common';
5
4
  import SafeLink from '@ndla/safelink';
6
5
  import type { SafeLinkProps } from '@ndla/safelink';
6
+ import { breakpoints, colors, fonts, mq, spacing, spacingUnit } from '@ndla/core';
7
7
 
8
- const classes = BEMHelper('c-content-card');
8
+ interface ContentCardContainerProps {
9
+ columnWidth: number;
10
+ }
11
+ const ContentCardContainer = styled.article<ContentCardContainerProps>`
12
+ position: relative;
13
+ display: block;
14
+ width: ${(p) => `${p.columnWidth}px`};
15
+ `;
16
+
17
+ const StyledHeading = styled.h1`
18
+ font-weight: ${fonts.weight.semibold};
19
+ ${fonts.sizes('14px', '16px')};
20
+ margin: ${spacing.xsmall} 0;
21
+ color: ${colors.brand.primary};
22
+
23
+ ${mq.range({ from: breakpoints.tablet })} {
24
+ margin: ${spacing.small} 0 ${spacing.xsmall};
25
+ ${fonts.sizes('20px', '22px')};
26
+ }
27
+ `;
28
+
29
+ const ContentCardLink = styled(SafeLink)`
30
+ color: ${colors.text.primary};
31
+ &:hover,
32
+ &:focus {
33
+ ${StyledHeading} {
34
+ text-decoration: underline;
35
+ }
36
+ }
37
+ `;
38
+
39
+ const ImageWrapper = styled.div`
40
+ width: 100%;
41
+ height: 72px;
42
+ border-radius: 5px;
43
+ position: relative;
44
+ overflow: hidden;
45
+ background: ${colors.background.grayDark};
46
+ ${mq.range({ from: breakpoints.tablet })} {
47
+ height: ${spacingUnit * 4.5}px;
48
+ }
49
+ `;
50
+
51
+ interface BackgroundImageProps {
52
+ image: string;
53
+ }
54
+ const BackgroundImage = styled.div<BackgroundImageProps>`
55
+ display: flex;
56
+ height: 100%;
57
+ width: 100%;
58
+ background-position: center center;
59
+ background-size: cover;
60
+ background-image: url(${(p) => p.image});
61
+ `;
62
+
63
+ const PlayBackground = styled.div`
64
+ position: absolute;
65
+ left: 50%;
66
+ top: 50%;
67
+ transform: translate3d(-50%, -50%, 0);
68
+ height: 35px;
69
+ width: 35px;
70
+ background-color: rgba(0, 0, 0, 0.48);
71
+ border-radius: 100%;
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ ${mq.range({ from: breakpoints.tablet })} {
76
+ height: 42px;
77
+ width: 42px;
78
+ }
79
+
80
+ .c-icon {
81
+ color: ${colors.white};
82
+ height: 20px;
83
+ width: 20px;
84
+ margin-right: -1px;
85
+
86
+ ${mq.range({ from: breakpoints.tablet })} {
87
+ height: 25px;
88
+ width: 25px;
89
+ }
90
+ }
91
+ `;
92
+
93
+ const StyledContentType = styled.p`
94
+ ${fonts.sizes('12px', '20px')};
95
+ position: absolute;
96
+ left: ${spacing.small};
97
+ bottom: ${spacing.small};
98
+ display: inline-block;
99
+ background: ${colors.brand.greyLightest};
100
+ border-radius: 2px;
101
+ font-weight: 600;
102
+ margin: 0;
103
+ padding: 0 ${spacing.xxsmall};
104
+
105
+ display: none;
106
+ ${mq.range({ from: breakpoints.tablet })} {
107
+ display: inline-block;
108
+ }
109
+ `;
110
+
111
+ const StyledDescription = styled.p`
112
+ ${fonts.sizes('16px')};
113
+ line-height: 1.25rem;
114
+ margin: 0;
115
+ display: none;
116
+
117
+ ${mq.range({ from: breakpoints.tablet })} {
118
+ display: block;
119
+ }
120
+ `;
9
121
 
10
122
  interface Props {
11
123
  title: string;
@@ -18,43 +130,23 @@ interface Props {
18
130
  }
19
131
 
20
132
  const ContentCard = ({ title, text, image, type, isFilm = false, toLinkProps, columnWidth }: Props) => (
21
- <article {...classes()} style={{ width: `${columnWidth}px` }}>
22
- <SafeLink {...toLinkProps()} title={title} {...classes('link')}>
133
+ <ContentCardContainer columnWidth={columnWidth}>
134
+ <ContentCardLink {...toLinkProps()} title={title}>
23
135
  <header>
24
- <div {...classes('image-wrapper')}>
25
- <div
26
- {...classes('background-image')}
27
- role="img"
28
- aria-label={title}
29
- style={{
30
- backgroundImage: `url(${image})`,
31
- }}
32
- />
136
+ <ImageWrapper>
137
+ <BackgroundImage image={image} role="img" aria-label={title} />
33
138
  {isFilm && (
34
- <div {...classes('play-background')}>
139
+ <PlayBackground>
35
140
  <Play />
36
- </div>
141
+ </PlayBackground>
37
142
  )}
38
- <p {...classes('type')}>{type}</p>
39
- </div>
40
- <h1 {...classes('heading')}>{title}</h1>
143
+ <StyledContentType>{type}</StyledContentType>
144
+ </ImageWrapper>
145
+ <StyledHeading>{title}</StyledHeading>
41
146
  </header>
42
- <p {...classes('description')}>{text}</p>
43
- </SafeLink>
44
- </article>
147
+ <StyledDescription>{text}</StyledDescription>
148
+ </ContentCardLink>
149
+ </ContentCardContainer>
45
150
  );
46
151
 
47
- ContentCard.propTypes = {
48
- title: PropTypes.string.isRequired,
49
- text: PropTypes.string.isRequired,
50
- type: PropTypes.string.isRequired,
51
- image: PropTypes.string.isRequired,
52
- isFilm: PropTypes.bool,
53
- toLinkProps: PropTypes.func.isRequired,
54
- };
55
-
56
- ContentCard.defaultProps = {
57
- isFilm: false,
58
- };
59
-
60
152
  export default ContentCard;
@@ -1,11 +1,36 @@
1
+ import styled from '@emotion/styled';
2
+ import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
1
3
  import { Download } from '@ndla/icons/common';
2
4
  import SafeLink from '@ndla/safelink';
3
5
  import Tooltip from '@ndla/tooltip';
4
6
  import React from 'react';
5
- import BEMHelper from 'react-bem-helper';
6
7
  import { FileFormat, FileType } from './FileList';
7
8
 
8
- const classes = BEMHelper('c-file-list');
9
+ const LinkText = styled.span`
10
+ & > span {
11
+ box-shadow: inset 0 -1px;
12
+ }
13
+ `;
14
+ const FileLink = styled(SafeLink)`
15
+ box-shadow: none;
16
+ position: relative;
17
+ color: ${colors.brand.primary};
18
+ margin-right: ${spacing.normal};
19
+ display: flex;
20
+ align-items: center;
21
+
22
+ &:last-child {
23
+ margin-right: 0;
24
+ }
25
+
26
+ &:hover,
27
+ &:focus,
28
+ &:active {
29
+ ${LinkText} {
30
+ box-shadow: none;
31
+ }
32
+ }
33
+ `;
9
34
 
10
35
  const renderFormat = (format: FileFormat, title: string, isPrimary: boolean, id: string, isDeadLink: boolean) => {
11
36
  const titleWithFormat = `${title} (${format.fileType.toUpperCase()})`;
@@ -22,20 +47,14 @@ const renderFormat = (format: FileFormat, title: string, isPrimary: boolean, id:
22
47
  }
23
48
 
24
49
  return (
25
- <SafeLink
26
- {...classes('link')}
27
- key={format.url}
28
- to={format.url}
29
- target="_blank"
30
- aria-label={titleWithFormat}
31
- aria-describedby={formatId}>
50
+ <FileLink key={format.url} to={format.url} target="_blank" aria-label={titleWithFormat} aria-describedby={formatId}>
32
51
  <Download />
33
52
  <Tooltip tooltip={format.tooltip}>
34
- <span {...classes('link-text')}>
53
+ <LinkText>
35
54
  <span>{isPrimary ? titleWithFormat : `(${format.fileType.toUpperCase()})`}</span>
36
- </span>
55
+ </LinkText>
37
56
  </Tooltip>
38
- </SafeLink>
57
+ </FileLink>
39
58
  );
40
59
  };
41
60
 
@@ -44,16 +63,27 @@ interface Props {
44
63
  file: FileType;
45
64
  }
46
65
 
66
+ const FileListItem = styled.li`
67
+ ${fonts.sizes('18px', '26px')};
68
+ font-weight: ${fonts.weight.semibold};
69
+ min-height: 60px;
70
+ background: ${colors.brand.greyLighter};
71
+ display: flex;
72
+ align-items: center;
73
+ flex-wrap: wrap;
74
+ margin-bottom: ${spacing.xsmall};
75
+ padding: ${spacing.small};
76
+ ${mq.range({ from: breakpoints.tablet })} {
77
+ padding: ${spacing.small} ${spacing.normal};
78
+ }
79
+ `;
80
+
47
81
  const File = ({ file, id }: Props) => {
48
82
  const formatLinks = file.formats.map((format, index) =>
49
83
  renderFormat(format, file.title, index === 0, id, !file.fileExists),
50
84
  );
51
85
 
52
- return (
53
- <li {...classes('item')} key={file.title}>
54
- {formatLinks}
55
- </li>
56
- );
86
+ return <FileListItem key={file.title}>{formatLinks}</FileListItem>;
57
87
  };
58
88
 
59
89
  export default File;
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
- import BEMHelper from 'react-bem-helper';
2
+ import styled from '@emotion/styled';
3
+ import { colors, fonts, spacing } from '@ndla/core';
3
4
  import File from './File';
4
5
 
5
- const classes = BEMHelper('c-file-list');
6
-
7
6
  export interface FileType {
8
7
  title: string;
9
8
  formats: FileFormat[];
@@ -22,15 +21,45 @@ interface Props {
22
21
  files: FileType[];
23
22
  }
24
23
 
24
+ const FileListSection = styled.section`
25
+ margin: ${spacing.large} 0;
26
+ padding: ${spacing.small} 0 ${spacing.normal} ${spacing.normal};
27
+ border-left: 2px solid ${colors.brand.greyLightest};
28
+ font-family: ${fonts.sans};
29
+
30
+ .c-icon {
31
+ margin-top: 3px;
32
+ flex-shrink: 0;
33
+ margin-right: ${spacing.small};
34
+ height: 18px;
35
+ width: 18px;
36
+ }
37
+ `;
38
+
39
+ const FileListHeading = styled.h1`
40
+ ${fonts.sizes('16px', '18px')};
41
+ letter-spacing: 0.05em;
42
+ margin: 0 0 ${spacing.xsmall} 0;
43
+ padding-bottom: ${spacing.xsmall};
44
+ border-bottom: 2px solid ${colors.brand.greyLight};
45
+ font-weight: ${fonts.weight.bold};
46
+ text-transform: uppercase;
47
+ `;
48
+
49
+ const FilesList = styled.ul`
50
+ margin: 0;
51
+ padding: 0;
52
+ `;
53
+
25
54
  const FileList = ({ files, heading, id }: Props) => (
26
- <section {...classes()}>
27
- <h1 {...classes('heading')}>{heading}</h1>
28
- <ul {...classes('files')}>
55
+ <FileListSection>
56
+ <FileListHeading>{heading}</FileListHeading>
57
+ <FilesList>
29
58
  {files.map((file) => (
30
59
  <File key={`file-${id}-${file.title}`} file={file} id={id} />
31
60
  ))}
32
- </ul>
33
- </section>
61
+ </FilesList>
62
+ </FileListSection>
34
63
  );
35
64
 
36
65
  export default FileList;
@@ -1,11 +1,31 @@
1
+ import styled from '@emotion/styled';
2
+ import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core/src';
1
3
  import React, { ReactNode } from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
-
4
- const classes = BEMHelper('c-info-box');
5
4
 
6
5
  interface Props {
7
6
  children?: ReactNode;
8
7
  }
9
- const InfoBox = ({ children }: Props) => <div {...classes()}>{children}</div>;
8
+
9
+ const StyledInfoBox = styled.div`
10
+ background: ${colors.support.yellowLight};
11
+ padding: ${spacing.small} ${spacing.normal};
12
+ font-family: ${fonts.sans};
13
+ ${fonts.sizes('14px', '18px')};
14
+ margin-bottom: ${spacing.medium};
15
+ ${mq.range({ from: breakpoints.tablet })} {
16
+ ${fonts.sizes('16px', '20px')};
17
+ padding: ${spacing.normal};
18
+ }
19
+
20
+ & > *:first-child {
21
+ margin-top: 0;
22
+ }
23
+
24
+ & > *:last-child {
25
+ margin-bottom: 0;
26
+ }
27
+ `;
28
+
29
+ const InfoBox = ({ children }: Props) => <StyledInfoBox>{children}</StyledInfoBox>;
10
30
 
11
31
  export default InfoBox;