@ndla/ui 44.0.9 → 44.0.11

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.
@@ -29,13 +29,12 @@ const classes = new BEMHelper({
29
29
  });
30
30
 
31
31
  type ArticleWrapperProps = {
32
- id: string;
33
32
  modifier?: string;
34
33
  children: ReactNode;
35
34
  };
36
35
 
37
- export const ArticleWrapper = forwardRef<HTMLElement, ArticleWrapperProps>(({ children, modifier, id }, ref) => (
38
- <article id={id} {...classes(undefined, modifier)} ref={ref}>
36
+ export const ArticleWrapper = forwardRef<HTMLElement, ArticleWrapperProps>(({ children, modifier }, ref) => (
37
+ <article {...classes(undefined, modifier)} ref={ref}>
39
38
  {children}
40
39
  </article>
41
40
  ));
@@ -44,9 +43,10 @@ type ArticleTitleProps = {
44
43
  icon?: ReactNode;
45
44
  label?: string;
46
45
  children: ReactNode;
46
+ id: string;
47
47
  };
48
48
 
49
- export const ArticleTitle = ({ children, icon, label }: ArticleTitleProps) => {
49
+ export const ArticleTitle = ({ children, icon, label, id }: ArticleTitleProps) => {
50
50
  const modifiers = [];
51
51
  if (icon) {
52
52
  modifiers.push('icon');
@@ -62,7 +62,7 @@ export const ArticleTitle = ({ children, icon, label }: ArticleTitleProps) => {
62
62
  <div {...classes('title', modifiers)}>
63
63
  {icon}
64
64
  {labelView}
65
- <Heading element="h1" headingStyle="h1" tabIndex={-1}>
65
+ <Heading element="h1" headingStyle="h1" id={id} tabIndex={-1}>
66
66
  {children}
67
67
  </Heading>
68
68
  </div>
@@ -184,20 +184,14 @@ export const Article = ({
184
184
  }
185
185
  }, [wrapperRef]);
186
186
 
187
- const {
188
- title,
189
- introduction,
190
- published,
191
- content,
192
- footNotes,
193
- copyright: { license: licenseObj, creators, rightsholders, processors },
194
- } = article;
187
+ const { title, introduction, published, content, footNotes, copyright } = article;
195
188
 
196
- const authors = creators.length || rightsholders.length ? creators : processors;
189
+ const authors =
190
+ copyright?.creators.length || copyright?.rightsholders.length ? copyright.creators : copyright?.processors;
197
191
 
198
192
  return (
199
193
  <div ref={wrapperRef}>
200
- <ArticleWrapper modifier={modifier} id={id} ref={articleRef}>
194
+ <ArticleWrapper modifier={modifier} ref={articleRef}>
201
195
  <LayoutItem layout="center">
202
196
  {accessMessage && <ArticleAccessMessage message={accessMessage} />}
203
197
 
@@ -209,7 +203,7 @@ export const Article = ({
209
203
  <ArticleHeaderWrapper competenceGoals={competenceGoals}>
210
204
  {heartButton ? <ArticleFavoritesButtonWrapper>{heartButton}</ArticleFavoritesButtonWrapper> : null}
211
205
 
212
- <ArticleTitle icon={icon} label={messages.label}>
206
+ <ArticleTitle id={id} icon={icon} label={messages.label}>
213
207
  {title}
214
208
  </ArticleTitle>
215
209
  <ArticleIntroduction renderMarkdown={renderMarkdown}>{introduction}</ArticleIntroduction>
@@ -226,9 +220,9 @@ export const Article = ({
226
220
  <ArticleByline
227
221
  footnotes={footNotes}
228
222
  authors={authors}
229
- suppliers={rightsholders}
223
+ suppliers={copyright?.rightsholders}
230
224
  published={published}
231
- license={licenseObj?.license ?? ''}
225
+ license={copyright?.license?.license ?? ''}
232
226
  licenseBox={licenseBox}
233
227
  />
234
228
  </LayoutItem>
@@ -95,7 +95,7 @@ const CampaignBlock = ({
95
95
  }: Props) => {
96
96
  return (
97
97
  <Container className={className} data-type="campaign-block">
98
- {imageBefore && <StyledImg src={imageBefore.src} />}
98
+ {imageBefore && <StyledImg src={imageBefore.src} alt="" />}
99
99
  <TextWrapper>
100
100
  <Heading css={headingStyle}>{title.title}</Heading>
101
101
  <StyledDescription>{description.text}</StyledDescription>
@@ -104,7 +104,7 @@ const CampaignBlock = ({
104
104
  <Forward />
105
105
  </StyledLink>
106
106
  </TextWrapper>
107
- {imageAfter && <StyledImg src={imageAfter.src} />}
107
+ {imageAfter && <StyledImg src={imageAfter.src} alt="" />}
108
108
  </Container>
109
109
  );
110
110
  };
@@ -78,9 +78,9 @@ export const FrontpageArticle = ({ article, id, isWide, licenseBox }: Props) =>
78
78
  }
79
79
 
80
80
  const authors =
81
- article.copyright.creators.length || article.copyright.rightsholders.length
81
+ article.copyright?.creators.length || article.copyright?.rightsholders.length
82
82
  ? article.copyright.creators
83
- : article.copyright.processors;
83
+ : article.copyright?.processors;
84
84
  return (
85
85
  <StyledArticle style={cssVars}>
86
86
  <LayoutItem>
@@ -92,8 +92,8 @@ export const FrontpageArticle = ({ article, id, isWide, licenseBox }: Props) =>
92
92
  <LayoutItem>{content}</LayoutItem>
93
93
  <ArticleByline
94
94
  authors={authors}
95
- suppliers={article.copyright.rightsholders}
96
- license={article.copyright.license?.license!}
95
+ suppliers={article.copyright?.rightsholders}
96
+ license={article.copyright?.license?.license!}
97
97
  published={article.published}
98
98
  accordionHeaderVariant={'white'}
99
99
  licenseBox={licenseBox}
@@ -39,6 +39,8 @@ const StyledCardContainer = styled(SafeLink)`
39
39
  }
40
40
 
41
41
  ${mq.range({ from: breakpoints.tablet })} {
42
+ min-height: 350px;
43
+ min-width: 250px;
42
44
  max-height: 350px;
43
45
  width: 250px;
44
46
  }
@@ -46,6 +48,7 @@ const StyledCardContainer = styled(SafeLink)`
46
48
 
47
49
  const StyledImg = styled.img`
48
50
  display: none;
51
+ flex: 1;
49
52
  border-radius: ${misc.borderRadius} ${misc.borderRadius} 0 0;
50
53
  width: 100%;
51
54
 
@@ -66,6 +69,7 @@ const StyledTitle = styled.span`
66
69
  min-height: 70px;
67
70
  align-items: center;
68
71
  padding-left: ${spacing.nsmall};
72
+ margin-top: auto;
69
73
 
70
74
  border: 1px solid ${colors.brand.lighter};
71
75
  border-radius: 0 0 ${misc.borderRadius} ${misc.borderRadius};
@@ -82,8 +86,8 @@ const StyledTitle = styled.span`
82
86
  const ProgrammeCard = ({ title, narrowImage, wideImage, url }: Programme) => {
83
87
  return (
84
88
  <StyledCardContainer to={url}>
85
- {narrowImage && <StyledImg data-is-mobile="false" src={narrowImage.src} alt={narrowImage.alt} />}
86
- {wideImage && <StyledImg data-is-mobile="true" src={wideImage.src} alt={wideImage.alt} />}
89
+ {narrowImage && <StyledImg data-is-mobile="false" src={narrowImage.src} loading="lazy" alt={narrowImage.alt} />}
90
+ {wideImage && <StyledImg data-is-mobile="true" src={wideImage.src} loading="lazy" alt={wideImage.alt} />}
87
91
  <StyledTitle>{title.title}</StyledTitle>
88
92
  </StyledCardContainer>
89
93
  );
package/src/types.ts CHANGED
@@ -70,7 +70,7 @@ export interface Article {
70
70
  introduction: string;
71
71
  content: ReactNode;
72
72
  footNotes: Array<FootNote>;
73
- copyright: Copyright;
73
+ copyright?: Copyright;
74
74
  published: string;
75
75
  }
76
76