@ndla/ui 22.0.0 → 22.0.3

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 (108) hide show
  1. package/es/Article/ArticleByline.js +7 -4
  2. package/es/Article/ArticleNotions.js +10 -6
  3. package/es/Breadcrumb/ActionBreadcrumb.js +4 -4
  4. package/es/CompetenceGoals/CompetenceGoalsDialog.js +8 -4
  5. package/es/ContentLoader/index.js +8 -3
  6. package/es/Filter/FilterButtons.js +10 -9
  7. package/es/Footer/FooterPrivacy.js +3 -2
  8. package/es/Masthead/MastheadSearchModal.js +4 -3
  9. package/es/Resource/BlockResource.js +105 -18
  10. package/es/Resource/ListResource.js +124 -26
  11. package/es/ResourcesWrapper/ResourcesTopicTitle.js +7 -4
  12. package/es/Search/ContentTypeResult.js +1 -2
  13. package/es/SearchTypeResult/PopupFilter.js +12 -8
  14. package/es/SearchTypeResult/SearchItem.js +8 -8
  15. package/es/SearchTypeResult/components/ItemContexts.js +8 -7
  16. package/es/SnackBar/DefaultSnackbar.js +56 -0
  17. package/es/SnackBar/SnackbarProvider.js +179 -0
  18. package/es/SnackBar/index.js +2 -2
  19. package/es/Topic/Topic.js +21 -20
  20. package/es/TreeStructure/FolderItem.js +64 -44
  21. package/es/TreeStructure/FolderItems.js +4 -4
  22. package/es/TreeStructure/TreeStructure.js +15 -8
  23. package/es/User/AuthModal.js +9 -8
  24. package/es/index.js +1 -1
  25. package/es/locale/messages-en.js +26 -5
  26. package/es/locale/messages-nb.js +26 -5
  27. package/es/locale/messages-nn.js +26 -5
  28. package/es/locale/messages-se.js +26 -5
  29. package/es/locale/messages-sma.js +26 -5
  30. package/lib/Article/ArticleByline.js +7 -4
  31. package/lib/Article/ArticleNotions.js +10 -6
  32. package/lib/Breadcrumb/ActionBreadcrumb.js +4 -4
  33. package/lib/CompetenceGoals/CompetenceGoalsDialog.js +8 -4
  34. package/lib/ContentLoader/index.d.ts +4 -8
  35. package/lib/ContentLoader/index.js +8 -3
  36. package/lib/Filter/FilterButtons.js +10 -9
  37. package/lib/Footer/FooterPrivacy.js +3 -2
  38. package/lib/Masthead/MastheadSearchModal.js +4 -3
  39. package/lib/Resource/BlockResource.d.ts +2 -1
  40. package/lib/Resource/BlockResource.js +106 -18
  41. package/lib/Resource/ListResource.d.ts +2 -1
  42. package/lib/Resource/ListResource.js +125 -26
  43. package/lib/ResourcesWrapper/ResourcesTopicTitle.js +7 -4
  44. package/lib/Search/ContentTypeResult.js +1 -2
  45. package/lib/SearchTypeResult/PopupFilter.js +12 -8
  46. package/lib/SearchTypeResult/SearchItem.js +8 -8
  47. package/lib/SearchTypeResult/components/ItemContexts.js +8 -7
  48. package/lib/SnackBar/DefaultSnackbar.d.ts +11 -0
  49. package/lib/SnackBar/DefaultSnackbar.js +70 -0
  50. package/lib/SnackBar/SnackbarProvider.d.ts +32 -0
  51. package/lib/SnackBar/SnackbarProvider.js +197 -0
  52. package/lib/SnackBar/index.d.ts +3 -3
  53. package/lib/SnackBar/index.js +23 -3
  54. package/lib/Topic/Topic.js +21 -20
  55. package/lib/TreeStructure/FolderItem.d.ts +1 -1
  56. package/lib/TreeStructure/FolderItem.js +65 -44
  57. package/lib/TreeStructure/FolderItems.js +4 -4
  58. package/lib/TreeStructure/TreeStructure.d.ts +1 -1
  59. package/lib/TreeStructure/TreeStructure.js +15 -8
  60. package/lib/TreeStructure/types.d.ts +2 -1
  61. package/lib/User/AuthModal.js +9 -8
  62. package/lib/index.d.ts +2 -2
  63. package/lib/index.js +24 -3
  64. package/lib/locale/messages-en.d.ts +21 -0
  65. package/lib/locale/messages-en.js +26 -5
  66. package/lib/locale/messages-nb.d.ts +21 -0
  67. package/lib/locale/messages-nb.js +26 -5
  68. package/lib/locale/messages-nn.d.ts +21 -0
  69. package/lib/locale/messages-nn.js +26 -5
  70. package/lib/locale/messages-se.d.ts +21 -0
  71. package/lib/locale/messages-se.js +26 -5
  72. package/lib/locale/messages-sma.d.ts +21 -0
  73. package/lib/locale/messages-sma.js +26 -5
  74. package/package.json +6 -6
  75. package/src/Article/ArticleByline.tsx +4 -1
  76. package/src/Article/ArticleNotions.tsx +4 -1
  77. package/src/Breadcrumb/ActionBreadcrumb.tsx +1 -1
  78. package/src/CompetenceGoals/CompetenceGoalsDialog.jsx +5 -2
  79. package/src/ContentLoader/index.tsx +9 -9
  80. package/src/Filter/FilterButtons.tsx +1 -0
  81. package/src/Footer/FooterPrivacy.tsx +4 -1
  82. package/src/Masthead/MastheadSearchModal.tsx +1 -0
  83. package/src/Resource/BlockResource.tsx +65 -4
  84. package/src/Resource/ListResource.tsx +85 -10
  85. package/src/ResourcesWrapper/ResourcesTopicTitle.tsx +5 -1
  86. package/src/Search/ContentTypeResult.tsx +0 -1
  87. package/src/SearchTypeResult/PopupFilter.tsx +3 -1
  88. package/src/SearchTypeResult/SearchItem.tsx +0 -1
  89. package/src/SearchTypeResult/components/ItemContexts.tsx +1 -0
  90. package/src/SnackBar/DefaultSnackbar.tsx +70 -0
  91. package/src/SnackBar/SnackbarProvider.tsx +147 -0
  92. package/src/SnackBar/index.ts +3 -5
  93. package/src/Topic/Topic.tsx +1 -0
  94. package/src/TreeStructure/FolderItem.tsx +56 -37
  95. package/src/TreeStructure/FolderItems.tsx +3 -2
  96. package/src/TreeStructure/TreeStructure.tsx +9 -4
  97. package/src/TreeStructure/types.ts +2 -1
  98. package/src/User/AuthModal.tsx +2 -1
  99. package/src/index.ts +2 -2
  100. package/src/locale/messages-en.ts +21 -0
  101. package/src/locale/messages-nb.ts +21 -0
  102. package/src/locale/messages-nn.ts +21 -0
  103. package/src/locale/messages-se.ts +21 -0
  104. package/src/locale/messages-sma.ts +21 -0
  105. package/es/SnackBar/SnackBar.js +0 -117
  106. package/lib/SnackBar/SnackBar.d.ts +0 -23
  107. package/lib/SnackBar/SnackBar.js +0 -127
  108. package/src/SnackBar/SnackBar.tsx +0 -183
