@ndla/ui 34.2.0 → 34.3.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.
@@ -27,6 +27,7 @@ import { contentTypeMapping } from '../model/ContentType';
27
27
 
28
28
  const BlockElementWrapper = styled.div`
29
29
  display: flex;
30
+ position: relative;
30
31
  text-decoration: none;
31
32
  box-shadow: none;
32
33
  flex-direction: column;
@@ -67,6 +68,7 @@ const BlockDescription = styled.p`
67
68
  `;
68
69
 
69
70
  const RightRow = styled(Row)`
71
+ z-index: 1;
70
72
  justify-content: flex-end;
71
73
  margin: 0 -${spacing.small} -${spacing.small} 0;
72
74
  `;
@@ -162,18 +164,11 @@ const BlockResource = ({
162
164
  targetBlank,
163
165
  resourceTypes,
164
166
  }: Props) => {
165
- const linkRef = useRef<HTMLAnchorElement>(null);
166
167
  const firstResourceType = resourceTypes?.[0]?.id ?? '';
167
168
  const Title = ResourceTitle.withComponent(headingLevel);
168
169
 
169
- const handleClick = () => {
170
- if (linkRef.current) {
171
- linkRef.current.click();
172
- }
173
- };
174
-
175
170
  return (
176
- <BlockElementWrapper onClick={handleClick} id={id}>
171
+ <BlockElementWrapper id={id}>
177
172
  <ImageWrapper>
178
173
  <BlockImage
179
174
  image={resourceImage}
@@ -184,7 +179,7 @@ const BlockResource = ({
184
179
  <BlockInfoWrapper>
185
180
  <ContentWrapper>
186
181
  <ResourceTypeAndTitleLoader loading={isLoading}>
187
- <ResourceTitleLink title={title} target={targetBlank ? '_blank' : undefined} to={link} ref={linkRef}>
182
+ <ResourceTitleLink title={title} target={targetBlank ? '_blank' : undefined} to={link}>
188
183
  <Title>{title}</Title>
189
184
  </ResourceTitleLink>
190
185
  </ResourceTypeAndTitleLoader>
@@ -27,6 +27,7 @@ import { contentTypeMapping } from '../model/ContentType';
27
27
  const ListResourceWrapper = styled.div`
28
28
  flex: 1;
29
29
  display: grid;
30
+ position: relative;
30
31
  grid-template-columns: auto minmax(50px, 1fr) auto;
31
32
  grid-template-areas:
32
33
  'image topicAndTitle tags'
@@ -101,6 +102,7 @@ interface TagsAndActionProps {
101
102
 
102
103
  const TagsandActionMenu = styled.div<TagsAndActionProps>`
103
104
  grid-area: tags;
105
+ z-index: 1;
104
106
  box-sizing: content-box;
105
107
  display: grid;
106
108
  grid-template-columns: 1fr auto auto;
@@ -217,17 +219,11 @@ const ListResource = ({
217
219
  }: ListResourceProps) => {
218
220
  const showDescription = description !== undefined;
219
221
  const imageType = showDescription ? 'normal' : 'compact';
220
- const linkRef = useRef<HTMLAnchorElement>(null);
221
222
  const firstContentType = resourceTypes?.[0]?.id ?? '';
222
223
  const Title = ResourceTitle.withComponent(headingLevel);
223
- const handleClick = () => {
224
- if (linkRef.current) {
225
- linkRef.current.click();
226
- }
227
- };
228
224
 
229
225
  return (
230
- <ListResourceWrapper onClick={handleClick} id={id}>
226
+ <ListResourceWrapper id={id}>
231
227
  <ImageWrapper imageSize={imageType}>
232
228
  <ListResourceImage
233
229
  resourceImage={resourceImage}
@@ -238,7 +234,7 @@ const ListResource = ({
238
234
  </ImageWrapper>
239
235
  <TopicAndTitleWrapper>
240
236
  <TypeAndTitleLoader loading={isLoading}>
241
- <StyledLink to={link} target={targetBlank ? '_blank' : undefined} ref={linkRef}>
237
+ <StyledLink to={link} target={targetBlank ? '_blank' : undefined}>
242
238
  <Title title={title}>{title}</Title>
243
239
  </StyledLink>
244
240
  <ResourceTypeList resourceTypes={resourceTypes} />
@@ -23,6 +23,16 @@ export interface ResourceImageProps {
23
23
  export const ResourceTitleLink = styled(SafeLink)`
24
24
  box-shadow: none;
25
25
  color: ${colors.brand.primary};
26
+ flex: 1;
27
+ :after {
28
+ content: '';
29
+ position: absolute;
30
+ z-index: 1;
31
+ top: 0;
32
+ right: 0;
33
+ bottom: 0;
34
+ left: 0;
35
+ }
26
36
  `;
27
37
 
28
38
  export const ResourceTitle = styled.h2`
@@ -131,9 +141,7 @@ export const TagList = ({ tags, tagLinkPrefix }: TagListProps) => {
131
141
  <StyledTagList aria-label={t('myNdla.tagList')}>
132
142
  {tags.map((tag, i) => (
133
143
  <StyledTagListElement key={`tag-${i}`}>
134
- <StyledSafeLink
135
- onClick={(e: MouseEvent<HTMLAnchorElement | HTMLElement>) => e.stopPropagation()}
136
- to={`${tagLinkPrefix ? tagLinkPrefix : ''}/${encodeURIComponent(tag)}`}>
144
+ <StyledSafeLink to={`${tagLinkPrefix ? tagLinkPrefix : ''}/${encodeURIComponent(tag)}`}>
137
145
  <HashTag />
138
146
  {tag}
139
147
  </StyledSafeLink>