diff --git a/mixins/Input.pixy b/mixins/Input.pixy index b5aa3884..352bd112 100644 --- a/mixins/Input.pixy +++ b/mixins/Input.pixy @@ -8,10 +8,10 @@ component InputTextArea(id string, value string, label string, placeholder strin label(for=id)= label + ":" textarea.widget-element.action(id=id, placeholder=placeholder, title=placeholder, data-action="save", data-trigger="change")= value -component InputNumber(id string, value int, label string, placeholder string, min string, max string) +component InputNumber(id string, value float64, label string, placeholder string, min string, max string, step string) .widget-input label(for=id)= label + ":" - input.widget-element.action(id=id, type="number", value=value, min=min, max=max, placeholder=placeholder, title=placeholder, data-action="save", data-trigger="change") + input.widget-element.action(id=id, type="number", value=value, min=min, max=max, step=step, placeholder=placeholder, title=placeholder, data-action="save", data-trigger="change") component InputSelection(id string, value string, label string, placeholder string) .widget-input diff --git a/pages/animelistitem/animelistitem.pixy b/pages/animelistitem/animelistitem.pixy index 8cf7f1d8..4c1276c4 100644 --- a/pages/animelistitem/animelistitem.pixy +++ b/pages/animelistitem/animelistitem.pixy @@ -3,9 +3,15 @@ component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn. .widget.anime-list-item-view(data-api="/api/animelist/" + viewUser.ID + "/update/" + anime.ID) h2= anime.Title.Canonical - InputNumber("Episodes", item.Episodes, "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount)) - InputNumber("Rating.Overall", int(item.Rating.Overall + 0.5), "Overall rating", "Overall rating on a scale of 0 to 10", "0", "10") - InputNumber("RewatchCount", item.RewatchCount, "Rewatched", "How often you rewatched this anime", "0", "100") + InputNumber("Episodes", float64(item.Episodes), "Episodes", "Number of episodes you watched", "0", arn.EpisodeCountMax(anime.EpisodeCount), "1") + + .anime-list-item-rating-edit + InputNumber("Rating.Overall", item.Rating.Overall, "Overall", "Overall rating on a scale of 0 to 10", "0", "10", "0.1") + InputNumber("Rating.Story", item.Rating.Story, "Story", "Story rating on a scale of 0 to 10", "0", "10", "0.1") + InputNumber("Rating.Visuals", item.Rating.Visuals, "Visuals", "Visuals rating on a scale of 0 to 10", "0", "10", "0.1") + InputNumber("Rating.Soundtrack", item.Rating.Soundtrack, "Soundtrack", "Soundtrack rating on a scale of 0 to 10", "0", "10", "0.1") + + InputNumber("RewatchCount", float64(item.RewatchCount), "Rewatched", "How often you rewatched this anime", "0", "100", "1") InputTextArea("Notes", item.Notes, "Notes", "Your notes") diff --git a/pages/animelistitem/animelistitem.scarlet b/pages/animelistitem/animelistitem.scarlet index 459e3881..a2812c5f 100644 --- a/pages/animelistitem/animelistitem.scarlet +++ b/pages/animelistitem/animelistitem.scarlet @@ -4,4 +4,11 @@ .anime-list-item-view-image max-width 55px - margin-bottom 1rem \ No newline at end of file + margin-bottom 1rem + +.anime-list-item-rating-edit + horizontal-wrap + justify-content space-between + width 100% + .widget-input + max-width 120px \ No newline at end of file diff --git a/scripts/actions.ts b/scripts/actions.ts index d1dcc4e5..52a9d68a 100644 --- a/scripts/actions.ts +++ b/scripts/actions.ts @@ -11,7 +11,11 @@ export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaE let value = input.value if(input.type === "number") { - obj[input.id] = parseInt(value) + if(input.getAttribute("step") === "1") { + obj[input.id] = parseInt(value) + } else { + obj[input.id] = parseFloat(value) + } } else { obj[input.id] = value }