@ndla/ui 6.1.2 → 6.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "6.1.2",
3
+ "version": "6.2.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,17 +31,17 @@
31
31
  "types"
32
32
  ],
33
33
  "dependencies": {
34
- "@ndla/button": "^2.1.2",
35
- "@ndla/carousel": "^1.2.2",
36
- "@ndla/core": "^2.0.0",
34
+ "@ndla/button": "^2.1.3",
35
+ "@ndla/carousel": "^1.2.3",
36
+ "@ndla/core": "^2.0.1",
37
37
  "@ndla/hooks": "^1.1.2",
38
38
  "@ndla/icons": "^1.6.1",
39
- "@ndla/licenses": "^4.0.1",
40
- "@ndla/modal": "^1.2.2",
41
- "@ndla/safelink": "^1.1.3",
42
- "@ndla/switch": "^0.1.2",
39
+ "@ndla/licenses": "^4.0.2",
40
+ "@ndla/modal": "^1.2.3",
41
+ "@ndla/safelink": "^1.1.4",
42
+ "@ndla/switch": "^0.1.3",
43
43
  "@ndla/tabs": "^1.1.2",
44
- "@ndla/tooltip": "^0.3.2",
44
+ "@ndla/tooltip": "^0.3.3",
45
45
  "@ndla/util": "^2.0.4",
46
46
  "@reach/menu-button": "^0.16.2",
47
47
  "@reach/slider": "^0.16.0",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "6002d3517851d20c9b1c2ab5267d0c91ec74721b"
84
+ "gitHead": "156f62b8d836ab751130960be775c219670ea5fc"
85
85
  }
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import React, { useState } from 'react';
9
+ import React, { HTMLAttributes, useState } from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import Sticky from 'react-sticky-el';
12
12
  import { breakpoints, fonts, mq, spacing } from '@ndla/core';
@@ -25,13 +25,15 @@ type WrapperProps = {
25
25
  };
26
26
 
27
27
  const StyleByType = (type: WrapperProps['boxType']) => {
28
- const styles = {
28
+ const styles: HTMLAttributes<HTMLElement>['style'] = {
29
29
  margin: '1px',
30
30
  color: '#444444',
31
31
  backgroundColor: '#f9f4c8',
32
32
  border: 'none',
33
33
  display: 'flex',
34
+ padding: '10px',
34
35
  width: 'auto',
36
+ borderRadius: '5px',
35
37
  position: 'relative',
36
38
  transform: 'auto',
37
39
  left: 'auto',
@@ -56,6 +58,8 @@ const StyleByType = (type: WrapperProps['boxType']) => {
56
58
  case 'masthead':
57
59
  styles.margin = '0 auto';
58
60
  styles.display = 'none';
61
+ styles.padding = '0';
62
+ styles.borderRadius = '0';
59
63
  break;
60
64
  }
61
65
  return styles;
@@ -71,7 +75,7 @@ const Wrapper = styled.div<WrapperProps>`
71
75
  padding: ${spacing.small};
72
76
  position: ${(props) => StyleByType(props.boxType).position};
73
77
  border: ${(props) => StyleByType(props.boxType).border};
74
- border-radius: 5px;
78
+ border-radius: ${(props) => StyleByType(props.boxType).borderRadius};
75
79
  transform: ${(props) => StyleByType(props.boxType).transform};
76
80
  left: ${(props) => StyleByType(props.boxType).left};
77
81
  z-index: 10;
@@ -80,7 +84,7 @@ const Wrapper = styled.div<WrapperProps>`
80
84
 
81
85
  const InfoWrapper = styled.div<WrapperProps>`
82
86
  margin: ${(props) => StyleByType(props.boxType).margin};
83
- padding: 10px;
87
+ padding: ${(props) => StyleByType(props.boxType).padding};
84
88
  display: flex;
85
89
  ${mq.range({ until: breakpoints.tabletWide })} {
86
90
  padding: 0 90px 0 0;
@@ -28,16 +28,19 @@ export interface ConceptNotionType {
28
28
  }
29
29
  interface Props {
30
30
  concept: ConceptNotionType;
31
+ disableScripts?: boolean;
31
32
  }
32
33
 
33
- const ConceptNotion = ({ concept }: Props) => {
34
+ const ConceptNotion = ({ concept, disableScripts }: Props) => {
34
35
  const notionId = `notion-${concept.id}`;
35
36
  const figureId = `notion-figure-${concept.id}`;
36
37
  const visualElementId = `visual-element-${concept.id}`;
37
38
 
38
39
  useEffect(() => {
39
- initArticleScripts();
40
- }, []);
40
+ if (!disableScripts) {
41
+ initArticleScripts();
42
+ }
43
+ }, [disableScripts]);
41
44
  return (
42
45
  <FigureNotion
43
46
  id={figureId}
@@ -42,8 +42,8 @@ const ContentWrapper = styled.div`
42
42
  }
43
43
  }
44
44
  `;
45
- const TextWrapper = styled.div`
46
- width: 75%;
45
+ const TextWrapper = styled.div<{ hasVisualElement: boolean }>`
46
+ width: ${(props) => (props.hasVisualElement ? '75%' : '100%')};
47
47
  ${mq.range({ until: breakpoints.tabletWide })} {
48
48
  width: 100%;
49
49
  }
@@ -223,7 +223,7 @@ const Notion = ({
223
223
  </ExpandVisualElementButton>
224
224
  </ImageWrapper>
225
225
  )}
226
- <TextWrapper>
226
+ <TextWrapper hasVisualElement={!!(imageElement || visualElement?.metaImage)}>
227
227
  {HTMLReactParser(
228
228
  renderMarkdown ? renderMarkdown(`**${title}** \u2013 ${text}`) : `<b>${title}</b> \u2013 ${text}`,
229
229
  )}
@@ -28,6 +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
32
 
32
33
  const classes = new BEMHelper({
33
34
  name: 'topic-menu',
@@ -72,6 +73,7 @@ export const TopicMenu = ({
72
73
  programmes,
73
74
  currentProgramme,
74
75
  initialSelectedMenu,
76
+ messages,
75
77
  }) => {
76
78
  const { t } = useTranslation();
77
79
  const [isNarrowScreen, setIsNarrowScreen] = useState(false);
@@ -148,6 +150,9 @@ export const TopicMenu = ({
148
150
 
149
151
  return (
150
152
  <nav>
153
+ {messages?.map((message) => (
154
+ <MessageBox type={MessageBoxType.masthead}>{message}</MessageBox>
155
+ ))}
151
156
  <ModalHeader modifier={['white', 'menu']}>
152
157
  <div {...classes('masthead-left')}>
153
158
  <button type="button" {...classes('close-button')} onClick={closeMenu}>