summaryrefslogtreecommitdiff
path: root/web/templates/shopping-mode.html
blob: 3a1a3bc39860687b3fe6f162435c8f12bcc348e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>{{.StoreName}} - Shopping</title>
    <link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
    <link rel="stylesheet" href="/static/css/output.css">
    <script src="/static/js/htmx.min.js"></script>
    <style>
        .store-switcher {
            scrollbar-width: none;
            -ms-overflow-style: none;
        }
        .store-switcher::-webkit-scrollbar {
            display: none;
        }
        .flash-success {
            background: rgba(34, 197, 94, 0.2);
            border-radius: 8px;
        }
        .text-shadow-sm { text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
        @media print {
            * {
                text-shadow: none !important;
            }
            body {
                background: white !important;
                color: black !important;
                font-size: 10px !important;
                line-height: 1.2 !important;
            }
            .no-print {
                display: none !important;
            }
            main {
                padding: 0 !important;
            }
            #shopping-items > div {
                display: grid !important;
                grid-template-columns: 1fr 1fr !important;
                gap: 0 12px !important;
            }
            #shopping-items > div > div {
                background: none !important;
                border: none !important;
                border-radius: 0 !important;
                padding: 1px 0 !important;
                color: black !important;
                gap: 3px !important;
            }
            #shopping-items span {
                color: black !important;
                font-size: 10px !important;
            }
            #shopping-items .item-qty {
                font-size: 8px !important;
                color: #666 !important;
            }
            #shopping-items .rounded-full {
                width: 8px !important;
                height: 8px !important;
                border-width: 1px !important;
                border-color: #888 !important;
            }
            #shopping-items .text-xs {
                display: none !important;
            }
        }
    </style>
</head>
<body class="bg-slate-950 text-slate-200" hx-headers='{"X-CSRF-Token": "{{.CSRFToken}}"}'>
    <!-- Header -->
    <header class="sticky top-0 z-50 bg-black/40 backdrop-blur-lg border-b border-white/10 no-print">
        <div class="flex items-center justify-between px-4 py-3">
            <a href="/?tab=shopping" class="text-white/70 hover:text-white p-2 -ml-2">
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
                </svg>
            </a>
            <h1 class="text-lg font-semibold">{{.StoreName}}</h1>
            <button onclick="window.print()" class="text-white/70 hover:text-white p-2 -mr-2">
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"></path>
                </svg>
            </button>
        </div>

        <!-- Store Switcher -->
        {{if gt (len .StoreNames) 1}}
        <div class="store-switcher flex gap-2 px-4 pb-3 overflow-x-auto">
            {{range .StoreNames}}
            <a href="/shopping/mode/{{.}}"
               class="px-3 py-1.5 rounded-full text-sm whitespace-nowrap transition-colors
                      {{if eq . $.StoreName}}bg-white/20 text-white{{else}}bg-white/5 text-white/60 hover:bg-white/10{{end}}">
                {{.}}
            </a>
            {{end}}
        </div>
        {{end}}
    </header>

    <!-- Print Header -->
    <div class="hidden print:block mb-1">
        <h1 class="text-sm font-semibold text-black">{{.StoreName}}</h1>
    </div>

    <!-- Items List -->
    <main class="p-4" id="shopping-items">
        {{template "shopping-mode-items" .}}
    </main>

    <!-- Quick Add Form (Fixed at Bottom) -->
    <div class="fixed bottom-0 left-0 right-0 bg-black/60 backdrop-blur-lg border-t border-white/10 p-4 no-print">
        <form id="quick-add-form" hx-post="/shopping/add"
              hx-target="#shopping-items"
              hx-swap="innerHTML"
              class="flex gap-2 transition-all">
            <input type="hidden" name="store" value="{{.StoreName}}">
            <input type="hidden" name="mode" value="shopping-mode">
            <input type="text" name="name" placeholder="Add item..."
                   class="flex-1 bg-white/10 border border-white/20 rounded-lg px-4 py-3 text-white placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-white/30"
                   required autocomplete="off">
            <button type="submit" class="bg-white/20 hover:bg-white/30 text-white px-5 py-3 rounded-lg font-medium transition-colors">
                Add
            </button>
        </form>
    </div>

    <!-- Spacer for fixed bottom form -->
    <div class="h-24 no-print"></div>

    <script>
    document.body.addEventListener('htmx:afterRequest', function(evt) {
        if (evt.detail.elt.id === 'quick-add-form' && evt.detail.successful) {
            evt.detail.elt.reset();
            evt.detail.elt.querySelector('input[name=name]').focus();
            evt.detail.elt.classList.add('flash-success');
            setTimeout(function() { evt.detail.elt.classList.remove('flash-success'); }, 300);
        }
    });
    </script>
</body>
</html>