File tree 3 files changed +53
-15
lines changed
ny-portal/src/app/(frontend)/komponenter
3 files changed +53
-15
lines changed Original file line number Diff line number Diff line change
1
+ import { client } from "@/sanity/client" ;
2
+ import { componentCardQuery } from "@/sanity/queries/component" ;
1
3
import imageUrlBuilder from "@sanity/image-url" ;
2
4
import NextLink from "next/link" ;
5
+ import { ComponentThumbnail } from "./ComponentThumbnail" ;
3
6
import styles from "./komponenter.module.scss" ;
4
- import { client } from "@/sanity/client" ;
5
- import { componentCardQuery } from "@/sanity/queries/component" ;
6
7
7
8
type Props = {
8
9
componentSlug : string ;
@@ -91,13 +92,12 @@ export const ComponentCard = async ({ componentSlug }: Props) => {
91
92
aria-label = { component . name || "Gå til komponent" }
92
93
aria-describedby = { `${ component . name } -description` }
93
94
>
94
- < picture className = { styles . image } >
95
- < source
96
- media = "(prefers-color-scheme: dark)"
97
- srcSet = { imageDarkUrl }
95
+ { imageDarkUrl && imageLightUrl ? (
96
+ < ComponentThumbnail
97
+ darkImage = { imageDarkUrl }
98
+ lightImage = { imageLightUrl }
98
99
/>
99
- < img className = { styles . image } src = { imageLightUrl } alt = "" />
100
- </ picture >
100
+ ) : null }
101
101
< p className = { styles . name } > { component . name } </ p >
102
102
< p
103
103
className = { styles . description }
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { Card , CardImage } from "@fremtind/jokul" ;
4
+ import styles from "./komponenter.module.scss" ;
5
+
6
+ type Props = {
7
+ lightImage : string ;
8
+ darkImage : string ;
9
+ } ;
10
+
11
+ export function ComponentThumbnail ( { darkImage, lightImage } : Props ) {
12
+ return (
13
+ < Card variant = "high" className = { styles . image } >
14
+ < picture >
15
+ < source
16
+ media = "(prefers-color-scheme: dark)"
17
+ srcSet = { darkImage }
18
+ />
19
+ < CardImage as = "img" placement = "top" src = { lightImage } alt = "" />
20
+ </ picture >
21
+ </ Card >
22
+ ) ;
23
+ }
Original file line number Diff line number Diff line change
1
+ /* stylelint-disable declaration-block-no-redundant-longhand-properties */
1
2
@use " @fremtind/jokul/styles/core/jkl" ;
2
3
3
4
.pageTitle {
25
26
margin : 0 ;
26
27
display : grid ;
27
28
grid-template-columns : repeat (auto-fit , minmax (250px , 1fr ));
28
- gap : jkl .$spacing-24 ;
29
+ column-gap : clamp (
30
+ var (--jkl-unit-10 ),
31
+ 0.4038rem + 0.3846vw ,
32
+ var (--jkl-unit-15 )
33
+ );
34
+
35
+ row-gap : clamp (
36
+ var (--jkl-unit-30 ),
37
+ 1.1154rem + 1.5385vw ,
38
+ var (--jkl-unit-50 )
39
+ );
29
40
container-type : inline-size ;
30
41
31
42
& .listView {
40
51
}
41
52
42
53
.componentCard {
54
+ --aspect-ratio : 1.5 ;
55
+
43
56
display : grid ;
44
57
grid-template-columns : 1fr ;
45
- gap : var (--jkl-unit-30 );
58
+ gap : clamp (var (--jkl-unit-10 ), 0.3077rem + 0.7692vw , var (--jkl-unit-20 ));
59
+ box-sizing : border-box ;
46
60
width : 100% ;
47
61
text-decoration : none ;
48
62
color : var (--color-text );
120
134
}
121
135
122
136
.image {
123
- width : 100% ;
124
- height : auto ;
125
- object-fit : cover ;
126
- border-radius : var (--jkl-spacing-16 );
127
- aspect-ratio : 1.6 ;
137
+ aspect-ratio : var (--aspect-ratio );
138
+
139
+ img {
140
+ object-fit : cover ;
141
+ aspect-ratio : var (--aspect-ratio );
142
+ }
128
143
}
129
144
}
You can’t perform that action at this time.
0 commit comments