Skip to content

Commit 17f35cb

Browse files
Merge pull request danskernesdigitalebibliotek#207 from itk-dev/feature/5409-favorites-list-material-component
Feature/5409-favorites-list-material-component
2 parents ceaa97a + da5d8af commit 17f35cb

File tree

6 files changed

+240
-3
lines changed

6 files changed

+240
-3
lines changed

base.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
@import "./src/stories/Library/Lists/list-intermediates/list-intermediates";
9393
@import "./src/stories/Library/instant-loan/instant-loan";
9494
@import "./src/stories/Library/scroll-lock-background/scroll-lock-background";
95+
@import "./src/stories/Library/favorites-list-material-component/favorites-list-material-component";
9596

9697
// Blocks
9798
@import "./src/stories/Blocks/footer/footer";

src/stories/Library/cover/Cover.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ const Cover: FC<CoverProps> = ({
2828
// Images inside links must have an non-empty alt text to meet accessibility requirements.
2929
// Only render the cover as a link if we have both an url and a description.
3030
return (
31-
<a className={classes.wrapper} href={coverUrl}>
31+
<a
32+
className={classes.wrapper}
33+
href={coverUrl}
34+
aria-label="cover aria label"
35+
aria-labelledby="cover labelled by"
36+
title="cover title text"
37+
>
3238
<CoverImage
3339
setImageLoaded={() => setImageLoaded(true)}
3440
src={src}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.favorites-list-mc {
2+
background-color: $c-global-tertiary-2;
3+
color: $c-text-primary-white;
4+
border-color: $c-text-secondary-gray;
5+
6+
@include breakpoint-m {
7+
padding: $s-6xl;
8+
}
9+
10+
&--bright {
11+
background-color: $c-global-primary;
12+
color: $c-text-primary-black;
13+
border-color: $c-global-tertiary-1;
14+
15+
@include breakpoint-m {
16+
padding: $s-6xl;
17+
}
18+
}
19+
20+
&__title {
21+
text-align: center;
22+
padding: $s-lg;
23+
24+
&--left {
25+
text-align: left;
26+
}
27+
28+
@include breakpoint-m {
29+
padding-bottom: $s-6xl;
30+
}
31+
}
32+
33+
&__buttons {
34+
display: flex;
35+
justify-content: end;
36+
margin-bottom: $s-md;
37+
}
38+
39+
&__grid {
40+
display: grid;
41+
grid-template-columns: 50% 50%;
42+
grid-template-rows: 50% 50%;
43+
44+
@include breakpoint-m {
45+
grid-template-columns: 25% 25% 25% 25%;
46+
}
47+
}
48+
}
49+
50+
.favorites-list-mc-material {
51+
border: 1px solid $c-text-secondary-gray;
52+
padding: $s-xl;
53+
display: flex;
54+
width: 100%;
55+
position: relative;
56+
height: 350px;
57+
58+
&--bright {
59+
border: 1px solid $c-global-tertiary-1;
60+
}
61+
62+
&__favourite {
63+
position: absolute;
64+
top: $s-sm;
65+
right: $s-sm;
66+
}
67+
68+
&__cover-container {
69+
display: flex;
70+
justify-content: center;
71+
width: 100%;
72+
margin-top: $s-sm;
73+
}
74+
75+
&__meta {
76+
position: absolute;
77+
left: $s-sm;
78+
bottom: $s-sm;
79+
width: 100%;
80+
padding-right: $s-sm;
81+
}
82+
83+
&__title {
84+
@extend %text-body-medium-regular-placeholder;
85+
text-decoration: none;
86+
display: block;
87+
overflow: hidden;
88+
white-space: nowrap;
89+
text-overflow: ellipsis;
90+
color: inherit;
91+
92+
&:hover {
93+
text-decoration: underline;
94+
}
95+
}
96+
97+
&__author {
98+
@extend %text-body-medium-regular-placeholder;
99+
font-weight: 500;
100+
overflow: hidden;
101+
white-space: nowrap;
102+
text-overflow: ellipsis;
103+
color: inherit;
104+
}
105+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { ComponentMeta, ComponentStory } from "@storybook/react";
2+
import FavoritesListMaterialComponent from "./favorites-list-material-component";
3+
4+
export default {
5+
title: "Library / Favorites list material-component",
6+
component: FavoritesListMaterialComponent,
7+
argTypes: {
8+
title: {
9+
control: "text",
10+
defaultValue: "Din favoritliste",
11+
},
12+
bright: {
13+
control: { type: "boolean" },
14+
defaultValue: true,
15+
},
16+
recommenderData: {
17+
control: "object",
18+
defaultValue: [
19+
{
20+
title: "Ella Fitzgerald",
21+
authors: "Af Isabel Sánchez Vegara",
22+
filled: true,
23+
},
24+
{
25+
title: "Ella Fitzgerald",
26+
authors: "Af Isabel Sánchez Vegara",
27+
filled: true,
28+
},
29+
{
30+
title: "Ella Fitzgerald",
31+
authors: "Af Isabel Sánchez Vegara",
32+
filled: true,
33+
},
34+
{
35+
title: "Ella Fitzgerald",
36+
authors: "Af Isabel Sánchez Vegara",
37+
filled: true,
38+
},
39+
],
40+
},
41+
},
42+
} as ComponentMeta<typeof FavoritesListMaterialComponent>;
43+
44+
const Template: ComponentStory<typeof FavoritesListMaterialComponent> = (
45+
args
46+
) => <FavoritesListMaterialComponent {...args} />;
47+
48+
export const FavoritesList = Template.bind({});
49+
FavoritesList.args = {};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import Cover from "../cover/Cover";
2+
import { ReactComponent as SvgIcon } from "../Icons/icon-favourite/icon-favourite.svg";
3+
4+
export type RecommenderData = {
5+
title: string;
6+
authors: string;
7+
filled: boolean;
8+
};
9+
export type RecommenderProps = {
10+
recommenderData: RecommenderData[];
11+
title: string;
12+
bright: boolean;
13+
};
14+
15+
const FavoritesListMaterialComponent: React.FC<RecommenderProps> = ({
16+
recommenderData,
17+
title,
18+
bright,
19+
}) => {
20+
return (
21+
<div
22+
className={`favorites-list-mc ${
23+
bright ? "favorites-list-mc--bright" : ""
24+
}`}
25+
>
26+
<h3 className="text-header-h3 recommender__title--left">{title}</h3>
27+
<div className="favorites-list-mc__buttons">
28+
<button
29+
type="button"
30+
className={`button-link ${bright ? "button-link--bright" : ""}`}
31+
>
32+
Gå til dine favoritter
33+
</button>
34+
</div>
35+
<ul className="favorites-list-mc__grid">
36+
{recommenderData.map(({ title: recTitle, filled, authors }) => (
37+
<li
38+
className={`favorites-list-mc-material ${
39+
bright ? "`favorites-list-mc-material--bright" : ""
40+
}`}
41+
>
42+
<div className="favorites-list-mc-material__favourite">
43+
<div className="button-favourite button-favourite">
44+
<SvgIcon
45+
className={`icon-favourite icon-favourite${
46+
!bright ? "--bright" : ""
47+
} ${
48+
filled
49+
? `icon-favourite--${!bright ? "bright-" : ""}filled`
50+
: ""
51+
}`}
52+
/>
53+
</div>
54+
</div>
55+
<div className="favorites-list-mc-material__cover-container">
56+
<Cover
57+
src="images/book_cover_3.jpg"
58+
size="medium"
59+
animate={false}
60+
tint="120"
61+
/>
62+
</div>
63+
<div className="favorites-list-mc-material__meta">
64+
<a className="favorites-list-mc-material__title">{recTitle}</a>
65+
<div className="favorites-list-mc-material__author">
66+
{authors}
67+
</div>
68+
</div>
69+
</li>
70+
))}
71+
</ul>
72+
</div>
73+
);
74+
};
75+
76+
export default FavoritesListMaterialComponent;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.scroll-lock-background {
2-
overflow: "hidden";
3-
height: "100vh";
2+
overflow: hidden;
3+
height: 100vh;
44
}

0 commit comments

Comments
 (0)