File tree Expand file tree Collapse file tree 4 files changed +110
-4
lines changed Expand file tree Collapse file tree 4 files changed +110
-4
lines changed Original file line number Diff line number Diff line change 14
14
"preview" : " vite preview"
15
15
},
16
16
"dependencies" : {
17
+ "@egjs/svelte-grid" : " 1.16.0" ,
17
18
"@floating-ui/dom" : " 1.5.3" ,
18
19
"@sanity/client" : " 6.10.0" ,
19
20
"@sanity/image-url" : " 1.0.2" ,
Original file line number Diff line number Diff line change 1
1
<script >
2
+ import { MasonryGrid } from ' @egjs/svelte-grid'
3
+
2
4
import GalleryCarousel from ' $lib/components/gallery-carousel.svelte'
3
5
import GalleryThumbnail from ' $lib/components/gallery-thumbnail.svelte'
4
6
import FadeUp from ' $lib/components/helpers/fade-up.svelte'
5
- import MasonryGrid from ' $lib/components/masonry-grid.svelte'
6
7
import PageIntro from ' $lib/components/page-intro.svelte'
7
8
import PageSection from ' $lib/components/page-section.svelte'
8
9
import PortableText from ' $lib/components/portable-text.svelte'
9
10
import TextLede from ' $lib/components/text-lede.svelte'
10
11
12
+ import { media } from ' ../../stores/media-queries.js'
13
+
11
14
/** @type {'screen-shots' | undefined} */
12
15
export let collection = undefined
13
16
@@ -47,6 +50,14 @@ function handleCloseCarousel() {
47
50
isCarouselOpen = false
48
51
initialIndex = 0
49
52
}
53
+
54
+ let gridGap = 16
55
+
56
+ $: if ($media .xl ) {
57
+ gridGap = 64
58
+ } else if ($media .md ) {
59
+ gridGap = 32
60
+ }
50
61
</script >
51
62
52
63
<svelte:head >
@@ -111,7 +122,7 @@ function handleCloseCarousel() {
111
122
</PageIntro >
112
123
<PageSection >
113
124
<div class =" grid gap-[9vh] md:gap-[11vh]" >
114
- <MasonryGrid items ={ images } gapClass = " gap-4 md:gap-8 xl:gap-16 " >
125
+ <MasonryGrid align = "stretch" column ={ 2 } gap ={ gridGap } >
115
126
{#each images as image , index }
116
127
<GalleryThumbnail
117
128
{image }
Original file line number Diff line number Diff line change
1
+ import { writable } from 'svelte/store'
2
+
3
+ /**
4
+ * @param {Record<string, MediaQueryList> } mqls
5
+ */
6
+ function calculateMedia ( mqls ) {
7
+ let media = { classNames : '' }
8
+ let mediaClasses = [ ]
9
+
10
+ for ( let name of Object . keys ( mqls ) ) {
11
+ media [ name ] = mqls [ name ] . matches
12
+ if ( media [ name ] ) {
13
+ mediaClasses . push ( `media-${ name } ` )
14
+ }
15
+ }
16
+
17
+ media . classNames = mediaClasses . join ( ' ' )
18
+
19
+ return media
20
+ }
21
+
22
+ function watchMedia ( mediaqueries ) {
23
+ return writable ( { classNames : '' } , ( set ) => {
24
+ if ( typeof window === 'undefined' ) return
25
+
26
+ let mqls = { }
27
+ let updateMedia = ( ) => set ( calculateMedia ( mqls ) )
28
+
29
+ for ( let key of Object . keys ( mediaqueries ) ) {
30
+ let foo = window . matchMedia ( mediaqueries [ key ] )
31
+ mqls [ key ] = foo
32
+ mqls [ key ] . addListener ( updateMedia )
33
+ }
34
+
35
+ updateMedia ( )
36
+
37
+ return ( ) => {
38
+ for ( let key of Object . keys ( mqls ) ) {
39
+ mqls [ key ] . removeListener ( updateMedia )
40
+ }
41
+ }
42
+ } )
43
+ }
44
+
45
+ export const media = watchMedia ( {
46
+ sm : '(max-width: 767px)' ,
47
+ md : '(min-width: 768px)' ,
48
+ lg : '(min-width: 1024px)' ,
49
+ xl : '(min-width: 1280px)' ,
50
+ } )
You can’t perform that action at this time.
0 commit comments