@ndla/ui 33.3.2 → 33.3.3

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": "33.3.2",
3
+ "version": "33.3.3",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "2cbff26d49ef6ed78bb1d789d6cca7b69461b269"
85
+ "gitHead": "312f7ebe89fd733409c3d62723cd7209bef67ad6"
86
86
  }
@@ -8,35 +8,33 @@
8
8
 
9
9
  import React, { ReactNode } from 'react';
10
10
  import styled from '@emotion/styled';
11
- import { fonts, spacing } from '@ndla/core';
11
+ import { css } from '@emotion/react';
12
+ import { colors, fonts, spacing } from '@ndla/core';
12
13
 
13
14
  import ResourceList, { ResourceListProps } from './ResourceList';
15
+ import { HeadingLevel } from '../types';
14
16
 
15
17
  const Wrapper = styled.section`
16
18
  margin-bottom: ${spacing.large};
17
19
  `;
18
20
 
19
- type StyledHeaderProps = {
20
- invertedStyle?: boolean;
21
- };
22
-
23
- const StyledHeader = styled.header<StyledHeaderProps>`
24
- margin: ${spacing.small} 0 ${spacing.xsmall};
25
- ${(props) => props.invertedStyle && `color: #fff`};
26
- `;
27
-
28
- const StyledHeading = styled.h1`
21
+ const headingStyle = css`
29
22
  ${fonts.sizes('16px', '18px')};
30
23
  font-weight: ${fonts.weight.bold};
31
24
  text-transform: uppercase;
32
25
  letter-spacing: 0.05em;
33
- margin: 0;
26
+ margin: ${spacing.small} 0 ${spacing.xsmall};
27
+ `;
28
+
29
+ const invertedStyle = css`
30
+ color: ${colors.white};
34
31
  `;
35
32
 
36
33
  type Props = {
37
34
  invertedStyle?: boolean;
38
35
  toggleAdditionalResources: () => void;
39
36
  heartButton?: (path: string) => ReactNode;
37
+ headingLevel?: HeadingLevel;
40
38
  };
41
39
 
42
40
  const ResourceGroup = ({
@@ -45,15 +43,12 @@ const ResourceGroup = ({
45
43
  showAdditionalResources,
46
44
  toggleAdditionalResources,
47
45
  contentType,
48
- invertedStyle,
46
+ invertedStyle: invertedStyleProp,
47
+ headingLevel: Heading = 'h1',
49
48
  heartButton,
50
49
  }: Props & ResourceListProps) => (
51
50
  <Wrapper>
52
- {title && (
53
- <StyledHeader invertedStyle={invertedStyle}>
54
- <StyledHeading>{title}</StyledHeading>
55
- </StyledHeader>
56
- )}
51
+ {title && <Heading css={[headingStyle, invertedStyleProp ? invertedStyle : undefined]}>{title}</Heading>}
57
52
  {resources.length > 0 ? (
58
53
  <ResourceList
59
54
  title={title}
@@ -80,9 +80,9 @@ const ListElement = styled.li<ListElementProps>`
80
80
  props.additional &&
81
81
  css`
82
82
  border-style: dashed;
83
- animation-name: ${fadeInAdditionalsKeyframe};
84
83
  animation-duration: 0.8s;
85
84
  animation-fill-mode: forwards;
85
+ animation: ${fadeInAdditionalsKeyframe};
86
86
  `}
87
87
  ${(props) => props.extraBottomMargin && `margin-bottom: ${spacing.large};`}
88
88
 
@@ -143,10 +143,7 @@ const ResourceLink = styled(SafeLink)`
143
143
  }
144
144
  `;
145
145
 
146
- type ActiveProps = {
147
- active?: boolean;
148
- };
149
- const Heading = styled.h2<ActiveProps>`
146
+ const headingStyle = css`
150
147
  font-weight: ${fonts.weight.semibold};
151
148
  transform: translateY(-1px);
152
149
  text-transform: none;
@@ -161,28 +158,21 @@ const Heading = styled.h2<ActiveProps>`
161
158
  ${fonts.sizes('20px', '26px')};
162
159
  }
163
160
 
164
- span {
165
- box-shadow: ${colors.link};
166
- }
161
+ box-shadow: ${colors.link};
167
162
 
168
163
  ${ResourceLink}:hover &,
169
164
  ${ResourceLink}:focus & {
170
- span {
171
- box-shadow: ${colors.linkHover};
172
- }
165
+ box-shadow: ${colors.linkHover};
166
+ }
167
+ `;
168
+
169
+ const activeHeadingStyle = css`
170
+ color: ${colors.brand.greyDark};
171
+ box-shadow: none;
172
+ small {
173
+ padding-left: ${spacing.small};
174
+ font-weight: ${fonts.weight.normal};
173
175
  }
174
- ${(props) =>
175
- props.active &&
176
- css`
177
- color: ${colors.brand.greyDark};
178
- span {
179
- box-shadow: none;
180
- }
181
- small {
182
- padding-left: ${spacing.small};
183
- font-weight: ${fonts.weight.normal};
184
- }
185
- `}
186
176
  `;
187
177
 
188
178
  const IconWrapper = styled.div`
@@ -247,6 +237,7 @@ const ResourceItem = ({
247
237
  const hidden = additional ? !showAdditionalResources : false;
248
238
  return (
249
239
  <ListElement
240
+ aria-current={active ? 'page' : undefined}
250
241
  contentType={contentType}
251
242
  hidden={hidden && !active}
252
243
  active={active}
@@ -257,21 +248,17 @@ const ResourceItem = ({
257
248
  <IconWrapper>
258
249
  <ContentTypeBadge type={contentType ?? ''} background border={false} />
259
250
  </IconWrapper>
260
- <Heading active>
261
- <span>
262
- {name}
263
- <small>{t('resource.youAreHere')}</small>
264
- </span>
265
- </Heading>
251
+ <span css={[headingStyle, activeHeadingStyle]}>
252
+ {name}
253
+ <small>{t('resource.youAreHere')}</small>
254
+ </span>
266
255
  </ActiveWrapper>
267
256
  ) : (
268
257
  <ResourceLink to={path}>
269
258
  <IconWrapper>
270
259
  <ContentTypeBadge type={contentType ?? ''} background border={false} />
271
260
  </IconWrapper>
272
- <Heading>
273
- <span>{name}</span>
274
- </Heading>
261
+ <span css={headingStyle}>{name}</span>
275
262
  </ResourceLink>
276
263
  )}
277
264
  <TypeWrapper>
@@ -288,18 +275,22 @@ const ResourceItem = ({
288
275
  <>
289
276
  {additional && (
290
277
  <Tooltip tooltip={contentTypeDescription}>
291
- <Additional
292
- className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons"
293
- aria-label={contentTypeDescription}
294
- />
278
+ <div>
279
+ <Additional
280
+ className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons"
281
+ aria-label={contentTypeDescription}
282
+ />
283
+ </div>
295
284
  </Tooltip>
296
285
  )}
297
286
  {!additional && (
298
287
  <Tooltip tooltip={contentTypeDescription}>
299
- <Core
300
- className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons"
301
- aria-label={contentTypeDescription}
302
- />
288
+ <div>
289
+ <Core
290
+ className="c-icon--20 u-margin-left-tiny c-topic-resource__list__additional-icons"
291
+ aria-label={contentTypeDescription}
292
+ />
293
+ </div>
303
294
  </Tooltip>
304
295
  )}
305
296
  </>