Skip to content

Commit

Permalink
feat: choose the images that will stay
Browse files Browse the repository at this point in the history
  • Loading branch information
viktomas committed Aug 15, 2023
1 parent e3c6f70 commit 17a3bdc
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 43 deletions.
59 changes: 59 additions & 0 deletions assets/compare-similar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}

h1 {
text-align: center;
margin: 20px;
}

ul {
padding: 0;
display: flex;
flex-wrap: wrap;
}

li {
padding: 0;
list-style-type: none;
max-height: 33vh;
max-width: 33vw;
}

.pic-num-2 li{
max-height: 100vh;
max-width: 50vw;
}
.pic-num-4 li {
max-height: 50vh;
max-width: 50vw;
}

label, .container, .li {
box-sizing: border-box;
display: block;
width: 100%;
height: 100%;
}

img {
width: 100%;
height: 100%;
object-fit: contain;
}


input[type="checkbox"] {
display:none;
}

input[type="checkbox"] + label{
padding: 0.5rem;
}

input[type="checkbox"]:checked + label{
background-color: green;
}
40 changes: 0 additions & 40 deletions assets/compoare-similar.css

This file was deleted.

11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ func main() {
imageFiles = append(imageFiles, k)
}
sort.Strings(imageFiles)
err := tmpl.Execute(w, imageFiles)
grid := 9
if len(imageFiles) <= 2 {
grid = 2
} else if len(imageFiles) <= 4 {
grid = 4
}
err := tmpl.Execute(w, map[string]any{
"grid": grid,
"pictures": imageFiles,
})
if err != nil {
http.Error(w, err.Error(), 500)
}
Expand Down
4 changes: 2 additions & 2 deletions templates/compare-similar.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ <h1>Decide which one will stay</h1>
<div class="control-bar">
<input type="submit" value="Delete pictures that are not selected"/>
</div>
<ul class="image-wrapper">
{{range .}}
<ul class="image-wrapper pic-num-{{ .grid }}">
{{ range .pictures }}
<li>
<div class="container">
<input type="checkbox" value="true" name="{{ . }}" id="{{ . }}" />
Expand Down

0 comments on commit 17a3bdc

Please sign in to comment.