@ndla/ui 43.0.0 → 43.0.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 (70) hide show
  1. package/es/Article/ArticleNotions.js +46 -53
  2. package/es/Filter/FilterButtons.js +49 -53
  3. package/es/Filter/FilterListPhone.js +78 -71
  4. package/es/LearningPaths/LearningPathMenuModalWrapper.js +39 -28
  5. package/es/Masthead/MastheadSearchModal.js +31 -35
  6. package/es/NDLAFilm/AboutNdlaFilm.js +16 -20
  7. package/es/NDLAFilm/FilmMovieSearch.js +43 -11
  8. package/es/ResourcesWrapper/ResourcesTopicTitle.js +36 -44
  9. package/es/Search/ToggleSearchButton.js +7 -6
  10. package/es/SearchTypeResult/PopupFilter.js +55 -69
  11. package/es/SearchTypeResult/SearchNotionsResult.js +9 -7
  12. package/es/SearchTypeResult/components/ItemContexts.js +41 -45
  13. package/es/SearchTypeResult/components/SubjectFilters.js +16 -17
  14. package/es/Topic/Topic.js +41 -45
  15. package/es/locale/messages-en.js +1 -0
  16. package/es/locale/messages-nb.js +1 -0
  17. package/es/locale/messages-nn.js +1 -0
  18. package/es/locale/messages-se.js +1 -0
  19. package/es/locale/messages-sma.js +1 -0
  20. package/lib/Article/ArticleNotions.js +45 -52
  21. package/lib/Filter/FilterButtons.js +48 -52
  22. package/lib/Filter/FilterListPhone.js +76 -69
  23. package/lib/LearningPaths/LearningPathMenuModalWrapper.js +47 -35
  24. package/lib/Masthead/MastheadSearchModal.js +29 -32
  25. package/lib/NDLAFilm/AboutNdlaFilm.js +15 -18
  26. package/lib/NDLAFilm/FilmMovieSearch.d.ts +1 -2
  27. package/lib/NDLAFilm/FilmMovieSearch.js +46 -11
  28. package/lib/ResourcesWrapper/ResourcesTopicTitle.js +35 -42
  29. package/lib/Search/ToggleSearchButton.d.ts +2 -1
  30. package/lib/Search/ToggleSearchButton.js +9 -6
  31. package/lib/SearchTypeResult/PopupFilter.d.ts +1 -3
  32. package/lib/SearchTypeResult/PopupFilter.js +54 -68
  33. package/lib/SearchTypeResult/SearchNotionsResult.js +9 -7
  34. package/lib/SearchTypeResult/components/ItemContexts.js +40 -44
  35. package/lib/SearchTypeResult/components/SubjectFilters.js +16 -17
  36. package/lib/Topic/Topic.js +40 -44
  37. package/lib/locale/messages-en.d.ts +1 -0
  38. package/lib/locale/messages-en.js +1 -0
  39. package/lib/locale/messages-nb.d.ts +1 -0
  40. package/lib/locale/messages-nb.js +1 -0
  41. package/lib/locale/messages-nn.d.ts +1 -0
  42. package/lib/locale/messages-nn.js +1 -0
  43. package/lib/locale/messages-se.d.ts +1 -0
  44. package/lib/locale/messages-se.js +1 -0
  45. package/lib/locale/messages-sma.d.ts +1 -0
  46. package/lib/locale/messages-sma.js +1 -0
  47. package/package.json +10 -10
  48. package/src/Article/ArticleNotions.tsx +29 -35
  49. package/src/Filter/FilterButtons.tsx +28 -34
  50. package/src/Filter/FilterListPhone.tsx +63 -62
  51. package/src/LearningPaths/LearningPathMenuModalWrapper.tsx +19 -18
  52. package/src/Masthead/MastheadSearchModal.tsx +21 -29
  53. package/src/NDLAFilm/AboutNdlaFilm.tsx +11 -10
  54. package/src/NDLAFilm/FilmMovieSearch.tsx +32 -9
  55. package/src/ResourcesWrapper/ResourcesTopicTitle.tsx +23 -27
  56. package/src/Search/ToggleSearchButton.tsx +15 -12
  57. package/src/SearchTypeResult/PopupFilter.tsx +55 -70
  58. package/src/SearchTypeResult/SearchNotionsResult.tsx +5 -2
  59. package/src/SearchTypeResult/components/ItemContexts.tsx +23 -28
  60. package/src/SearchTypeResult/components/SubjectFilters.tsx +9 -12
  61. package/src/Topic/Topic.tsx +15 -17
  62. package/src/locale/messages-en.ts +1 -0
  63. package/src/locale/messages-nb.ts +1 -0
  64. package/src/locale/messages-nn.ts +1 -0
  65. package/src/locale/messages-se.ts +1 -0
  66. package/src/locale/messages-sma.ts +1 -0
  67. package/es/NDLAFilm/CategorySelect.js +0 -135
  68. package/lib/NDLAFilm/CategorySelect.d.ts +0 -16
  69. package/lib/NDLAFilm/CategorySelect.js +0 -144
  70. package/src/NDLAFilm/CategorySelect.tsx +0 -197
