moodtracker/views/index.erb

133 lines
2.5 KiB
Text
Raw Normal View History

2024-10-12 19:00:33 +02:00
<head>
<meta charset="utf-8">
<script type="module">
import { Application, Controller } from "https://unpkg.com/@hotwired/stimulus/dist/stimulus.js"
window.Stimulus = Application.start()
Stimulus.register("mood", class extends Controller {
static targets = [ "image" ]
showMode(event) {
const image = this.imageTarget
image.src = event.target.dataset.mode + ".png"
}
showCurrent() {
const image = this.imageTarget
image.src = "<%= @last_mood.mode %>.png"
}
})
</script>
2024-02-11 22:19:19 +01:00
<style>
2024-09-22 20:50:55 +02:00
body {
margin: 0px;
font: 1.8rem "Fira Sans", sans-serif;
}
2024-06-02 20:19:02 +02:00
main {
display: flex;
align-items: center;
justify-content: center;
2024-09-22 20:50:55 +02:00
flex-wrap: wrap;
2024-06-02 20:19:02 +02:00
}
2024-09-22 20:50:55 +02:00
2024-02-11 22:19:19 +01:00
.mode {
2024-06-02 20:19:02 +02:00
height: 100vh;
2024-09-22 20:50:55 +02:00
flex: 1 527px;
2024-02-11 22:19:19 +01:00
}
img {
height: 100%;
2024-09-22 20:50:55 +02:00
width:100%;
// min-width: 527px;
object-fit: contain;
2024-02-11 22:19:19 +01:00
}
2024-06-02 20:19:02 +02:00
table {
empty-cells: hide;
border-collapse: collapse;
}
tbody tr td {
border: 1px solid black;
border-spacing: 3px;
min-width: 20px;
min-height: 20px;
border-radius: 50%;
margin: 5px;
}
2024-09-22 20:50:55 +02:00
.tracker {
display: flex;
flex: 1 527px;
flex-direction: column;
flex-wrap: wrap;
align-items: center;
justify-content: center;
background-color: lightgoldenrodyellow;
height: 100vh;
width: 100%;
}
.info h1 {
margin-bottom: 40px;
font-weight: 350;
}
.tracks {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: flex-start;
margin: 30px;
}
2024-06-02 20:19:02 +02:00
.week {
display: flex;
2024-09-22 20:50:55 +02:00
flex-direction: column;
justify-items: start;
flex-wrap: wrap;
margin-bottom: 20px;
2024-06-02 20:19:02 +02:00
}
.day {
border: 1px;
2024-09-22 20:50:55 +02:00
margin: 4px;
min-width: 20px;
min-height: 20px;
2024-06-02 20:19:02 +02:00
}
.creatif {
2024-09-22 20:50:55 +02:00
background-color: red;
2024-06-02 20:19:02 +02:00
}
.en-charge {
background-color: orange;
}
.frigo-vide {
2024-09-22 20:50:55 +02:00
background-color: grey;
2024-06-02 20:19:02 +02:00
}
.croisiere {
background-color: green;
}
2024-02-11 22:19:19 +01:00
</style>
2024-10-12 19:00:33 +02:00
</head>
<main data-controller="mood">
2024-06-02 20:19:02 +02:00
<div class="mode">
2024-10-12 19:00:33 +02:00
<img data-mood-target="image" src="<%= @last_mood.mode %>.png">
2024-06-02 20:19:02 +02:00
</div>
2024-09-22 20:50:55 +02:00
<div class="tracker">
<div class="info">
<h1>Humeurs 2024</h1>
</div>
<div class="tracks">
2024-06-02 20:19:02 +02:00
2024-09-22 20:50:55 +02:00
<% @mood_log.each do |week| %>
<div class="week">
<% week.each do |d| %>
<% if d[1] %>
2024-10-12 19:00:33 +02:00
<div data-mode="<%= d[1] %>" data-action="mouseover->mood#showMode mouseleave->mood#showCurrent" title="<%= d[0] %> : <%= d[1] %>" class="day <%= d[1] %>"></div>
2024-09-22 20:50:55 +02:00
<% else %>
<div class="day"></div>
<% end %>
2024-06-02 20:19:02 +02:00
<% end %>
2024-09-22 20:50:55 +02:00
</div>
<% end %>
</div>
2024-06-02 20:19:02 +02:00
</div>
</main>