@ndla/ui 44.0.0 → 44.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "44.0.0",
3
+ "version": "44.0.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -40,9 +40,9 @@
40
40
  "@ndla/forms": "^4.3.17",
41
41
  "@ndla/hooks": "^2.0.9",
42
42
  "@ndla/icons": "^4.0.2",
43
- "@ndla/licenses": "^7.1.2",
43
+ "@ndla/licenses": "^7.1.3",
44
44
  "@ndla/modal": "^4.0.1",
45
- "@ndla/notion": "^5.0.15",
45
+ "@ndla/notion": "^5.0.16",
46
46
  "@ndla/safelink": "^4.1.16",
47
47
  "@ndla/select": "^2.4.8",
48
48
  "@ndla/switch": "^1.1.9",
@@ -51,6 +51,7 @@
51
51
  "@ndla/util": "^3.1.15",
52
52
  "@radix-ui/react-popover": "^1.0.6",
53
53
  "@radix-ui/react-slider": "^1.1.2",
54
+ "date-fns": "^2.30.0",
54
55
  "framer-motion": "^6.5.1",
55
56
  "html-react-parser": "^3.0.8",
56
57
  "i18next-browser-languagedetector": "^6.1.1",
@@ -82,5 +83,5 @@
82
83
  "publishConfig": {
83
84
  "access": "public"
84
85
  },
85
- "gitHead": "dfd245ca3261ca1209556b43c6185220e2fd7639"
86
+ "gitHead": "494677b86370dc86e7642c6c3934435339f87e18"
86
87
  }
@@ -33,6 +33,9 @@ const BlockWrapper = styled.div`
33
33
  border-radius: ${misc.borderRadius};
34
34
  border: 1px solid ${colors.brand.lighter};
35
35
  max-width: 348px;
36
+ & ~ & {
37
+ margin-top: ${spacing.medium};
38
+ }
36
39
  ${mq.range({ from: breakpoints.tabletWide })} {
37
40
  max-width: 773px;
38
41
  flex-direction: row;
@@ -6,11 +6,14 @@
6
6
  *
7
7
  */
8
8
 
9
+ import { format } from 'date-fns';
10
+ import { enGB, nb, nn } from 'date-fns/locale';
9
11
  import styled from '@emotion/styled';
10
12
  import SafeLink from '@ndla/safelink';
11
13
  import { Forward, CalendarEd } from '@ndla/icons/common';
12
14
  import { breakpoints, colors, spacing, mq } from '@ndla/core';
13
15
  import { LinkBlockEmbedData } from '@ndla/types-embed';
16
+ import { useMemo } from 'react';
14
17
  import Heading from '../Typography/Heading';
15
18
 
16
19
  const StyledForward = styled(Forward)`
@@ -69,6 +72,12 @@ const StyledCalenderEd = styled(CalendarEd)`
69
72
  `;
70
73
 
71
74
  const LinkBlock = ({ title, language, date, url }: Omit<LinkBlockEmbedData, 'resource'>) => {
75
+ const formattedDate = useMemo(() => {
76
+ if (!date) return null;
77
+ const locale = language === 'nb' ? nb : language === 'nn' ? nn : enGB;
78
+ return format(new Date(date), 'dd. LLLL. yyyy', { locale });
79
+ }, [date, language]);
80
+
72
81
  return (
73
82
  <StyledSafeLink to={url}>
74
83
  <InfoWrapper>
@@ -78,7 +87,7 @@ const LinkBlock = ({ title, language, date, url }: Omit<LinkBlockEmbedData, 'res
78
87
  {date && (
79
88
  <StyledDateContainer>
80
89
  <StyledCalenderEd />
81
- {date}
90
+ {formattedDate}
82
91
  </StyledDateContainer>
83
92
  )}
84
93
  </InfoWrapper>