@ndla/ui 16.1.1 → 18.0.0
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/Article.js +3 -3
- package/es/Article/ArticleFavoritesButton.js +4 -3
- package/es/Breadcrumblist/Breadcrumblist.js +7 -7
- package/es/Frontpage/FrontpageAllSubjects.js +8 -8
- package/es/Masthead/Masthead.js +2 -3
- package/es/Messages/MessageBanner.js +75 -0
- package/es/Messages/MessageBox.js +123 -0
- package/es/{MessageBox → Messages}/MessageBoxTag.js +1 -1
- package/es/{MessageBox → Messages}/index.js +3 -3
- package/es/MyNdla/Resource/Folder.js +6 -6
- package/es/MyNdla/index.js +1 -2
- package/es/Notion/ConceptNotion.js +1 -1
- package/es/Notion/index.js +2 -1
- package/es/Programme/Programme.js +6 -6
- package/es/Programme/ProgrammeSubjects.js +2 -2
- package/es/Resource/ListResource.js +6 -6
- package/es/TagSelector/SuggestionInput.js +111 -56
- package/es/TagSelector/Suggestions.js +19 -15
- package/es/TagSelector/TagSelector.js +8 -7
- package/es/Topic/Topic.js +22 -24
- package/es/TopicMenu/TopicMenu.js +2 -4
- package/es/TreeStructure/FolderItem.js +39 -28
- package/es/TreeStructure/FolderItems.js +8 -5
- package/es/TreeStructure/TreeStructure.js +6 -4
- package/es/TreeStructure/TreeStructureWrapper.js +2 -2
- package/es/index.js +3 -3
- package/es/locale/messages-en.js +9 -2
- package/es/locale/messages-nb.js +10 -3
- package/es/locale/messages-nn.js +11 -4
- package/es/locale/messages-se.js +10 -3
- package/es/locale/messages-sma.js +10 -3
- package/lib/Article/Article.js +3 -3
- package/lib/Article/ArticleFavoritesButton.js +4 -3
- package/lib/Breadcrumblist/Breadcrumblist.js +7 -7
- package/lib/Breadcrumblist/index.d.ts +1 -0
- package/lib/Frontpage/FrontpageAllSubjects.js +9 -9
- package/lib/Masthead/Masthead.js +2 -3
- package/lib/Messages/MessageBanner.d.ts +16 -0
- package/lib/Messages/MessageBanner.js +78 -0
- package/lib/{MessageBox → Messages}/MessageBox.d.ts +6 -14
- package/lib/Messages/MessageBox.js +128 -0
- package/lib/{MessageBox → Messages}/MessageBoxTag.d.ts +0 -0
- package/lib/{MessageBox → Messages}/MessageBoxTag.js +1 -1
- package/lib/{MessageBox → Messages}/index.d.ts +3 -3
- package/lib/Messages/index.js +31 -0
- package/lib/MyNdla/Resource/Folder.js +6 -6
- package/lib/MyNdla/index.d.ts +1 -2
- package/lib/MyNdla/index.js +0 -8
- package/lib/Notion/ConceptNotion.d.ts +1 -1
- package/lib/Notion/ConceptNotion.js +1 -1
- package/lib/Notion/index.d.ts +4 -1
- package/lib/Notion/index.js +11 -3
- package/lib/Programme/Programme.js +6 -6
- package/lib/Programme/ProgrammeSubjects.js +3 -3
- package/lib/Resource/ListResource.js +6 -6
- package/lib/TagSelector/SuggestionInput.js +111 -57
- package/lib/TagSelector/Suggestions.js +26 -23
- package/lib/TagSelector/TagSelector.js +8 -7
- package/lib/Topic/Topic.js +22 -24
- package/lib/TopicMenu/TopicMenu.js +2 -4
- package/lib/TreeStructure/FolderItem.d.ts +3 -2
- package/lib/TreeStructure/FolderItem.js +38 -28
- package/lib/TreeStructure/FolderItems.d.ts +1 -1
- package/lib/TreeStructure/FolderItems.js +8 -5
- package/lib/TreeStructure/TreeStructure.d.ts +1 -1
- package/lib/TreeStructure/TreeStructure.js +6 -4
- package/lib/TreeStructure/TreeStructure.types.d.ts +6 -3
- package/lib/TreeStructure/TreeStructureWrapper.js +2 -2
- package/lib/index.d.ts +8 -4
- package/lib/index.js +13 -13
- package/lib/locale/messages-en.d.ts +7 -0
- package/lib/locale/messages-en.js +9 -2
- package/lib/locale/messages-nb.d.ts +7 -0
- package/lib/locale/messages-nb.js +10 -3
- package/lib/locale/messages-nn.d.ts +7 -0
- package/lib/locale/messages-nn.js +11 -4
- package/lib/locale/messages-se.d.ts +7 -0
- package/lib/locale/messages-se.js +10 -3
- package/lib/locale/messages-sma.d.ts +7 -0
- package/lib/locale/messages-sma.js +10 -3
- package/package.json +13 -13
- package/src/Article/Article.tsx +1 -1
- package/src/Article/ArticleFavoritesButton.tsx +4 -3
- package/src/Breadcrumblist/Breadcrumblist.tsx +1 -1
- package/src/Breadcrumblist/{index.tsx → index.ts} +1 -0
- package/src/Frontpage/FrontpageAllSubjects.tsx +1 -1
- package/src/Masthead/Masthead.tsx +3 -6
- package/src/Messages/MessageBanner.tsx +66 -0
- package/src/Messages/MessageBox.tsx +156 -0
- package/src/{MessageBox → Messages}/MessageBoxTag.tsx +0 -0
- package/src/{MessageBox → Messages}/index.ts +3 -3
- package/src/MyNdla/Resource/Folder.tsx +1 -1
- package/src/MyNdla/index.ts +1 -2
- package/src/Notion/ConceptNotion.tsx +2 -1
- package/src/Notion/index.ts +4 -1
- package/src/Programme/Programme.tsx +1 -1
- package/src/Programme/ProgrammeSubjects.tsx +1 -1
- package/src/Resource/ListResource.tsx +1 -1
- package/src/TagSelector/SuggestionInput.tsx +90 -24
- package/src/TagSelector/Suggestions.tsx +14 -0
- package/src/TagSelector/TagSelector.tsx +6 -4
- package/src/Topic/Topic.tsx +2 -2
- package/src/TopicMenu/TopicMenu.jsx +2 -2
- package/src/TreeStructure/FolderItem.tsx +43 -19
- package/src/TreeStructure/FolderItems.tsx +3 -0
- package/src/TreeStructure/TreeStructure.tsx +2 -0
- package/src/TreeStructure/TreeStructure.types.ts +7 -3
- package/src/TreeStructure/TreeStructureWrapper.tsx +1 -1
- package/src/index.ts +17 -4
- package/src/locale/messages-en.ts +10 -2
- package/src/locale/messages-nb.ts +10 -3
- package/src/locale/messages-nn.ts +11 -4
- package/src/locale/messages-se.ts +10 -3
- package/src/locale/messages-sma.ts +10 -3
- package/es/MessageBox/MessageBox.js +0 -220
- package/es/MyNdla/Navigation/VerticalNavigation.js +0 -51
- package/es/MyNdla/Navigation/index.js +0 -2
- package/lib/MessageBox/MessageBox.js +0 -234
- package/lib/MessageBox/index.js +0 -35
- package/lib/MyNdla/Navigation/VerticalNavigation.d.ts +0 -10
- package/lib/MyNdla/Navigation/VerticalNavigation.js +0 -61
- package/lib/MyNdla/Navigation/index.d.ts +0 -2
- package/lib/MyNdla/Navigation/index.js +0 -15
- package/src/MessageBox/MessageBox.tsx +0 -201
- package/src/MyNdla/Navigation/VerticalNavigation.tsx +0 -93
- package/src/MyNdla/Navigation/index.ts +0 -2
|
@@ -1,201 +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, { HTMLAttributes, useState } from 'react';
|
|
10
|
-
import styled from '@emotion/styled';
|
|
11
|
-
import { breakpoints, fonts, mq, spacing } from '@ndla/core';
|
|
12
|
-
import { InformationOutline, HumanMaleBoard } from '@ndla/icons/common';
|
|
13
|
-
import { WithTranslation, withTranslation } from 'react-i18next';
|
|
14
|
-
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
import { Remarkable } from 'remarkable';
|
|
17
|
-
import { CloseButton } from '@ndla/button';
|
|
18
|
-
|
|
19
|
-
export enum MessageBoxType {
|
|
20
|
-
ghost = 'ghost',
|
|
21
|
-
fullpage = 'fullpage',
|
|
22
|
-
medium = 'medium',
|
|
23
|
-
masthead = 'masthead',
|
|
24
|
-
}
|
|
25
|
-
type WrapperProps = {
|
|
26
|
-
boxType?: MessageBoxType;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const StyleByType = (type: WrapperProps['boxType']) => {
|
|
30
|
-
const styles: HTMLAttributes<HTMLElement>['style'] = {
|
|
31
|
-
margin: '1px',
|
|
32
|
-
color: '#444444',
|
|
33
|
-
backgroundColor: '#f9f4c8',
|
|
34
|
-
border: 'none',
|
|
35
|
-
display: 'flex',
|
|
36
|
-
padding: '10px',
|
|
37
|
-
width: 'auto',
|
|
38
|
-
borderRadius: '5px',
|
|
39
|
-
position: 'relative',
|
|
40
|
-
transform: 'auto',
|
|
41
|
-
left: 'auto',
|
|
42
|
-
}; //Different CSS properties for different types of message-boxes
|
|
43
|
-
switch (type) {
|
|
44
|
-
case 'fullpage':
|
|
45
|
-
styles.margin = '0 auto';
|
|
46
|
-
styles.display = 'none';
|
|
47
|
-
styles.width = '100vw';
|
|
48
|
-
styles.position = 'relative';
|
|
49
|
-
styles.left = '50%';
|
|
50
|
-
styles.padding = '0';
|
|
51
|
-
styles.transform = 'translateX(-50%)';
|
|
52
|
-
break;
|
|
53
|
-
case 'medium':
|
|
54
|
-
styles.margin = '0px';
|
|
55
|
-
break;
|
|
56
|
-
case 'ghost':
|
|
57
|
-
styles.backgroundColor = 'transparent';
|
|
58
|
-
styles.border = '1px solid #D1D6DB';
|
|
59
|
-
styles.color = '#444444';
|
|
60
|
-
break;
|
|
61
|
-
case 'masthead':
|
|
62
|
-
styles.margin = '0 auto';
|
|
63
|
-
styles.display = 'none';
|
|
64
|
-
styles.padding = '0';
|
|
65
|
-
styles.borderRadius = '0';
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
return styles;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const Wrapper = styled.div<WrapperProps>`
|
|
72
|
-
background: ${(props) => StyleByType(props.boxType).backgroundColor};
|
|
73
|
-
color: ${(props) => StyleByType(props.boxType).color};
|
|
74
|
-
font-size: 18px;
|
|
75
|
-
line-height: 32px;
|
|
76
|
-
font-family: ${fonts.sans};
|
|
77
|
-
display: flex;
|
|
78
|
-
padding: ${spacing.small};
|
|
79
|
-
position: ${(props) => StyleByType(props.boxType).position};
|
|
80
|
-
border: ${(props) => StyleByType(props.boxType).border};
|
|
81
|
-
border-radius: ${(props) => StyleByType(props.boxType).borderRadius};
|
|
82
|
-
transform: ${(props) => StyleByType(props.boxType).transform};
|
|
83
|
-
left: ${(props) => StyleByType(props.boxType).left};
|
|
84
|
-
width: ${(props) => StyleByType(props.boxType).width};
|
|
85
|
-
`;
|
|
86
|
-
|
|
87
|
-
const InfoWrapper = styled.div<WrapperProps>`
|
|
88
|
-
margin: ${(props) => StyleByType(props.boxType).margin};
|
|
89
|
-
padding: ${(props) => StyleByType(props.boxType).padding};
|
|
90
|
-
display: flex;
|
|
91
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
92
|
-
padding: 0 90px 0 0;
|
|
93
|
-
}
|
|
94
|
-
${mq.range({ until: breakpoints.mobileWide })} {
|
|
95
|
-
padding: 0 5px 0 0;
|
|
96
|
-
font-size: 16px;
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
const TextWrapper = styled.div<WrapperProps>`
|
|
100
|
-
display: flex;
|
|
101
|
-
align-items: center;
|
|
102
|
-
flex-wrap: wrap;
|
|
103
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
104
|
-
line-height: 24px;
|
|
105
|
-
font-size: 16px;
|
|
106
|
-
}
|
|
107
|
-
& p {
|
|
108
|
-
margin: 0;
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
const IconWrapper = styled.div<WrapperProps>`
|
|
113
|
-
padding-right: ${spacing.small};
|
|
114
|
-
display: ${(props) => StyleByType(props.boxType).display};
|
|
115
|
-
align-items: flex-start;
|
|
116
|
-
${mq.range({ from: breakpoints.tabletWide })} {
|
|
117
|
-
padding-top: 4px;
|
|
118
|
-
}
|
|
119
|
-
`;
|
|
120
|
-
|
|
121
|
-
const LinkWrapper = styled.div`
|
|
122
|
-
display: block;
|
|
123
|
-
width: 100%;
|
|
124
|
-
background-color: #f9f4c8;
|
|
125
|
-
padding-bottom: 20px;
|
|
126
|
-
margin-top: -2px;
|
|
127
|
-
padding-left: 58px;
|
|
128
|
-
border-radius: 0px 0px 5px 5px;
|
|
129
|
-
${mq.range({ until: breakpoints.mobileWide })} {
|
|
130
|
-
padding-left: 45px;
|
|
131
|
-
}
|
|
132
|
-
`;
|
|
133
|
-
const Link = styled.a`
|
|
134
|
-
color: #20588f;
|
|
135
|
-
font-size: 16px;
|
|
136
|
-
padding-bottom: 1px;
|
|
137
|
-
margin: 0px 40px 1px 2px;
|
|
138
|
-
font-family: ${fonts.sans};
|
|
139
|
-
${mq.range({ until: breakpoints.mobileWide })} {
|
|
140
|
-
margin: 0px 15px 1px 5px;
|
|
141
|
-
box-shadow: none;
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
const CloseButtonWrapper = styled.div`
|
|
145
|
-
position: absolute;
|
|
146
|
-
top: 10px;
|
|
147
|
-
right: 1px;
|
|
148
|
-
`;
|
|
149
|
-
|
|
150
|
-
type LinkProps = {
|
|
151
|
-
href?: string;
|
|
152
|
-
text?: string;
|
|
153
|
-
};
|
|
154
|
-
type Props = {
|
|
155
|
-
type?: WrapperProps['boxType'];
|
|
156
|
-
children?: string;
|
|
157
|
-
links?: LinkProps[];
|
|
158
|
-
showCloseButton?: boolean;
|
|
159
|
-
onClose?: () => void;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const markdown = new Remarkable({ breaks: true });
|
|
163
|
-
markdown.inline.ruler.enable(['sub', 'sup']);
|
|
164
|
-
markdown.block.ruler.disable(['list', 'table']);
|
|
165
|
-
|
|
166
|
-
export const MessageBox = ({ type, children = '', links, showCloseButton, onClose }: Props & WithTranslation) => {
|
|
167
|
-
const [hideMessageBox, setHideMessageBox] = useState(false);
|
|
168
|
-
const onCloseMessageBox = () => {
|
|
169
|
-
setHideMessageBox(true);
|
|
170
|
-
onClose?.();
|
|
171
|
-
};
|
|
172
|
-
const Icon = type === 'ghost' ? HumanMaleBoard : InformationOutline;
|
|
173
|
-
return (
|
|
174
|
-
<>
|
|
175
|
-
<Wrapper boxType={type} style={{ display: hideMessageBox ? 'none' : 'flex' }}>
|
|
176
|
-
<InfoWrapper boxType={type}>
|
|
177
|
-
<IconWrapper boxType={type}>
|
|
178
|
-
<Icon style={{ width: '24px', height: '24px' }} />
|
|
179
|
-
</IconWrapper>
|
|
180
|
-
<TextWrapper dangerouslySetInnerHTML={{ __html: markdown.render(children) }}></TextWrapper>
|
|
181
|
-
</InfoWrapper>
|
|
182
|
-
{showCloseButton && (
|
|
183
|
-
<CloseButtonWrapper>
|
|
184
|
-
<CloseButton onClick={onCloseMessageBox} />
|
|
185
|
-
</CloseButtonWrapper>
|
|
186
|
-
)}
|
|
187
|
-
</Wrapper>
|
|
188
|
-
|
|
189
|
-
{links && (
|
|
190
|
-
//loops through the links passed in as properties if there are any and creates a working link for each of them
|
|
191
|
-
<LinkWrapper style={{ display: hideMessageBox ? 'none' : 'flex' }}>
|
|
192
|
-
{links.map((x) => (
|
|
193
|
-
<Link href={x.href}>{x.text}</Link>
|
|
194
|
-
))}
|
|
195
|
-
</LinkWrapper>
|
|
196
|
-
)}
|
|
197
|
-
</>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export default withTranslation()(MessageBox);
|
|
@@ -1,93 +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, { ReactNode } from 'react';
|
|
10
|
-
import styled from '@emotion/styled';
|
|
11
|
-
import { colors, spacing } from '@ndla/core';
|
|
12
|
-
import SafeLinkButton from '@ndla/safelink';
|
|
13
|
-
import { mq, breakpoints } from '@ndla/core';
|
|
14
|
-
|
|
15
|
-
const NavigationWrapper = styled.div`
|
|
16
|
-
display: flex;
|
|
17
|
-
justify-content: flex-start;
|
|
18
|
-
margin: 0;
|
|
19
|
-
max-width: 20vw;
|
|
20
|
-
border-right: 1px solid ${colors.brand.greyLighter};
|
|
21
|
-
height: 100%;
|
|
22
|
-
${mq.range({ until: breakpoints.tabletWide })} {
|
|
23
|
-
display: none;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
const Navigation = styled.div`
|
|
28
|
-
padding: ${spacing.large};
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
const NavigationElementText = styled.div`
|
|
32
|
-
color: ${colors.text.primary};
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const NavigationElement = styled(SafeLinkButton)`
|
|
36
|
-
display: flex;
|
|
37
|
-
align-items: center;
|
|
38
|
-
gap: 11px;
|
|
39
|
-
height: 30px;
|
|
40
|
-
box-shadow: none;
|
|
41
|
-
&:hover {
|
|
42
|
-
background-color: ${colors.brand.lighter};
|
|
43
|
-
border-radius: 5%;
|
|
44
|
-
svg {
|
|
45
|
-
fill: ${colors.brand.primary};
|
|
46
|
-
}
|
|
47
|
-
${NavigationElementText} {
|
|
48
|
-
color: ${colors.brand.primary};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
&:focus {
|
|
52
|
-
svg {
|
|
53
|
-
fill: ${colors.brand.primary};
|
|
54
|
-
}
|
|
55
|
-
${NavigationElementText} {
|
|
56
|
-
color: ${colors.brand.primary};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
const IconWrapper = styled.div`
|
|
62
|
-
svg {
|
|
63
|
-
fill: ${colors.text.primary};
|
|
64
|
-
height: 20px;
|
|
65
|
-
width: 20px;
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
interface NavProps {
|
|
70
|
-
navElements?: {
|
|
71
|
-
icon: ReactNode;
|
|
72
|
-
url: string;
|
|
73
|
-
name: string;
|
|
74
|
-
}[];
|
|
75
|
-
}
|
|
76
|
-
export const VerticalNavigation = ({ navElements }: NavProps) => {
|
|
77
|
-
return (
|
|
78
|
-
<NavigationWrapper>
|
|
79
|
-
<Navigation>
|
|
80
|
-
{navElements?.map((element) => {
|
|
81
|
-
return (
|
|
82
|
-
<NavigationElement to={element.url}>
|
|
83
|
-
<IconWrapper>{element.icon}</IconWrapper>
|
|
84
|
-
<NavigationElementText>{element.name}</NavigationElementText>
|
|
85
|
-
</NavigationElement>
|
|
86
|
-
);
|
|
87
|
-
})}
|
|
88
|
-
</Navigation>
|
|
89
|
-
</NavigationWrapper>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default VerticalNavigation;
|