lens @ 99a7e9ab02ae1980874be35f6a2651ca4bfdb951

feat: Simplify mosaic

The old implementation was not good and would render the list on mobile
in the wrong order
diff --git a/pkg/list/list.go b/pkg/list/list.go
index 482e5bfeb2622dd890a125085cf3ad7e0e676b44..8f3d875fb4b6fc17202dabaab72642ea5f0b41f2 100644
--- a/pkg/list/list.go
+++ b/pkg/list/list.go
@@ -31,6 +31,24 @@
 	return chuncks
 }
 
+func Chunck[T any](slice []T, size int) [][]T {
+	var divided [][]T
+
+	chunkSize := (len(slice) + size - 1) / size
+
+	for i := 0; i < len(slice); i += chunkSize {
+		end := i + chunkSize
+
+		if end > len(slice) {
+			end = len(slice)
+		}
+
+		divided = append(divided, slice[i:end])
+	}
+
+	return divided
+}
+
 func Zip[T, U any](left []T, right []U) []Pair[T, U] {
 	// pick the array with the smaller length
 	l := len(left)
diff --git a/scss/main.scss b/scss/main.scss
index 532a38a801bf6cc40f6e57780c6fc35505883439..95db99f8c9b0a4205248ba19e48654860ad7cbbb 100644
--- a/scss/main.scss
+++ b/scss/main.scss
@@ -15,6 +15,8 @@
 $table-cell-padding: 0.5em;
 $table-cell-border-width: 0;
 
+$section-padding: 0 1.5rem;
+
 $tag-delete-margin: 15px;
 
 $title-weight: normal;
@@ -57,19 +59,6 @@ .container {
     margin-top: 30px;
 }
 
-.card-image {
-    padding: 5px;
-}
-
-.image.is-fit {
-  height: auto;
-  width: 100%;
-}
-
-.column {
-    padding: 0;
-}
-
 th {
     font-weight: normal;
 }
@@ -79,10 +68,6 @@     padding-left: 15px;
     padding-right: 15px;
 }
 
-.img {
-    object-fit: cover;
-}
-
 .text-size-1{
     @extend .is-size-4 !optional;
 }
@@ -90,3 +75,34 @@
 .text-size-2{
     @extend .is-size-5 !optional;
 }
+
+.gallary_container{
+  display: grid;
+  gap: 1rem;
+  grid-template-columns: repeat(auto-fit, minmax(15em, 1fr));
+  grid-auto-rows: 15.5em;  
+  padding: 10px;
+}
+
+.image_container img{
+  width: 100%;
+  height: 100%; 
+    box-shadow: rgba(3, 8, 20, 0.1) 0px 0.15rem 0.5rem, rgba(2, 8, 20, 0.1) 0px 0.075rem 0.175rem;
+  object-fit: cover;
+}
+
+@media screen and (min-width: $breakpoint) {
+  .image-tall {
+    grid-row: span 2 / auto;
+  }
+
+  .image-wide {
+    grid-column: span 2 / auto;
+  }
+}
+
+// Fix horizontal scroll on iOS
+.scrolling-element {
+    overflow-x: scroll; /* Must be 'scroll' not 'auto' */
+    -webkit-overflow-scrolling: touch;
+}
diff --git a/templates/album.qtpl b/templates/album.qtpl
index 58fc499ccceb04cbb33f4c8f9ec495293b043020..246c77c1d193cf0d767a9c55f520bf9e6f9d3e90 100644
--- a/templates/album.qtpl
+++ b/templates/album.qtpl
@@ -20,15 +20,15 @@
 {% func (p *AlbumPage) Title() %}Media{% endfunc %}
 
 {% func (p *AlbumPage) Content() %}
-<h1 class="title text-size-1">{%s p.Name %}</h1>
-<div class="tags are-large">
-{% for _, a := range p.Albums %}
-  <a href="/album?albumId={%s FromUInttoString(&a.ID) %}" class="tag text-size-2">{%s a.Name %}</a>
-{% endfor %}
-</div>
-<div class="columns">
+<section class="section">
+    <h1 class="title text-size-1">{%s p.Name %}</h1>
+    <div class="tags are-large">
+    {% for _, a := range p.Albums %}
+      <a href="/album?albumId={%s FromUInttoString(&a.ID) %}" class="tag text-size-2">{%s a.Name %}</a>
+    {% endfor %}
+    </div>
+</section>
 {%= Mosaic(p.Medias, p.PreloadAttr()) %}
-</div>
 <div>
     <a href="/album?albumId={%s FromUInttoString(p.Next.AlbumID) %}&page={%d p.Next.Page %}" class="button is-pulled-right">next</a>
 </div>
diff --git a/templates/media.qtpl b/templates/media.qtpl
index 737d03d63a2ae301fc37dd3a9926e216a6fe325a..6a1382716a967cb94aef46cf9edd29fdaec4cefe 100644
--- a/templates/media.qtpl
+++ b/templates/media.qtpl
@@ -18,9 +18,7 @@
 {% func (p *MediaPage) Title() %}Media{% endfunc %}
 
 {% func (p *MediaPage) Content() %}
-<div class="columns">
 {%= Mosaic(p.Medias, p.PreloadAttr()) %}
-</div>
 <div>
     <a href="/media?page={%d p.Next.Page %}" class="button is-pulled-right">next</a>
 </div>
diff --git a/templates/mosaic.qtpl b/templates/mosaic.qtpl
index 21a8bae9560e8e3c9b07bfd4aa75a66ec2465360..9e941b68fd2b003208c7e83b52e002bc411bcd8f 100644
--- a/templates/mosaic.qtpl
+++ b/templates/mosaic.qtpl
@@ -1,26 +1,13 @@
 {% import "git.sr.ht/~gabrielgio/img/pkg/database/repository" %}
-{% import "git.sr.ht/~gabrielgio/img/pkg/list" %}
 
 {% func Mosaic(medias []*repository.Media, preloadAttr string) %}
-<div class="columns">
-{% for _, c := range list.Distribuite(medias, 6) %}
-    <div class="column is-2">
-    {% for _, media := range c %}
-    <div class="card-image">
-       <a href="/detail?path_hash={%s media.PathHash %}">
-       {% if media.IsVideo() %}
-       <video class="image is-fit" controls muted="true" poster="/media/thumbnail?path_hash={%s media.PathHash %}" preload="{%s preloadAttr %}">
-           <source src="/media/image?path_hash={%s media.PathHash %}" type="{%s media.MIMEType %}">
-       </video>
-       {% else %}
-       <figure class="image is-fit">
-           <img src="/media/thumbnail?path_hash={%s media.PathHash %}">
-       </figure>
-       </a>
-        {% endif %}
-    </div>
-    {% endfor %}
-    </div>
+<div class="gallary_container">
+{% for _, media := range medias %}
+    <a href="/detail?path_hash={%s media.PathHash %}">
+        <figure class="image_container">
+            <img src="/media/thumbnail?path_hash={%s media.PathHash %}" >
+        </figure>
+    </a>
 {% endfor %}
 </div>
 {% endfunc %}