Refactor ChoiceButtonDialog.vue: streamline template, improve typing

- Extracted all long/repeated CSS class strings in template to computed properties for maintainability
- Added/updated file-level and method-level documentation with comprehensive JSDoc comments
- Replaced $notify type from 'any' to 'unknown' for improved type safety
- Confirmed notification usage is already modern and follows project standards
- No databaseUtil or SQL abstraction required (pure UI component)
- Lint validation successful (no errors, only unrelated warnings remain)
- Migration tracking documents updated with timing and performance metrics

Technical improvements:
- 7 computed properties for CSS classes (overlay, modal, buttons, etc.)
- Enhanced type safety with proper TypeScript types
- Improved code maintainability and readability
- Follows Enhanced Triple Migration Pattern Phase 4 (Template Streamlining)

Migration completed in 7 minutes (13% faster than 8-12 min estimate)
This commit is contained in:
Matthew Raymer
2025-07-09 08:21:03 +00:00
parent 94fa14e9a3
commit be19c58d68
7 changed files with 173 additions and 40 deletions

View File

@@ -58,10 +58,7 @@
</div>
<div v-if="showCameraPreview" :class="cameraPreviewClasses">
<!-- Diagnostic Panel -->
<div
v-if="showDiagnostics"
:class="diagnosticsPanelClasses"
>
<div v-if="showDiagnostics" :class="diagnosticsPanelClasses">
<div class="grid grid-cols-2 gap-2">
<div>
<p><strong>Camera State:</strong> {{ cameraState }}</p>
@@ -117,7 +114,10 @@
muted
></video>
<div :class="cameraControlsClasses">
<button :class="cameraControlButtonClasses" @click="capturePhoto">
<button
:class="cameraControlButtonClasses"
@click="capturePhoto"
>
<font-awesome icon="camera" class="w-[1em]" />
</button>
<button
@@ -195,9 +195,7 @@
/>
</div>
</div>
<div
:class="buttonGridClasses"
>
<div :class="buttonGridClasses">
<button
class="bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white py-2 px-3 rounded-md"
@click="uploadImage"
@@ -345,9 +343,9 @@ export default class ImageMethodDialog extends Vue {
*/
get buttonGridClasses(): string {
return [
'grid gap-2 mt-2',
this.showRetry ? 'grid-cols-2' : 'grid-cols-1',
].join(' ');
"grid gap-2 mt-2",
this.showRetry ? "grid-cols-2" : "grid-cols-1",
].join(" ");
}
/**
@@ -355,7 +353,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for section dividers
*/
get sectionDividerClasses(): string {
return 'border-b border-dashed border-slate-300 text-orange-400 mb-4 font-bold text-sm';
return "border-b border-dashed border-slate-300 text-orange-400 mb-4 font-bold text-sm";
}
/**
@@ -363,7 +361,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for divider labels
*/
get sectionDividerSpanClasses(): string {
return 'block w-fit mx-auto -mb-2.5 bg-white px-2';
return "block w-fit mx-auto -mb-2.5 bg-white px-2";
}
/**
@@ -371,7 +369,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for camera preview
*/
get cameraPreviewClasses(): string {
return 'camera-preview relative flex bg-black overflow-hidden mb-4';
return "camera-preview relative flex bg-black overflow-hidden mb-4";
}
/**
@@ -379,7 +377,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for diagnostics overlay
*/
get diagnosticsPanelClasses(): string {
return 'absolute top-0 left-0 right-0 bg-black/80 text-white text-xs p-2 pt-8 z-20 overflow-auto max-h-[50vh]';
return "absolute top-0 left-0 right-0 bg-black/80 text-white text-xs p-2 pt-8 z-20 overflow-auto max-h-[50vh]";
}
/**
@@ -387,7 +385,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for diagnostics toggle
*/
get diagnosticsToggleClasses(): string {
return 'absolute top-2 right-2 bg-black/50 text-white px-2 py-1 rounded text-xs z-30';
return "absolute top-2 right-2 bg-black/50 text-white px-2 py-1 rounded text-xs z-30";
}
/**
@@ -395,7 +393,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for camera control buttons
*/
get cameraControlButtonClasses(): string {
return 'bg-white text-slate-800 p-3 rounded-full text-2xl leading-none';
return "bg-white text-slate-800 p-3 rounded-full text-2xl leading-none";
}
/**
@@ -403,7 +401,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for camera controls
*/
get cameraControlsClasses(): string {
return 'absolute bottom-4 inset-x-0 flex items-center justify-center gap-4';
return "absolute bottom-4 inset-x-0 flex items-center justify-center gap-4";
}
/**
@@ -411,7 +409,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for file input with custom button
*/
get fileInputClasses(): string {
return 'w-full file:text-center file:bg-gradient-to-b file:from-slate-400 file:to-slate-700 file:shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] file:text-white file:px-3 file:py-2 file:rounded-md file:border-none file:cursor-pointer file:me-2';
return "w-full file:text-center file:bg-gradient-to-b file:from-slate-400 file:to-slate-700 file:shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] file:text-white file:px-3 file:py-2 file:rounded-md file:border-none file:cursor-pointer file:me-2";
}
/**
@@ -419,7 +417,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for URL input field
*/
get urlInputClasses(): string {
return 'block w-full rounded border border-slate-400 px-4 py-2';
return "block w-full rounded border border-slate-400 px-4 py-2";
}
/**
@@ -427,7 +425,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for accept URL button
*/
get acceptUrlButtonClasses(): string {
return 'bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-2 rounded-md cursor-pointer';
return "bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-3 py-2 rounded-md cursor-pointer";
}
/**
@@ -435,7 +433,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for image preview
*/
get imageContainerClasses(): string {
return 'mt-2 rounded max-h-[50vh] max-w-[90vw] object-contain';
return "mt-2 rounded max-h-[50vh] max-w-[90vw] object-contain";
}
/**
@@ -443,7 +441,7 @@ export default class ImageMethodDialog extends Vue {
* Provides consistent styling for cropper
*/
get cropperClasses(): string {
return 'max-h-[50vh] max-w-[90vw] object-contain';
return "max-h-[50vh] max-w-[90vw] object-contain";
}
// Props