@ndla/ui 23.0.0 → 24.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 (148) hide show
  1. package/es/Article/ArticleAuthorContent.js +2 -4
  2. package/es/Article/ArticleFavoritesButton.js +2 -2
  3. package/es/AuthorInfo/AuthorInfo.js +29 -16
  4. package/es/ContentCard/ContentCard.js +66 -25
  5. package/es/FileList/File.js +34 -8
  6. package/es/FileList/FileList.js +29 -3
  7. package/es/InfoBox/InfoBox.js +10 -3
  8. package/es/InfoWidget/InfoWidget.js +67 -22
  9. package/es/MyNdla/Resource/FolderInput.js +19 -6
  10. package/es/NoContentBox/NoContentBox.js +1 -6
  11. package/es/Portrait/Portrait.js +19 -13
  12. package/es/Resource/BlockResource.js +7 -6
  13. package/es/Resource/ListResource.js +8 -7
  14. package/es/Search/ActiveFilterContent.js +4 -14
  15. package/es/Search/ActiveFilters.js +8 -19
  16. package/es/Search/SearchField.js +31 -52
  17. package/es/Search/SearchResult.js +113 -136
  18. package/es/Search/ToggleSearchButton.js +34 -43
  19. package/es/Search/index.js +2 -8
  20. package/es/TagSelector/SuggestionInput.js +9 -19
  21. package/es/TreeStructure/FolderItems.js +3 -3
  22. package/es/TreeStructure/FolderNameInput.js +33 -14
  23. package/es/TreeStructure/TreeStructure.js +3 -2
  24. package/es/all.css +1 -1
  25. package/es/index-javascript.js +0 -1
  26. package/es/index.js +2 -1
  27. package/es/locale/messages-en.js +11 -5
  28. package/es/locale/messages-nb.js +9 -3
  29. package/es/locale/messages-nn.js +11 -5
  30. package/es/locale/messages-se.js +29 -23
  31. package/es/locale/messages-sma.js +43 -37
  32. package/lib/Article/ArticleAuthorContent.js +9 -4
  33. package/lib/Article/ArticleFavoritesButton.js +2 -2
  34. package/lib/AuthorInfo/AuthorInfo.d.ts +1 -11
  35. package/lib/AuthorInfo/AuthorInfo.js +36 -20
  36. package/lib/ContentCard/ContentCard.d.ts +1 -15
  37. package/lib/ContentCard/ContentCard.js +60 -28
  38. package/lib/FileList/File.js +36 -12
  39. package/lib/FileList/FileList.js +28 -5
  40. package/lib/InfoBox/InfoBox.js +12 -5
  41. package/lib/InfoWidget/InfoWidget.js +61 -25
  42. package/lib/MediaList/MediaList.d.ts +1 -1
  43. package/lib/MyNdla/Resource/FolderInput.js +18 -5
  44. package/lib/NoContentBox/NoContentBox.js +1 -8
  45. package/lib/Portrait/Portrait.js +19 -14
  46. package/lib/Resource/BlockResource.js +7 -6
  47. package/lib/Resource/ListResource.js +8 -7
  48. package/lib/Search/ActiveFilterContent.d.ts +13 -0
  49. package/lib/Search/ActiveFilterContent.js +4 -15
  50. package/lib/Search/ActiveFilters.d.ts +13 -0
  51. package/lib/Search/ActiveFilters.js +8 -20
  52. package/lib/Search/SearchField.d.ts +19 -0
  53. package/lib/Search/SearchField.js +32 -56
  54. package/lib/Search/SearchResult.d.ts +36 -0
  55. package/lib/Search/SearchResult.js +116 -159
  56. package/lib/Search/ToggleSearchButton.d.ts +16 -0
  57. package/lib/Search/ToggleSearchButton.js +36 -46
  58. package/lib/Search/index.d.ts +12 -0
  59. package/lib/Search/index.js +0 -54
  60. package/lib/SearchTypeResult/SearchTypeHeader.d.ts +1 -1
  61. package/lib/TagSelector/SuggestionInput.js +9 -19
  62. package/lib/TreeStructure/FolderItems.js +3 -3
  63. package/lib/TreeStructure/FolderNameInput.js +35 -14
  64. package/lib/TreeStructure/TreeStructure.js +3 -2
  65. package/lib/TreeStructure/types.d.ts +1 -1
  66. package/lib/all.css +1 -1
  67. package/lib/index-javascript.js +0 -74
  68. package/lib/index.d.ts +1 -0
  69. package/lib/index.js +38 -1
  70. package/lib/locale/messages-en.d.ts +7 -1
  71. package/lib/locale/messages-en.js +11 -5
  72. package/lib/locale/messages-nb.d.ts +6 -0
  73. package/lib/locale/messages-nb.js +9 -3
  74. package/lib/locale/messages-nn.d.ts +7 -1
  75. package/lib/locale/messages-nn.js +11 -5
  76. package/lib/locale/messages-se.d.ts +7 -1
  77. package/lib/locale/messages-se.js +29 -23
  78. package/lib/locale/messages-sma.d.ts +12 -6
  79. package/lib/locale/messages-sma.js +43 -37
  80. package/package.json +10 -10
  81. package/src/Article/ArticleAuthorContent.tsx +1 -1
  82. package/src/Article/ArticleFavoritesButton.tsx +2 -2
  83. package/src/AuthorInfo/AuthorInfo.tsx +53 -19
  84. package/src/ContentCard/ContentCard.tsx +127 -35
  85. package/src/FileList/File.tsx +47 -17
  86. package/src/FileList/FileList.tsx +37 -8
  87. package/src/InfoBox/InfoBox.tsx +24 -4
  88. package/src/InfoWidget/InfoWidget.tsx +83 -34
  89. package/src/MediaList/MediaList.tsx +1 -1
  90. package/src/MyNdla/Resource/FolderInput.tsx +18 -3
  91. package/src/NoContentBox/NoContentBox.tsx +2 -7
  92. package/src/Portrait/Portrait.tsx +25 -10
  93. package/src/Resource/BlockResource.tsx +1 -1
  94. package/src/Resource/ListResource.tsx +3 -1
  95. package/src/Search/{ActiveFilterContent.jsx → ActiveFilterContent.tsx} +11 -12
  96. package/src/Search/{ActiveFilters.jsx → ActiveFilters.tsx} +20 -17
  97. package/src/Search/{SearchField.jsx → SearchField.tsx} +58 -68
  98. package/src/Search/SearchResult.tsx +360 -0
  99. package/src/Search/ToggleSearchButton.tsx +73 -0
  100. package/src/Search/component.search.scss +0 -4
  101. package/src/Search/index.ts +16 -0
  102. package/src/SectionHeading/SectionHeading.tsx +1 -0
  103. package/src/TagSelector/SuggestionInput.tsx +0 -9
  104. package/src/TreeStructure/FolderItems.tsx +1 -1
  105. package/src/TreeStructure/FolderNameInput.tsx +34 -9
  106. package/src/TreeStructure/TreeStructure.tsx +1 -0
  107. package/src/TreeStructure/types.ts +1 -1
  108. package/src/all.scss +0 -1
  109. package/src/index-javascript.js +0 -15
  110. package/src/index.ts +2 -0
  111. package/src/locale/messages-en.ts +10 -4
  112. package/src/locale/messages-nb.ts +9 -3
  113. package/src/locale/messages-nn.ts +10 -4
  114. package/src/locale/messages-se.ts +29 -23
  115. package/src/locale/messages-sma.ts +41 -35
  116. package/src/main.scss +0 -7
  117. package/es/Search/SearchFilter.js +0 -72
  118. package/es/Search/SearchFilterList.js +0 -115
  119. package/es/Search/SearchOverlay.js +0 -39
  120. package/es/Search/SearchPage.js +0 -178
  121. package/es/Search/SearchPopoverFilter.js +0 -152
  122. package/es/Search/SearchResultAuthor.js +0 -51
  123. package/lib/Search/SearchFilter.js +0 -88
  124. package/lib/Search/SearchFilterList.js +0 -137
  125. package/lib/Search/SearchOverlay.js +0 -62
  126. package/lib/Search/SearchPage.js +0 -207
  127. package/lib/Search/SearchPopoverFilter.js +0 -172
  128. package/lib/Search/SearchResultAuthor.js +0 -60
  129. package/src/AuthorInfo/component.author-info.scss +0 -54
  130. package/src/ContentCard/component.content-card.scss +0 -109
  131. package/src/FileList/component.file-list.scss +0 -102
  132. package/src/InfoBox/component.info-box.scss +0 -21
  133. package/src/InfoWidget/component.info-widget.scss +0 -52
  134. package/src/NoContentBox/component.no-content-box.scss +0 -17
  135. package/src/Portrait/component.portrait.scss +0 -29
  136. package/src/Search/SearchFilter.jsx +0 -82
  137. package/src/Search/SearchFilterList.jsx +0 -110
  138. package/src/Search/SearchOverlay.jsx +0 -38
  139. package/src/Search/SearchPage.jsx +0 -178
  140. package/src/Search/SearchPopoverFilter.jsx +0 -109
  141. package/src/Search/SearchResult.jsx +0 -239
  142. package/src/Search/SearchResultAuthor.jsx +0 -54
  143. package/src/Search/ToggleSearchButton.jsx +0 -64
  144. package/src/Search/component.search-filter.scss +0 -67
  145. package/src/Search/component.search-overlay.scss +0 -103
  146. package/src/Search/component.search-page.scss +0 -125
  147. package/src/Search/component.search-result-author.scss +0 -65
  148. package/src/Search/index.js +0 -34
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
13
-
14
- var _safelink = _interopRequireDefault(require("@ndla/safelink"));
15
-
16
- var _Portrait = _interopRequireDefault(require("../Portrait"));
17
-
18
- var _core = require("@emotion/core");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
-
24
- var classes = new _reactBemHelper["default"]('c-search-result-author');
25
-
26
- var SearchResultAuthor = function SearchResultAuthor(_ref) {
27
- var messages = _ref.messages,
28
- url = _ref.url,
29
- image = _ref.image,
30
- modifier = _ref.modifier;
31
- return (0, _core.jsx)("div", classes('', modifier), (0, _core.jsx)("div", null, (0, _core.jsx)("h1", classes('heading'), messages.authorName), (0, _core.jsx)("p", null, messages.role), (0, _core.jsx)("p", null, messages.phone), (0, _core.jsx)("div", classes('links'), messages.email && (0, _core.jsx)(_safelink["default"], {
32
- to: "mailto:".concat(messages.email)
33
- }, messages.email), url && (0, _core.jsx)(_safelink["default"], _extends({
34
- to: url
35
- }, classes('url')), messages.readmoreLabel))), (0, _core.jsx)(_Portrait["default"], _extends({
36
- src: image,
37
- alt: messages.authorName
38
- }, classes('portrait-image'))));
39
- };
40
-
41
- SearchResultAuthor.propTypes = {
42
- messages: _propTypes["default"].shape({
43
- authorName: _propTypes["default"].string.isRequired,
44
- role: _propTypes["default"].string.isRequired,
45
- phone: _propTypes["default"].string,
46
- email: _propTypes["default"].string,
47
- readmoreLabel: function readmoreLabel(props, propName, componentName) {
48
- if (typeof props.url === 'string' && typeof props[propName] !== 'string') {
49
- return new Error("".concat(componentName, " messages.readmoreLabel is required when propTypes.url"));
50
- }
51
-
52
- return null;
53
- }
54
- }),
55
- image: _propTypes["default"].string.isRequired,
56
- url: _propTypes["default"].string,
57
- modifier: _propTypes["default"].oneOf(['desktop', 'tablet']).isRequired
58
- };
59
- var _default = SearchResultAuthor;
60
- exports["default"] = _default;
@@ -1,54 +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
- .c-author-info {
10
- display: flex;
11
- align-items: flex-start;
12
- padding-bottom: $spacing--large;
13
- font-family: $font;
14
- &__portrait-image {
15
- margin-right: $spacing--large;
16
- @include mq($until: desktop) {
17
- margin-right: $spacing--medium;
18
- width: 7rem;
19
- height: 7rem;
20
- span {
21
- width: 7rem;
22
- height: 7rem;
23
- }
24
- }
25
- @include mq($until: tablet) {
26
- margin-right: $spacing--small;
27
- width: 4rem;
28
- height: 4rem;
29
- span {
30
- width: 4rem;
31
- height: 4rem;
32
- }
33
- }
34
- }
35
- &__heading {
36
- margin: 0 0 $spacing--small;
37
- @include mq($until: desktop) {
38
- @include font-size(22px, 22px);
39
- }
40
- @include mq($until: tablet) {
41
- @include font-size(18px, 18px);
42
- margin-bottom: $spacing--small / 2;
43
- }
44
- }
45
- p, a {
46
- margin: 0;
47
- @include mq($until: tablet) {
48
- @include font-size(14px, 22px);
49
- }
50
- }
51
- &__readmore {
52
- margin: $spacing 0;
53
- }
54
- }
@@ -1,109 +0,0 @@
1
- .c-content-card {
2
- position: relative;
3
- display: block;
4
- width: 100%;
5
-
6
- &__image-wrapper {
7
- width: 100%;
8
- height: 72px;
9
- border-radius: 5px;
10
- position: relative;
11
- overflow: hidden;
12
- background: $background-color--gray-dark;
13
-
14
- @include mq(tablet) {
15
- height: $spacing--large * 2.5;
16
- }
17
- }
18
-
19
- &__link {
20
- color: $primary-color;
21
- &:hover,
22
- &:focus {
23
- .c-content-card__heading {
24
- text-decoration: underline;
25
- }
26
- }
27
- }
28
-
29
- &__type {
30
- @include inuit-font-size(12px, 20px);
31
- position: absolute;
32
- left: $spacing--small;
33
- bottom: $spacing--small;
34
- display: inline-block;
35
- background: $brand-grey--lightest;
36
- border-radius: 2px;
37
- font-weight: 600;
38
- margin: 0;
39
- padding: 0 $spacing--small/3;
40
-
41
- display: none;
42
-
43
- @include mq(tablet) {
44
- display: inline-block;
45
- }
46
- }
47
-
48
- &__heading {
49
- font-weight: $font-weight-semibold;
50
- @include font-size(14px, 16px);
51
- margin: $spacing--small / 2 0;
52
- color: $brand-color;
53
-
54
- @include mq(tablet) {
55
- margin: $spacing--small 0 $spacing--small / 2;
56
- @include font-size(20px, 22px);
57
- }
58
- }
59
-
60
- &__description {
61
- @include inuit-font-size(16px);
62
- line-height: 1.25rem;
63
- // font-family: $font-serif;
64
- margin: 0;
65
- display: none;
66
-
67
- @include mq(tablet) {
68
- display: block;
69
- }
70
- }
71
-
72
- &__play-background {
73
- position: absolute;
74
- left: 50%;
75
- top: 50%;
76
- transform: translate3d(-50%, -50%, 0);
77
- height: 35px;
78
- width: 35px;
79
- background-color: rgba(0, 0, 0, 0.48);
80
- border-radius: 100%;
81
- display: flex;
82
- align-items: center;
83
- justify-content: center;
84
-
85
- @include mq(tablet) {
86
- height: 42px;
87
- width: 42px;
88
- }
89
-
90
- .c-icon {
91
- color: $white;
92
- height: 20px;
93
- width: 20px;
94
- margin-right: -1px;
95
-
96
- @include mq(tablet) {
97
- height: 25px;
98
- width: 25px;
99
- }
100
- }
101
- }
102
- &__background-image {
103
- display: flex;
104
- height: 100%;
105
- width: 100%;
106
- background-position: center center;
107
- background-size: cover;
108
- }
109
- }
@@ -1,102 +0,0 @@
1
- .c-file-list {
2
- margin: $spacing--large 0;
3
- padding: $spacing--small 0 $spacing $spacing;
4
- border-left: 2px solid $brand-grey--lightest;
5
- font-family: $font;
6
-
7
- &__heading {
8
- @include font-size(16px, 18px);
9
- letter-spacing: 0.05em;
10
- margin: 0 0 $spacing--small / 2 0;
11
- padding-bottom: $spacing--small / 2;
12
-
13
- border-bottom: 2px solid $brand-grey--light;
14
- font-weight: $font-weight-bold;
15
- text-transform: uppercase;
16
- }
17
-
18
- &__files {
19
- margin: 0;
20
- padding: 0;
21
- }
22
-
23
- &__item {
24
- @include font-size(18px, 26px);
25
- font-weight: $font-weight-semibold;
26
- min-height: 60px;
27
- background: $brand-grey--lighter;
28
- display: flex;
29
- align-items: center;
30
- flex-wrap: wrap;
31
- margin-bottom: $spacing--small / 2;
32
- padding: $spacing--small;
33
-
34
- @include mq(tablet) {
35
- padding: $spacing--small $spacing;
36
- }
37
- }
38
-
39
- &__link {
40
- box-shadow: none;
41
- position: relative;
42
- color: $brand-color;
43
- margin-right: $spacing;
44
- display: flex;
45
- align-items: center;
46
-
47
- &:last-child {
48
- margin-right: 0;
49
- }
50
-
51
- &:hover,
52
- &:focus,
53
- &:active {
54
- .c-file-list__link-text {
55
- & > span {
56
- box-shadow: $link--hover;
57
- }
58
- }
59
- }
60
- }
61
-
62
- &__link-text {
63
- & > span {
64
- box-shadow: $link;
65
- }
66
- }
67
-
68
- &__tooltip {
69
- position: absolute;
70
- display: none;
71
- left: 50%;
72
- top: -$spacing--small;
73
- transform: translate3d(-50%, -100%, 0);
74
- width: 300px;
75
- text-align: center;
76
- z-index: 1;
77
-
78
- &[aria-hidden='false'] {
79
- display: block;
80
- animation-name: fadeIn;
81
- animation-duration: 0.3s;
82
- }
83
- }
84
-
85
- &__tooltip-text {
86
- display: inline-block;
87
- text-align: left;
88
- background: $brand-color;
89
- padding: $spacing--small;
90
- @include font-size(14px, 18px);
91
- font-weight: $font-weight-normal;
92
- color: $white;
93
- }
94
-
95
- .c-icon {
96
- margin-top: 3px;
97
- flex-shrink: 0;
98
- margin-right: $spacing--small;
99
- height: 18px;
100
- width: 18px;
101
- }
102
- }
@@ -1,21 +0,0 @@
1
- .c-info-box {
2
- background: $yellow-light;
3
- padding: $spacing--small $spacing;
4
- font-family: $font;
5
- @include font-size(14px, 18px);
6
-
7
- margin-bottom: $spacing--medium;
8
-
9
- @include mq(tablet) {
10
- @include font-size(16px, 20px);
11
- padding: $spacing;
12
- }
13
-
14
- & > *:first-child {
15
- margin-top: 0;
16
- }
17
-
18
- & > *:last-child {
19
- margin-bottom: 0;
20
- }
21
- }
@@ -1,52 +0,0 @@
1
- .c-info-widget {
2
- max-width: 600px;
3
-
4
- &--center {
5
- margin: 0 auto;
6
- }
7
-
8
- &__description {
9
- padding: $spacing;
10
- background: $brand-color--lighter;
11
- color: $brand-color--dark;
12
- @include font-size(18px, 26px);
13
-
14
- p {
15
- margin-top: 0;
16
-
17
- &:last-child {
18
- margin-bottom: 0;
19
- }
20
- }
21
- }
22
-
23
- &__links {
24
- display: flex;
25
- align-items: center;
26
- justify-content: flex-end;
27
- }
28
-
29
- &__main-link {
30
- color: $brand-color--dark;
31
- @include font-size(16px, 24px);
32
- }
33
-
34
- &__icon-link {
35
- width: 47px;
36
- height: 47px;
37
- border-radius: 100%;
38
- background: $brand-color--lighter;
39
- color: $brand-color--dark;
40
- box-shadow: none;
41
- display: flex;
42
- justify-content: center;
43
- align-items: center;
44
-
45
- .c-icon {
46
- width: 20px;
47
- height: 20px;
48
- }
49
-
50
- margin-right: $spacing--small;
51
- }
52
- }
@@ -1,17 +0,0 @@
1
- /**
2
- ** NO CONTENT BOX
3
- ** No content found in lists (used by Topic and resources lists)
4
- **/
5
-
6
-
7
- .c-no-content-box {
8
- background: $brand-grey--lightest;
9
- border: 1px dashed $brand-color--light;
10
- text-align: center;
11
- padding: $spacing--small $spacing--small $spacing;
12
- font-family: $font;
13
- p {
14
- @include font-size(16px, 18px);
15
- margin: $spacing--small;
16
- }
17
- }
@@ -1,29 +0,0 @@
1
- .c-portrait {
2
- width: 7rem;
3
- height: 7rem;
4
- span {
5
- display: block;
6
- border-radius: 50%;
7
- background-color: rgba(0,0,0,0.16);
8
- background-size: cover;
9
- background-position: center center;
10
- width: 7rem;
11
- height: 7rem;
12
- }
13
- &--small {
14
- width: 4rem;
15
- height: 4rem;
16
- span {
17
- width: 4rem;
18
- height: 4rem;
19
- }
20
- }
21
- &--large {
22
- width: 10rem;
23
- height: 10rem;
24
- span {
25
- width: 10rem;
26
- height: 10rem;
27
- }
28
- }
29
- }
@@ -1,82 +0,0 @@
1
- import React from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
- import PropTypes from 'prop-types';
4
-
5
- import { FilterList } from '../Filter';
6
-
7
- const searchFilterClasses = BEMHelper({
8
- prefix: 'c-',
9
- name: 'search-filter',
10
- outputIsString: true,
11
- });
12
-
13
- const valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
14
-
15
- const SearchFilter = ({
16
- label,
17
- options,
18
- values,
19
- defaultVisibleCount,
20
- showLabel,
21
- hideLabel,
22
- narrowScreenOnly,
23
- contextFilter,
24
- onChange,
25
- noFilterSelectedLabel,
26
- children,
27
- }) => {
28
- const modifiers = [];
29
-
30
- if (narrowScreenOnly) {
31
- modifiers.push('narrow-screen-only');
32
- }
33
-
34
- if (contextFilter) {
35
- modifiers.push('context-filter');
36
- }
37
-
38
- return (
39
- <div className={searchFilterClasses('', modifiers)}>
40
- <FilterList
41
- options={options}
42
- label={label}
43
- labelNotVisible={contextFilter}
44
- values={values}
45
- defaultVisibleCount={defaultVisibleCount}
46
- modifiers={!contextFilter ? 'search' : null}
47
- showLabel={showLabel}
48
- hideLabel={hideLabel}
49
- onChange={onChange}
50
- alignedGroup
51
- noFilterSelectedLabel={noFilterSelectedLabel}
52
- />
53
- {children}
54
- </div>
55
- );
56
- };
57
-
58
- SearchFilter.propTypes = {
59
- label: PropTypes.string.isRequired,
60
- options: PropTypes.arrayOf(
61
- PropTypes.shape({
62
- value: valueShape.isRequired,
63
- title: PropTypes.string.isRequired,
64
- noResults: PropTypes.bool,
65
- }),
66
- ).isRequired,
67
- values: PropTypes.arrayOf(valueShape),
68
- defaultVisibleCount: PropTypes.number,
69
- onChange: PropTypes.func,
70
- showLabel: PropTypes.string,
71
- hideLabel: PropTypes.string,
72
- narrowScreenOnly: PropTypes.bool,
73
- noFilterSelectedLabel: PropTypes.string,
74
- contextFilter: PropTypes.bool,
75
- children: PropTypes.node,
76
- };
77
-
78
- SearchFilter.defaultProps = {
79
- values: [],
80
- };
81
-
82
- export default SearchFilter;
@@ -1,110 +0,0 @@
1
- import React, { Fragment } from 'react';
2
- import BEMHelper from 'react-bem-helper';
3
- import PropTypes from 'prop-types';
4
-
5
- import { FilterList, ToggleItem } from '../Filter';
6
-
7
- const searchFilterClasses = BEMHelper({
8
- prefix: 'c-',
9
- name: 'search-filter',
10
- outputIsString: true,
11
- });
12
-
13
- const valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
14
-
15
- const SearchFilterList = ({
16
- label,
17
- options,
18
- values,
19
- narrowScreenOnly,
20
- onChange,
21
- onSubfilterChange,
22
- preid,
23
- noFilterSelectedLabel,
24
- subjectValues,
25
- children,
26
- }) => {
27
- return (
28
- <div className={searchFilterClasses('')}>
29
- <div>
30
- {options.map((option, index) => {
31
- const itemModifiers = [];
32
- const checked = values.some((value) => value === option.value);
33
-
34
- if (!checked && index + 1 > this.state.visibleCount) {
35
- itemModifiers.push('hidden');
36
- }
37
-
38
- const disabled = option.noResults || option.hits === 0;
39
-
40
- if (disabled) {
41
- itemModifiers.push('no-results');
42
- }
43
-
44
- return (
45
- <Fragment key={option.value}>
46
- <ToggleItem
47
- modifiers={itemModifiers}
48
- id={preid + option.value}
49
- value={option.value}
50
- disabled={disabled}
51
- tabIndex={disabled ? -1 : 0}
52
- checked={checked}
53
- icon={option.icon}
54
- label={option.title}
55
- component="div"
56
- onChange={(event) => {
57
- let newValues = null;
58
- if (event.currentTarget.checked) {
59
- newValues = [...values, option.value];
60
- } else {
61
- newValues = values.filter((value) => value !== option.value);
62
- }
63
- if (onChange) {
64
- onChange(newValues, option.value);
65
- }
66
- }}
67
- />
68
- <div className={searchFilterClasses()}>
69
- <FilterList
70
- options={option.subjectFilters}
71
- label={label}
72
- labelNotVisible
73
- values={subjectValues[option.value]}
74
- onChange={(subjectFilters, subjectFilter) =>
75
- onSubfilterChange(option.value, subjectFilters, subjectFilter)
76
- }
77
- alignedGroup
78
- noFilterSelectedLabel={noFilterSelectedLabel}
79
- />
80
- </div>
81
- </Fragment>
82
- );
83
- })}
84
- </div>
85
- {children}
86
- </div>
87
- );
88
- };
89
-
90
- SearchFilterList.propTypes = {
91
- label: PropTypes.string.isRequired,
92
- options: PropTypes.arrayOf(
93
- PropTypes.shape({
94
- value: valueShape.isRequired,
95
- title: PropTypes.string.isRequired,
96
- noResults: PropTypes.bool,
97
- }),
98
- ).isRequired,
99
- values: PropTypes.arrayOf(valueShape),
100
- onChange: PropTypes.func,
101
- onSubfilterChange: PropTypes.func,
102
- noFilterSelectedLabel: PropTypes.string,
103
- children: PropTypes.node,
104
- };
105
-
106
- SearchFilterList.defaultProps = {
107
- values: [],
108
- };
109
-
110
- export default SearchFilterList;
@@ -1,38 +0,0 @@
1
- import React, { Fragment } from 'react';
2
- import PropTypes from 'prop-types';
3
- import BEMHelper from 'react-bem-helper';
4
- import { Cross } from '@ndla/icons/action';
5
- import { CSSTransition } from 'react-transition-group';
6
-
7
- import Fade from '../Animation/Fade';
8
-
9
- const classes = BEMHelper({
10
- prefix: 'c-',
11
- name: 'search-overlay',
12
- });
13
-
14
- const SearchOverlay = ({ close, isOpen, children }) => (
15
- <Fragment>
16
- <Fade in={isOpen}>
17
- <div className="o-backdrop" />
18
- </Fade>
19
- <CSSTransition timeout={300} classNames={classes().className} unmountOnExit in={isOpen}>
20
- <div {...classes()}>
21
- <div {...classes('container o-wrapper')}>
22
- {children}
23
- <button {...classes('close-button')} type="button" onClick={close}>
24
- <Cross />
25
- </button>
26
- </div>
27
- </div>
28
- </CSSTransition>
29
- </Fragment>
30
- );
31
-
32
- SearchOverlay.propTypes = {
33
- isOpen: PropTypes.bool.isRequired,
34
- close: PropTypes.func,
35
- children: PropTypes.node.isRequired,
36
- };
37
-
38
- export default SearchOverlay;