@ndla/ui 16.2.0 → 17.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.
Files changed (49) hide show
  1. package/es/Article/Article.js +3 -3
  2. package/es/Breadcrumblist/Breadcrumblist.js +7 -7
  3. package/es/Frontpage/FrontpageAllSubjects.js +8 -8
  4. package/es/Masthead/Masthead.js +2 -3
  5. package/es/Messages/MessageBanner.js +75 -0
  6. package/es/Messages/MessageBox.js +123 -0
  7. package/es/{MessageBox → Messages}/MessageBoxTag.js +1 -1
  8. package/es/{MessageBox → Messages}/index.js +3 -3
  9. package/es/Programme/Programme.js +6 -6
  10. package/es/Programme/ProgrammeSubjects.js +2 -2
  11. package/es/Topic/Topic.js +22 -24
  12. package/es/TopicMenu/TopicMenu.js +2 -4
  13. package/es/index.js +1 -1
  14. package/lib/Article/Article.js +3 -3
  15. package/lib/Breadcrumblist/Breadcrumblist.js +7 -7
  16. package/lib/Frontpage/FrontpageAllSubjects.js +9 -9
  17. package/lib/Masthead/Masthead.js +2 -3
  18. package/lib/Messages/MessageBanner.d.ts +16 -0
  19. package/lib/Messages/MessageBanner.js +78 -0
  20. package/lib/{MessageBox → Messages}/MessageBox.d.ts +6 -14
  21. package/lib/Messages/MessageBox.js +128 -0
  22. package/lib/{MessageBox → Messages}/MessageBoxTag.d.ts +0 -0
  23. package/lib/{MessageBox → Messages}/MessageBoxTag.js +1 -1
  24. package/lib/{MessageBox → Messages}/index.d.ts +3 -3
  25. package/lib/Messages/index.js +31 -0
  26. package/lib/Programme/Programme.js +6 -6
  27. package/lib/Programme/ProgrammeSubjects.js +3 -3
  28. package/lib/Topic/Topic.js +22 -24
  29. package/lib/TopicMenu/TopicMenu.js +2 -4
  30. package/lib/index.d.ts +1 -1
  31. package/lib/index.js +6 -6
  32. package/package.json +13 -13
  33. package/src/Article/Article.tsx +1 -1
  34. package/src/Breadcrumblist/Breadcrumblist.tsx +1 -1
  35. package/src/Frontpage/FrontpageAllSubjects.tsx +1 -1
  36. package/src/Masthead/Masthead.tsx +3 -6
  37. package/src/Messages/MessageBanner.tsx +66 -0
  38. package/src/Messages/MessageBox.tsx +156 -0
  39. package/src/{MessageBox → Messages}/MessageBoxTag.tsx +0 -0
  40. package/src/{MessageBox → Messages}/index.ts +3 -3
  41. package/src/Programme/Programme.tsx +1 -1
  42. package/src/Programme/ProgrammeSubjects.tsx +1 -1
  43. package/src/Topic/Topic.tsx +2 -2
  44. package/src/TopicMenu/TopicMenu.jsx +2 -2
  45. package/src/index.ts +1 -1
  46. package/es/MessageBox/MessageBox.js +0 -220
  47. package/lib/MessageBox/MessageBox.js +0 -234
  48. package/lib/MessageBox/index.js +0 -35
  49. package/src/MessageBox/MessageBox.tsx +0 -201
