File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 21
21
:key =" entry.id"
22
22
class =" flex border-bottom-bg p-medium" >
23
23
<div class =" col-sm-3 pr-xsmall" >
24
- <img v-if =" entry.image" :src =" `${entry.image.file.url}${imgUrlParams}`" class =" main block" />
24
+ <picture v-if =" entry.image?.file?.url" class =" main block" >
25
+ <source :srcset =" `${entry.image?.file?.url}${imgUrlParams}`" media =" (prefers-color-scheme: light)" />
26
+ <source v-if =" entry.imageDark" :srcset =" `${entry.imageDark.file?.url}${imgUrlParams}`" media =" (prefers-color-scheme: dark)" />
27
+ <!-- fallback -->
28
+ <img :src =" `${entry.image?.file?.url}${imgUrlParams}`" />
29
+ </picture >
30
+ <robot-icon v-else size =" 1.75rem" style =" float : right " />
25
31
</div >
26
32
<div class =" col-sm-9 pl-xsmall" >
27
33
<a v-if =" entry.link" :href =" entry.link" target =" blank" class =" mb-none line-height-1" >
42
48
<script >
43
49
import { getNews } from ' ../js/contentfulClient'
44
50
import { documentToHtmlString } from ' @contentful/rich-text-html-renderer'
51
+ import { RobotIcon } from ' ./icons'
45
52
export default {
53
+ components: {
54
+ RobotIcon
55
+ },
46
56
data : () => ({
47
57
expanded: false ,
48
58
news: [],
@@ -103,10 +113,10 @@ export default {
103
113
}
104
114
@media (prefers - color - scheme : dark ) {
105
115
.inner - news- container: not (.expanded ):: after {
106
- background: linear- gradient (transparent 80 % , #1a1a1a 100 % );
116
+ background: linear- gradient (transparent 80 % , #1a1a1a 100 % );
107
117
}
108
118
}
109
- img .main {
119
+ picture .main , picture img {
110
120
width: 100 % ;
111
121
border- radius: 0 .25rem ;
112
122
}
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ export const getNews = async() => {
27
27
} )
28
28
. then ( ( { items } ) => items . map ( ( { fields } ) => ( {
29
29
...fields ,
30
- image : fields . image ?. fields
30
+ image : fields . image ?. fields ,
31
+ imageDark : fields . imageDark ?. fields // optional, for darkmode, eg white text variant
31
32
} ) ) )
32
33
return items
33
34
}
You can’t perform that action at this time.
0 commit comments