-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): add spacing & bg image tools (#23)
- Loading branch information
1 parent
4c2f9db
commit 70aef91
Showing
5 changed files
with
418 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/components/editor/components/tools/BackgroundImageTool.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<div class="background-tool"> | ||
<EditorToolLabel> | ||
{{ title }} | ||
</EditorToolLabel> | ||
<div class="body"> | ||
<EditorToolLabel>URL </EditorToolLabel> | ||
<ElInput | ||
v-model="localValue.url" | ||
placeholder="Image URLs" | ||
/> | ||
|
||
<EditorToolLabel>Repeat </EditorToolLabel> | ||
<ElRadioGroup v-model="localValue.repeat"> | ||
<ElRadioButton label="no-repeat"> | ||
No Repeat | ||
</ElRadioButton> | ||
<ElRadioButton label="repeat"> | ||
Repeat | ||
</ElRadioButton> | ||
</ElRadioGroup> | ||
|
||
<EditorToolLabel> Size </EditorToolLabel> | ||
<ElRadioGroup v-model="localValue.size"> | ||
<ElRadioButton label="unset"> | ||
None | ||
</ElRadioButton> | ||
<ElRadioButton label="cover"> | ||
Cover | ||
</ElRadioButton> | ||
<ElRadioButton label="contain"> | ||
Contain | ||
</ElRadioButton> | ||
</ElRadioGroup> | ||
|
||
<EditorToolLabel> Position </EditorToolLabel> | ||
<ElRadioGroup v-model="localValue.position"> | ||
<ElRadioButton label="top"> | ||
Top | ||
</ElRadioButton> | ||
<ElRadioButton label="button"> | ||
Button | ||
</ElRadioButton> | ||
<ElRadioButton label="center"> | ||
Center | ||
</ElRadioButton> | ||
<ElRadioButton label="left"> | ||
Left | ||
</ElRadioButton> | ||
<ElRadioButton label="right"> | ||
Right | ||
</ElRadioButton> | ||
</ElRadioGroup> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { reactive, watch } from 'vue' | ||
import type { BackgroundImageTool } from '@/types/editor' | ||
import { useComponentsStore } from '@/store/components' | ||
interface Props { | ||
id: string | ||
value: BackgroundImageTool['value'] | ||
title: string | ||
} | ||
const props = defineProps<Props>() | ||
const { updateToolById } = useComponentsStore() | ||
const localValue = reactive<BackgroundImageTool['value']>(props.value) | ||
watch( | ||
localValue, | ||
() => { | ||
updateToolById<BackgroundImageTool>(props.id, 'value', localValue) | ||
}, | ||
{ | ||
deep: true, | ||
}, | ||
) | ||
</script> | ||
|
||
<style lang="scss" scoped></style> |
62 changes: 62 additions & 0 deletions
62
src/components/editor/components/tools/spacing/SpacingInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<input | ||
v-model="localValue" | ||
class="spacing-input" | ||
type="number" | ||
> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
interface Props { | ||
modelValue: number | ||
} | ||
interface Emits { | ||
(e: 'update:model-value', value: number): void | ||
} | ||
const props = defineProps<Props>() | ||
const emit = defineEmits<Emits>() | ||
const localValue = computed({ | ||
get: () => props.modelValue, | ||
set: (v) => { | ||
emit('update:model-value', v) | ||
}, | ||
}) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.spacing-input { | ||
border: none; | ||
width: 40px; | ||
text-align: center; | ||
margin: 0; | ||
outline: none; | ||
border-radius: 4px; | ||
color: var(--color-text-primary); | ||
&:hover { | ||
outline: 1px solid var(--color-border); | ||
} | ||
&:focus { | ||
outline: 1px solid var(--color-primary); | ||
} | ||
&[disabled] { | ||
background-color: var(--color-background); | ||
color: var(--color-grey-500); | ||
cursor: not-allowed; | ||
&:hover { | ||
outline: none; | ||
} | ||
} | ||
} | ||
input[type='number']::-webkit-inner-spin-button, | ||
input[type='number']::-webkit-outer-spin-button { | ||
-webkit-appearance: none; | ||
margin: 0; | ||
} | ||
</style> |
Oops, something went wrong.