coyotte508 HF staff commited on
Commit
34660c6
β€’
1 Parent(s): 5e27702

πŸ’„ Better UI for e-shop

Browse files
src/lib/components/Picture.svelte CHANGED
@@ -17,3 +17,15 @@
17
  on:load
18
  />
19
  {/if}
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  on:load
18
  />
19
  {/if}
20
+
21
+ <style>
22
+ img.hover-zoom {
23
+ transition: 400ms;
24
+
25
+ transform: scale(1);
26
+ }
27
+
28
+ img:hover.hover-zoom {
29
+ transform: scale(1.2);
30
+ }
31
+ </style>
src/routes/tissus-et-finitions/+page.svelte ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import Container from '$lib/components/Container.svelte';
3
+ import Picture from '$lib/components/Picture.svelte';
4
+ import Masonry from '$lib/components/Masonry.svelte';
5
+ import type { PageData } from './$types';
6
+
7
+ export let data: PageData;
8
+
9
+ const pictures = data.pictures.map((p) => ({ ...p, loaded: false }));
10
+ </script>
11
+
12
+ <Container class="my-4">
13
+ <h1 class="text-4xl text-oxford mb-3">Tissus et finitions</h1>
14
+ <Masonry>
15
+ {#each pictures as picture}
16
+ <a
17
+ href="/photos/raw/{picture.storage[0]._id}"
18
+ class="relative picture-link"
19
+ data-title={picture.name}
20
+ >
21
+ <Picture
22
+ minStorage={1}
23
+ {picture}
24
+ class="max-w-full {picture.loaded ? 'loaded' : ''}"
25
+ loading="lazy"
26
+ />
27
+ </a>
28
+ {/each}
29
+ </Masonry>
30
+ </Container>
31
+
32
+ <style>
33
+ .picture-link {
34
+ overflow: hidden;
35
+ }
36
+
37
+ .picture-link::after {
38
+ position: absolute;
39
+ content: attr(data-title);
40
+ text-align: center;
41
+ left: 0;
42
+ right: 0;
43
+ bottom: 1rem;
44
+ color: white;
45
+ text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
46
+ font-size: 2rem;
47
+ opacity: 0.4;
48
+ transition-duration: 400ms;
49
+ }
50
+
51
+ :global(.picture-link img) {
52
+ transition-duration: 400ms;
53
+ transform: scale(0);
54
+ }
55
+
56
+ :global(.picture-link img.loaded) {
57
+ transform: scale(1);
58
+ }
59
+
60
+ :global(.picture-link:hover img.loaded) {
61
+ transform: scale(1.2);
62
+ }
63
+
64
+ .picture-link:hover::after {
65
+ opacity: 1;
66
+ }
67
+ </style>
src/routes/vente/+page.svelte CHANGED
@@ -34,9 +34,17 @@
34
  <Masonry>
35
  {#each published as product}
36
  <a href="/vente/{product._id}" class="product">
37
- <Picture picture={product.photos[0]} minStorage={1} class="picture mx-auto" />
38
- <span class="name">{product.name}</span>
39
- <span class="price text-right">{product.price} €</span>
 
 
 
 
 
 
 
 
40
  </a>
41
  {/each}
42
  <!-- In case there is only one product. We don't want a product to take full row in desktop mode -->
@@ -48,28 +56,18 @@
48
  .product {
49
  display: grid;
50
  gap: 0.5rem;
51
- grid-template-columns: 1fr auto;
52
  grid-template-rows: auto auto;
53
- grid-template-areas:
54
- 'picture picture'
55
- 'name price';
56
  }
57
 
58
- :global(.product > .picture) {
59
- grid-area: picture;
60
  max-height: 24rem;
61
- max-width: 100%;
 
62
  }
63
 
64
- .product > .name {
65
- grid-area: name;
66
-
67
  white-space: nowrap;
68
  text-overflow: ellipsis;
69
  overflow: hidden;
70
  }
71
-
72
- .product > .price {
73
- grid-area: price;
74
- }
75
  </style>
 
34
  <Masonry>
35
  {#each published as product}
36
  <a href="/vente/{product._id}" class="product">
37
+ <div class="overflow-hidden">
38
+ <Picture
39
+ picture={product.photos[0]}
40
+ minStorage={1}
41
+ class="picture mx-auto max-w-full hover-zoom"
42
+ />
43
+ </div>
44
+ <div class="flex">
45
+ <span class="name">{product.name}</span>
46
+ <span class="price ml-auto">{product.price} €</span>
47
+ </div>
48
  </a>
49
  {/each}
50
  <!-- In case there is only one product. We don't want a product to take full row in desktop mode -->
 
56
  .product {
57
  display: grid;
58
  gap: 0.5rem;
 
59
  grid-template-rows: auto auto;
 
 
 
60
  }
61
 
62
+ :global(.product .picture) {
 
63
  max-height: 24rem;
64
+ width: 100%;
65
+ object-fit: cover;
66
  }
67
 
68
+ .product .name {
 
 
69
  white-space: nowrap;
70
  text-overflow: ellipsis;
71
  overflow: hidden;
72
  }
 
 
 
 
73
  </style>