@ndla/ui 42.1.2 → 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 (121) hide show
  1. package/es/Article/ArticleNotions.js +46 -53
  2. package/es/AudioPlayer/Controls.js +41 -39
  3. package/es/Breadcrumb/index.js +0 -1
  4. package/es/Filter/FilterButtons.js +49 -53
  5. package/es/Filter/FilterListPhone.js +78 -71
  6. package/es/LanguageSelector/LanguageSelector.js +31 -36
  7. package/es/LearningPaths/LearningPathMenuModalWrapper.js +39 -28
  8. package/es/Masthead/MastheadSearchModal.js +31 -35
  9. package/es/MyNdla/Resource/Folder.js +10 -16
  10. package/es/MyNdla/index.js +1 -3
  11. package/es/NDLAFilm/AboutNdlaFilm.js +16 -20
  12. package/es/NDLAFilm/FilmMovieSearch.js +43 -11
  13. package/es/Resource/BlockResource.js +8 -11
  14. package/es/Resource/ListResource.js +8 -11
  15. package/es/Resource/resourceComponents.js +46 -35
  16. package/es/ResourcesWrapper/ResourcesTopicTitle.js +36 -44
  17. package/es/Search/ToggleSearchButton.js +7 -6
  18. package/es/SearchTypeResult/PopupFilter.js +55 -69
  19. package/es/SearchTypeResult/SearchNotionsResult.js +9 -7
  20. package/es/SearchTypeResult/components/ItemContexts.js +41 -45
  21. package/es/SearchTypeResult/components/SubjectFilters.js +16 -17
  22. package/es/Topic/Topic.js +41 -45
  23. package/es/TreeStructure/FolderItem.js +7 -11
  24. package/es/index.js +2 -2
  25. package/es/locale/messages-en.js +1 -0
  26. package/es/locale/messages-nb.js +1 -0
  27. package/es/locale/messages-nn.js +1 -0
  28. package/es/locale/messages-se.js +1 -0
  29. package/es/locale/messages-sma.js +1 -0
  30. package/lib/Article/ArticleNotions.js +45 -52
  31. package/lib/AudioPlayer/Controls.js +40 -38
  32. package/lib/Breadcrumb/index.d.ts +0 -1
  33. package/lib/Breadcrumb/index.js +0 -7
  34. package/lib/Filter/FilterButtons.js +48 -52
  35. package/lib/Filter/FilterListPhone.js +76 -69
  36. package/lib/LanguageSelector/LanguageSelector.js +31 -36
  37. package/lib/LearningPaths/LearningPathMenuModalWrapper.js +47 -35
  38. package/lib/Masthead/MastheadSearchModal.js +29 -32
  39. package/lib/MyNdla/Resource/Folder.d.ts +3 -4
  40. package/lib/MyNdla/Resource/Folder.js +10 -16
  41. package/lib/MyNdla/index.d.ts +1 -3
  42. package/lib/MyNdla/index.js +0 -14
  43. package/lib/NDLAFilm/AboutNdlaFilm.js +15 -18
  44. package/lib/NDLAFilm/FilmMovieSearch.d.ts +1 -2
  45. package/lib/NDLAFilm/FilmMovieSearch.js +46 -11
  46. package/lib/Resource/BlockResource.d.ts +3 -3
  47. package/lib/Resource/BlockResource.js +8 -11
  48. package/lib/Resource/ListResource.d.ts +3 -3
  49. package/lib/Resource/ListResource.js +8 -11
  50. package/lib/Resource/resourceComponents.js +45 -34
  51. package/lib/ResourcesWrapper/ResourcesTopicTitle.js +35 -42
  52. package/lib/Search/ToggleSearchButton.d.ts +2 -1
  53. package/lib/Search/ToggleSearchButton.js +9 -6
  54. package/lib/SearchTypeResult/PopupFilter.d.ts +1 -3
  55. package/lib/SearchTypeResult/PopupFilter.js +54 -68
  56. package/lib/SearchTypeResult/SearchNotionsResult.js +9 -7
  57. package/lib/SearchTypeResult/components/ItemContexts.js +40 -44
  58. package/lib/SearchTypeResult/components/SubjectFilters.js +16 -17
  59. package/lib/Topic/Topic.js +40 -44
  60. package/lib/TreeStructure/FolderItem.js +7 -11
  61. package/lib/index.d.ts +2 -2
  62. package/lib/index.js +0 -12
  63. package/lib/locale/messages-en.d.ts +1 -0
  64. package/lib/locale/messages-en.js +1 -0
  65. package/lib/locale/messages-nb.d.ts +1 -0
  66. package/lib/locale/messages-nb.js +1 -0
  67. package/lib/locale/messages-nn.d.ts +1 -0
  68. package/lib/locale/messages-nn.js +1 -0
  69. package/lib/locale/messages-se.d.ts +1 -0
  70. package/lib/locale/messages-se.js +1 -0
  71. package/lib/locale/messages-sma.d.ts +1 -0
  72. package/lib/locale/messages-sma.js +1 -0
  73. package/package.json +11 -12
  74. package/src/Article/ArticleNotions.tsx +29 -35
  75. package/src/AudioPlayer/Controls.tsx +22 -26
  76. package/src/Breadcrumb/index.ts +0 -2
  77. package/src/Filter/FilterButtons.tsx +28 -34
  78. package/src/Filter/FilterListPhone.tsx +63 -62
  79. package/src/LanguageSelector/LanguageSelector.tsx +26 -32
  80. package/src/LearningPaths/LearningPathMenuModalWrapper.tsx +19 -18
  81. package/src/Masthead/MastheadSearchModal.tsx +21 -29
  82. package/src/MyNdla/Resource/Folder.stories.tsx +27 -5
  83. package/src/MyNdla/Resource/Folder.tsx +4 -19
  84. package/src/MyNdla/index.ts +1 -3
  85. package/src/NDLAFilm/AboutNdlaFilm.tsx +11 -10
  86. package/src/NDLAFilm/FilmMovieSearch.tsx +32 -9
  87. package/src/Resource/BlockResource.stories.tsx +1 -1
  88. package/src/Resource/BlockResource.tsx +4 -6
  89. package/src/Resource/ListResource.tsx +4 -6
  90. package/src/Resource/Resource.stories.tsx +32 -2
  91. package/src/Resource/resourceComponents.tsx +34 -24
  92. package/src/ResourcesWrapper/ResourcesTopicTitle.tsx +23 -27
  93. package/src/Search/ToggleSearchButton.tsx +15 -12
  94. package/src/SearchTypeResult/PopupFilter.tsx +55 -70
  95. package/src/SearchTypeResult/SearchNotionsResult.tsx +5 -2
  96. package/src/SearchTypeResult/components/ItemContexts.tsx +23 -28
  97. package/src/SearchTypeResult/components/SubjectFilters.tsx +9 -12
  98. package/src/Topic/Topic.tsx +15 -17
  99. package/src/TreeStructure/FolderItem.tsx +2 -4
  100. package/src/index.ts +2 -2
  101. package/src/locale/messages-en.ts +1 -0
  102. package/src/locale/messages-nb.ts +1 -0
  103. package/src/locale/messages-nn.ts +1 -0
  104. package/src/locale/messages-se.ts +1 -0
  105. package/src/locale/messages-sma.ts +1 -0
  106. package/es/Breadcrumb/ActionBreadcrumb.js +0 -74
  107. package/es/MyNdla/Resource/FolderMenu.js +0 -74
  108. package/es/MyNdla/SettingsMenu.js +0 -98
  109. package/es/NDLAFilm/CategorySelect.js +0 -135
  110. package/lib/Breadcrumb/ActionBreadcrumb.d.ts +0 -15
  111. package/lib/Breadcrumb/ActionBreadcrumb.js +0 -82
  112. package/lib/MyNdla/Resource/FolderMenu.d.ts +0 -16
  113. package/lib/MyNdla/Resource/FolderMenu.js +0 -81
  114. package/lib/MyNdla/SettingsMenu.d.ts +0 -15
  115. package/lib/MyNdla/SettingsMenu.js +0 -102
  116. package/lib/NDLAFilm/CategorySelect.d.ts +0 -16
  117. package/lib/NDLAFilm/CategorySelect.js +0 -144
  118. package/src/Breadcrumb/ActionBreadcrumb.tsx +0 -87
  119. package/src/MyNdla/Resource/FolderMenu.tsx +0 -102
  120. package/src/MyNdla/SettingsMenu.tsx +0 -96
  121. package/src/NDLAFilm/CategorySelect.tsx +0 -197
