@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.
- package/es/Article/ArticleByline.js +7 -4
- package/es/Article/ArticleNotions.js +10 -6
- package/es/Breadcrumb/ActionBreadcrumb.js +4 -4
- package/es/CompetenceGoals/CompetenceGoalsDialog.js +8 -4
- package/es/ContentLoader/index.js +8 -3
- package/es/Filter/FilterButtons.js +10 -9
- package/es/Footer/FooterPrivacy.js +3 -2
- package/es/Masthead/MastheadSearchModal.js +4 -3
- package/es/Resource/BlockResource.js +105 -18
- package/es/Resource/ListResource.js +124 -26
- package/es/ResourcesWrapper/ResourcesTopicTitle.js +7 -4
- package/es/Search/ContentTypeResult.js +1 -2
- package/es/SearchTypeResult/PopupFilter.js +12 -8
- package/es/SearchTypeResult/SearchItem.js +8 -8
- package/es/SearchTypeResult/components/ItemContexts.js +8 -7
- package/es/SnackBar/DefaultSnackbar.js +56 -0
- package/es/SnackBar/SnackbarProvider.js +179 -0
- package/es/SnackBar/index.js +2 -2
- package/es/Topic/Topic.js +21 -20
- package/es/TreeStructure/FolderItem.js +64 -44
- package/es/TreeStructure/FolderItems.js +4 -4
- package/es/TreeStructure/TreeStructure.js +15 -8
- package/es/User/AuthModal.js +9 -8
- package/es/index.js +1 -1
- package/es/locale/messages-en.js +26 -5
- package/es/locale/messages-nb.js +26 -5
- package/es/locale/messages-nn.js +26 -5
- package/es/locale/messages-se.js +26 -5
- package/es/locale/messages-sma.js +26 -5
- package/lib/Article/ArticleByline.js +7 -4
- package/lib/Article/ArticleNotions.js +10 -6
- package/lib/Breadcrumb/ActionBreadcrumb.js +4 -4
- package/lib/CompetenceGoals/CompetenceGoalsDialog.js +8 -4
- package/lib/ContentLoader/index.d.ts +4 -8
- package/lib/ContentLoader/index.js +8 -3
- package/lib/Filter/FilterButtons.js +10 -9
- package/lib/Footer/FooterPrivacy.js +3 -2
- package/lib/Masthead/MastheadSearchModal.js +4 -3
- package/lib/Resource/BlockResource.d.ts +2 -1
- package/lib/Resource/BlockResource.js +106 -18
- package/lib/Resource/ListResource.d.ts +2 -1
- package/lib/Resource/ListResource.js +125 -26
- package/lib/ResourcesWrapper/ResourcesTopicTitle.js +7 -4
- package/lib/Search/ContentTypeResult.js +1 -2
- package/lib/SearchTypeResult/PopupFilter.js +12 -8
- package/lib/SearchTypeResult/SearchItem.js +8 -8
- package/lib/SearchTypeResult/components/ItemContexts.js +8 -7
- package/lib/SnackBar/DefaultSnackbar.d.ts +11 -0
- package/lib/SnackBar/DefaultSnackbar.js +70 -0
- package/lib/SnackBar/SnackbarProvider.d.ts +32 -0
- package/lib/SnackBar/SnackbarProvider.js +197 -0
- package/lib/SnackBar/index.d.ts +3 -3
- package/lib/SnackBar/index.js +23 -3
- package/lib/Topic/Topic.js +21 -20
- package/lib/TreeStructure/FolderItem.d.ts +1 -1
- package/lib/TreeStructure/FolderItem.js +65 -44
- package/lib/TreeStructure/FolderItems.js +4 -4
- package/lib/TreeStructure/TreeStructure.d.ts +1 -1
- package/lib/TreeStructure/TreeStructure.js +15 -8
- package/lib/TreeStructure/types.d.ts +2 -1
- package/lib/User/AuthModal.js +9 -8
- package/lib/index.d.ts +2 -2
- package/lib/index.js +24 -3
- package/lib/locale/messages-en.d.ts +21 -0
- package/lib/locale/messages-en.js +26 -5
- package/lib/locale/messages-nb.d.ts +21 -0
- package/lib/locale/messages-nb.js +26 -5
- package/lib/locale/messages-nn.d.ts +21 -0
- package/lib/locale/messages-nn.js +26 -5
- package/lib/locale/messages-se.d.ts +21 -0
- package/lib/locale/messages-se.js +26 -5
- package/lib/locale/messages-sma.d.ts +21 -0
- package/lib/locale/messages-sma.js +26 -5
- package/package.json +6 -6
- package/src/Article/ArticleByline.tsx +4 -1
- package/src/Article/ArticleNotions.tsx +4 -1
- package/src/Breadcrumb/ActionBreadcrumb.tsx +1 -1
- package/src/CompetenceGoals/CompetenceGoalsDialog.jsx +5 -2
- package/src/ContentLoader/index.tsx +9 -9
- package/src/Filter/FilterButtons.tsx +1 -0
- package/src/Footer/FooterPrivacy.tsx +4 -1
- package/src/Masthead/MastheadSearchModal.tsx +1 -0
- package/src/Resource/BlockResource.tsx +65 -4
- package/src/Resource/ListResource.tsx +85 -10
- package/src/ResourcesWrapper/ResourcesTopicTitle.tsx +5 -1
- package/src/Search/ContentTypeResult.tsx +0 -1
- package/src/SearchTypeResult/PopupFilter.tsx +3 -1
- package/src/SearchTypeResult/SearchItem.tsx +0 -1
- package/src/SearchTypeResult/components/ItemContexts.tsx +1 -0
- package/src/SnackBar/DefaultSnackbar.tsx +70 -0
- package/src/SnackBar/SnackbarProvider.tsx +147 -0
- package/src/SnackBar/index.ts +3 -5
- package/src/Topic/Topic.tsx +1 -0
- package/src/TreeStructure/FolderItem.tsx +56 -37
- package/src/TreeStructure/FolderItems.tsx +3 -2
- package/src/TreeStructure/TreeStructure.tsx +9 -4
- package/src/TreeStructure/types.ts +2 -1
- package/src/User/AuthModal.tsx +2 -1
- package/src/index.ts +2 -2
- package/src/locale/messages-en.ts +21 -0
- package/src/locale/messages-nb.ts +21 -0
- package/src/locale/messages-nn.ts +21 -0
- package/src/locale/messages-se.ts +21 -0
- package/src/locale/messages-sma.ts +21 -0
- package/es/SnackBar/SnackBar.js +0 -117
- package/lib/SnackBar/SnackBar.d.ts +0 -23
- package/lib/SnackBar/SnackBar.js +0 -127
- 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;
|