Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
refactor: grid layout
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Aug 9, 2023
1 parent 736859e commit 8872279
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 45 deletions.
12 changes: 3 additions & 9 deletions src/components/ActionEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SingleStringEdit from '@/components/array/SingleStringEdit.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import JsonEdit from '@/components/atomic/JsonEdit.vue'
import TargetEdit from '@/components/task/TargetEdit.vue'
import FormLayout from '@/layout/FormLayout.vue'
const props = defineProps<{
value: Task
Expand All @@ -34,14 +35,7 @@ const taskActValue = computed(() => props.value.action ?? 'DoNothing')
</script>

<template>
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<FormLayout>
<ClearButton
propkey="action"
:value="value.action ?? null"
Expand Down Expand Up @@ -167,5 +161,5 @@ const taskActValue = computed(() => props.value.action ?? 'DoNothing')
@update:value="v => updateEditOn(edit, 'custom_action_param', v)"
></JsonEdit>
</template>
</div>
</FormLayout>
</template>
12 changes: 3 additions & 9 deletions src/components/MiscEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Task } from '@/types'
import ArrayNavigateEdit from './task/ArrayNavigateEdit.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import FreezeEdit from '@/components/task/FreezeEdit.vue'
import FormLayout from '@/layout/FormLayout.vue'
defineProps<{
value: Task
Expand All @@ -15,14 +16,7 @@ defineProps<{
</script>

<template>
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<FormLayout>
<ClearButton
propkey="next"
:value="value.next ?? null"
Expand Down Expand Up @@ -168,5 +162,5 @@ defineProps<{
@update:value="v => updateEditOn(edit, 'notify', v)"
></NSwitch>
</div>
</div>
</FormLayout>
</template>
12 changes: 3 additions & 9 deletions src/components/RecognizerEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ArrayStringEdit from '@/components/array/ArrayStringEdit.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import JsonEdit from '@/components/atomic/JsonEdit.vue'
import RectEdit from '@/components/atomic/RectEdit.vue'
import FormLayout from '@/layout/FormLayout.vue'
const props = defineProps<{
value: Task
Expand All @@ -31,14 +32,7 @@ const templMethodOptions = [1, 3, 5].map(x => ({
</script>

<template>
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<FormLayout>
<ClearButton
propkey="recognition"
:value="value.recognition ?? null"
Expand Down Expand Up @@ -211,5 +205,5 @@ const templMethodOptions = [1, 3, 5].map(x => ({
@update:value="v => updateEditOn(edit, 'custom_recognizer_param', v)"
></JsonEdit>
</template>
</div>
</FormLayout>
</template>
12 changes: 3 additions & 9 deletions src/components/TaskEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import ClearButton from '@/components/atomic/ClearButton.vue'
import JsonEdit from '@/components/atomic/JsonEdit.vue'
import ArrayNavigateEdit from '@/components/task/ArrayNavigateEdit.vue'
import SingleNavigateEdit from '@/components/task/SingleNavigateEdit.vue'
import FormLayout from '@/layout/FormLayout.vue'
const props = defineProps<{
name: string
Expand Down Expand Up @@ -206,14 +207,7 @@ function tryDelete() {
<MiscEdit :value="value" :edit="edit"></MiscEdit>
</NCollapseItem>
<NCollapseItem title="引用" name="ref">
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<FormLayout>
<ClearButton propkey="<unknown>" :value="null" :edit="() => {}">
前序任务
</ClearButton>
Expand All @@ -227,7 +221,7 @@ function tryDelete() {
array
readonly
></ArrayNavigateEdit>
</div>
</FormLayout>
</NCollapseItem>
</NCollapse>
</div>
Expand Down
12 changes: 3 additions & 9 deletions src/components/task/FreezeEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ClearButton from '@/components/atomic/ClearButton.vue'
import FloatInput from '@/components/atomic/FloatInput.vue'
import SwitchButton from '@/components/atomic/SwitchButton.vue'
import TargetEdit from '@/components/task/TargetEdit.vue'
import FormLayout from '@/layout/FormLayout.vue'
type T = null | number | WaitFreezes
Expand Down Expand Up @@ -65,14 +66,7 @@ const templMethodOptions = [1, 3, 5].map(x => ({
<DataObjectOutlined></DataObjectOutlined>
</SwitchButton>
</div>
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<FormLayout>
<template v-if="notObject">
<NInputNumber
:value="value as number | null"
Expand Down Expand Up @@ -135,6 +129,6 @@ const templMethodOptions = [1, 3, 5].map(x => ({
placeholder="5"
></NSelect>
</template>
</div>
</FormLayout>
</div>
</template>
15 changes: 15 additions & 0 deletions src/layout/FormLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div class="mFormLayout">
<slot></slot>
</div>
</template>

<style>
.mFormLayout {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
row-gap: 1rem;
column-gap: 0.5rem;
align-items: center;
}
</style>

0 comments on commit 8872279

Please sign in to comment.