@@ -1,183 +0,0 @@
1
- /**
2
- * Copyright (c) 2022-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, { ReactElement, useRef, useEffect, useState } from 'react';
10
- import styled from '@emotion/styled';
11
- import Button, { IconButton } from '@ndla/button';
12
- import { spacing, spacingUnit, shadows, misc, fonts, colors, mq, breakpoints } from '@ndla/core';
13
- import { Cross } from '@ndla/icons/action';
14
- import { useTranslation } from 'react-i18next';
15
-
16
- const StyledActionButton = styled(Button)`
17
- color: ${colors.white};
18
- padding: ${spacing.xsmall} ${spacing.small};
19
- box-shadow: none;
20
- &:focus,
21
- &:hover {
22
- color: ${colors.brand.greyLightest};
23
- background: ${colors.brand.greyDark};
24
- &:after {
25
- opacity: 0;
26
- }
27
- }
28
- &:after {
29
- content: '';
30
- display: flex;
31
- height: 1px;
32
- width: 100%;
33
- background: ${colors.white};
34
- transform: translateY(-2px);
35
- }
36
- `;
37
-
38
- const StyledIconButton = styled(IconButton)`
39
- svg {
40
- color: ${colors.brand.greyMedium};
41
- }
42
- &:hover,
43
- &:focus {
44
- background: ${colors.brand.greyDark};
45
- svg {
46
- color: ${colors.brand.greyLightest};
47
- }
48
- }
49
- `;
50
-
51
- const WrapperForButtons = styled.div`
52
- display: flex;
53
- ${mq.range({ from: breakpoints.tablet })} {
54
- gap: ${spacing.xxsmall};
55
- }
56
- `;
57
-
58
- interface StyledProps {
59
- expired?: boolean;
60
- }
61
-
62
- const Wrapper = styled.div`
63
- position: fixed;
64
- z-index: 99999;
65
- bottom: ${spacing.small};
66
- left: ${spacing.small};
67
- right: ${spacing.small};
68
- display: flex;
69
- justify-content: center;
70
- `;
71
-
72
- const StyledNotification = styled.div<StyledProps>`
73
- max-width: 960px;
74
- ${fonts.sizes(18, 1.25)};
75
- background: ${colors.text.primary};
76
- color: ${colors.white};
77
- box-shadow: ${shadows.levitate1};
78
- padding: ${spacing.small};
79
- padding-right: ${spacing.xsmall};
80
- gap: ${spacing.medium};
81
- ${mq.range({ from: breakpoints.tablet })} {
82
- gap: ${spacing.large};
83
- padding: ${spacing.small} ${spacing.normal} ${spacing.small} ${spacing.medium};
84
- }
85
- ${mq.range({ from: breakpoints.desktop })} {
86
- gap: ${spacingUnit * 3};
87
- }
88
- display: flex;
89
- align-items: center;
90
- > div:first-of-type {
91
- flex-grow: 1;
92
- display: flex;
93
- align-items: center;
94
- justify-content: center;
95
- }
96
- &:empty {
97
- display: none;
98
- }
99
- border-radius: ${misc.borderRadius};
100
- @keyframes snackbar-animations-in {
101
- 0% {
102
- opacity: 0;
103
- transform: translateY(${spacing.medium});
104
- }
105
- 100% {
106
- opacity: 1;
107
- }
108
- }
109
- @keyframes snackbar-animations-out {
110
- 0% {
111
- opacity: 1;
112
- }
113
- 100% {
114
- opacity: 0;
115
- transform: translateY(${spacing.medium});
116
- }
117
- }
118
- animation: ${(props) => (props.expired ? 'snackbar-animations-out' : 'snackbar-animations-in')} 200ms ease-in-out;
119
- animation-fill-mode: forwards;
120
- ${fonts.sizes('18px')};
121
- font-family: ${fonts.sans};
122
- `;
123
-
124
- export interface SnackBarItem {
125
- children?: ReactElement;
126
- snackbarItemId?: string;
127
- }
128
-
129
- interface SnackBarProps extends SnackBarItem {
130
- id: string;
131
- onKill?: (id: string | undefined) => void;
132
- actionButtons?: {
133
- text: string;
134
- onClick: () => void;
135
- ariaLabel: string;
136
- }[];
137
- }
138
-
139
- const SnackBar = ({ onKill, children, snackbarItemId, id, actionButtons }: SnackBarProps) => {
140
- const { t } = useTranslation();
141
- const [expired, setExpired] = useState(false);
142
- const timeoutId = useRef<null | ReturnType<typeof setTimeout>>();
143
- useEffect(() => {
144
- if (timeoutId.current) {
145
- timeoutId && clearTimeout(timeoutId.current);
146
- }
147
- timeoutId.current = setTimeout(() => {
148
- setExpired(true);
149
- }, 8000);
150
-
151
- return () => {
152
- timeoutId.current && clearTimeout(timeoutId.current);
153
- };
154
- }, [snackbarItemId, timeoutId]);
155
- return (
156
- <Wrapper>
157
- <StyledNotification
158
- id={id}
159
- aria-live="polite"
160
- expired={expired || !children}
161
- onAnimationEnd={() => expired && onKill && onKill(snackbarItemId)}>
162
- {children && (
163
- <>
164
- <div>{children}</div>
165
- <WrapperForButtons>
166
- {actionButtons &&
167
- actionButtons.map(({ onClick, text, ariaLabel }) => (
168
- <StyledActionButton key={text} link aria-label={ariaLabel} onClick={onClick}>
169
- {text}
170
- </StyledActionButton>
171
- ))}
172
- <StyledIconButton aria-label={t('snackbar.close')} size="xsmall" outline onClick={() => setExpired(true)}>
173
- <Cross />
174
- </StyledIconButton>
175
- </WrapperForButtons>
176
- </>
177
- )}
178
- </StyledNotification>
179
- </Wrapper>
180
- );
181
- };
182
-
183
- export default SnackBar;