diff --git a/src/ncounter/App.svelte b/src/ncounter/App.svelte
index 42ffea1..84f6418 100644
--- a/src/ncounter/App.svelte
+++ b/src/ncounter/App.svelte
@@ -11,14 +11,16 @@
{#if showAddDialog}
{/if}
{#if showAbout}
@@ -32,6 +34,7 @@ import { counters } from './db.js';
let showAddDialog = false;
let showAbout = false;
let newCounter = null;
+let dialogForm = null;
function focus(node){
node.focus();
@@ -41,6 +44,7 @@ function showAdd(){
newCounter = {
title: '',
initialValue: 0,
+ max: '',
saveHistory: false,
history: []
}
@@ -49,9 +53,15 @@ function showAdd(){
}
function add(){
+ if(!dialogForm.checkValidity()) {
+ dialogForm.removeAttribute('novalidate');
+ return;
+ }
+
const counter = {
...newCounter,
- value: newCounter.initialValue
+ max: newCounter.max !== '' ? +newCounter.max : null,
+ value: +newCounter.initialValue
}
counters.add(counter);
@@ -60,10 +70,6 @@ function add(){
}
\ No newline at end of file
diff --git a/src/ncounter/site.css b/src/ncounter/site.css
index 02bb4e1..397b497 100644
--- a/src/ncounter/site.css
+++ b/src/ncounter/site.css
@@ -125,6 +125,13 @@ button:focus, button:hover {
width: auto;
}
+.dialog-content .buttons {
+ display: flex;
+ flex-direction: row-reverse;
+ justify-content: space-between;
+ width: 100%;
+}
+
.dialog-content button:focus, .dialog-content button:hover {
border: 0;
outline: 2px solid var(--button-color);