@@ -41,7 +41,7 @@ var _NavigationBox = _interopRequireDefault(require("../Navigation/NavigationBox
41
41
 
42
42
  var _Programme = require("../Programme");
43
43
 
44
- var _MessageBox = require("../MessageBox");
44
+ var _Messages = require("../Messages");
45
45
 
46
46
  var _core = require("@emotion/core");
47
47
 
@@ -212,9 +212,7 @@ var TopicMenu = function TopicMenu(_ref) {
212
212
  var disableSubTopic = disableMain && hasExpandedSubtopics;
213
213
  var sliderCounter = !expandedTopicId ? 0 : expandedSubtopicsId.length + 1;
214
214
  return (0, _core.jsx)("nav", null, messages === null || messages === void 0 ? void 0 : messages.map(function (message) {
215
- return (0, _core.jsx)(_MessageBox.MessageBox, {
216
- type: _MessageBox.MessageBoxType.masthead
217
- }, message);
215
+ return (0, _core.jsx)(_Messages.MessageBanner, null, message);
218
216
  }), (0, _core.jsx)(_modal.ModalHeader, {
219
217
  modifier: ['white', 'menu']
220
218
  }, (0, _core.jsx)("div", classes('masthead-left'), (0, _core.jsx)("button", _extends({
package/lib/index.d.ts CHANGED
@@ -45,7 +45,7 @@ export { default as AuthModal } from './User';
45
45
  export type { FeideGoGroup, FeideGroup, FeideOrg, FeideUserApiType, FeideMembershipType, FeideUser } from './User';
46
46
  export { default as CreatedBy } from './CreatedBy';
47
47
  export { default as Breadcrumblist } from './Breadcrumblist';
48
- export { MessageBox, MessageBoxTag, MessageBoxType } from './MessageBox';
48
+ export { MessageBox, MessageBoxTag, MessageBanner } from './Messages';
49
49
  export { ResourceBox } from './ResourceBox';
50
50
  export { default as AudioPlayer, initAudioPlayers } from './AudioPlayer';
51
51
  export { NavigationHeading, NavigationBox, NavigationTopicAbout } from './Navigation';
package/lib/index.js CHANGED
@@ -95,7 +95,7 @@ var _exportNames = {
95
95
  Breadcrumblist: true,
96
96
  MessageBox: true,
97
97
  MessageBoxTag: true,
98
- MessageBoxType: true,
98
+ MessageBanner: true,
99
99
  ResourceBox: true,
100
100
  AudioPlayer: true,
101
101
  initAudioPlayers: true,
@@ -714,19 +714,19 @@ Object.defineProperty(exports, "Breadcrumblist", {
714
714
  Object.defineProperty(exports, "MessageBox", {
715
715
  enumerable: true,
716
716
  get: function get() {
717
- return _MessageBox.MessageBox;
717
+ return _Messages.MessageBox;
718
718
  }
719
719
  });
720
720
  Object.defineProperty(exports, "MessageBoxTag", {
721
721
  enumerable: true,
722
722
  get: function get() {
723
- return _MessageBox.MessageBoxTag;
723
+ return _Messages.MessageBoxTag;
724
724
  }
725
725
  });
726
- Object.defineProperty(exports, "MessageBoxType", {
726
+ Object.defineProperty(exports, "MessageBanner", {
727
727
  enumerable: true,
728
728
  get: function get() {
729
- return _MessageBox.MessageBoxType;
729
+ return _Messages.MessageBanner;
730
730
  }
731
731
  });
732
732
  Object.defineProperty(exports, "ResourceBox", {
@@ -1361,7 +1361,7 @@ var _CreatedBy = _interopRequireDefault(require("./CreatedBy"));
1361
1361
 
1362
1362
  var _Breadcrumblist = _interopRequireDefault(require("./Breadcrumblist"));
1363
1363
 
1364
- var _MessageBox = require("./MessageBox");
1364
+ var _Messages = require("./Messages");
1365
1365
 
1366
1366
  var _ResourceBox = require("./ResourceBox");
1367
1367
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "16.2.0",
3
+ "version": "17.0.0",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,18 +31,18 @@
31
31
  "types"
32
32
  ],
33
33
  "dependencies": {
34
- "@ndla/button": "^2.5.0",
35
- "@ndla/carousel": "^1.2.10",
36
- "@ndla/core": "^2.2.0",
34
+ "@ndla/button": "^2.5.1",
35
+ "@ndla/carousel": "^1.2.11",
36
+ "@ndla/core": "^2.3.0",
37
37
  "@ndla/hooks": "^1.1.4",
38
- "@ndla/icons": "^1.9.0",
39
- "@ndla/licenses": "^5.0.1",
40
- "@ndla/modal": "^1.2.11",
41
- "@ndla/notion": "^3.1.15",
42
- "@ndla/safelink": "^2.0.6",
43
- "@ndla/switch": "^0.1.6",
44
- "@ndla/tabs": "^1.1.9",
45
- "@ndla/tooltip": "^2.1.1",
38
+ "@ndla/icons": "^1.10.0",
39
+ "@ndla/licenses": "^5.0.2",
40
+ "@ndla/modal": "^1.2.12",
41
+ "@ndla/notion": "^3.1.16",
42
+ "@ndla/safelink": "^2.0.7",
43
+ "@ndla/switch": "^0.1.7",
44
+ "@ndla/tabs": "^1.1.10",
45
+ "@ndla/tooltip": "^2.1.2",
46
46
  "@ndla/util": "^3.0.0",
47
47
  "@reach/menu-button": "^0.16.2",
48
48
  "@reach/slider": "^0.16.0",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "97d16d07a6f4d4fc04c5114f01aac6c9480b0341"
84
+ "gitHead": "224c9c0d69875fa7d84a591cfbf15b6df340adc5"
85
85
  }
@@ -24,7 +24,7 @@ import LayoutItem from '../Layout';
24
24
  import ArticleHeaderWrapper from './ArticleHeaderWrapper';
25
25
  import ArticleNotions, { NotionRelatedContent } from './ArticleNotions';
26
26
  import ArticleAccessMessage from './ArticleAccessMessage';
27
- import MessageBox from '../MessageBox/MessageBox';
27
+ import MessageBox from '../Messages/MessageBox';
28
28
  import { ConceptNotionType } from '../Notion/ConceptNotion';
29
29
 
30
30
  const classes = new BEMHelper({
@@ -18,7 +18,7 @@ import {
18
18
  } from '@ndla/icons/action';
19
19
  import SafeLink from '@ndla/safelink';
20
20
  import { useTranslation } from 'react-i18next';
21
- import MessageBoxTag from '../MessageBox/MessageBoxTag';
21
+ import MessageBoxTag from '../Messages/MessageBoxTag';
22
22
  import { useMastheadHeight } from '../Masthead';
23
23
 
24
24
  type WrapperProps = {
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
4
4
  import Tabs from '@ndla/tabs';
5
5
  import SafeLink from '@ndla/safelink';
6
6
  import { colors, fonts, mq, breakpoints } from '@ndla/core';
7
- import { MessageBox } from '../MessageBox';
7
+ import { MessageBox } from '../Messages';
8
8
  // @ts-ignore
9
9
  import { ToggleItem } from '../Filter';
10
10
 
@@ -10,7 +10,7 @@ import React, { ReactNode, useEffect, useRef } from 'react';
10
10
  import BEMHelper from 'react-bem-helper';
11
11
  import { WithTranslation, withTranslation } from 'react-i18next';
12
12
  import { DisplayOnPageYOffset } from '../Animation';
13
- import { MessageBox, MessageBoxType } from '../MessageBox';
13
+ import { MessageBanner } from '../Messages';
14
14
 
15
15
  const classes = new BEMHelper({
16
16
  name: 'masthead',
@@ -95,12 +95,9 @@ export const Masthead = ({
95
95
  )}
96
96
  <div id="masthead" {...classes('', { fixed: !!fixed, infoContent: !!infoContent, ndlaFilm: !!ndlaFilm })}>
97
97
  {messages?.map((message) => (
98
- <MessageBox
99
- type={MessageBoxType.masthead}
100
- showCloseButton={message.closable}
101
- onClose={() => onCloseAlert?.(message.number)}>
98
+ <MessageBanner showCloseButton={message.closable} onClose={() => onCloseAlert?.(message.number)}>
102
99
  {message.content}
103
- </MessageBox>
100
+ </MessageBanner>
104
101
  ))}
105
102
  {infoContent && (
106
103
  <DisplayOnPageYOffset yOffsetMin={0} yOffsetMax={90}>
@@ -0,0 +1,66 @@
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 from 'react';
10
+ import styled from '@emotion/styled';
11
+ import { colors, spacing } from '@ndla/core';
12
+ // @ts-ignore
13
+ import { Remarkable } from 'remarkable';
14
+ import { CloseButton } from '@ndla/button';
15
+
16
+ interface WrapperProps {
17
+ small?: boolean;
18
+ }
19
+
20
+ const MessageBannerWrapper = styled.div<WrapperProps>`
21
+ display: grid;
22
+ grid-template-areas: '. content closebutton';
23
+ grid-template-columns: minmax(30px, 1fr) minmax(0, auto) minmax(30px, 1fr);
24
+ padding: ${({ small }) => (small ? spacing.xxsmall : spacing.small)};
25
+ background: ${colors.support.yellowLight};
26
+ color: ${colors.brand.greyDark};
27
+ border: none;
28
+ `;
29
+
30
+ const TextWrapper = styled.div`
31
+ display: flex;
32
+ grid-area: content;
33
+ align-items: center;
34
+ & p {
35
+ margin: 0;
36
+ }
37
+ `;
38
+
39
+ const StyledClosebutton = styled(CloseButton)`
40
+ grid-area: closebutton;
41
+ padding: 0;
42
+ justify-self: flex-end;
43
+ align-self: flex-start;
44
+ `;
45
+
46
+ interface Props {
47
+ small?: boolean;
48
+ children?: string;
49
+ showCloseButton?: boolean;
50
+ onClose?: () => void;
51
+ }
52
+
53
+ const markdown = new Remarkable({ breaks: true });
54
+ markdown.inline.ruler.enable(['sub', 'sup']);
55
+ markdown.block.ruler.disable(['list', 'table']);
56
+
57
+ const MessageBanner = ({ children, onClose, showCloseButton, small }: Props) => {
58
+ return (
59
+ <MessageBannerWrapper small={small}>
60
+ <TextWrapper dangerouslySetInnerHTML={{ __html: markdown.render(children) }} />
61
+ {showCloseButton && <StyledClosebutton onClick={onClose} />}
62
+ </MessageBannerWrapper>
63
+ );
64
+ };
65
+
66
+ export default MessageBanner;
@@ -0,0 +1,156 @@
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 from 'react';
10
+ import styled from '@emotion/styled';
11
+ import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
12
+ import { InformationOutline, HumanMaleBoard, Forward, WarningOutline } 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
+ import { css } from '@emotion/core';
19
+
20
+ const markdown = new Remarkable({ breaks: true });
21
+ markdown.inline.ruler.enable(['sub', 'sup']);
22
+ markdown.block.ruler.disable(['list', 'table']);
23
+
24
+ type MessageBoxType = 'ghost' | 'danger';
25
+
26
+ interface StyledProps {
27
+ type?: MessageBoxType;
28
+ }
29
+
30
+ const MessageBoxWrapper = styled.div<StyledProps>`
31
+ display: flex;
32
+ padding: ${spacing.small};
33
+ font-family: ${fonts.sans};
34
+ border-radius: 5px;
35
+ background: ${colors.support.yellowLight};
36
+ color: ${colors.brand.greyDark};
37
+
38
+ ${fonts.sizes('18px')};
39
+ ${mq.range({ until: breakpoints.tabletWide })} {
40
+ ${fonts.sizes('16px')};
41
+ }
42
+
43
+ ${({ type }) =>
44
+ type === 'ghost' &&
45
+ css`
46
+ background: transparent;
47
+ border: 1px solid ${colors.brand.neutral7};
48
+ color: ${colors.brand.greyDark};
49
+ `}
50
+
51
+ ${({ type }) =>
52
+ type === 'danger' &&
53
+ css`
54
+ background: ${colors.support.redLightest};
55
+ color: ${colors.support.red};
56
+ `}
57
+ `;
58
+
59
+ const InfoWrapper = styled.div`
60
+ display: flex;
61
+ flex-direction: row;
62
+ flex: 1;
63
+ padding: ${spacing.small};
64
+ padding-right: 0;
65
+ `;
66
+
67
+ const TextWrapper = styled.div`
68
+ & p {
69
+ margin: 0;
70
+ }
71
+ `;
72
+
73
+ const IconWrapper = styled.div`
74
+ display: flex;
75
+ align-items: flex-start;
76
+ padding-right: ${spacing.small};
77
+
78
+ svg {
79
+ width: 24px;
80
+ height: 24px;
81
+ }
82
+ `;
83
+
84
+ const LinkWrapper = styled.div`
85
+ display: flex;
86
+ flex-wrap: wrap;
87
+ gap: ${spacing.normal};
88
+ padding-top: ${spacing.nsmall};
89
+
90
+ svg {
91
+ flex-shrink: 0;
92
+ }
93
+ `;
94
+
95
+ const Link = styled.a`
96
+ display: flex;
97
+ align-items: center;
98
+ color: ${colors.brand.primary};
99
+ gap: ${spacing.xxsmall};
100
+ font-weight: ${fonts.weight.semibold};
101
+ `;
102
+
103
+ const StyledClosebutton = styled(CloseButton)`
104
+ padding: 0;
105
+ `;
106
+
107
+ interface LinkProps {
108
+ href?: string;
109
+ text?: string;
110
+ }
111
+
112
+ interface Props {
113
+ type?: MessageBoxType;
114
+ children?: string;
115
+ links?: LinkProps[];
116
+ showCloseButton?: boolean;
117
+ onClose?: () => void;
118
+ }
119
+
120
+ const Icon = ({ type }: StyledProps) => {
121
+ if (type === 'ghost') {
122
+ return <HumanMaleBoard />;
123
+ }
124
+ if (type === 'danger') {
125
+ return <WarningOutline />;
126
+ }
127
+ return <InformationOutline />;
128
+ };
129
+
130
+ export const MessageBox = ({ type, children = '', links, showCloseButton, onClose }: Props & WithTranslation) => {
131
+ return (
132
+ <MessageBoxWrapper type={type}>
133
+ <InfoWrapper>
134
+ <IconWrapper>
135
+ <Icon type={type} />
136
+ </IconWrapper>
137
+ <div>
138
+ <TextWrapper dangerouslySetInnerHTML={{ __html: markdown.render(children) }} />
139
+ {links && (
140
+ <LinkWrapper>
141
+ {links.map((x) => (
142
+ <Link href={x.href}>
143
+ <span>{x.text}</span>
144
+ <Forward />
145
+ </Link>
146
+ ))}
147
+ </LinkWrapper>
148
+ )}
149
+ </div>
150
+ </InfoWrapper>
151
+ {showCloseButton && <StyledClosebutton onClick={onClose} />}
152
+ </MessageBoxWrapper>
153
+ );
154
+ };
155
+
156
+ export default withTranslation()(MessageBox);
File without changes
@@ -6,8 +6,8 @@
6
6
  *
7
7
  */
8
8
 
9
- import MessageBox from './MessageBox';
10
9
  import MessageBoxTag from './MessageBoxTag';
11
- import { MessageBoxType } from './MessageBox';
10
+ import MessageBox from './MessageBox';
11
+ import MessageBanner from './MessageBanner';
12
12
 
13
- export { MessageBox, MessageBoxTag, MessageBoxType };
13
+ export { MessageBox, MessageBoxTag, MessageBanner };
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
5
5
  import LayoutItem, { OneColumn } from '../Layout';
6
6
  import ProgrammeSubjects from './ProgrammeSubjects';
7
7
  import { GradesProps } from './ProgrammeSubjects';
8
- import MessageBox from '../MessageBox/MessageBox';
8
+ import MessageBox from '../Messages/MessageBox';
9
9
  import { NavigationHeading } from '..';
10
10
  const StyledWrapper = styled.div`
11
11
  display: flex;
@@ -12,7 +12,7 @@ import styled from '@emotion/styled';
12
12
  import Button from '@ndla/button';
13
13
  import { breakpoints, mq } from '@ndla/core';
14
14
  import { NavigationBox } from '../Navigation';
15
- import { MessageBox } from '../MessageBox';
15
+ import { MessageBox } from '../Messages';
16
16
 
17
17
  const GradesMenu = styled.div`
18
18
  margin-bottom: 28px;
@@ -21,7 +21,7 @@ import Loader from './Loader';
21
21
  import { ItemProps } from '../Navigation/NavigationBox';
22
22
  import { NavigationBox } from '../Navigation';
23
23
  import { makeSrcQueryString, ImageCrop, ImageFocalPoint } from '../Image';
24
- import { MessageBox, MessageBoxType } from '../MessageBox';
24
+ import { MessageBox } from '../Messages';
25
25
 
26
26
  type InvertItProps = {
27
27
  invertedStyle?: boolean;
@@ -331,7 +331,7 @@ const Topic = ({
331
331
  </StyledAdditionalResource>
332
332
  )}
333
333
  </TopicHeading>
334
- {messageBox && <MessageBox type={MessageBoxType.medium}>{messageBox}</MessageBox>}
334
+ {messageBox && <MessageBox>{messageBox}</MessageBox>}
335
335
  <TopicIntroduction invertedStyle={invertedStyle}>
336
336
  {renderMarkdown ? parse(renderMarkdown(topic.introduction)) : topic.introduction}
337
337
  </TopicIntroduction>
@@ -28,7 +28,7 @@ import Logo from '../Logo';
28
28
  import FrontpageAllSubjects from '../Frontpage/FrontpageAllSubjects';
29
29
  import NavigationBox from '../Navigation/NavigationBox';
30
30
  import { ProgrammeSubjects } from '../Programme';
31
- import { MessageBox, MessageBoxType } from '../MessageBox';
31
+ import { MessageBanner } from '../Messages';
32
32
 
33
33
  const classes = new BEMHelper({
34
34
  name: 'topic-menu',
@@ -153,7 +153,7 @@ export const TopicMenu = ({
153
153
  return (
154
154
  <nav>
155
155
  {messages?.map((message) => (
156
- <MessageBox type={MessageBoxType.masthead}>{message}</MessageBox>
156
+ <MessageBanner>{message}</MessageBanner>
157
157
  ))}
158
158
  <ModalHeader modifier={['white', 'menu']}>
159
159
  <div {...classes('masthead-left')}>
package/src/index.ts CHANGED
@@ -127,7 +127,7 @@ export { default as CreatedBy } from './CreatedBy';
127
127
 
128
128
  export { default as Breadcrumblist } from './Breadcrumblist';
129
129
 
130
- export { MessageBox, MessageBoxTag, MessageBoxType } from './MessageBox';
130
+ export { MessageBox, MessageBoxTag, MessageBanner } from './Messages';
131
131
 
132
132
  export { ResourceBox } from './ResourceBox';
133
133