@@ -97,6 +97,7 @@ declare const messages: {
97
97
  share: string;
98
98
  shared: string;
99
99
  unShare: string;
100
+ copyLink: string;
100
101
  link: string;
101
102
  header: {
102
103
  private: string;
@@ -1100,6 +1100,7 @@ var messages = _objectSpread(_objectSpread({
1100
1100
  share: 'Share folder',
1101
1101
  shared: 'Shared',
1102
1102
  unShare: 'Sharing stopped. The folder is no longer shared',
1103
+ copyLink: 'Copy link to folder',
1103
1104
  link: 'Link is copied',
1104
1105
  header: {
1105
1106
  private: 'Do you want to share this folder?',
@@ -97,6 +97,7 @@ declare const messages: {
97
97
  share: string;
98
98
  shared: string;
99
99
  unShare: string;
100
+ copyLink: string;
100
101
  link: string;
101
102
  header: {
102
103
  private: string;
@@ -1098,6 +1098,7 @@ var messages = _objectSpread(_objectSpread({
1098
1098
  share: 'Del mappe',
1099
1099
  shared: 'Delt',
1100
1100
  unShare: 'Delingen er avsluttet. Mappen er ikke lenger delt.',
1101
+ copyLink: 'Kopier lenke til mappa',
1101
1102
  link: 'Lenken er kopiert',
1102
1103
  header: {
1103
1104
  private: 'Vil du dele denne mappa?',
@@ -98,6 +98,7 @@ declare const messages: {
98
98
  shared: string;
99
99
  unShare: string;
100
100
  link: string;
101
+ copyLink: string;
101
102
  header: {
102
103
  private: string;
103
104
  shared: string;
@@ -1099,6 +1099,7 @@ var messages = _objectSpread(_objectSpread({
1099
1099
  shared: 'Delt',
1100
1100
  unShare: 'Delinga er avslutta. Mappa er ikkje lenger delt',
1101
1101
  link: 'Lenka er kopiert',
1102
+ copyLink: 'Kopier lenke til mappa',
1102
1103
  header: {
1103
1104
  private: 'Vil du dele denne mappa?',
1104
1105
  shared: 'Denne mappa er delt',
@@ -97,6 +97,7 @@ declare const messages: {
97
97
  share: string;
98
98
  shared: string;
99
99
  unShare: string;
100
+ copyLink: string;
100
101
  link: string;
101
102
  header: {
102
103
  private: string;
@@ -1098,6 +1098,7 @@ var messages = _objectSpread(_objectSpread({
1098
1098
  share: 'Juoge máhpa',
1099
1099
  shared: 'Juogaduvvon',
1100
1100
  unShare: 'Juohkin lea loahpahuvvon. Máhppa ii leat šat juogaduvvon.',
1101
+ copyLink: 'Kopier lenke til mappa',
1101
1102
  link: 'Liŋka lea máŋgejuvvon.',
1102
1103
  header: {
1103
1104
  private: 'Áiggut go juogadit dán máhpa?',
@@ -97,6 +97,7 @@ declare const messages: {
97
97
  share: string;
98
98
  shared: string;
99
99
  unShare: string;
100
+ copyLink: string;
100
101
  link: string;
101
102
  header: {
102
103
  private: string;
@@ -1098,6 +1098,7 @@ var messages = _objectSpread(_objectSpread({
1098
1098
  share: 'Del mappe',
1099
1099
  shared: 'Delt',
1100
1100
  unShare: 'Delingen er avsluttet. Mappen er ikke lenger delt.',
1101
+ copyLink: 'Kopier lenke til mappa',
1101
1102
  link: 'Lenken er kopiert',
1102
1103
  header: {
1103
1104
  private: 'Vil du dele denne mappen?',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "43.0.0",
3
+ "version": "43.0.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,26 +31,26 @@
31
31
  "types"
32
32
  ],
33
33
  "dependencies": {
34
- "@ndla/accordion": "^2.2.15",
34
+ "@ndla/accordion": "^2.2.16",
35
35
  "@ndla/article-scripts": "^3.0.19",
36
- "@ndla/button": "^11.0.0",
36
+ "@ndla/button": "^11.0.1",
37
37
  "@ndla/carousel": "^3.1.11",
38
38
  "@ndla/core": "^4.1.4",
39
- "@ndla/dropdown-menu": "^1.0.0",
40
- "@ndla/forms": "^4.3.15",
39
+ "@ndla/dropdown-menu": "^1.0.1",
40
+ "@ndla/forms": "^4.3.16",
41
41
  "@ndla/hooks": "^2.0.8",
42
42
  "@ndla/icons": "^4.0.1",
43
43
  "@ndla/licenses": "^7.1.1",
44
- "@ndla/modal": "^3.0.11",
45
- "@ndla/notion": "^5.0.13",
46
- "@ndla/safelink": "^4.1.14",
44
+ "@ndla/modal": "^4.0.0",
45
+ "@ndla/notion": "^5.0.14",
46
+ "@ndla/safelink": "^4.1.15",
47
+ "@ndla/select": "^2.4.7",
47
48
  "@ndla/switch": "^1.1.8",
48
49
  "@ndla/tabs": "^3.0.4",
49
50
  "@ndla/tooltip": "^4.1.13",
50
51
  "@ndla/util": "^3.1.14",
51
52
  "@radix-ui/react-popover": "^1.0.6",
52
53
  "@radix-ui/react-slider": "^1.1.2",
53
- "focus-trap-react": "^8.9.2",
54
54
  "framer-motion": "^6.5.1",
55
55
  "html-react-parser": "^3.0.8",
56
56
  "i18next-browser-languagedetector": "^6.1.1",
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "2aa95438581ea00bd5f1eac85a1514511bfe0de2"
85
+ "gitHead": "8e45543b08254be6779eacff708494896344bee8"
86
86
  }
@@ -9,7 +9,7 @@
9
9
  import React from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import { useTranslation } from 'react-i18next';
12
- import { ModalHeader, ModalCloseButton, ModalBody, Modal, ModalTitle } from '@ndla/modal';
12
+ import { ModalHeader, ModalCloseButton, ModalBody, Modal, ModalTitle, ModalTrigger, ModalContent } from '@ndla/modal';
13
13
  import { mq, breakpoints, fonts, colors } from '@ndla/core';
14
14
  import { Explanation, NotionFlip } from '@ndla/icons/common';
15
15
  import { ConceptNotion } from '../Notion';
@@ -165,48 +165,42 @@ type ArticleNotionsProps = {
165
165
  export const ArticleNotions = ({ notions, relatedContent = [], buttonOffsetRight, type }: ArticleNotionsProps) => {
166
166
  const { t } = useTranslation();
167
167
  const leftOffset = `${buttonOffsetRight - 32}px`;
168
- const headingId = 'popupNotionHeading';
169
168
 
170
169
  return (
171
170
  <ArticleNotionsContainer>
172
- <Modal
173
- aria-labelledby={headingId}
174
- activateButton={
171
+ <Modal>
172
+ <ModalTrigger>
175
173
  <NotionsTrigger role="button" aria-label={t('article.notionsPrompt')} style={{ left: leftOffset }}>
176
174
  <NotionFlip />
177
175
  <Explanation />
178
- <span id={headingId}>{t('article.notionsPrompt')}</span>
176
+ <span>{t('article.notionsPrompt')}</span>
179
177
  </NotionsTrigger>
180
- }
181
- size="large"
182
- >
183
- {(onClose: () => void) => (
184
- <div>
185
- <ModalHeader className="no-padding">
186
- <ModalHeadingContainer>
187
- <Explanation />
188
- <ModalTitle>{t('article.notionsPrompt')}</ModalTitle>
189
- </ModalHeadingContainer>
190
- <ModalCloseButton onClick={onClose} title="Lukk" />
191
- </ModalHeader>
192
- <ModalBody modifier="notions-modal-body no-padding">
193
- <NotionsContainer>
194
- {notions.map((notion) => (
195
- <ConceptNotion key={notion.id} concept={notion} type={type} />
178
+ </ModalTrigger>
179
+ <ModalContent size="large">
180
+ <ModalHeader className="no-padding">
181
+ <ModalHeadingContainer>
182
+ <Explanation />
183
+ <ModalTitle>{t('article.notionsPrompt')}</ModalTitle>
184
+ </ModalHeadingContainer>
185
+ <ModalCloseButton />
186
+ </ModalHeader>
187
+ <ModalBody modifier="notions-modal-body no-padding">
188
+ <NotionsContainer>
189
+ {notions.map((notion) => (
190
+ <ConceptNotion key={notion.id} concept={notion} type={type} />
191
+ ))}
192
+ </NotionsContainer>
193
+ {relatedContent.length > 0 && (
194
+ <RelatedContentContainer>
195
+ {relatedContent.map((content, i) => (
196
+ <li key={`notion-related-item-${i + 1}`}>
197
+ <a href={content.url}>{content.label}</a>
198
+ </li>
196
199
  ))}
197
- </NotionsContainer>
198
- {relatedContent.length > 0 && (
199
- <RelatedContentContainer>
200
- {relatedContent.map((content, i) => (
201
- <li key={`notion-related-item-${i + 1}`}>
202
- <a href={content.url}>{content.label}</a>
203
- </li>
204
- ))}
205
- </RelatedContentContainer>
206
- )}
207
- </ModalBody>
208
- </div>
209
- )}
200
+ </RelatedContentContainer>
201
+ )}
202
+ </ModalBody>
203
+ </ModalContent>
210
204
  </Modal>
211
205
  </ArticleNotionsContainer>
212
206
  );
@@ -11,7 +11,7 @@ import { ButtonV2 } from '@ndla/button';
11
11
  import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { Cross as CrossIcon, Plus as PlusIcon } from '@ndla/icons/action';
14
- import { ModalHeader, ModalBody, ModalCloseButton, Modal } from '@ndla/modal';
14
+ import { ModalHeader, ModalBody, ModalCloseButton, Modal, ModalTrigger, ModalContent } from '@ndla/modal';
15
15
  import ToggleItem from './ToggleItem';
16
16
  import FilterCarousel from './FilterCarousel';
17
17
 
@@ -126,45 +126,39 @@ export const FilterButtons = ({ heading, items, onFilterToggle, onRemoveAllFilte
126
126
  </ButtonV2>
127
127
  </StyledButtonElementWrapper>
128
128
  ))}
129
- <Modal
130
- aria-label={t('searchPage.searchFilterMessages.resourceTypeFilter.button')}
131
- size="full"
132
- animation="subtle"
133
- activateButton={
134
- <StyledButtonElementWrapper>
129
+ <Modal aria-label={t('searchPage.searchFilterMessages.resourceTypeFilter.button')}>
130
+ <StyledButtonElementWrapper>
131
+ <ModalTrigger>
135
132
  <ButtonV2 colorTheme="light" size="normal" shape="pill">
136
133
  <StyledButtonContent>{labels.openFilter}</StyledButtonContent>
137
134
  <StyledButtonContentSelected>
138
135
  <PlusIcon />
139
136
  </StyledButtonContentSelected>
140
137
  </ButtonV2>
141
- </StyledButtonElementWrapper>
142
- }
143
- >
144
- {(onClose: () => void) => (
145
- <>
146
- <ModalHeader>
147
- <h1>{heading}</h1>
148
- <ModalCloseButton title={t('modal.closeModal')} onClick={onClose} />
149
- </ModalHeader>
150
- <ModalBody modifier="slide-in-left">
151
- <StyledList>
152
- {items.map((item: ItemProps) => (
153
- <StyledListItem key={item.value}>
154
- <ToggleItem
155
- id={item.value}
156
- value={item.value}
157
- checked={item.selected}
158
- label={item.label}
159
- component="div"
160
- onChange={() => onFilterToggle(item.value)}
161
- />
162
- </StyledListItem>
163
- ))}
164
- </StyledList>
165
- </ModalBody>
166
- </>
167
- )}
138
+ </ModalTrigger>
139
+ </StyledButtonElementWrapper>
140
+ <ModalContent size="full" animation="subtle">
141
+ <ModalHeader>
142
+ <h1>{heading}</h1>
143
+ <ModalCloseButton />
144
+ </ModalHeader>
145
+ <ModalBody modifier="slide-in-left">
146
+ <StyledList>
147
+ {items.map((item: ItemProps) => (
148
+ <StyledListItem key={item.value}>
149
+ <ToggleItem
150
+ id={item.value}
151
+ value={item.value}
152
+ checked={item.selected}
153
+ label={item.label}
154
+ component="div"
155
+ onChange={() => onFilterToggle(item.value)}
156
+ />
157
+ </StyledListItem>
158
+ ))}
159
+ </StyledList>
160
+ </ModalBody>
161
+ </ModalContent>
168
162
  </Modal>
169
163
  </StyledButtonsWrapper>
170
164
  )}
@@ -6,9 +6,9 @@
6
6
  * FRI OG BEGRENSET
7
7
  */
8
8
 
9
- import React, { ChangeEvent, useEffect, useState } from 'react';
9
+ import React, { ChangeEvent, useCallback, useEffect, useState } from 'react';
10
10
  import { ChevronDown, ChevronUp } from '@ndla/icons/common';
11
- import { ModalHeader, ModalBody, ModalCloseButton, Modal } from '@ndla/modal';
11
+ import { ModalHeader, ModalBody, ModalCloseButton, Modal, ModalTrigger, ModalContent } from '@ndla/modal';
12
12
  import { ButtonV2 } from '@ndla/button';
13
13
  import debounce from 'lodash/debounce';
14
14
  import { classes } from './filterClasses';
@@ -69,6 +69,7 @@ const FilterListPhone = ({
69
69
  isGroupedOptions,
70
70
  showActiveFiltersOnSmallScreen,
71
71
  }: Props) => {
72
+ const [open, setOpen] = useState(false);
72
73
  const [isNarrowScreen, setIsNarrowScreen] = useState(false);
73
74
  const [visibleCount, setVisibleCount] = useState(defaultVisibleCount);
74
75
 
@@ -93,6 +94,10 @@ const FilterListPhone = ({
93
94
  /* eslint react/no-did-mount-set-state: 1 */
94
95
  };
95
96
 
97
+ const onClose = useCallback(() => {
98
+ setOpen(false);
99
+ }, []);
100
+
96
101
  const handleChange = (event: ChangeEvent<HTMLInputElement>, option: Option) => {
97
102
  let newValues = null;
98
103
  if (event.currentTarget.checked) {
@@ -137,74 +142,70 @@ const FilterListPhone = ({
137
142
  }}
138
143
  />
139
144
  )}
140
- <Modal
141
- size="full"
142
- activateButton={
145
+ <Modal open={open} onOpenChange={setOpen}>
146
+ <ModalTrigger>
143
147
  <ButtonV2 variant="outline" {...classes('modal-button')}>
144
148
  {messages.openFilter}
145
149
  </ButtonV2>
146
- }
147
- >
148
- {(onClose) => (
149
- <>
150
- <ModalHeader>
151
- <div {...classes('modal-header')}>
152
- <div {...classes('modal-heading')}>
153
- {!isNarrowScreen && label && <h1 {...classes('label')}>{label}</h1>}
154
- <ButtonV2 variant="outline" onClick={onClose}>
155
- {messages.useFilter}
156
- </ButtonV2>
157
- </div>
158
- <ModalCloseButton title={messages.closeFilter} onClick={onClose} />
150
+ </ModalTrigger>
151
+ <ModalContent size="full">
152
+ <ModalHeader>
153
+ <div {...classes('modal-header')}>
154
+ <div {...classes('modal-heading')}>
155
+ {!isNarrowScreen && label && <h1 {...classes('label')}>{label}</h1>}
156
+ <ButtonV2 variant="outline" onClick={onClose}>
157
+ {messages.useFilter}
158
+ </ButtonV2>
159
159
  </div>
160
- </ModalHeader>
161
- <ModalBody modifier="no-side-padding-mobile">
162
- {isNarrowScreen && label && <h1 {...classes('label')}>{label}</h1>}
163
- {groupedOptions.map((options, index) => (
164
- <ul
165
- key={index}
166
- {...classes('item-wrapper', {
167
- 'aligned-grouping': !!alignedGroup,
168
- 'collapse-mobile': !!collapseMobile,
169
- 'grouped-options': !!isGroupedOptions,
170
- })}
171
- >
172
- {options.map((option) => {
173
- const itemModifiers = [];
160
+ <ModalCloseButton title={messages.closeFilter} />
161
+ </div>
162
+ </ModalHeader>
163
+ <ModalBody modifier="no-side-padding-mobile">
164
+ {isNarrowScreen && label && <h1 {...classes('label')}>{label}</h1>}
165
+ {groupedOptions.map((options, index) => (
166
+ <ul
167
+ key={index}
168
+ {...classes('item-wrapper', {
169
+ 'aligned-grouping': !!alignedGroup,
170
+ 'collapse-mobile': !!collapseMobile,
171
+ 'grouped-options': !!isGroupedOptions,
172
+ })}
173
+ >
174
+ {options.map((option) => {
175
+ const itemModifiers = [];
174
176
 
175
- const checked = values.some((value) => value === option.value);
177
+ const checked = values.some((value) => value === option.value);
176
178
 
177
- if (option.noResults) {
178
- itemModifiers.push('no-results');
179
- }
179
+ if (option.noResults) {
180
+ itemModifiers.push('no-results');
181
+ }
180
182
 
181
- if (option.disabled) {
182
- itemModifiers.push('disabled');
183
- }
184
- return (
185
- <ToggleItem
186
- key={option.value}
187
- id={preid + option.value}
188
- value={option.value}
189
- checked={checked}
190
- onChange={(event) => handleChange(event, option)}
191
- label={option.title}
192
- disabled={option.disabled}
193
- modifiers={itemModifiers}
194
- />
195
- );
196
- })}
197
- </ul>
198
- ))}
183
+ if (option.disabled) {
184
+ itemModifiers.push('disabled');
185
+ }
186
+ return (
187
+ <ToggleItem
188
+ key={option.value}
189
+ id={preid + option.value}
190
+ value={option.value}
191
+ checked={checked}
192
+ onChange={(event) => handleChange(event, option)}
193
+ label={option.title}
194
+ disabled={option.disabled}
195
+ modifiers={itemModifiers}
196
+ />
197
+ );
198
+ })}
199
+ </ul>
200
+ ))}
199
201
 
200
- <div {...classes('usefilter-wrapper')}>
201
- <ButtonV2 variant="outline" onClick={onClose}>
202
- {messages.useFilter}
203
- </ButtonV2>
204
- </div>
205
- </ModalBody>
206
- </>
207
- )}
202
+ <div {...classes('usefilter-wrapper')}>
203
+ <ButtonV2 variant="outline" onClick={onClose}>
204
+ {messages.useFilter}
205
+ </ButtonV2>
206
+ </div>
207
+ </ModalBody>
208
+ </ModalContent>
208
209
  </Modal>
209
210
  </div>
210
211
  );
@@ -6,9 +6,9 @@
6
6
  *
7
7
  */
8
8
 
9
- import React, { ReactNode } from 'react';
9
+ import React, { ReactNode, useCallback, useState } from 'react';
10
10
  import { spacing, mq, breakpoints, colors } from '@ndla/core';
11
- import { ModalHeader, ModalBody, ModalCloseButton, Modal } from '@ndla/modal';
11
+ import { ModalHeader, ModalBody, ModalTrigger, ModalCloseButton, Modal, ModalContent } from '@ndla/modal';
12
12
  import { css } from '@emotion/react';
13
13
  import { ButtonV2 } from '@ndla/button';
14
14
  import { LearningPath } from '@ndla/icons/contentType';
@@ -30,7 +30,7 @@ const buttonToggleCss = css`
30
30
  }
31
31
  `;
32
32
 
33
- const StyledModal = styled(Modal)`
33
+ const StyledModalContent = styled(ModalContent)`
34
34
  background-color: ${colors.brand.greyLightest};
35
35
  `;
36
36
 
@@ -40,28 +40,29 @@ type ModalWrapperProps = {
40
40
  };
41
41
 
42
42
  const ModalWrapperComponent = ({ innerWidth, children }: ModalWrapperProps) => {
43
+ const [open, setIsOpen] = useState(false);
43
44
  const { t } = useTranslation();
45
+
46
+ const onClose = useCallback(() => {
47
+ setIsOpen(false);
48
+ }, []);
49
+
44
50
  if (innerWidth < 601) {
45
51
  return (
46
- <StyledModal
47
- animationDuration={200}
48
- size="full"
49
- activateButton={
52
+ <Modal open={open} onOpenChange={setIsOpen}>
53
+ <ModalTrigger>
50
54
  <ButtonV2 css={buttonToggleCss}>
51
55
  <LearningPath />
52
56
  <span>{t('learningPath.openMenuTooltip')}</span>
53
57
  </ButtonV2>
54
- }
55
- >
56
- {(closeModal: VoidFunction) => (
57
- <>
58
- <ModalHeader>
59
- <ModalCloseButton title={t('modal.closeModal')} onClick={closeModal} />
60
- </ModalHeader>
61
- <ModalBody>{children(closeModal)}</ModalBody>
62
- </>
63
- )}
64
- </StyledModal>
58
+ </ModalTrigger>
59
+ <StyledModalContent animationDuration={200} size="full">
60
+ <ModalHeader>
61
+ <ModalCloseButton />
62
+ </ModalHeader>
63
+ <ModalBody>{children(onClose)}</ModalBody>
64
+ </StyledModalContent>
65
+ </Modal>
65
66
  );
66
67
  }
67
68
  return <>{children(() => {})}</>;
@@ -1,5 +1,5 @@
1
- import React, { ReactNode, useState } from 'react';
2
- import { Drawer } from '@ndla/modal';
1
+ import React, { ReactNode, useCallback, useState } from 'react';
2
+ import { Drawer, Modal, ModalTrigger } from '@ndla/modal';
3
3
  import { IconButtonV2 as IconButton } from '@ndla/button';
4
4
  import { Cross } from '@ndla/icons/action';
5
5
  import styled from '@emotion/styled';
@@ -63,42 +63,34 @@ const StyledHeader = styled.div`
63
63
  const MastheadSearchModal = ({ onClose: onSearchClose, children, hideOnNarrowScreen, ndlaFilm }: Props) => {
64
64
  const { t } = useTranslation();
65
65
  const [isOpen, setIsOpen] = useState(false);
66
+
67
+ const closeModal = useCallback(() => {
68
+ onSearchClose();
69
+ setIsOpen(false);
70
+ }, [onSearchClose]);
71
+
66
72
  return (
67
- <>
68
- <ToggleSearchButton hideOnNarrowScreen={hideOnNarrowScreen} onClick={() => setIsOpen(true)} ndlaFilm={ndlaFilm}>
69
- {t('masthead.menu.search')}
70
- </ToggleSearchButton>
73
+ <Modal open={isOpen} onOpenChange={setIsOpen}>
74
+ <ModalTrigger>
75
+ <ToggleSearchButton hideOnNarrowScreen={hideOnNarrowScreen} onClick={() => setIsOpen(true)} ndlaFilm={ndlaFilm}>
76
+ {t('masthead.menu.search')}
77
+ </ToggleSearchButton>
78
+ </ModalTrigger>
71
79
  <StyledDrawer
72
- controlled
73
80
  aria-label={t('searchPage.searchFieldPlaceholder')}
74
81
  position="top"
75
82
  expands
76
83
  size="small"
77
- animation="slideIn"
78
84
  animationDuration={200}
79
- isOpen={isOpen}
80
- onClose={() => {
81
- setIsOpen(false);
82
- onSearchClose();
83
- }}
84
85
  >
85
- {(closeModal) => (
86
- <>
87
- <StyledHeader>
88
- {children(closeModal)}
89
- <IconButton
90
- aria-label={t('welcomePage.closeSearch')}
91
- variant="ghost"
92
- colorTheme="light"
93
- onClick={closeModal}
94
- >
95
- <Cross className="c-icon--medium" />
96
- </IconButton>
97
- </StyledHeader>
98
- </>
99
- )}
86
+ <StyledHeader>
87
+ {children(closeModal)}
88
+ <IconButton aria-label={t('welcomePage.closeSearch')} variant="ghost" colorTheme="light" onClick={closeModal}>
89
+ <Cross className="c-icon--medium" />
90
+ </IconButton>
91
+ </StyledHeader>
100
92
  </StyledDrawer>
101
- </>
93
+ </Modal>
102
94
  );
103
95
  };
104
96
 
@@ -1,7 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import styled from '@emotion/styled';
4
- import { ModalHeader, ModalBody, ModalCloseButton, Modal } from '@ndla/modal';
4
+ import { ModalHeader, ModalBody, ModalCloseButton, Modal, ModalTrigger, ModalContent } from '@ndla/modal';
5
5
  import { colors, spacing, mq, breakpoints } from '@ndla/core';
6
6
  import { ButtonV2 as Button } from '@ndla/button';
7
7
  import VisualElement from './VisualElement';
@@ -64,15 +64,16 @@ const AboutNdlaFilm = ({ aboutNDLAVideo, moreAboutNdlaFilm }: Props) => {
64
64
  <div>
65
65
  <h2 id={titleId}>{aboutNDLAVideo.title}</h2>
66
66
  <p>{aboutNDLAVideo.description}</p>
67
- <Modal size="full" activateButton={<Button variant="link">{t('ndlaFilm.about.more')}</Button>}>
68
- {(onClose) => (
69
- <>
70
- <ModalHeader>
71
- <ModalCloseButton onClick={onClose} />
72
- </ModalHeader>
73
- <ModalBody>{moreAboutNdlaFilm}</ModalBody>
74
- </>
75
- )}
67
+ <Modal>
68
+ <ModalTrigger>
69
+ <Button variant="link">{t('ndlaFilm.about.more')}</Button>
70
+ </ModalTrigger>
71
+ <ModalContent size="full">
72
+ <ModalHeader>
73
+ <ModalCloseButton />
74
+ </ModalHeader>
75
+ <ModalBody>{moreAboutNdlaFilm}</ModalBody>
76
+ </ModalContent>
76
77
  </Modal>
77
78
  </div>
78
79
  </StyledAside>