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
16 changes: 14 additions & 2 deletions src/components/email-components/EImg.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { AlignTool } from '@/types/editor'
import { computed } from 'vue'
import { useComponentsStore } from '@/store/components'

interface Props {
Expand All @@ -8,11 +9,22 @@ interface Props {
imgAttrs?: HTMLImageElement
align?: AlignTool['value']
link?: string
width?: string | number
}

defineProps<Props>()
const props = defineProps<Props>()

const { editableId, editableToolName } = useComponentsStore()

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

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

<template>
Expand All @@ -22,7 +34,7 @@ const { editableId, editableToolName } = useComponentsStore()
:class="{
'p-edit-tool': editableId === id && editableToolName === group,
}"
style="width: 100%"
:style="columnStyle"
>
<MLink :href="link">
<MImg v-bind="imgAttrs" />
Expand Down
15 changes: 14 additions & 1 deletion src/components/email-components/EMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@
import type { AlignTool } from '@/types/editor'
import type { Menu } from '@/types/email-components/components'
import { MColumn, MLink, MRow } from '@mysigmail/vue-email-components'
import { computed } from 'vue'
import { useComponentsStore } from '@/store/components'

interface Props {
id: string
group: string
align?: AlignTool['value']
width?: string | number
items: Menu[]
}

defineProps<Props>()
const props = defineProps<Props>()

const { editableId, editableToolName } = useComponentsStore()

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

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

<template>
<MColumn
class="e-list p-hover-tools"
:style="columnStyle"
:class="{
'p-edit-tool': editableId === id && editableToolName === group,
}"
Expand Down
15 changes: 14 additions & 1 deletion src/components/email-components/ESocial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@
import type { AlignTool } from '@/types/editor'
import type { Social } from '@/types/email-components/components'
import { MColumn, MLink, MRow } from '@mysigmail/vue-email-components'
import { computed } from 'vue'
import { useComponentsStore } from '@/store/components'

interface Props {
id: string
group: string
align?: AlignTool['value']
width?: string | number
items: Social[]
}

defineProps<Props>()
const props = defineProps<Props>()

const { editableId, editableToolName } = useComponentsStore()

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

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

<template>
<MColumn
class="e-list p-hover-tools"
:style="columnStyle"
:class="{
'p-edit-tool': editableId === id && editableToolName === group,
}"
Expand Down
15 changes: 14 additions & 1 deletion src/components/email-components/EText.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useComponentsStore } from '@/store/components'

interface Props {
id: string
group: string
value?: string
width?: string | number
}

defineProps<Props>()
const props = defineProps<Props>()

const { editableId, editableToolName } = useComponentsStore()

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

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

<template>
<MColumn
class="p-hover-tools"
:style="columnStyle"
:class="{
'p-edit-tool': editableId === id && editableToolName === group,
}"
Expand Down
8 changes: 8 additions & 0 deletions src/components/email-components/SchemaEmailComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ function resolveAlign(path?: string) {
return resolve<AlignTool['value']>(path)
}

function resolveWidth(path?: string) {
return resolve<string | number>(path)
}

