Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/img/apple-watch-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/bosco-shots-ZoEdO0G0xmI-unsplash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions src/components/email-components/EButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<script setup lang="ts">
import type { AlignTool } from '@/types/editor'
import { MButton, MColumn } from '@mysigmail/vue-email-components'
import { computed } from 'vue'
import { useComponentsStore } from '@/store/components'

interface Props {
id: string
group: string
text?: string
attrs?: Record<string, unknown>
align?: AlignTool['value']
width?: string | number
inline?: boolean
}

const props = defineProps<Props>()

const { editableId, editableToolName } = useComponentsStore()

const isEditable = computed(() => {
return editableId.value === props.id && editableToolName.value === props.group
})

const columnStyle = computed(() => {
const value = props.width
if (value === undefined || value === null || value === '')
return undefined

return {
width: typeof value === 'number' ? `${value}px` : value,
}
})

const inlineStyle = computed(() => {
const style: Record<string, string> = {}

if (props.align)
style.textAlign = props.align

const value = props.width

if (value !== undefined && value !== null && value !== '')
style.width = typeof value === 'number' ? `${value}px` : value

if (!Object.keys(style).length)
return undefined

return style
})
</script>

<template>
<div
v-if="inline"
class="p-hover-tools"
:style="inlineStyle"
:class="{
'p-edit-tool': isEditable,
}"
>
<MButton v-bind="attrs">
{{ text }}
</MButton>
</div>

<MColumn
v-else
class="p-hover-tools"
:align="align"
:style="columnStyle"
:class="{
'p-edit-tool': isEditable,
}"
>
<MButton v-bind="attrs">
{{ text }}
</MButton>
</MColumn>
</template>

<style lang="scss" scoped></style>
1 change: 1 addition & 0 deletions src/components/email-components/EText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const columnStyle = computed(() => {
}"
>
<div v-html="value" />
<slot />
</MColumn>
</template>

Expand Down
28 changes: 28 additions & 0 deletions src/components/email-components/SchemaEmailComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,34 @@ function onRootClick() {
:value="resolveString(child.value)"
v-bind="resolveAttrs(child.attrs)"
@click="onEditTool(child.group, index)"
>
<template
v-for="(nestedChild, nestedIndex) in child.children || []"
:key="`${nodeIndex}_${childIndex}_${nestedIndex}`"
>
<EButton
v-if="nestedChild.type === 'button' && isVisible(nestedChild.if)"
:id="id"
:group="nestedChild.group"
:align="resolveAlign(nestedChild.align)"
:width="resolveWidth(nestedChild.width)"
:text="resolveString(nestedChild.text)"
:attrs="resolveAttrs(nestedChild.attrs)"
inline
@click.stop="onEditTool(nestedChild.group, index)"
/>
</template>
</EText>

<EButton
v-if="child.type === 'button' && isVisible(child.if)"
:id="id"
:group="child.group"
:align="resolveAlign(child.align)"
:width="resolveWidth(child.width)"
:text="resolveString(child.text)"
:attrs="resolveAttrs(child.attrs)"
@click.stop="onEditTool(child.group, index)"
/>
</template>
</MRow>
Expand Down
Loading