Skip to content

Commit 797a924

Browse files
committed
green minimize
1 parent ab9986e commit 797a924

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/components/GardenPlanner.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:can-undo="canUndo"
99
:can-redo="canRedo"
1010
:can-clear="placedPlants.length > 0"
11+
:can-fit-to-plants="canFitToPlants"
1112
:summary-active="showSummary"
1213
:zoom="zoom"
1314
:grid-width="gridWidth"
@@ -21,6 +22,7 @@
2122
@import="showDesignImport = true"
2223
@toggle-summary="handleSummaryToggle"
2324
@toggle-3d="toggle3D"
25+
@fit-to-plants="handleGridSizeFit"
2426
@open-grid-editor="showGridEditor = true"
2527
@toggle-snap="toggleSnapIncrement"
2628
@zoom-out="zoom = Math.max(zoom - 0.1, 0.5)"
@@ -377,6 +379,10 @@ const summaryData = computed(() => {
377379
378380
// Grid editor handlers
379381
const minGridSize = computed(() => getMinGridSize());
382+
const canFitToPlants = computed(() => {
383+
const min = minGridSize.value;
384+
return placedPlants.value.length > 0 && (gridWidth.value > min.width || gridHeight.value > min.height);
385+
});
380386
381387
const handleGridSizeApply = (width: number, height: number) => {
382388
const result = setGridSize(width, height);

src/components/PlannerToolbar.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@
9090
</button>
9191
</div>
9292

93+
<button
94+
v-if="canFitToPlants"
95+
class="toolbar-button fit-button icon-only"
96+
type="button"
97+
@click="$emit('fit-to-plants')"
98+
title="Use minimum grid size (trim whitespace)"
99+
aria-label="Use minimum grid size"
100+
>
101+
<Minimize2 :size="16" class="icon" />
102+
<span class="button-text">Use minimum</span>
103+
</button>
104+
93105
<button
94106
class="toolbar-button grid-dimensions-button"
95107
@click="$emit('open-grid-editor')"
@@ -136,6 +148,7 @@ import {
136148
Upload,
137149
Grid3x3,
138150
Tag,
151+
Minimize2,
139152
} from 'lucide-vue-next';
140153
141154
type LabelMode = 'off' | 'all';
@@ -145,6 +158,7 @@ const props = defineProps<{
145158
canUndo: boolean;
146159
canRedo: boolean;
147160
canClear: boolean;
161+
canFitToPlants?: boolean;
148162
summaryActive?: boolean;
149163
zoom: number;
150164
gridWidth: number;
@@ -161,6 +175,7 @@ defineEmits<{
161175
(e: 'import'): void;
162176
(e: 'toggle-summary'): void;
163177
(e: 'toggle-3d'): void;
178+
(e: 'fit-to-plants'): void;
164179
(e: 'open-grid-editor'): void;
165180
(e: 'toggle-snap'): void;
166181
(e: 'zoom-in'): void;
@@ -299,6 +314,18 @@ const labelsLabel = computed(() => {
299314
border-color: #15803d;
300315
}
301316
317+
.toolbar-button.fit-button {
318+
color: #16a34a;
319+
border-color: #16a34a;
320+
background-color: transparent;
321+
}
322+
323+
.toolbar-button.fit-button:hover:not(:disabled) {
324+
background-color: rgba(22, 163, 74, 0.10);
325+
border-color: #15803d;
326+
color: #15803d;
327+
}
328+
302329
.snap-toggle-button {
303330
font-family: 'Roboto Mono', monospace;
304331
}

0 commit comments

Comments
 (0)