Improve sync, composer UX, and project layout
This commit is contained in:
parent
84909ff4e0
commit
4a815cb764
1893
assets/app.js
1893
assets/app.js
File diff suppressed because it is too large
Load Diff
463
assets/style.css
463
assets/style.css
@ -111,7 +111,19 @@ h1 {
|
|||||||
box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
|
box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-controls { display: flex; gap: 10px; }
|
.header-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
||||||
|
|
||||||
|
.sync-banner {
|
||||||
|
background: var(--input-bg);
|
||||||
|
border: 1px dashed var(--border);
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.sync-banner:hover { color: var(--project-color); border-color: var(--project-color); }
|
||||||
|
|
||||||
.header-btn {
|
.header-btn {
|
||||||
background: rgba(255,255,255,0.2);
|
background: rgba(255,255,255,0.2);
|
||||||
@ -254,13 +266,127 @@ h1 {
|
|||||||
.field-group-inline { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
|
.field-group-inline { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
|
||||||
|
|
||||||
.abbrev-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
|
.abbrev-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
|
||||||
.secondary.small { padding: 4px 8px; font-size: 0.8rem; }
|
.primary,
|
||||||
|
.secondary {
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-family: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
|
||||||
|
}
|
||||||
|
.primary {
|
||||||
|
background: var(--text);
|
||||||
|
color: var(--bg);
|
||||||
|
border-color: var(--text);
|
||||||
|
box-shadow: 0 4px 10px rgba(0,0,0,0.08);
|
||||||
|
}
|
||||||
|
.primary:hover {
|
||||||
|
background: var(--project-color);
|
||||||
|
border-color: var(--project-color);
|
||||||
|
color: var(--card-bg);
|
||||||
|
}
|
||||||
|
.secondary {
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
box-shadow: 0 3px 8px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
.secondary:hover { border-color: var(--project-color); color: var(--project-color); }
|
||||||
|
.secondary.danger {
|
||||||
|
color: var(--danger);
|
||||||
|
border-color: rgba(181, 107, 84, 0.35);
|
||||||
|
}
|
||||||
|
.secondary.danger:hover {
|
||||||
|
border-color: var(--danger);
|
||||||
|
color: var(--danger);
|
||||||
|
background: rgba(181, 107, 84, 0.08);
|
||||||
|
}
|
||||||
|
.primary.small,
|
||||||
|
.secondary.small {
|
||||||
|
padding: 4px 8px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
.pattern-footer-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
|
.pattern-footer-actions { margin-top: 16px; display: flex; justify-content: flex-end; }
|
||||||
|
|
||||||
/* Existing Step & View Styles (Preserved/Tweaked) */
|
/* Existing Step & View Styles (Preserved/Tweaked) */
|
||||||
.pattern-steps-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
|
.pattern-steps-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
|
||||||
.pattern-step-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
|
.pattern-step-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
|
||||||
|
.pattern-steps-actions { display: flex; gap: 8px; align-items: center; }
|
||||||
|
.pattern-buttons.inline-buttons button {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--text);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.pattern-buttons.inline-buttons button:hover {
|
||||||
|
border-color: var(--project-color);
|
||||||
|
color: var(--project-color);
|
||||||
|
}
|
||||||
|
.pattern-step-card .primary.small,
|
||||||
|
.pattern-step-card .btn-icon-small,
|
||||||
|
.pattern-step-card .step-collapse-btn {
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.pattern-step-card .btn-icon-small {
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
.pattern-step-card .btn-icon-small:hover {
|
||||||
|
border-color: var(--project-color);
|
||||||
|
color: var(--project-color);
|
||||||
|
}
|
||||||
|
.pattern-step-card .btn-icon-small.danger:hover {
|
||||||
|
color: var(--danger);
|
||||||
|
border-color: var(--danger);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pattern-library-controls {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.pattern-library-controls input,
|
||||||
|
.pattern-library-controls select {
|
||||||
|
padding: 8px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--text);
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
.pattern-library { display: grid; gap: 10px; }
|
||||||
|
.pattern-library-item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
.pattern-lib-title { font-weight: 700; }
|
||||||
|
.pattern-lib-subtitle { color: var(--text-muted); font-size: 0.9rem; }
|
||||||
|
.pattern-lib-meta { color: var(--text-muted); font-size: 0.85rem; }
|
||||||
|
.pattern-lib-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
|
||||||
|
|
||||||
|
.pattern-step-card.is-collapsed .pattern-step-body { display: none; }
|
||||||
|
.step-meta { color: var(--text-muted); font-size: 0.85rem; }
|
||||||
|
.step-title-group .step-meta { margin-left: 6px; margin-right: 6px; white-space: nowrap; }
|
||||||
|
.step-collapse-btn i { transition: transform 0.2s ease; }
|
||||||
|
.pattern-step-card.is-collapsed .step-collapse-btn i { transform: rotate(-90deg); }
|
||||||
|
|
||||||
|
.muted { color: var(--text-muted); }
|
||||||
|
.small { font-size: 0.85rem; }
|
||||||
|
|
||||||
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
|
||||||
|
|
||||||
@ -411,7 +537,7 @@ h1 {
|
|||||||
}
|
}
|
||||||
.extras-row {
|
.extras-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
.extras-row input {
|
.extras-row input {
|
||||||
@ -610,6 +736,43 @@ h1 {
|
|||||||
box-shadow: 0 14px 32px rgba(0,0,0,0.22);
|
box-shadow: 0 14px 32px rgba(0,0,0,0.22);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(44, 35, 25, 0.6);
|
||||||
|
display: none;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 215;
|
||||||
|
padding: 20px;
|
||||||
|
backdrop-filter: blur(2px);
|
||||||
|
}
|
||||||
|
.settings-overlay.active { display: flex; }
|
||||||
|
.settings-modal {
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: var(--text);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 18px;
|
||||||
|
width: min(420px, 92vw);
|
||||||
|
box-shadow: 0 14px 32px rgba(0,0,0,0.22);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.settings-head { display: flex; justify-content: space-between; align-items: center; }
|
||||||
|
.settings-body { display: grid; gap: 6px; }
|
||||||
|
.settings-toggle {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--input-bg);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.settings-toggle input { transform: scale(1.1); }
|
||||||
|
.settings-note { margin: 0 0 6px; color: var(--text-muted); font-size: 0.9rem; }
|
||||||
.auth-modal-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
|
.auth-modal-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
|
||||||
.auth-subtext { margin: 4px 0 10px; color: var(--text-muted); font-size: 0.92rem; }
|
.auth-subtext { margin: 4px 0 10px; color: var(--text-muted); font-size: 0.92rem; }
|
||||||
.auth-status { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
|
.auth-status { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
|
||||||
@ -634,6 +797,15 @@ h1 {
|
|||||||
.auth-hint { margin: 4px 0; color: var(--text-muted); font-size: 0.9rem; }
|
.auth-hint { margin: 4px 0; color: var(--text-muted); font-size: 0.9rem; }
|
||||||
.auth-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
|
.auth-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
|
||||||
.auth-actions-stack { flex-wrap: wrap; justify-content: flex-start; }
|
.auth-actions-stack { flex-wrap: wrap; justify-content: flex-start; }
|
||||||
|
.auth-modal.is-logged-out .auth-status { display: none; }
|
||||||
|
.auth-modal.is-logged-out .auth-tabs { margin-top: 4px; }
|
||||||
|
.auth-modal.is-logged-out .auth-content { margin-top: 0.6rem; }
|
||||||
|
.auth-modal.is-logged-out .auth-form { gap: 6px; }
|
||||||
|
.auth-divider {
|
||||||
|
border: none;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
margin: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.auth-profile { display: none; }
|
.auth-profile { display: none; }
|
||||||
.auth-profile form { display: grid; gap: 8px; }
|
.auth-profile form { display: grid; gap: 8px; }
|
||||||
@ -706,6 +878,39 @@ h1 {
|
|||||||
.pattern-toolbar { flex-direction: column; align-items: flex-start; }
|
.pattern-toolbar { flex-direction: column; align-items: flex-start; }
|
||||||
.pattern-tabs { justify-content: center; }
|
.pattern-tabs { justify-content: center; }
|
||||||
.pattern-tab { flex: 1 1 120px; text-align: center; }
|
.pattern-tab { flex: 1 1 120px; text-align: center; }
|
||||||
|
.pattern-sheet-header {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
.header-main {
|
||||||
|
width: 100%;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.pattern-sheet-title {
|
||||||
|
font-size: 1.05rem;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
.header-actions {
|
||||||
|
width: 100%;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: flex-start;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.pattern-save-indicator {
|
||||||
|
width: 100%;
|
||||||
|
margin-right: 0;
|
||||||
|
order: 1;
|
||||||
|
}
|
||||||
|
.icon-action {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
.pattern-close {
|
||||||
|
font-size: 1.6rem;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
@ -743,17 +948,32 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.project-header {
|
.project-header {
|
||||||
display: flex; justify-content: space-between; align-items: center;
|
display: grid;
|
||||||
padding: 15px 5px; margin-bottom: 10px; gap: 10px;
|
grid-template-columns: minmax(0, 1fr) auto;
|
||||||
|
align-items: center;
|
||||||
|
padding: 15px 5px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-title-group { display: flex; align-items: center; gap: 10px; }
|
.project-title-group { align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; flex-wrap: wrap; }
|
||||||
|
.project-title-group::after {
|
||||||
|
content: "";
|
||||||
|
flex-basis: 100%;
|
||||||
|
order: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.project-title {
|
.project-title {
|
||||||
font-size: 1.4rem; font-weight: 800; color: var(--project-color);
|
font-size: 1.4rem; font-weight: 800; color: var(--project-color);
|
||||||
text-transform: uppercase; letter-spacing: 1px;
|
text-transform: uppercase; letter-spacing: 1px;
|
||||||
font-family: 'Playfair Display', Georgia, serif;
|
font-family: 'Playfair Display', Georgia, serif;
|
||||||
|
min-width: 0; max-width: 100%;
|
||||||
|
white-space: normal; overflow: visible; text-overflow: clip;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
order: 2;
|
||||||
}
|
}
|
||||||
|
.btn-toggle-project { order: 0; }
|
||||||
|
.btn-rename-project { order: 3; }
|
||||||
|
|
||||||
.btn-toggle-project {
|
.btn-toggle-project {
|
||||||
background: none; border: none; color: var(--project-color);
|
background: none; border: none; color: var(--project-color);
|
||||||
@ -764,7 +984,7 @@ h1 {
|
|||||||
.project-collapsed .part-list { max-height: 0; opacity: 0; pointer-events: none; }
|
.project-collapsed .part-list { max-height: 0; opacity: 0; pointer-events: none; }
|
||||||
.project-collapsed { margin-bottom: 1rem; opacity: 0.8; box-shadow: none; }
|
.project-collapsed { margin-bottom: 1rem; opacity: 0.8; box-shadow: none; }
|
||||||
|
|
||||||
.project-actions { display: flex; gap: 8px; align-items: center; }
|
.project-actions { display: flex; align-items: center; flex-wrap: nowrap; justify-content: flex-end; }
|
||||||
|
|
||||||
.btn-add-part {
|
.btn-add-part {
|
||||||
background: var(--project-color); color: var(--card-bg); border: none;
|
background: var(--project-color); color: var(--card-bg); border: none;
|
||||||
@ -854,11 +1074,12 @@ h1 {
|
|||||||
.part-card.is-minimized .count-subtext,
|
.part-card.is-minimized .count-subtext,
|
||||||
.part-card.is-minimized .btn-reset-part,
|
.part-card.is-minimized .btn-reset-part,
|
||||||
.part-card.is-minimized .btn-delete-part { display: none; }
|
.part-card.is-minimized .btn-delete-part { display: none; }
|
||||||
|
.part-card.is-minimized .instructions-block { display: none; }
|
||||||
|
|
||||||
.part-header { display: flex; justify-content: space-between; align-items: center; }
|
.part-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
|
||||||
.part-card:not(.is-minimized) .part-header { margin-bottom: 15px; }
|
.part-card:not(.is-minimized) .part-header { margin-bottom: 15px; }
|
||||||
|
|
||||||
.part-name-group { display: flex; align-items: center; gap: 12px; flex-grow: 1; }
|
.part-name-group { display: flex; align-items: center; gap: 12px; flex-grow: 1; min-width: 0; flex-wrap: wrap; }
|
||||||
|
|
||||||
.check-container { position: relative; cursor: pointer; width: 26px; height: 26px; flex-shrink: 0; }
|
.check-container { position: relative; cursor: pointer; width: 26px; height: 26px; flex-shrink: 0; }
|
||||||
.check-container input { opacity: 0; cursor: pointer; height: 0; width: 0; }
|
.check-container input { opacity: 0; cursor: pointer; height: 0; width: 0; }
|
||||||
@ -877,7 +1098,7 @@ h1 {
|
|||||||
.part-name {
|
.part-name {
|
||||||
font-size: 1.1rem; font-weight: 700; color: var(--text);
|
font-size: 1.1rem; font-weight: 700; color: var(--text);
|
||||||
border-bottom: 2px dashed var(--project-color); /* Dashed looks more like stitching */
|
border-bottom: 2px dashed var(--project-color); /* Dashed looks more like stitching */
|
||||||
cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
|
cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.part-mini-count {
|
.part-mini-count {
|
||||||
@ -887,8 +1108,7 @@ h1 {
|
|||||||
.is-finished .part-name { text-decoration: line-through; color: var(--success); border-bottom: none; }
|
.is-finished .part-name { text-decoration: line-through; color: var(--success); border-bottom: none; }
|
||||||
.is-finished .part-mini-count { color: var(--success); }
|
.is-finished .part-mini-count { color: var(--success); }
|
||||||
|
|
||||||
.part-actions { display: flex; gap: 8px; align-items: center; }
|
.part-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
|
||||||
.part-actions { justify-content: flex-end; min-width: 120px; }
|
|
||||||
.icon-btn {
|
.icon-btn {
|
||||||
background: none; border: none; font-size: 1.3rem; padding: 5px; color: var(--text-muted);
|
background: none; border: none; font-size: 1.3rem; padding: 5px; color: var(--text-muted);
|
||||||
cursor: pointer; transition: color 0.2s;
|
cursor: pointer; transition: color 0.2s;
|
||||||
@ -899,6 +1119,27 @@ h1 {
|
|||||||
.btn-delete-part:hover { color: var(--danger); }
|
.btn-delete-part:hover { color: var(--danger); }
|
||||||
.btn-toggle-part { transition: transform 0.2s; }
|
.btn-toggle-part { transition: transform 0.2s; }
|
||||||
|
|
||||||
|
.instructions-block {
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
background: var(--input-bg);
|
||||||
|
}
|
||||||
|
.instructions-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.instructions-body { margin-top: 6px; }
|
||||||
|
.instructions-block.collapsed .instructions-body { display: none; }
|
||||||
|
.instruction-title { font-weight: 600; margin-bottom: 4px; }
|
||||||
|
.instruction-rows { margin: 0; padding-left: 18px; }
|
||||||
|
.instruction-rows li { margin-bottom: 4px; }
|
||||||
|
.instruction-note { margin-top: 6px; color: var(--text); }
|
||||||
|
.instruction-image { margin-top: 8px; max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
|
||||||
|
|
||||||
.count-display {
|
.count-display {
|
||||||
font-size: 3.5rem; font-weight: 800; text-align: center; color: var(--project-color); margin: 0.5rem 0 0.4rem 0; touch-action: manipulation;
|
font-size: 3.5rem; font-weight: 800; text-align: center; color: var(--project-color); margin: 0.5rem 0 0.4rem 0; touch-action: manipulation;
|
||||||
text-shadow: 1px 1px 0px var(--card-bg);
|
text-shadow: 1px 1px 0px var(--card-bg);
|
||||||
@ -1404,7 +1645,8 @@ button:active { transform: scale(0.97); box-shadow: none; }
|
|||||||
|
|
||||||
.image-input-group {
|
.image-input-group {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.image-input-group input { flex: 1; }
|
.image-input-group input { flex: 1; }
|
||||||
@ -1416,16 +1658,84 @@ button:active { transform: scale(0.97); box-shadow: none; }
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
.step-img-preview.compact img {
|
||||||
|
max-width: 160px;
|
||||||
|
max-height: 160px;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.view-step-img {
|
.view-step-img {
|
||||||
max-width: 400px; /* Reduced max-width */
|
max-width: 260px;
|
||||||
height: auto; /* Maintain aspect ratio */
|
height: auto; /* Maintain aspect ratio */
|
||||||
object-fit: contain; /* Ensure entire image is visible */
|
object-fit: contain; /* Ensure entire image is visible */
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
margin: 10px auto; /* Center image */
|
margin: 10px auto; /* Center image */
|
||||||
display: block;
|
display: block;
|
||||||
|
cursor: zoom-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.finished-photo-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
.finished-photo-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.view-photo-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.view-row {
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.15s ease;
|
||||||
|
}
|
||||||
|
.view-row.is-done {
|
||||||
|
text-decoration: line-through;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-preview-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(44, 35, 25, 0.7);
|
||||||
|
display: none;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 300;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.image-preview-overlay.active { display: flex; }
|
||||||
|
.image-preview-dialog {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
padding: 12px;
|
||||||
|
max-width: min(920px, 92vw);
|
||||||
|
max-height: 90vh;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.image-preview-img {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: calc(90vh - 40px);
|
||||||
|
display: block;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
.image-preview-close {
|
||||||
|
position: absolute;
|
||||||
|
top: 6px;
|
||||||
|
right: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
font-size: 1.6rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.image-preview-close:hover { color: var(--text); }
|
||||||
|
|
||||||
/* Preview Checkmarks */
|
/* Preview Checkmarks */
|
||||||
.view-check {
|
.view-check {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -1500,28 +1810,118 @@ button:active { transform: scale(0.97); box-shadow: none; }
|
|||||||
padding: 16px;
|
padding: 16px;
|
||||||
background: var(--bg); /* Contrast */
|
background: var(--bg); /* Contrast */
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
display: grid;
|
||||||
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sticky Headers for Groups */
|
.abbrev-grid {
|
||||||
.abbrev-group {
|
display: grid;
|
||||||
margin-bottom: 16px;
|
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
||||||
background: var(--card-bg);
|
gap: 6px;
|
||||||
border-radius: 12px;
|
padding: 8px 10px;
|
||||||
overflow: hidden;
|
}
|
||||||
|
.abbrev-pill {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 3px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 8px;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
|
background: var(--card-bg);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: border-color 0.2s, background-color 0.2s, color 0.2s;
|
||||||
|
}
|
||||||
|
.abbrev-pill .code { font-weight: 700; font-size: 0.9rem; }
|
||||||
|
.abbrev-pill .desc { font-size: 0.75rem; color: var(--text-muted); }
|
||||||
|
.abbrev-pill.is-selected {
|
||||||
|
border-color: var(--project-color);
|
||||||
|
background: color-mix(in srgb, var(--project-color) 12%, var(--card-bg));
|
||||||
|
}
|
||||||
|
.abbrev-pill.is-selected .code { color: var(--project-color); }
|
||||||
|
.abbrev-pill.just-added {
|
||||||
|
animation: abbrevPop 0.18s ease;
|
||||||
|
}
|
||||||
|
@keyframes abbrevPop {
|
||||||
|
0% { transform: scale(0.96); }
|
||||||
|
60% { transform: scale(1.03); }
|
||||||
|
100% { transform: scale(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
.abbrev-group summary {
|
.abbrev-panel {
|
||||||
position: sticky;
|
border: 1px solid var(--border);
|
||||||
top: 0;
|
border-radius: 12px;
|
||||||
z-index: 5;
|
background: var(--card-bg);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.abbrev-panel-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 12px;
|
||||||
background: var(--input-bg);
|
background: var(--input-bg);
|
||||||
padding: 10px 16px;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
.available-panel .abbrev-groups {
|
||||||
|
max-height: 48vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 8px 10px 12px;
|
||||||
|
}
|
||||||
|
.selected-panel .selected-grid {
|
||||||
|
padding: 8px 10px 10px;
|
||||||
|
max-height: 180px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.abbrev-group {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
border-bottom: 1px dashed var(--border);
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
overflow: visible;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.abbrev-group:last-child { border-bottom: none; }
|
||||||
|
.abbrev-group-title {
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin: 6px 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
.abbrev-group[open] > summary { border-bottom: 1px solid var(--border); }
|
.abbrev-custom-head {
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
background: var(--input-bg);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
.abbrev-custom-body {
|
||||||
|
padding: 10px 12px 12px;
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.abbrev-custom-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.abbrev-custom-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
.abbrev-custom-btn {
|
||||||
|
justify-self: end;
|
||||||
|
background: var(--project-color);
|
||||||
|
color: var(--card-bg);
|
||||||
|
border: none;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 700;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.abbrev-custom-btn:hover { opacity: 0.9; }
|
||||||
|
|
||||||
/* Selected Summary on Main Page */
|
/* Selected Summary on Main Page */
|
||||||
#abbrevSummary {
|
#abbrevSummary {
|
||||||
@ -1625,6 +2025,15 @@ button:active { transform: scale(0.97); box-shadow: none; }
|
|||||||
.swal-text { margin: 0 0 16px; color: var(--text-muted); }
|
.swal-text { margin: 0 0 16px; color: var(--text-muted); }
|
||||||
|
|
||||||
.swal-actions { display: flex; justify-content: center; gap: 10px; }
|
.swal-actions { display: flex; justify-content: center; gap: 10px; }
|
||||||
|
.swal-remember {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin: -4px 0 12px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
.swal-btn {
|
.swal-btn {
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
@ -24,9 +24,9 @@
|
|||||||
inkscape:deskcolor="#d1d1d1"
|
inkscape:deskcolor="#d1d1d1"
|
||||||
inkscape:document-units="in"
|
inkscape:document-units="in"
|
||||||
showgrid="true"
|
showgrid="true"
|
||||||
inkscape:zoom="1.1206597"
|
inkscape:zoom="0.34361842"
|
||||||
inkscape:cx="69.155693"
|
inkscape:cx="618.41853"
|
||||||
inkscape:cy="576"
|
inkscape:cy="598.0471"
|
||||||
inkscape:window-width="2560"
|
inkscape:window-width="2560"
|
||||||
inkscape:window-height="1532"
|
inkscape:window-height="1532"
|
||||||
inkscape:window-x="0"
|
inkscape:window-x="0"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
83
index.html
83
index.html
@ -23,9 +23,9 @@
|
|||||||
<h1 id="appTitle">Toadstool Cottage Counter</h1>
|
<h1 id="appTitle">Toadstool Cottage Counter</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-controls">
|
<div class="header-controls">
|
||||||
|
<button class="sync-banner" id="syncBanner" onclick="openAuthModal()" title="Sign in to sync">Local-only mode</button>
|
||||||
<button class="header-btn hidden" id="installBtn" title="Install app"><i class="fa-solid fa-download"></i></button>
|
<button class="header-btn hidden" id="installBtn" title="Install app"><i class="fa-solid fa-download"></i></button>
|
||||||
<button class="header-btn" id="motionBtn" onclick="toggleAnimations()" title="Toggle Animations"><i class="fa-solid fa-wand-magic-sparkles"></i></button>
|
<button class="header-btn" id="settingsBtn" onclick="openSettingsModal()" title="Settings"><i class="fa-solid fa-gear"></i></button>
|
||||||
<button class="header-btn" id="themeBtn" onclick="toggleTheme()" title="Toggle Dark Mode"><i class="fa-solid fa-moon"></i></button>
|
|
||||||
<button class="header-btn" id="focusBtn" onclick="toggleFocusMode()" title="Focus Mode (Keeps Screen On)"><i class="fa-solid fa-eye"></i></button>
|
<button class="header-btn" id="focusBtn" onclick="toggleFocusMode()" title="Focus Mode (Keeps Screen On)"><i class="fa-solid fa-eye"></i></button>
|
||||||
<button class="header-btn" id="saveLoadBtn" onclick="openSaveModal()" title="Save/Load"><i class="fa-solid fa-floppy-disk"></i></button>
|
<button class="header-btn" id="saveLoadBtn" onclick="openSaveModal()" title="Save/Load"><i class="fa-solid fa-floppy-disk"></i></button>
|
||||||
<button class="header-btn" id="authBtn" onclick="openAuthModal()" title="Sign in to sync"><i class="fa-solid fa-user"></i></button>
|
<button class="header-btn" id="authBtn" onclick="openAuthModal()" title="Sign in to sync"><i class="fa-solid fa-user"></i></button>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<div class="container" id="app"></div>
|
<div class="container" id="app"></div>
|
||||||
|
|
||||||
<button class="fab" onclick="openModal('addProject')">+</button>
|
<button class="fab" onclick="openModal('addProject')">+</button>
|
||||||
<button class="fab fab-pattern" onclick="openPatternComposer()" title="Open Pattern Composer"><i class="fa-solid fa-swatchbook"></i></button>
|
<button class="fab fab-pattern" id="patternFab" onclick="openPatternComposer()" title="Open Pattern Composer"><i class="fa-solid fa-swatchbook"></i></button>
|
||||||
|
|
||||||
<div class="modal-overlay" id="modalOverlay">
|
<div class="modal-overlay" id="modalOverlay">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@ -88,22 +88,44 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-overlay" id="settingsOverlay">
|
||||||
|
<div class="settings-modal">
|
||||||
|
<div class="settings-head">
|
||||||
|
<h3 class="color-title">Settings</h3>
|
||||||
|
<button class="pattern-close" onclick="closeSettingsModal()">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="settings-body">
|
||||||
|
<label class="settings-toggle">
|
||||||
|
<span>Dark mode</span>
|
||||||
|
<input type="checkbox" id="settingDarkMode" onchange="setDarkMode(this.checked)">
|
||||||
|
</label>
|
||||||
|
<p class="settings-note">Use a darker theme that is easier on the eyes at night.</p>
|
||||||
|
<label class="settings-toggle">
|
||||||
|
<span>Animations</span>
|
||||||
|
<input type="checkbox" id="settingAnimations" onchange="setAnimations(this.checked)">
|
||||||
|
</label>
|
||||||
|
<p class="settings-note">Toggle ambient motion like fireflies and micro-animations.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="auth-overlay" id="authOverlay">
|
<div class="auth-overlay" id="authOverlay">
|
||||||
<div class="auth-modal">
|
<div class="auth-modal">
|
||||||
<div class="auth-modal-head">
|
<div class="auth-modal-head">
|
||||||
<div>
|
<div>
|
||||||
<h3 class="color-title">Welcome Back!</h3>
|
<h3 class="color-title">Account</h3>
|
||||||
<p class="auth-subtext">Stay free forever. Sign in only if you want cloud backups and device switching.</p>
|
<p class="auth-subtext">Sign in to sync across devices.</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="pattern-close" onclick="closeAuthModal()">×</button>
|
<button class="pattern-close" onclick="closeAuthModal()">×</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="auth-status">
|
<div class="auth-status">
|
||||||
<span id="authStatusBadge" class="status-pill">Signed out</span>
|
<span id="authStatusBadge" class="status-pill">Signed out</span>
|
||||||
<span id="authLastSync" class="status-subtext">Last sync: never</span>
|
<span id="authLastSync" class="status-subtext">Status: unknown</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="auth-tabs">
|
<div class="auth-tabs">
|
||||||
<button class="auth-tab active" data-mode="login" onclick="setAuthMode('login')">Login</button>
|
<button class="auth-tab active" data-mode="login" onclick="setAuthMode('login')">Login</button>
|
||||||
<button class="auth-tab" data-mode="signup" onclick="setAuthMode('signup')">Sign up</button>
|
<button class="auth-tab" data-mode="signup" onclick="setAuthMode('signup')">Sign up</button>
|
||||||
|
<button class="auth-tab" data-mode="reset" onclick="setAuthMode('reset')">Reset</button>
|
||||||
<button class="auth-tab" id="profileTabBtn" data-mode="profile" onclick="setAuthMode('profile')" style="display:none;">Profile</button>
|
<button class="auth-tab" id="profileTabBtn" data-mode="profile" onclick="setAuthMode('profile')" style="display:none;">Profile</button>
|
||||||
<button class="auth-tab" id="adminTabBtn" data-mode="admin" onclick="setAuthMode('admin')" style="display:none;">Admin</button>
|
<button class="auth-tab" id="adminTabBtn" data-mode="admin" onclick="setAuthMode('admin')" style="display:none;">Admin</button>
|
||||||
</div>
|
</div>
|
||||||
@ -114,8 +136,8 @@
|
|||||||
<input id="loginEmail" type="email" placeholder="you@example.com" autocomplete="email" required>
|
<input id="loginEmail" type="email" placeholder="you@example.com" autocomplete="email" required>
|
||||||
<label class="field-label" for="loginPassword">Password</label>
|
<label class="field-label" for="loginPassword">Password</label>
|
||||||
<input id="loginPassword" type="password" placeholder="••••••••" autocomplete="current-password" required>
|
<input id="loginPassword" type="password" placeholder="••••••••" autocomplete="current-password" required>
|
||||||
<p class="auth-hint">Cloud sync is not required. Offline data stays on this device.</p>
|
|
||||||
<div class="auth-actions">
|
<div class="auth-actions">
|
||||||
|
<button type="button" class="modal-btn btn-secondary" onclick="setAuthMode('reset')">Forgot password?</button>
|
||||||
<button type="button" class="modal-btn btn-cancel" onclick="closeAuthModal()">Cancel</button>
|
<button type="button" class="modal-btn btn-cancel" onclick="closeAuthModal()">Cancel</button>
|
||||||
<button type="submit" class="modal-btn btn-save">Login</button>
|
<button type="submit" class="modal-btn btn-save">Login</button>
|
||||||
</div>
|
</div>
|
||||||
@ -129,13 +151,34 @@
|
|||||||
<input id="signupPassword" type="password" placeholder="••••••••" autocomplete="new-password" required>
|
<input id="signupPassword" type="password" placeholder="••••••••" autocomplete="new-password" required>
|
||||||
<label class="field-label" for="signupConfirmPassword">Confirm Password</label>
|
<label class="field-label" for="signupConfirmPassword">Confirm Password</label>
|
||||||
<input id="signupConfirmPassword" type="password" placeholder="••••••••" autocomplete="new-password" required>
|
<input id="signupConfirmPassword" type="password" placeholder="••••••••" autocomplete="new-password" required>
|
||||||
<p class="auth-hint">When enabled, we’ll sync projects/patterns securely.</p>
|
|
||||||
<div class="auth-actions">
|
<div class="auth-actions">
|
||||||
<button type="button" class="modal-btn btn-cancel" onclick="closeAuthModal()">Cancel</button>
|
<button type="button" class="modal-btn btn-cancel" onclick="closeAuthModal()">Cancel</button>
|
||||||
<button type="submit" class="modal-btn btn-save">Sign Up</button>
|
<button type="submit" class="modal-btn btn-save">Sign Up</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="resetContent" class="auth-tab-content">
|
||||||
|
<form class="auth-form" onsubmit="return requestPasswordReset(event)">
|
||||||
|
<label class="field-label" for="resetEmail">Email</label>
|
||||||
|
<input id="resetEmail" type="email" placeholder="you@example.com" autocomplete="email" required>
|
||||||
|
<div class="auth-actions">
|
||||||
|
<button type="button" class="modal-btn btn-cancel" onclick="setAuthMode('login')">Back to login</button>
|
||||||
|
<button type="submit" class="modal-btn btn-save">Send reset</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<hr class="auth-divider">
|
||||||
|
<form id="resetConfirmForm" class="auth-form" onsubmit="return confirmPasswordReset(event)">
|
||||||
|
<label class="field-label" for="resetToken">Reset Token</label>
|
||||||
|
<input id="resetToken" type="text" placeholder="Paste your reset token" autocomplete="one-time-code" required>
|
||||||
|
<label class="field-label" for="resetPassword">New Password</label>
|
||||||
|
<input id="resetPassword" type="password" placeholder="••••••••" autocomplete="new-password" required>
|
||||||
|
<label class="field-label" for="resetConfirmPassword">Confirm New Password</label>
|
||||||
|
<input id="resetConfirmPassword" type="password" placeholder="••••••••" autocomplete="new-password" required>
|
||||||
|
<div class="auth-actions">
|
||||||
|
<button type="submit" class="modal-btn btn-save">Update password</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
<div id="adminContent" class="auth-tab-content">
|
<div id="adminContent" class="auth-tab-content">
|
||||||
<div id="adminPanel" class="admin-panel">
|
<div id="adminPanel" class="admin-panel">
|
||||||
<h4>Pending Approvals</h4>
|
<h4>Pending Approvals</h4>
|
||||||
@ -198,6 +241,7 @@
|
|||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
<span class="pattern-save-indicator" id="patternSaveIndicator">Saved</span>
|
<span class="pattern-save-indicator" id="patternSaveIndicator">Saved</span>
|
||||||
<button class="icon-action" onclick="savePatternDraft()" title="Save to Basket"><i class="fa-solid fa-bookmark"></i></button>
|
<button class="icon-action" onclick="savePatternDraft()" title="Save to Basket"><i class="fa-solid fa-bookmark"></i></button>
|
||||||
|
<button class="icon-action" onclick="savePatternAndStartProject()" title="Save & Start Project"><i class="fa-solid fa-play"></i></button>
|
||||||
<button class="icon-action" onclick="exportPatternPDF()" title="Export PDF"><i class="fa-solid fa-file-pdf"></i></button>
|
<button class="icon-action" onclick="exportPatternPDF()" title="Export PDF"><i class="fa-solid fa-file-pdf"></i></button>
|
||||||
<button class="icon-action" onclick="sharePattern()" title="Share Link"><i class="fa-solid fa-link"></i></button>
|
<button class="icon-action" onclick="sharePattern()" title="Share Link"><i class="fa-solid fa-link"></i></button>
|
||||||
<button class="icon-action danger" onclick="clearPatternOutput()" title="Clear Draft"><i class="fa-solid fa-eraser"></i></button>
|
<button class="icon-action danger" onclick="clearPatternOutput()" title="Clear Draft"><i class="fa-solid fa-eraser"></i></button>
|
||||||
@ -260,6 +304,10 @@
|
|||||||
|
|
||||||
<label class="field-label" for="patternNotes">Notes / Finishing</label>
|
<label class="field-label" for="patternNotes">Notes / Finishing</label>
|
||||||
<textarea id="patternNotes" rows="2" placeholder="Assembly, finishing, safety warnings, credits..."></textarea>
|
<textarea id="patternNotes" rows="2" placeholder="Assembly, finishing, safety warnings, credits..."></textarea>
|
||||||
|
|
||||||
|
<label class="field-label" style="margin-top: 10px;">Finished Photos</label>
|
||||||
|
<div id="finishedPhotoList" class="finished-photo-list"></div>
|
||||||
|
<button class="secondary small" type="button" onclick="addFinishedPhoto()">Add Photo</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-card full-width">
|
<div class="input-card full-width">
|
||||||
@ -283,16 +331,29 @@
|
|||||||
|
|
||||||
<div class="pattern-section" data-section="steps">
|
<div class="pattern-section" data-section="steps">
|
||||||
<div class="pattern-steps-head">
|
<div class="pattern-steps-head">
|
||||||
<h4>Pattern Steps</h4>
|
<div>
|
||||||
|
<h4>Pattern Steps</h4>
|
||||||
|
<p class="muted small">Build steps and rows in order. Collapse steps to stay focused.</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="patternSteps"></div>
|
<div id="patternSteps"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pattern-section" data-section="library">
|
<div class="pattern-section" data-section="library">
|
||||||
<div class="pattern-steps-head">
|
<div class="pattern-steps-head">
|
||||||
<h4>Saved Patterns</h4>
|
<div>
|
||||||
|
<h4>Saved Patterns</h4>
|
||||||
|
<p class="muted small">Search, load, or start a project.</p>
|
||||||
|
</div>
|
||||||
<button class="primary" onclick="savePatternDraft()">Save Current Draft</button>
|
<button class="primary" onclick="savePatternDraft()">Save Current Draft</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pattern-library-controls">
|
||||||
|
<input id="patternSearch" type="text" placeholder="Search patterns..." oninput="renderPatternLibrary()">
|
||||||
|
<select id="patternSort" onchange="renderPatternLibrary()">
|
||||||
|
<option value="recent">Most recent</option>
|
||||||
|
<option value="name">Name A–Z</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div id="patternLibrary" class="pattern-library"></div>
|
<div id="patternLibrary" class="pattern-library"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -317,7 +378,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="assets/app.js"></script>
|
<script src="assets/app.js?v=3"></script>
|
||||||
<footer class="footer-bg" aria-hidden="true"></footer>
|
<footer class="footer-bg" aria-hidden="true"></footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -8,20 +8,81 @@
|
|||||||
<style>
|
<style>
|
||||||
body { background: var(--bg); color: var(--text); padding: 16px; }
|
body { background: var(--bg); color: var(--text); padding: 16px; }
|
||||||
.viewer { max-width: 720px; margin: 0 auto; padding: 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 24px rgba(0,0,0,0.1); }
|
.viewer { max-width: 720px; margin: 0 auto; padding: 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 24px rgba(0,0,0,0.1); }
|
||||||
.viewer h1 { margin: 0 0 6px; }
|
.viewer h1 { margin: 0 0 6px; color: var(--project-color); }
|
||||||
.viewer h3 { margin: 12px 0 6px; }
|
.viewer h3 { margin: 12px 0 6px; }
|
||||||
.viewer pre { white-space: pre-wrap; background: var(--input-bg); padding: 10px; border-radius: 10px; border: 1px solid var(--border); }
|
.viewer pre { white-space: pre-wrap; background: var(--input-bg); padding: 10px; border-radius: 10px; border: 1px solid var(--border); }
|
||||||
.step-list { display: grid; gap: 10px; margin: 12px 0; }
|
.step-list { display: grid; gap: 12px; margin: 12px 0; }
|
||||||
.step-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--card-bg); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
|
.step-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--card-bg); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
|
||||||
|
.step-card.collapsed .step-body { display: none; }
|
||||||
|
.step-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; }
|
||||||
|
.step-title .title { font-weight: 700; }
|
||||||
|
.step-title .caret { color: var(--text-muted); transition: transform 0.2s ease; }
|
||||||
|
.step-card.collapsed .step-title .caret { transform: rotate(-90deg); }
|
||||||
.step-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
|
.step-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
|
||||||
.step-title input { margin-right: 8px; }
|
.step-title input { margin-right: 8px; }
|
||||||
.step-rows { margin-top: 6px; }
|
.step-rows { margin-top: 8px; display: grid; gap: 6px; }
|
||||||
|
.step-row { cursor: pointer; }
|
||||||
|
.step-row.is-done { text-decoration: line-through; color: var(--text-muted); }
|
||||||
|
.step-title-bar {
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--card-bg);
|
||||||
|
background: var(--project-color);
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.step-media { margin-top: 8px; }
|
||||||
|
.step-media img { max-width: 260px; max-height: 260px; width: auto; height: auto; border-radius: 10px; border: 1px solid var(--border); display: block; cursor: zoom-in; }
|
||||||
.note-box { width: 100%; min-height: 80px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); padding: 8px; }
|
.note-box { width: 100%; min-height: 80px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); padding: 8px; }
|
||||||
.meta { display: grid; gap: 6px; margin: 10px 0; font-size: 0.95rem; }
|
.meta { display: grid; gap: 6px; margin: 10px 0; font-size: 0.95rem; }
|
||||||
.pill { display: inline-block; padding: 4px 8px; border-radius: 999px; background: var(--input-bg); border: 1px solid var(--border); font-size: 0.85rem; margin-right: 6px; margin-bottom: 4px; }
|
.pill { display: inline-block; padding: 4px 8px; border-radius: 999px; background: var(--input-bg); border: 1px solid var(--border); font-size: 0.85rem; margin-right: 6px; margin-bottom: 4px; }
|
||||||
.top-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
.top-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
||||||
.back-link { text-decoration: none; color: var(--text); font-weight: 700; }
|
.back-link { text-decoration: none; color: var(--text); font-weight: 700; }
|
||||||
.back-link:hover { color: var(--project-color); }
|
.back-link:hover { color: var(--project-color); }
|
||||||
|
.list { margin: 0; padding-left: 18px; }
|
||||||
|
.list li { margin-bottom: 4px; }
|
||||||
|
.color-swatch { display: inline-flex; align-items: center; gap: 6px; }
|
||||||
|
.swatch-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border); display: inline-block; }
|
||||||
|
.image-preview-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(44, 35, 25, 0.7);
|
||||||
|
display: none;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 400;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.image-preview-overlay.active { display: flex; }
|
||||||
|
.image-preview-dialog {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
padding: 12px;
|
||||||
|
max-width: min(920px, 92vw);
|
||||||
|
max-height: 90vh;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.image-preview-img {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: calc(90vh - 40px);
|
||||||
|
display: block;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
.image-preview-close {
|
||||||
|
position: absolute;
|
||||||
|
top: 6px;
|
||||||
|
right: 8px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
font-size: 1.6rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.image-preview-close:hover { color: var(--text); }
|
||||||
|
.viewer-photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
|
||||||
|
.viewer-photo { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; }
|
||||||
@media (max-width: 600px) { .viewer { padding: 12px; } }
|
@media (max-width: 600px) { .viewer { padding: 12px; } }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -33,7 +94,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1 id="pvTitle">Pattern</h1>
|
<h1 id="pvTitle">Pattern</h1>
|
||||||
<div id="pvDesigner" class="meta"></div>
|
<div id="pvDesigner" class="meta"></div>
|
||||||
|
<div id="pvGauge" class="meta"></div>
|
||||||
<div id="pvMaterials"></div>
|
<div id="pvMaterials"></div>
|
||||||
|
<div id="pvTools"></div>
|
||||||
|
<div id="pvPalette"></div>
|
||||||
|
<div id="pvFinishedPhotos"></div>
|
||||||
|
<div id="pvAbbrev"></div>
|
||||||
|
<div id="pvStitches"></div>
|
||||||
|
<div id="pvRows"></div>
|
||||||
<h3>Steps</h3>
|
<h3>Steps</h3>
|
||||||
<div id="pvSteps" class="step-list"></div>
|
<div id="pvSteps" class="step-list"></div>
|
||||||
<h3>Notes</h3>
|
<h3>Notes</h3>
|
||||||
@ -42,41 +110,154 @@
|
|||||||
<script>
|
<script>
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
const data = params.get('data');
|
const data = params.get('data');
|
||||||
|
const token = params.get('token');
|
||||||
let patternDraft = null;
|
let patternDraft = null;
|
||||||
try {
|
function renderError(message) {
|
||||||
if (!data) throw new Error('Missing pattern data');
|
document.body.innerHTML = `<div style="padding:20px;">Failed to load pattern: ${message}</div>`;
|
||||||
const json = decodeURIComponent(escape(atob(data)));
|
|
||||||
const parsed = JSON.parse(json);
|
|
||||||
if (!parsed.patternDraft) throw new Error('Invalid payload');
|
|
||||||
patternDraft = parsed.patternDraft;
|
|
||||||
} catch (e) {
|
|
||||||
document.body.innerHTML = `<div style="padding:20px;">Failed to load pattern: ${e.message}</div>`;
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
const storageKey = `pattern-viewer-${patternDraft.meta?.title || 'pattern'}`;
|
function resolveImageUrl(url) {
|
||||||
let progress = JSON.parse(localStorage.getItem(storageKey) || '{}');
|
if (!url) return '';
|
||||||
|
if (/^https?:\/\//i.test(url) || url.startsWith('data:')) return url;
|
||||||
|
if (url.startsWith('/uploads/')) {
|
||||||
|
return `${window.location.origin}${url}`;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openImagePreview(url) {
|
||||||
|
if (!url) return;
|
||||||
|
let overlay = document.getElementById('imagePreviewOverlay');
|
||||||
|
if (!overlay) {
|
||||||
|
overlay = document.createElement('div');
|
||||||
|
overlay.id = 'imagePreviewOverlay';
|
||||||
|
overlay.className = 'image-preview-overlay';
|
||||||
|
overlay.innerHTML = `
|
||||||
|
<div class="image-preview-dialog">
|
||||||
|
<button class="image-preview-close" type="button" aria-label="Close preview">×</button>
|
||||||
|
<img class="image-preview-img" alt="Preview">
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
overlay.addEventListener('click', (e) => {
|
||||||
|
if (e.target === overlay) overlay.classList.remove('active');
|
||||||
|
});
|
||||||
|
overlay.querySelector('.image-preview-close').addEventListener('click', () => {
|
||||||
|
overlay.classList.remove('active');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const img = overlay.querySelector('.image-preview-img');
|
||||||
|
if (img) img.src = url;
|
||||||
|
overlay.classList.add('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPattern() {
|
||||||
|
try {
|
||||||
|
if (data) {
|
||||||
|
const json = decodeURIComponent(escape(atob(data)));
|
||||||
|
const parsed = JSON.parse(json);
|
||||||
|
if (!parsed.patternDraft) throw new Error('Invalid payload');
|
||||||
|
return parsed.patternDraft;
|
||||||
|
}
|
||||||
|
if (token) {
|
||||||
|
const resp = await fetch(`/share/${encodeURIComponent(token)}`);
|
||||||
|
const payload = await resp.json();
|
||||||
|
if (!resp.ok) throw new Error(payload.error || 'Share link invalid');
|
||||||
|
const serverData = payload.pattern?.data?.draft || payload.pattern?.data;
|
||||||
|
if (!serverData) throw new Error('Missing pattern data');
|
||||||
|
return serverData;
|
||||||
|
}
|
||||||
|
throw new Error('Missing pattern data');
|
||||||
|
} catch (e) {
|
||||||
|
renderError(e.message);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let progress = {};
|
||||||
|
let storageKey = '';
|
||||||
function saveProgress() {
|
function saveProgress() {
|
||||||
localStorage.setItem(storageKey, JSON.stringify(progress));
|
localStorage.setItem(storageKey, JSON.stringify(progress));
|
||||||
}
|
}
|
||||||
|
const weightLabels = new Map([
|
||||||
|
['0', 'Lace (0)'],
|
||||||
|
['1', 'Super Fine (1)'],
|
||||||
|
['2', 'Fine (2)'],
|
||||||
|
['3', 'Light (3)'],
|
||||||
|
['4', 'Medium (4)'],
|
||||||
|
['5', 'Bulky (5)'],
|
||||||
|
['6', 'Super Bulky (6)'],
|
||||||
|
['7', 'Jumbo (7)']
|
||||||
|
]);
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
document.getElementById('pvTitle').textContent = patternDraft.meta?.title || 'Pattern';
|
document.getElementById('pvTitle').textContent = patternDraft.meta?.title || 'Pattern';
|
||||||
document.getElementById('pvDesigner').textContent = patternDraft.meta?.designer || '';
|
document.getElementById('pvDesigner').textContent = patternDraft.meta?.designer || '';
|
||||||
|
const gaugeBlock = [
|
||||||
|
patternDraft.gaugeSts || '',
|
||||||
|
patternDraft.gaugeRows ? ' - ' + patternDraft.gaugeRows : '',
|
||||||
|
patternDraft.gaugeHook ? ' - ' + patternDraft.gaugeHook : ''
|
||||||
|
].filter(Boolean).join('');
|
||||||
|
document.getElementById('pvGauge').innerHTML = gaugeBlock || patternDraft.size
|
||||||
|
? `<div><strong>Gauge / Size:</strong> ${[gaugeBlock, patternDraft.gauge || '', patternDraft.size || ''].filter(Boolean).join(' | ')}</div>`
|
||||||
|
: '';
|
||||||
const mats = patternDraft.materials || '';
|
const mats = patternDraft.materials || '';
|
||||||
document.getElementById('pvMaterials').innerHTML = mats ? `<h3>Materials</h3><pre>${mats}</pre>` : '';
|
document.getElementById('pvMaterials').innerHTML = mats ? `<h3>Materials</h3><pre>${mats}</pre>` : '';
|
||||||
|
const yarns = (patternDraft.yarns || []).map(y => {
|
||||||
|
const weightKey = y.weight !== undefined && y.weight !== null ? String(y.weight) : '';
|
||||||
|
const weightLabel = weightLabels.get(weightKey) || (weightKey ? `Weight ${weightKey}` : '');
|
||||||
|
const label = `${y.note || 'Yarn'}${weightLabel ? `: ${weightLabel}` : ''}`.trim();
|
||||||
|
return `<li>${label}${y.color ? ` <span class="color-swatch"><span class="swatch-dot" style="background:${y.color}"></span></span>` : ''}</li>`;
|
||||||
|
}).join('');
|
||||||
|
const hooks = (patternDraft.hooks || []).map(h => `<li>${h.size || ''}${h.note ? ` (${h.note})` : ''}</li>`).join('');
|
||||||
|
document.getElementById('pvTools').innerHTML = (yarns || hooks)
|
||||||
|
? `<h3>Yarns & Hooks</h3>${yarns ? `<ul class="list">${yarns}</ul>` : ''}${hooks ? `<p><strong>Hooks:</strong></p><ul class="list">${hooks}</ul>` : ''}`
|
||||||
|
: '';
|
||||||
|
const palette = (patternDraft.palette || []).map(c => `<li class="color-swatch"><span class="swatch-dot" style="background:${c}"></span></li>`).join('');
|
||||||
|
document.getElementById('pvPalette').innerHTML = palette ? `<h3>Palette</h3><ul class="list">${palette}</ul>` : '';
|
||||||
|
const finishedPhotos = (patternDraft.finishedPhotos || []).map(p => {
|
||||||
|
const url = resolveImageUrl(p.url);
|
||||||
|
return `<img class="viewer-photo" src="${url}" alt="Finished photo" onclick="openImagePreview('${url}')">`;
|
||||||
|
}).join('');
|
||||||
|
document.getElementById('pvFinishedPhotos').innerHTML = finishedPhotos ? `<h3>Finished Photos</h3><div class="viewer-photo-grid">${finishedPhotos}</div>` : '';
|
||||||
|
const customMap = new Map((patternDraft.customAbbrev || []).map(item => [item.code, item.desc]));
|
||||||
|
const selected = (patternDraft.abbrevSelection || []).map(code => {
|
||||||
|
const desc = customMap.get(code) || '';
|
||||||
|
return desc ? `<li>${code} - ${desc}</li>` : `<li>${code}</li>`;
|
||||||
|
}).join('');
|
||||||
|
const abbrevText = (patternDraft.abbrev || '').trim();
|
||||||
|
document.getElementById('pvAbbrev').innerHTML = abbrevText || selected
|
||||||
|
? `<h3>Abbreviations</h3>${abbrevText ? `<pre>${abbrevText}</pre>` : `<ul class="list">${selected}</ul>`}`
|
||||||
|
: '';
|
||||||
|
const stitches = (patternDraft.stitches || '').trim();
|
||||||
|
document.getElementById('pvStitches').innerHTML = stitches ? `<h3>Stitch Guide</h3><pre>${stitches}</pre>` : '';
|
||||||
|
const rowsOutput = (patternDraft.output || '').trim();
|
||||||
|
document.getElementById('pvRows').innerHTML = rowsOutput ? `<h3>Rows</h3><pre>${rowsOutput}</pre>` : '';
|
||||||
const stepsEl = document.getElementById('pvSteps');
|
const stepsEl = document.getElementById('pvSteps');
|
||||||
stepsEl.innerHTML = '';
|
stepsEl.innerHTML = '';
|
||||||
(patternDraft.steps || []).forEach((step, idx) => {
|
(patternDraft.steps || []).forEach((step, idx) => {
|
||||||
const card = document.createElement('div');
|
const card = document.createElement('div');
|
||||||
card.className = 'step-card';
|
const isCollapsed = progress[idx]?.collapsed;
|
||||||
const rows = (step.rows || []).map((r,i) => `<div><input type="checkbox" data-step="${idx}" data-row="${i}" ${progress[idx]?.rows?.[i]?'checked':''}> Row ${i+1}: ${r}</div>`).join('');
|
card.className = `step-card ${isCollapsed ? 'collapsed' : ''}`;
|
||||||
|
const rows = (step.rows || []).map((r,i) => {
|
||||||
|
const done = progress[idx]?.rows?.[i];
|
||||||
|
return `<div class="step-row ${done ? 'is-done' : ''}" data-step="${idx}" data-row="${i}">Row ${i+1}: ${r}</div>`;
|
||||||
|
}).join('');
|
||||||
|
const note = step.note ? `<p><strong>Step Note:</strong> ${step.note}</p>` : '';
|
||||||
|
const imgUrl = resolveImageUrl(step.image);
|
||||||
|
const img = step.image ? `<div class="step-media"><img src="${imgUrl}" alt="Step ${idx + 1} image" onclick="openImagePreview('${imgUrl}')"></div>` : '';
|
||||||
card.innerHTML = `
|
card.innerHTML = `
|
||||||
<div class="step-title">
|
<div class="step-title" data-step="${idx}">
|
||||||
<div><strong>Step ${idx+1}</strong> ${step.title ? '– ' + step.title : ''}</div>
|
<div class="title">Step ${idx+1}${step.title ? ` – ${step.title}` : ''}</div>
|
||||||
|
<div class="caret">▾</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="step-rows">${rows || '<em>No rows yet.</em>'}</div>
|
<div class="step-body">
|
||||||
<div style="margin-top:6px;">
|
<div class="step-title-bar">${step.title || `Step ${idx + 1}`}</div>
|
||||||
<label>Notes</label>
|
<div class="step-rows">${rows || '<em>No rows yet.</em>'}</div>
|
||||||
<textarea data-step="${idx}" class="note-box" placeholder="Notes for this step...">${progress[idx]?.note || ''}</textarea>
|
${note}
|
||||||
|
${img}
|
||||||
|
<div style="margin-top:6px;">
|
||||||
|
<label>Notes</label>
|
||||||
|
<textarea data-step="${idx}" class="note-box" placeholder="Notes for this step...">${progress[idx]?.note || ''}</textarea>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
stepsEl.appendChild(card);
|
stepsEl.appendChild(card);
|
||||||
@ -84,14 +265,23 @@
|
|||||||
const pvNotes = document.getElementById('pvNotes');
|
const pvNotes = document.getElementById('pvNotes');
|
||||||
pvNotes.value = progress.globalNote || '';
|
pvNotes.value = progress.globalNote || '';
|
||||||
}
|
}
|
||||||
document.addEventListener('change', (e) => {
|
document.addEventListener('click', (e) => {
|
||||||
if (e.target.matches('input[type="checkbox"][data-step]')) {
|
if (e.target.matches('.step-title')) {
|
||||||
|
const s = Number(e.target.dataset.step);
|
||||||
|
progress[s] = progress[s] || { rows: {} };
|
||||||
|
progress[s].collapsed = !progress[s].collapsed;
|
||||||
|
saveProgress();
|
||||||
|
const card = e.target.closest('.step-card');
|
||||||
|
if (card) card.classList.toggle('collapsed', progress[s].collapsed);
|
||||||
|
}
|
||||||
|
if (e.target.matches('.step-row')) {
|
||||||
const s = Number(e.target.dataset.step);
|
const s = Number(e.target.dataset.step);
|
||||||
const r = Number(e.target.dataset.row);
|
const r = Number(e.target.dataset.row);
|
||||||
progress[s] = progress[s] || { rows: {} };
|
progress[s] = progress[s] || { rows: {} };
|
||||||
progress[s].rows = progress[s].rows || {};
|
progress[s].rows = progress[s].rows || {};
|
||||||
progress[s].rows[r] = e.target.checked;
|
progress[s].rows[r] = !progress[s].rows[r];
|
||||||
saveProgress();
|
saveProgress();
|
||||||
|
e.target.classList.toggle('is-done', progress[s].rows[r]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.addEventListener('input', (e) => {
|
document.addEventListener('input', (e) => {
|
||||||
@ -106,7 +296,12 @@
|
|||||||
saveProgress();
|
saveProgress();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
render();
|
(async function init() {
|
||||||
|
patternDraft = await loadPattern();
|
||||||
|
storageKey = `pattern-viewer-${patternDraft.meta?.title || 'pattern'}`;
|
||||||
|
progress = JSON.parse(localStorage.getItem(storageKey) || '{}');
|
||||||
|
render();
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -23,6 +23,7 @@ async function initDb(retries = 10) {
|
|||||||
`);
|
`);
|
||||||
await pool.query(`alter table users add column if not exists is_admin boolean not null default false`);
|
await pool.query(`alter table users add column if not exists is_admin boolean not null default false`);
|
||||||
await pool.query(`alter table users add column if not exists status text not null default 'pending'`);
|
await pool.query(`alter table users add column if not exists status text not null default 'pending'`);
|
||||||
|
await pool.query(`create index if not exists users_email_lower_idx on users (lower(email))`);
|
||||||
await pool.query(`
|
await pool.query(`
|
||||||
create table if not exists sessions (
|
create table if not exists sessions (
|
||||||
token uuid primary key,
|
token uuid primary key,
|
||||||
@ -86,6 +87,10 @@ async function initDb(retries = 10) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeEmail(email) {
|
||||||
|
return String(email || '').trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
async function withClient(fn) {
|
async function withClient(fn) {
|
||||||
const client = await pool.connect();
|
const client = await pool.connect();
|
||||||
try {
|
try {
|
||||||
@ -100,21 +105,33 @@ function hashPassword(pw) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createUser(email, password) {
|
async function createUser(email, password) {
|
||||||
|
const normalizedEmail = normalizeEmail(email);
|
||||||
const id = crypto.randomUUID();
|
const id = crypto.randomUUID();
|
||||||
const password_hash = hashPassword(password);
|
const password_hash = hashPassword(password);
|
||||||
|
const existing = await pool.query(
|
||||||
|
`select id, email, display_name, note, is_admin, status from users where lower(email)=$1`,
|
||||||
|
[normalizedEmail]
|
||||||
|
);
|
||||||
|
if (existing.rows.length) {
|
||||||
|
return { existing: true, ...existing.rows[0] };
|
||||||
|
}
|
||||||
const countRes = await pool.query(`select count(*)::int as c from users`);
|
const countRes = await pool.query(`select count(*)::int as c from users`);
|
||||||
const isFirst = countRes.rows[0].c === 0;
|
const isFirst = countRes.rows[0].c === 0;
|
||||||
await pool.query(
|
await pool.query(
|
||||||
`insert into users (id, email, password_hash, status, is_admin) values ($1, $2, $3, $4, $5)
|
`insert into users (id, email, password_hash, status, is_admin) values ($1, $2, $3, $4, $5)
|
||||||
on conflict (email) do nothing`,
|
on conflict (email) do nothing`,
|
||||||
[id, email, password_hash, isFirst ? 'active' : 'pending', isFirst]
|
[id, normalizedEmail, password_hash, isFirst ? 'active' : 'pending', isFirst]
|
||||||
);
|
);
|
||||||
const row = await pool.query(`select id, email, display_name, note, is_admin, status from users where email=$1`, [email]);
|
const row = await pool.query(
|
||||||
return row.rows[0];
|
`select id, email, display_name, note, is_admin, status from users where lower(email)=$1`,
|
||||||
|
[normalizedEmail]
|
||||||
|
);
|
||||||
|
return { existing: false, ...row.rows[0] };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function verifyUser(email, password) {
|
async function verifyUser(email, password) {
|
||||||
const row = await pool.query(`select * from users where email=$1`, [email]);
|
const normalizedEmail = normalizeEmail(email);
|
||||||
|
const row = await pool.query(`select * from users where lower(email)=$1`, [normalizedEmail]);
|
||||||
if (!row.rows.length) return null;
|
if (!row.rows.length) return null;
|
||||||
const user = row.rows[0];
|
const user = row.rows[0];
|
||||||
if (user.password_hash !== hashPassword(password)) return null;
|
if (user.password_hash !== hashPassword(password)) return null;
|
||||||
@ -156,6 +173,15 @@ async function getProfile(userId) {
|
|||||||
return row.rows[0];
|
return row.rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getUserByEmail(email) {
|
||||||
|
const normalizedEmail = normalizeEmail(email);
|
||||||
|
const res = await pool.query(
|
||||||
|
`select id, email, display_name, note, is_admin, status from users where lower(email)=$1`,
|
||||||
|
[normalizedEmail]
|
||||||
|
);
|
||||||
|
return res.rows[0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
async function upsertItems(table, userId, items = []) {
|
async function upsertItems(table, userId, items = []) {
|
||||||
if (!items.length) return;
|
if (!items.length) return;
|
||||||
if (table === 'patterns') {
|
if (table === 'patterns') {
|
||||||
@ -305,5 +331,6 @@ module.exports = {
|
|||||||
listAllUsers,
|
listAllUsers,
|
||||||
setPassword,
|
setPassword,
|
||||||
createResetToken,
|
createResetToken,
|
||||||
consumeResetToken
|
consumeResetToken,
|
||||||
|
getUserByEmail
|
||||||
};
|
};
|
||||||
|
|||||||
@ -27,7 +27,8 @@ const {
|
|||||||
setPassword,
|
setPassword,
|
||||||
createResetToken,
|
createResetToken,
|
||||||
consumeResetToken,
|
consumeResetToken,
|
||||||
setUserAdmin
|
setUserAdmin,
|
||||||
|
getUserByEmail
|
||||||
} = require('./db');
|
} = require('./db');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
@ -86,11 +87,18 @@ app.get('/', (_req, res) => {
|
|||||||
app.post('/api/signup', (req, res) => {
|
app.post('/api/signup', (req, res) => {
|
||||||
const { email, password, displayName = '' } = req.body || {};
|
const { email, password, displayName = '' } = req.body || {};
|
||||||
if (!email || !password) return res.status(400).json({ error: 'Email and password required' });
|
if (!email || !password) return res.status(400).json({ error: 'Email and password required' });
|
||||||
|
if (password.length < 8) return res.status(400).json({ error: 'Password must be at least 8 characters' });
|
||||||
createUser(email, password)
|
createUser(email, password)
|
||||||
.then(async (user) => {
|
.then(async (user) => {
|
||||||
|
if (user.existing) {
|
||||||
|
return res.status(409).json({ error: 'Account already exists. Please log in instead.' });
|
||||||
|
}
|
||||||
await upsertProfile(user.id, displayName, '');
|
await upsertProfile(user.id, displayName, '');
|
||||||
|
if (user.status !== 'active') {
|
||||||
|
return res.status(202).json({ status: user.status });
|
||||||
|
}
|
||||||
const token = await createSession(user.id);
|
const token = await createSession(user.id);
|
||||||
return res.json({ token, email: user.email });
|
return res.json({ token, email: user.email, status: user.status });
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
@ -105,7 +113,7 @@ app.post('/api/login', (req, res) => {
|
|||||||
verifyUser(email, password)
|
verifyUser(email, password)
|
||||||
.then(async (user) => {
|
.then(async (user) => {
|
||||||
if (!user) return res.status(401).json({ error: 'Invalid credentials' });
|
if (!user) return res.status(401).json({ error: 'Invalid credentials' });
|
||||||
if (user.pending) return res.status(403).json({ error: 'Account pending approval', status: user.status });
|
if (user.pending) return res.status(403).json({ error: 'Account not active', status: user.status });
|
||||||
const token = await createSession(user.id);
|
const token = await createSession(user.id);
|
||||||
return res.json({ token, email: user.email, is_admin: user.is_admin });
|
return res.json({ token, email: user.email, is_admin: user.is_admin });
|
||||||
})
|
})
|
||||||
@ -201,36 +209,19 @@ const upload = multer({ storage: multer.memoryStorage(), limits: { fileSize: 10
|
|||||||
app.post('/api/upload', requireAuth, upload.single('file'), async (req, res) => {
|
app.post('/api/upload', requireAuth, upload.single('file'), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (!req.file) return res.status(400).json({ error: 'File required' });
|
if (!req.file) return res.status(400).json({ error: 'File required' });
|
||||||
|
const filename = `${Date.now()}-${uuid()}.webp`;
|
||||||
let filename;
|
const outPath = path.join(UPLOAD_DIR, filename);
|
||||||
let outPath;
|
await sharp(req.file.buffer)
|
||||||
|
.rotate() // Auto-rotate based on EXIF
|
||||||
try {
|
.resize({ width: 1200, height: 1200, fit: 'inside', withoutEnlargement: true })
|
||||||
// Attempt optimization
|
.webp({ quality: 80 })
|
||||||
filename = `${Date.now()}-${uuid()}.webp`;
|
.toFile(outPath);
|
||||||
outPath = path.join(UPLOAD_DIR, filename);
|
const baseUrl = `${req.protocol}://${req.get('host')}`;
|
||||||
|
const url = `${baseUrl}/uploads/${filename}`;
|
||||||
await sharp(req.file.buffer)
|
|
||||||
.rotate() // Auto-rotate based on EXIF
|
|
||||||
.resize({ width: 1200, height: 1200, fit: 'inside', withoutEnlargement: true })
|
|
||||||
.webp({ quality: 80 })
|
|
||||||
.toFile(outPath);
|
|
||||||
|
|
||||||
} catch (sharpErr) {
|
|
||||||
console.warn('Image optimization failed, falling back to raw save:', sharpErr.message);
|
|
||||||
// Fallback: Save original
|
|
||||||
const ext = (req.file.originalname.split('.').pop() || 'jpg').toLowerCase();
|
|
||||||
const safeExt = ['png', 'jpg', 'jpeg', 'webp', 'gif', 'avif'].includes(ext) ? ext : 'jpg';
|
|
||||||
filename = `${Date.now()}-${uuid()}.${safeExt}`;
|
|
||||||
outPath = path.join(UPLOAD_DIR, filename);
|
|
||||||
await fs.promises.writeFile(outPath, req.file.buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = `/uploads/${filename}`;
|
|
||||||
res.json({ url });
|
res.json({ url });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
res.status(500).json({ error: err.message, stack: err.stack });
|
res.status(500).json({ error: 'Image processing failed' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -286,7 +277,7 @@ app.post('/api/password-reset/request', async (req, res) => {
|
|||||||
const { email } = req.body || {};
|
const { email } = req.body || {};
|
||||||
if (!email) return res.status(400).json({ error: 'Email required' });
|
if (!email) return res.status(400).json({ error: 'Email required' });
|
||||||
try {
|
try {
|
||||||
const userRow = await listAllUsers().then(users => users.find(u => u.email === email));
|
const userRow = await getUserByEmail(email);
|
||||||
if (!userRow) return res.json({ ok: true }); // don't leak
|
if (!userRow) return res.json({ ok: true }); // don't leak
|
||||||
const reset = await createResetToken(userRow.id);
|
const reset = await createResetToken(userRow.id);
|
||||||
console.log(`Password reset token for ${email}: ${reset.token}`);
|
console.log(`Password reset token for ${email}: ${reset.token}`);
|
||||||
@ -301,6 +292,7 @@ app.post('/api/password-reset/request', async (req, res) => {
|
|||||||
app.post('/api/password-reset/confirm', async (req, res) => {
|
app.post('/api/password-reset/confirm', async (req, res) => {
|
||||||
const { token, password } = req.body || {};
|
const { token, password } = req.body || {};
|
||||||
if (!token || !password) return res.status(400).json({ error: 'Token and password required' });
|
if (!token || !password) return res.status(400).json({ error: 'Token and password required' });
|
||||||
|
if (password.length < 8) return res.status(400).json({ error: 'Password must be at least 8 characters' });
|
||||||
try {
|
try {
|
||||||
const userId = await consumeResetToken(token);
|
const userId = await consumeResetToken(token);
|
||||||
if (!userId) return res.status(400).json({ error: 'Invalid or expired token' });
|
if (!userId) return res.status(400).json({ error: 'Invalid or expired token' });
|
||||||
|
|||||||
5
sw.js
5
sw.js
@ -1,9 +1,9 @@
|
|||||||
const CACHE_NAME = 'toadstool-tally-v1';
|
const CACHE_NAME = 'toadstool-tally-v2';
|
||||||
const ASSETS = [
|
const ASSETS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
'/assets/style.css',
|
'/assets/style.css',
|
||||||
'/assets/app.js',
|
'/assets/app.js?v=3',
|
||||||
'/assets/textures/mushroom.svg',
|
'/assets/textures/mushroom.svg',
|
||||||
'/assets/icons/favicon-96x96.png',
|
'/assets/icons/favicon-96x96.png',
|
||||||
'/assets/icons/favicon.ico',
|
'/assets/icons/favicon.ico',
|
||||||
@ -18,6 +18,7 @@ self.addEventListener('install', (event) => {
|
|||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS))
|
||||||
);
|
);
|
||||||
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('activate', (event) => {
|
self.addEventListener('activate', (event) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user