function resolveAttrs(path?: string) {
return resolve<Record<string, unknown>>(path)
}
Expand Down Expand Up @@ -103,6 +107,7 @@ function onRootClick() {
:id="id"
:group="child.group"
:align="resolveAlign(child.align)"
:width="resolveWidth(child.width)"
:img-attrs="resolveImageAttrs(child.attrs)"
:link="resolveString(child.link)"
@click="onEditTool(child.group, index)"
Expand All @@ -113,6 +118,7 @@ function onRootClick() {
:id="id"
:group="child.group"
:align="resolveAlign(child.align)"
:width="resolveWidth(child.width)"
:items="resolveMenuItems(child.items)"
@click="onEditTool(child.group, index)"
/>
Expand All @@ -122,6 +128,7 @@ function onRootClick() {
:id="id"
:group="child.group"
:align="resolveAlign(child.align)"
:width="resolveWidth(child.width)"
:items="resolveSocialItems(child.items)"
@click="onEditTool(child.group, index)"
/>
Expand All @@ -130,6 +137,7 @@ function onRootClick() {
v-if="child.type === 'text' && isVisible(child.if)"
:id="id"
:group="child.group"
:width="resolveWidth(child.width)"
:value="resolveString(child.value)"
v-bind="resolveAttrs(child.attrs)"
@click="onEditTool(child.group, index)"
Expand Down
22 changes: 20 additions & 2 deletions src/components/email-components/catalog/header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { defineEmailBlockSchema } from '@/components/email-components/schema/typ

interface HeaderSchemaModel {
Layout: SchemaGroupFields<'attrs'>
Logo: SchemaGroupFields<'show' | 'attrs' | 'link' | 'align'>
Menu: SchemaGroupFields<'show' | 'items' | 'align'>
Logo: SchemaGroupFields<'show' | 'attrs' | 'link' | 'align' | 'width'>
Menu: SchemaGroupFields<'show' | 'items' | 'align' | 'width'>
Text: SchemaGroupFields<'show' | 'margin' | 'value' | 'attrs'>
}

Expand All @@ -29,13 +29,15 @@ const headerSchema = defineEmailBlockSchema<HeaderSchemaModel>({
attrs: 'Logo.attrs',
link: 'Logo.link',
align: 'Logo.align',
width: 'Logo.width',
},
{
type: 'menu',
group: 'Menu',
if: 'Menu.show',
items: 'Menu.items',
align: 'Menu.align',
width: 'Menu.width',
},
],
},
Expand Down Expand Up @@ -112,6 +114,10 @@ const header1: ComponentBuilder = (_, label) => {
group: 'Logo',
value: 'left',
}),
f.columnWidth({
group: 'Logo',
value: 35,
}),
f.image({
group: 'Logo',
value: {
Expand All @@ -128,6 +134,10 @@ const header1: ComponentBuilder = (_, label) => {
group: 'Menu',
value: 'right',
}),
f.columnWidth({
group: 'Menu',
value: 65,
}),
f.list({
group: 'Menu',
value: menuItems(COLOR.theme.light),
Expand Down Expand Up @@ -181,6 +191,10 @@ const header2: ComponentBuilder = (_, label) => {
group: 'Logo',
value: 'left',
}),
f.columnWidth({
group: 'Logo',
value: 35,
}),
f.image({
group: 'Logo',
value: {
Expand All @@ -197,6 +211,10 @@ const header2: ComponentBuilder = (_, label) => {
group: 'Menu',
value: 'right',
}),
f.columnWidth({
group: 'Menu',
value: 65,
}),
f.list({
group: 'Menu',
value: menuItems(COLOR.theme.dark),
Expand Down
26 changes: 23 additions & 3 deletions src/components/email-components/catalog/menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { defineEmailBlockSchema } from '@/components/email-components/schema/typ

interface MenuSchemaModel {
Layout: SchemaGroupFields<'attrs'>
Logo: SchemaGroupFields<'show' | 'attrs' | 'link' | 'align' | 'padding'>
Menu: SchemaGroupFields<'show' | 'items' | 'align' | 'padding'>
Logo: SchemaGroupFields<'show' | 'attrs' | 'link' | 'align' | 'padding' | 'width'>
Menu: SchemaGroupFields<'show' | 'items' | 'align' | 'padding' | 'width'>
Divider: SchemaGroupFields<'show' | 'color' | 'padding'>
Social: SchemaGroupFields<'show' | 'items' | 'align'>
Social: SchemaGroupFields<'show' | 'items' | 'align' | 'width'>
}

const menuRootSchema = {
Expand All @@ -32,13 +32,15 @@ const menu1Schema = defineEmailBlockSchema<MenuSchemaModel>({
attrs: 'Logo.attrs',
link: 'Logo.link',
align: 'Logo.align',
width: 'Logo.width',
},
{
type: 'menu',
group: 'Menu',
if: 'Menu.show',
items: 'Menu.items',
align: 'Menu.align',
width: 'Menu.width',
},
],
},
Expand Down Expand Up @@ -104,13 +106,15 @@ const menu3Schema = defineEmailBlockSchema<MenuSchemaModel>({
attrs: 'Logo.attrs',
link: 'Logo.link',
align: 'Logo.align',
width: 'Logo.width',
},
{
type: 'social',
group: 'Social',
if: 'Social.show',
items: 'Social.items',
align: 'Social.align',
width: 'Social.width',
},
],
},
Expand Down Expand Up @@ -241,6 +245,10 @@ const menu1: ComponentBuilder = (theme, label) => {
group: 'Logo',
value: 'left',
}),
f.columnWidth({
group: 'Logo',
value: 35,
}),
f.image({
group: 'Logo',
value: {
Expand All @@ -257,6 +265,10 @@ const menu1: ComponentBuilder = (theme, label) => {
group: 'Menu',
value: 'right',
}),
f.columnWidth({
group: 'Menu',
value: 65,
}),
f.list({
group: 'Menu',
value: menuItems(linkColor),
Expand Down Expand Up @@ -370,6 +382,10 @@ const menu3: ComponentBuilder = (theme, label) => {
group: 'Logo',
value: 'left',
}),
f.columnWidth({
group: 'Logo',
value: 35,
}),
f.image({
group: 'Logo',
value: {
Expand All @@ -386,6 +402,10 @@ const menu3: ComponentBuilder = (theme, label) => {
group: 'Social',
value: 'right',
}),
f.columnWidth({
group: 'Social',
value: 65,
}),
f.list({
group: 'Social',
value: socialItems(facebook, twitter, instagram),
Expand Down
13 changes: 13 additions & 0 deletions src/components/email-components/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ interface ColorConfig extends FieldConfig {
value: string
}

interface ColumnWidthConfig extends FieldConfig {
value: number
}

interface ImageConfig extends FieldConfig {
value: ImageTool['value']
}
Expand Down Expand Up @@ -116,6 +120,15 @@ export const f = {
value: config.value,
})
},
columnWidth(config: ColumnWidthConfig) {
return toolBuilder<InputNumberTool>({
group: config.group,
key: 'columnWidth',
label: 'Column Width (%)',
type: 'inputNumber',
value: config.value,
})
},
content(config: TextConfig) {
return toolBuilder<TextEditorTool>({
group: config.group,
Expand Down
Loading