@ndla/ui 16.2.0 → 18.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/Article.js +3 -3
  2. package/es/Article/ArticleFavoritesButton.js +4 -3
  3. package/es/Breadcrumblist/Breadcrumblist.js +7 -7
  4. package/es/Frontpage/FrontpageAllSubjects.js +8 -8
  5. package/es/Masthead/Masthead.js +2 -3
  6. package/es/Masthead/MastheadAuthModal.js +8 -3
  7. package/es/Messages/MessageBanner.js +75 -0
  8. package/es/Messages/MessageBox.js +123 -0
  9. package/es/{MessageBox → Messages}/MessageBoxTag.js +1 -1
  10. package/es/{MessageBox → Messages}/index.js +3 -3
  11. package/es/MyNdla/Resource/Folder.js +7 -7
  12. package/es/MyNdla/index.js +1 -2
  13. package/es/Programme/Programme.js +6 -6
  14. package/es/Programme/ProgrammeSubjects.js +2 -2
  15. package/es/Resource/ListResource.js +6 -6
  16. package/es/Resource/resourceComponents.js +8 -8
  17. package/es/TagSelector/SuggestionInput.js +111 -56
  18. package/es/TagSelector/Suggestions.js +19 -15
  19. package/es/TagSelector/TagSelector.js +8 -7
  20. package/es/Topic/Topic.js +22 -24
  21. package/es/TopicMenu/TopicMenu.js +2 -4
  22. package/es/TreeStructure/FolderItem.js +5 -5
  23. package/es/TreeStructure/FolderItems.js +3 -3
  24. package/es/TreeStructure/TreeStructure.js +51 -73
  25. package/es/TreeStructure/keyboardNavigation/keyboardNavigation.js +23 -11
  26. package/es/index.js +2 -2
  27. package/es/locale/messages-en.js +9 -1
  28. package/es/locale/messages-nb.js +10 -2
  29. package/es/locale/messages-nn.js +11 -3
  30. package/es/locale/messages-se.js +10 -2
  31. package/es/locale/messages-sma.js +10 -2
  32. package/lib/Article/Article.js +3 -3
  33. package/lib/Article/ArticleFavoritesButton.js +4 -3
  34. package/lib/Breadcrumblist/Breadcrumblist.js +7 -7
  35. package/lib/Frontpage/FrontpageAllSubjects.js +9 -9
  36. package/lib/Masthead/Masthead.js +2 -3
  37. package/lib/Masthead/MastheadAuthModal.js +14 -7
  38. package/lib/Messages/MessageBanner.d.ts +16 -0
  39. package/lib/Messages/MessageBanner.js +78 -0
  40. package/lib/{MessageBox → Messages}/MessageBox.d.ts +6 -14
  41. package/lib/Messages/MessageBox.js +128 -0
  42. package/lib/{MessageBox → Messages}/MessageBoxTag.d.ts +0 -0
  43. package/lib/{MessageBox → Messages}/MessageBoxTag.js +1 -1
  44. package/lib/{MessageBox → Messages}/index.d.ts +3 -3
  45. package/lib/Messages/index.js +31 -0
  46. package/lib/MyNdla/Resource/Folder.js +7 -7
  47. package/lib/MyNdla/index.d.ts +1 -2
  48. package/lib/MyNdla/index.js +0 -8
  49. package/lib/Programme/Programme.js +6 -6
  50. package/lib/Programme/ProgrammeSubjects.js +3 -3
  51. package/lib/Resource/ListResource.js +6 -6
  52. package/lib/Resource/resourceComponents.js +8 -8
  53. package/lib/TagSelector/SuggestionInput.js +111 -57
  54. package/lib/TagSelector/Suggestions.js +26 -23
  55. package/lib/TagSelector/TagSelector.js +8 -7
  56. package/lib/Topic/Topic.js +22 -24
  57. package/lib/TopicMenu/TopicMenu.js +2 -4
  58. package/lib/TreeStructure/FolderItem.js +5 -5
  59. package/lib/TreeStructure/FolderItems.js +3 -3
  60. package/lib/TreeStructure/TreeStructure.js +52 -73
  61. package/lib/TreeStructure/TreeStructure.types.d.ts +2 -2
  62. package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.js +23 -11
  63. package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.types.d.ts +1 -1
  64. package/lib/index.d.ts +2 -2
  65. package/lib/index.js +6 -13
  66. package/lib/locale/messages-en.d.ts +8 -0
  67. package/lib/locale/messages-en.js +9 -1
  68. package/lib/locale/messages-nb.d.ts +8 -0
  69. package/lib/locale/messages-nb.js +10 -2
  70. package/lib/locale/messages-nn.d.ts +8 -0
  71. package/lib/locale/messages-nn.js +11 -3
  72. package/lib/locale/messages-se.d.ts +8 -0
  73. package/lib/locale/messages-se.js +10 -2
  74. package/lib/locale/messages-sma.d.ts +8 -0
  75. package/lib/locale/messages-sma.js +10 -2
  76. package/package.json +13 -13
  77. package/src/Article/Article.tsx +1 -1
  78. package/src/Article/ArticleFavoritesButton.tsx +4 -3
  79. package/src/Breadcrumblist/Breadcrumblist.tsx +1 -1
  80. package/src/Frontpage/FrontpageAllSubjects.tsx +1 -1
  81. package/src/Masthead/Masthead.tsx +3 -6
  82. package/src/Masthead/MastheadAuthModal.tsx +9 -0
  83. package/src/Messages/MessageBanner.tsx +66 -0
  84. package/src/Messages/MessageBox.tsx +156 -0
  85. package/src/{MessageBox → Messages}/MessageBoxTag.tsx +0 -0
  86. package/src/{MessageBox → Messages}/index.ts +3 -3
  87. package/src/MyNdla/Resource/Folder.tsx +2 -2
  88. package/src/MyNdla/index.ts +1 -2
  89. package/src/Programme/Programme.tsx +1 -1
  90. package/src/Programme/ProgrammeSubjects.tsx +1 -1
  91. package/src/Resource/ListResource.tsx +1 -1
  92. package/src/Resource/resourceComponents.tsx +3 -0
  93. package/src/TagSelector/SuggestionInput.tsx +90 -24
  94. package/src/TagSelector/Suggestions.tsx +14 -0
  95. package/src/TagSelector/TagSelector.tsx +6 -4
  96. package/src/Topic/Topic.tsx +2 -2
  97. package/src/TopicMenu/TopicMenu.jsx +2 -2
  98. package/src/TreeStructure/FolderItem.tsx +5 -2
  99. package/src/TreeStructure/FolderItems.tsx +1 -1
  100. package/src/TreeStructure/TreeStructure.tsx +33 -35
  101. package/src/TreeStructure/TreeStructure.types.ts +2 -2
  102. package/src/TreeStructure/keyboardNavigation/keyboardNavigation.ts +7 -7
  103. package/src/TreeStructure/keyboardNavigation/keyboardNavigation.types.ts +1 -1
  104. package/src/index.ts +2 -2
  105. package/src/locale/messages-en.ts +10 -1
  106. package/src/locale/messages-nb.ts +10 -2
  107. package/src/locale/messages-nn.ts +11 -3
  108. package/src/locale/messages-se.ts +10 -2
  109. package/src/locale/messages-sma.ts +10 -2
  110. package/es/MessageBox/MessageBox.js +0 -220
  111. package/es/MyNdla/Navigation/VerticalNavigation.js +0 -51
  112. package/es/MyNdla/Navigation/index.js +0 -2
  113. package/lib/MessageBox/MessageBox.js +0 -234
  114. package/lib/MessageBox/index.js +0 -35
  115. package/lib/MyNdla/Navigation/VerticalNavigation.d.ts +0 -10
  116. package/lib/MyNdla/Navigation/VerticalNavigation.js +0 -61
  117. package/lib/MyNdla/Navigation/index.d.ts +0 -2
  118. package/lib/MyNdla/Navigation/index.js +0 -15
  119. package/src/MessageBox/MessageBox.tsx +0 -201
  120. package/src/MyNdla/Navigation/VerticalNavigation.tsx +0 -93
  121. 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;
@@ -1,2 +0,0 @@
1
- import VerticalNavigation from './VerticalNavigation';
2
- export { VerticalNavigation };