-
Notifications
You must be signed in to change notification settings - Fork 448
Feat: Fixed option for control after/before generate #7517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,9 @@ | ||
| <script setup lang="ts"> | ||
| import Button from 'primevue/button' | ||
| import Popover from 'primevue/popover' | ||
| import ToggleSwitch from 'primevue/toggleswitch' | ||
| import RadioButton from 'primevue/radiobutton' | ||
| import { computed, ref } from 'vue' | ||
|
|
||
| import { useSettingStore } from '@/platform/settings/settingStore' | ||
| import { useDialogService } from '@/services/dialogService' | ||
|
|
||
| import { NumberControlMode } from '../composables/useStepperControl' | ||
|
|
||
|
|
@@ -19,7 +17,6 @@ type ControlOption = { | |
|
|
||
| const popover = ref() | ||
| const settingStore = useSettingStore() | ||
| const dialogService = useDialogService() | ||
|
|
||
| const toggle = (event: Event) => { | ||
| popover.value.toggle(event) | ||
|
|
@@ -40,10 +37,10 @@ const controlOptions: ControlOption[] = [ | |
| ] as ControlOption[]) | ||
| : []), | ||
| { | ||
| mode: NumberControlMode.RANDOMIZE, | ||
| icon: 'icon-[lucide--shuffle]', | ||
| title: 'randomize', | ||
| description: 'randomizeDesc' | ||
| mode: NumberControlMode.FIXED, | ||
| icon: 'icon-[lucide--pencil-off]', | ||
| title: 'fixed', | ||
| description: 'fixedDesc' | ||
| }, | ||
| { | ||
| mode: NumberControlMode.INCREMENT, | ||
|
|
@@ -56,34 +53,20 @@ const controlOptions: ControlOption[] = [ | |
| text: '-1', | ||
| title: 'decrement', | ||
| description: 'decrementDesc' | ||
| }, | ||
| { | ||
| mode: NumberControlMode.RANDOMIZE, | ||
| icon: 'icon-[lucide--shuffle]', | ||
| title: 'randomize', | ||
| description: 'randomizeDesc' | ||
| } | ||
| ] | ||
|
|
||
| const widgetControlMode = computed(() => | ||
| settingStore.get('Comfy.WidgetControlMode') | ||
| ) | ||
|
|
||
| const props = defineProps<{ | ||
| controlMode: NumberControlMode | ||
| }>() | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'update:controlMode': [mode: NumberControlMode] | ||
| }>() | ||
|
|
||
| const handleToggle = (mode: NumberControlMode) => { | ||
| if (props.controlMode === mode) return | ||
| emit('update:controlMode', mode) | ||
| } | ||
|
|
||
| const isActive = (mode: NumberControlMode) => { | ||
| return props.controlMode === mode | ||
| } | ||
|
|
||
| const handleEditSettings = () => { | ||
| popover.value.hide() | ||
| dialogService.showSettingsDialog() | ||
| } | ||
| const controlMode = defineModel<NumberControlMode>() | ||
| </script> | ||
|
|
||
| <template> | ||
|
|
@@ -147,30 +130,14 @@ const handleEditSettings = () => { | |
| </div> | ||
| </div> | ||
|
|
||
| <ToggleSwitch | ||
| :model-value="isActive(option.mode)" | ||
| <RadioButton | ||
| v-model="controlMode" | ||
| class="flex-shrink-0" | ||
| @update:model-value=" | ||
| (v) => | ||
| v | ||
| ? handleToggle(option.mode) | ||
| : handleToggle(NumberControlMode.FIXED) | ||
| " | ||
| :input-id="option.mode" | ||
| :value="option.mode" | ||
| /> | ||
|
Comment on lines
+133
to
138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider accessibility improvements for RadioButton labels. The RadioButton uses Consider wrapping the RadioButton and its descriptive content in a Example improvement: - <div
- v-for="option in controlOptions"
- :key="option.mode"
- class="flex items-center justify-between py-2 gap-7"
- >
+ <label
+ v-for="option in controlOptions"
+ :key="option.mode"
+ :for="option.mode"
+ class="flex items-center justify-between py-2 gap-7 cursor-pointer"
+ >
<div class="flex items-center gap-2 flex-1 min-w-0">
<!-- icon and text content -->
</div>
<RadioButton
v-model="controlMode"
class="flex-shrink-0"
:input-id="option.mode"
:value="option.mode"
/>
- </div>
+ </label>This would improve keyboard navigation and screen reader support by making the entire option clickable and properly associating the label with the input.
🤖 Prompt for AI Agents |
||
| </div> | ||
| </div> | ||
| <div class="border-t border-border-subtle"></div> | ||
| <Button | ||
| class="w-full bg-secondary-background hover:bg-secondary-background-hover border-0 rounded-lg p-2 text-sm" | ||
| @click="handleEditSettings" | ||
| > | ||
| <div class="flex items-center justify-center gap-1"> | ||
| <i class="pi pi-cog text-xs text-muted-foreground" /> | ||
| <span class="font-normal text-base-foreground">{{ | ||
| $t('widgets.numberControl.editSettings') | ||
| }}</span> | ||
| </div> | ||
| </Button> | ||
| </div> | ||
| </Popover> | ||
| </template> | ||
Uh oh!
There was an error while loading. Please reload this page.