@@ -1,102 +0,0 @@
1
- /**
2
- * Copyright (c) 2023-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
- import { MenuItemProps, ButtonV2 } from '@ndla/button';
10
- import { FourlineHamburger, List } from '@ndla/icons/action';
11
- import Tooltip from '@ndla/tooltip';
12
- import styled from '@emotion/styled';
13
- import { colors, spacing } from '@ndla/core';
14
- import { useTranslation } from 'react-i18next';
15
- import { LayoutType } from './Folder';
16
- import SettingsMenu from '../SettingsMenu';
17
-
18
- interface Props {
19
- menuItems: MenuItemProps[];
20
- viewType?: LayoutType;
21
- onViewTypeChange?: (type: LayoutType) => void;
22
- }
23
-
24
- const ViewButtonWrapper = styled.div`
25
- display: flex;
26
- gap: ${spacing.small};
27
- div,
28
- button {
29
- display: flex;
30
- flex: 1;
31
- }
32
- `;
33
-
34
- const ViewTypeWrapper = styled.div`
35
- display: flex;
36
- flex-direction: column;
37
- gap: ${spacing.xsmall};
38
- padding: ${spacing.small};
39
- border-bottom: 1px solid ${colors.brand.neutral7};
40
- border-top: 1px solid ${colors.brand.neutral7};
41
- span {
42
- color: ${colors.brand.primary};
43
- }
44
- `;
45
-
46
- const ViewButton = styled(ButtonV2)`
47
- background-color: transparent;
48
- color: ${colors.brand.primary};
49
- svg {
50
- width: 40px;
51
- height: 40px;
52
- }
53
- &[aria-current='true'] {
54
- background-color: ${colors.brand.lightest};
55
- }
56
- &[aria-current='false'] {
57
- color: ${colors.brand.light};
58
- border-color: ${colors.brand.light};
59
- }
60
- `;
61
-
62
- const FolderMenu = ({ menuItems, viewType, onViewTypeChange }: Props) => {
63
- const { t } = useTranslation();
64
- return (
65
- <SettingsMenu menuItems={menuItems}>
66
- {(_) => {
67
- if (!viewType || !onViewTypeChange) {
68
- return null;
69
- }
70
- return (
71
- <ViewTypeWrapper>
72
- <span>{t('myNdla.selectView')}</span>
73
- <ViewButtonWrapper>
74
- <Tooltip tooltip={t('myNdla.listView')}>
75
- <ViewButton
76
- size="large"
77
- aria-current={viewType === 'list'}
78
- colorTheme="primary"
79
- onClick={() => onViewTypeChange('list')}
80
- >
81
- <FourlineHamburger />
82
- </ViewButton>
83
- </Tooltip>
84
- <Tooltip tooltip={t('myNdla.detailView')}>
85
- <ViewButton
86
- size="large"
87
- aria-current={viewType === 'listLarger'}
88
- colorTheme="primary"
89
- onClick={() => onViewTypeChange('listLarger')}
90
- >
91
- <List />
92
- </ViewButton>
93
- </Tooltip>
94
- </ViewButtonWrapper>
95
- </ViewTypeWrapper>
96
- );
97
- }}
98
- </SettingsMenu>
99
- );
100
- };
101
-
102
- export default FolderMenu;
@@ -1,96 +0,0 @@
1
- /**
2
- * Copyright (c) 2023-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
- import { ReactNode } from 'react';
10
- import styled from '@emotion/styled';
11
- import { isMobile, isTablet } from 'react-device-detect';
12
- import { useTranslation } from 'react-i18next';
13
- import { IconButtonV2, MenuItemProps, MenuButton, ButtonV2 } from '@ndla/button';
14
- import { Drawer, ModalBody, ModalCloseButton, ModalHeader } from '@ndla/modal';
15
- import { HorizontalMenu } from '@ndla/icons/contentType';
16
- import { breakpoints, colors, misc, mq, spacing } from '@ndla/core';
17
-
18
- interface Props {
19
- menuItems?: MenuItemProps[];
20
- children?: (close: () => void) => ReactNode;
21
- }
22
-
23
- const StyledDrawer = styled(Drawer)`
24
- max-height: 100%;
25
- border-top-left-radius: ${misc.borderRadius};
26
- border-top-right-radius: ${misc.borderRadius};
27
- ${mq.range({ until: breakpoints.tablet })} {
28
- min-height: 20%;
29
- }
30
- `;
31
-
32
- const StyledUl = styled.ul`
33
- padding: 0;
34
- list-style: none;
35
- `;
36
-
37
- const StyledModalBody = styled(ModalBody)`
38
- padding: 0 0 ${spacing.large} 0px;
39
- `;
40
-
41
- const StyledLi = styled.li`
42
- border-bottom: 1px solid ${colors.brand.neutral7};
43
- `;
44
-
45
- const SettingsMenu = ({ menuItems, children }: Props) => {
46
- const { t } = useTranslation();
47
- if (isMobile || isTablet) {
48
- return (
49
- <StyledDrawer
50
- expands
51
- position="bottom"
52
- size="small"
53
- activateButton={
54
- <IconButtonV2 aria-label={t('myNdla.more')} colorTheme="light" variant="ghost">
55
- <HorizontalMenu />
56
- </IconButtonV2>
57
- }
58
- >
59
- {(close) => (
60
- <>
61
- <ModalHeader>
62
- <h1>{t('myNdla.settings')}</h1>
63
- <ModalCloseButton onClick={close} />
64
- </ModalHeader>
65
- <StyledModalBody>
66
- {children?.(close)}
67
- {!!menuItems?.length && (
68
- <StyledUl>
69
- {menuItems.map((item, i) => (
70
- <StyledLi key={i}>
71
- <ButtonV2
72
- fontWeight="normal"
73
- variant="ghost"
74
- colorTheme={item.type}
75
- onClick={(e) => {
76
- close();
77
- item.onClick(e);
78
- }}
79
- >
80
- {item.icon}
81
- {item.text}
82
- </ButtonV2>
83
- </StyledLi>
84
- ))}
85
- </StyledUl>
86
- )}
87
- </StyledModalBody>
88
- </>
89
- )}
90
- </StyledDrawer>
91
- );
92
- }
93
- return <MenuButton align="end" size="small" menuItems={menuItems} />;
94
- };
95
-
96
- export default SettingsMenu;
@@ -1,197 +0,0 @@
1
- /**
2
- * Copyright (c) 2019-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
- import React, { useEffect, useRef, useState } from 'react';
10
- import FocusTrapReact from 'focus-trap-react';
11
- import styled from '@emotion/styled';
12
- import { keyframes } from '@emotion/react';
13
- import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
14
- import { ChevronDown } from '@ndla/icons/common';
15
- import { useTranslation } from 'react-i18next';
16
- import { MovieResourceType } from './types';
17
-
18
- const zoomInSelect = keyframes`
19
- 0% {
20
- display: none;
21
- opacity: 0;
22
- }
23
- 1% {
24
- display: flex;
25
- transform: scale3d(0.95, 0.95, 0.95);
26
- opacity: 0;
27
- }
28
- 100% {
29
- opacity: 1;
30
- transform: scale3d(1, 1, 1);
31
- }
32
- `;
33
-
34
- const DropdownContainer = styled.div`
35
- position: relative;
36
- margin: 0 0 ${spacing.normal};
37
- `;
38
-
39
- const DropdownButton = styled.button`
40
- border-radius: 4px;
41
- ${fonts.sizes('22px', '26px')};
42
- border: 0;
43
- text-transform: uppercase;
44
- background: ${colors.ndlaFilm.filmColorBright};
45
- color: ${colors.white};
46
- padding: ${spacing.small} ${spacing.nsmall};
47
- font-weight: ${fonts.weight.semibold};
48
- display: flex;
49
- align-items: center;
50
- text-align: left;
51
- justify-content: space-between;
52
- width: 100%;
53
- letter-spacing: 0.05em;
54
- ${mq.range({ from: breakpoints.tablet })} {
55
- padding: ${spacing.small} ${spacing.normal};
56
- }
57
- div:first-child {
58
- ${mq.range({ until: breakpoints.tablet })} {
59
- display: flex;
60
- flex-direction: column;
61
- small {
62
- padding: 0;
63
- }
64
- }
65
- }
66
- small {
67
- text-transform: none;
68
- padding-left: ${spacing.small};
69
- font-weight: normal;
70
- }
71
- `;
72
-
73
- interface DropdownWrapperProps {
74
- offsetDropdown: number;
75
- }
76
-
77
- const DropdownWrapper = styled.div<DropdownWrapperProps>`
78
- top: -${(props) => props.offsetDropdown * 52 + 13}px;
79
- ${DropdownButton} {
80
- border-radius: 0;
81
- text-transform: none;
82
- letter-spacing: 0;
83
- }
84
- display: flex;
85
- flex-direction: column;
86
- padding: $spacing--small 0;
87
- background: ${colors.brand.lighter};
88
- border-radius: 4px;
89
- left: 0;
90
- right: 0;
91
- animation: ${zoomInSelect} 200ms ease;
92
- box-shadow: 0 0 30px rgba(${colors.black}, 0.6);
93
- position: absolute;
94
- z-index: 9999;
95
- button,
96
- a {
97
- color: ${colors.text.primary};
98
- border: 0;
99
- outline: 0;
100
- text-align: left;
101
- background: transparent;
102
- padding: ${spacing.small};
103
- padding-left: ${spacing.normal};
104
- font-weight: ${fonts.weight.semibold};
105
- text-decoration: none;
106
- box-shadow: none;
107
- transition: background 200ms ease;
108
- &:hover,
109
- &:focus {
110
- color: ${colors.brand.primary};
111
- background: rgba(0, 0, 0, 0.2);
112
- }
113
- }
114
- `;
115
-
116
- interface Props {
117
- resourceTypes: MovieResourceType[];
118
- resourceTypeSelected?: MovieResourceType;
119
- ariaControlId?: string;
120
- onChangeResourceType: (resourceId?: string) => void;
121
- }
122
-
123
- const CategorySelect = ({ resourceTypes, resourceTypeSelected, ariaControlId, onChangeResourceType }: Props) => {
124
- const { t } = useTranslation();
125
- const refs = useRef<Record<string, HTMLButtonElement | null>>({});
126
-
127
- const [resourceTypesIsOpen, setResourceTypesIsOpen] = useState<boolean>(false);
128
-
129
- const updateRef = (el: HTMLButtonElement | null, name: string) => {
130
- refs.current[name] = el;
131
- };
132
-
133
- useEffect(() => {
134
- if (resourceTypeSelected && refs.current[resourceTypeSelected.id]) {
135
- refs.current[resourceTypeSelected.id]?.focus();
136
- }
137
- }, [resourceTypesIsOpen, resourceTypeSelected]);
138
-
139
- const onSelect = (val?: string) => {
140
- onChangeResourceType(val);
141
- setResourceTypesIsOpen(false);
142
- };
143
-
144
- const offsetDropDown = resourceTypeSelected
145
- ? resourceTypes.findIndex((resource) => resource.id === resourceTypeSelected.id) + 1
146
- : 0;
147
-
148
- return (
149
- <DropdownContainer className="u-12/12">
150
- <DropdownButton
151
- aria-expanded={!!resourceTypesIsOpen}
152
- aria-controls="selectCategory"
153
- type="button"
154
- tabIndex={resourceTypesIsOpen ? -1 : 0}
155
- onClick={() => setResourceTypesIsOpen(true)}
156
- >
157
- <div>
158
- <span>{t('ndlaFilm.search.chooseCategory')}</span>
159
- <small>{(resourceTypeSelected && resourceTypeSelected.name) || t('ndlaFilm.search.categoryFromNdla')}</small>
160
- </div>
161
- <div>
162
- <ChevronDown className="c-icon--22" />
163
- </div>
164
- </DropdownButton>
165
- {resourceTypesIsOpen && (
166
- <FocusTrapReact
167
- active={resourceTypesIsOpen}
168
- focusTrapOptions={{
169
- onDeactivate: () => setResourceTypesIsOpen(false),
170
- clickOutsideDeactivates: true,
171
- escapeDeactivates: true,
172
- }}
173
- >
174
- <DropdownWrapper id="selectCategory" offsetDropdown={offsetDropDown}>
175
- <DropdownButton aria-controls={ariaControlId} type="button" onClick={() => onSelect()}>
176
- <span>{t('ndlaFilm.search.categoryFromNdla')}</span>
177
- </DropdownButton>
178
- {resourceTypes.map((resourceType) => (
179
- <DropdownButton
180
- aria-controls={ariaControlId}
181
- type="button"
182
- ref={(el) => updateRef(el, resourceType.id)}
183
- onClick={() => onSelect(resourceType.id)}
184
- data-id={resourceType.id}
185
- key={resourceType.id}
186
- >
187
- <span>{resourceType.name}</span>
188
- </DropdownButton>
189
- ))}
190
- </DropdownWrapper>
191
- </FocusTrapReact>
192
- )}
193
- </DropdownContainer>
194
- );
195
- };
196
-
197
- export default CategorySelect;