Skip to content

Commit 16718a4

Browse files
feat: add header components (#24)
1 parent 70aef91 commit 16718a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+847
-28
lines changed

public/img/components/content-1.jpg

-97.7 KB
Binary file not shown.

public/img/components/content-10.jpg

-49.3 KB
Binary file not shown.

public/img/components/content-2.jpg

-58.2 KB
Binary file not shown.

public/img/components/content-3.jpg

-97.7 KB
Binary file not shown.

public/img/components/content-4.jpg

-69.1 KB
Binary file not shown.

public/img/components/content-5.jpg

-41.5 KB
Binary file not shown.

public/img/components/content-6.jpg

-28.2 KB
Binary file not shown.

public/img/components/content-7.jpg

-25.6 KB
Binary file not shown.

public/img/components/content-8.jpg

-68.9 KB
Binary file not shown.

public/img/components/content-9.jpg

-68.9 KB
Binary file not shown.

public/img/components/cta-1.jpg

-75.5 KB
Binary file not shown.

public/img/components/cta-2.jpg

-56.2 KB
Binary file not shown.

public/img/components/cta-3.jpg

-63.9 KB
Binary file not shown.

public/img/components/cta-4.jpg

-30.9 KB
Binary file not shown.

public/img/components/cta-5.jpg

-29.5 KB
Binary file not shown.

public/img/components/cta-6.jpg

-104 KB
Binary file not shown.

public/img/components/ecommerce-1.jpg

-50.5 KB
Binary file not shown.

public/img/components/ecommerce-2.jpg

-133 KB
Binary file not shown.

public/img/components/ecommerce-3.jpg

-47.8 KB
Binary file not shown.

public/img/components/ecommerce-4.jpg

-28.5 KB
Binary file not shown.

public/img/components/ecommerce-5.jpg

-32.4 KB
Binary file not shown.

public/img/components/feature-1.jpg

-48.2 KB
Binary file not shown.

public/img/components/feature-2.jpg

-26 KB
Binary file not shown.

public/img/components/feature-3.jpg

-43.8 KB
Binary file not shown.

public/img/components/feature-4.jpg

-68.8 KB
Binary file not shown.

public/img/components/feature-5.jpg

-61 KB
Binary file not shown.

public/img/components/feature-6.jpg

-32.2 KB
Binary file not shown.
-13.6 KB
Binary file not shown.
-12.6 KB
Binary file not shown.
-19.8 KB
Binary file not shown.
-18.6 KB
Binary file not shown.
-19.6 KB
Binary file not shown.
-18 KB
Binary file not shown.
-26.1 KB
Binary file not shown.
-24.8 KB
Binary file not shown.

public/img/components/header-1.jpg

-50.3 KB
Binary file not shown.

public/img/components/header-1.png

-26.2 KB

public/img/components/header-2.jpg

-45.7 KB
Binary file not shown.

public/img/components/header-2.png

-50.3 KB

public/img/components/header-3.jpg

-53.8 KB
Binary file not shown.

public/img/components/header-4.jpg

-92.8 KB
Binary file not shown.

public/img/components/header-5.jpg

-65.2 KB
Binary file not shown.

public/img/components/header-6.jpg

-47.7 KB
Binary file not shown.

src/assets/scss/preview.scss

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ body {
2121
box-sizing: border-box;
2222
}
2323

24+
a {
25+
color: inherit;
26+
text-decoration: none;
27+
}
28+
2429
.p-html, .p-body {
2530
height: 100%;
2631
}

src/assets/scss/variables.scss

+7-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323

2424
--font-primary: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
2525

26-
--color-primary: hsl(210, 100%, 63%);
27-
--color-danger: hsl(0, 87%, 69%);
28-
--color-bg: hsl(0, 0%, 100%);
29-
3026
--color-contrast-lower: hsl(0, 0%, 97%);
3127
--color-contrast-lower-alt: hsl(0, 0%, 92%);
3228
--color-contrast-low: hsl(0, 0%, 85%);
@@ -45,5 +41,11 @@
4541
--color-grey-800: hsl(0, 0%, 30%);
4642
--color-grey-900: hsl(0, 0%, 0%);
4743

44+
--color-primary: hsl(210, 100%, 63%);
45+
--color-danger: hsl(0, 87%, 69%);
46+
--color-bg: hsl(0, 0%, 100%);
47+
48+
--color-text-primary: var(--color-grey-800);
49+
4850
--color-border: var(--color-grey-400);
49-
}
51+
}

src/components/editor/EditorCanvas.vue

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@
3232
</template>
3333

3434
<script setup lang="ts">
35-
import {
36-
MBody,
37-
MContainer,
38-
MHtml,
39-
MPreview,
40-
} from '@mysigmail/vue-email-components'
35+
import { MBody, MContainer, MHtml, MPreview } from '@mysigmail/vue-email-components'
4136
import type { CSSProperties } from 'vue'
4237
import { computed, onMounted, ref } from 'vue'
4338
import Sortable from 'sortablejs'
@@ -49,13 +44,18 @@ import Menu2 from '@/components/email-components/menu/Menu2.vue'
4944
import Menu3 from '@/components/email-components/menu/Menu3.vue'
5045
import Menu4 from '@/components/email-components/menu/Menu4.vue'
5146
47+
import Header1 from '@/components/email-components/header/Header1.vue'
48+
import Header2 from '@/components/email-components/header/Header2.vue'
49+
5250
const { installed, isDragging, moveComponent, general } = useComponentsStore()
5351
5452
const components: Record<string, any> = {
5553
Menu1,
5654
Menu2,
5755
Menu3,
5856
Menu4,
57+
Header1,
58+
Header2,
5959
}
6060
6161
const listRef = ref<HTMLElement>()
@@ -66,9 +66,7 @@ const container: CSSProperties = {
6666
6767
const style = computed<CSSProperties>(() => {
6868
return {
69-
backgroundImage: general.background.image
70-
? `url(${general.background.image})`
71-
: '',
69+
backgroundImage: general.background.image ? `url(${general.background.image})` : '',
7270
backgroundRepeat: general.background.repeat,
7371
backgroundColor: general.background.color,
7472
backgroundSize: general.background.size,

src/components/editor/components/tools/text/TextEditorActions.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
placeholder="Type a link"
3434
/>
3535
<template #reference>
36-
<ElButton>
36+
<ElButton :class="{ 'is-active': editor?.getAttributes('link')?.href }">
3737
<UniconsLinkH />
3838
</ElButton>
3939
</template>

src/components/email-components/EDivider.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<MColumn
44
class="p-hover-tools"
55
:class="{
6-
'p-edit-tool': editableId === id && editableToolName === 'Divider',
6+
'p-edit-tool': editableId === id && editableToolName === group,
77
}"
88
>
99
<MHr :style="{ borderColor: color }" />

src/components/email-components/EImg.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class="p-hover-tools"
44
:align="align"
55
:class="{
6-
'p-edit-tool': editableId === id && editableToolName === 'Logo',
6+
'p-edit-tool': editableId === id && editableToolName === group,
77
}"
88
style="width: 100%"
99
>
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<template>
2+
<MColumn
3+
class="p-hover-tools"
4+
:class="{
5+
'p-edit-tool': editableId === id && editableToolName === group,
6+
}"
7+
>
8+
<div v-html="value" />
9+
</MColumn>
10+
</template>
11+
12+
<script setup lang="ts">
13+
import { useComponentsStore } from '@/store/components'
14+
15+
interface Props {
16+
id: string
17+
group: string
18+
value?: string
19+
}
20+
21+
defineProps<Props>()
22+
23+
const { editableId, editableToolName } = useComponentsStore()
24+
</script>
25+
26+
<style lang="scss" scoped></style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { computed } from 'vue'
2+
import { useLayout } from './layout'
3+
import { useLogo } from './logo'
4+
import { useText } from './text'
5+
import { useMenu } from './menu'
6+
import type { Tool } from '@/types/editor'
7+
import { getToolsByGroup } from '@/store/components/utils'
8+
9+
export function useCommon(tools: Tool[]) {
10+
const toolsByGroup = computed(() => getToolsByGroup(tools))
11+
12+
const layoutTools = useLayout(toolsByGroup)
13+
const logoTools = useLogo(toolsByGroup)
14+
const menuTools = useMenu(toolsByGroup)
15+
const textTools = useText(toolsByGroup)
16+
17+
return {
18+
...layoutTools,
19+
...logoTools,
20+
...menuTools,
21+
...textTools,
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { ComputedRef } from 'vue'
2+
import { computed } from 'vue'
3+
import { getValueFromToolsByGroupByName } from '@/store/components/utils'
4+
import type { BackgroundImageTool, ColorPickerTool, SpacingTool, Tool } from '@/types/editor'
5+
6+
export function useLayout(toolsByGroup: ComputedRef<Record<string, Tool[]>>) {
7+
const layoutPadding = computed(() => {
8+
const padding = getValueFromToolsByGroupByName<SpacingTool>(
9+
toolsByGroup.value,
10+
'Layout',
11+
'Spacings',
12+
)?.padding
13+
14+
return padding?.map(i => `${i}px`).join(' ')
15+
})
16+
17+
const layoutBackground = computed(() => {
18+
return getValueFromToolsByGroupByName<ColorPickerTool>(
19+
toolsByGroup.value,
20+
'Layout',
21+
'Background Color',
22+
)
23+
})
24+
25+
const layoutBackgroundImage = computed(() => {
26+
return getValueFromToolsByGroupByName<BackgroundImageTool>(
27+
toolsByGroup.value,
28+
'Layout',
29+
'Background Image',
30+
)
31+
})
32+
33+
const layoutAttrs = computed(() => {
34+
return {
35+
style: {
36+
padding: layoutPadding.value,
37+
backgroundColor: layoutBackground.value,
38+
backgroundImage: `url(${layoutBackgroundImage.value?.url})`,
39+
backgroundSize: layoutBackgroundImage.value?.size,
40+
backgroundPosition: layoutBackgroundImage.value?.position,
41+
},
42+
} as HTMLElement
43+
})
44+
45+
return {
46+
layoutAttrs,
47+
layoutBackground,
48+
layoutBackgroundImage,
49+
layoutPadding,
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { ComputedRef } from 'vue'
2+
import { computed } from 'vue'
3+
import { getValueFromToolsByGroupByName } from '@/store/components/utils'
4+
import type {
5+
AlignTool,
6+
ImageTool,
7+
PaddingTool,
8+
SpacingTool,
9+
ToggleTool,
10+
Tool,
11+
} from '@/types/editor'
12+
13+
export function useLogo(toolsByGroup: ComputedRef<Record<string, Tool[]>>) {
14+
const logoImage = computed(() => {
15+
return getValueFromToolsByGroupByName<ImageTool>(toolsByGroup.value, 'Logo', 'Image')
16+
})
17+
18+
const logoAlign = computed(() => {
19+
return getValueFromToolsByGroupByName<AlignTool>(toolsByGroup.value, 'Logo', 'Align')
20+
})
21+
22+
const logoPadding = computed(() => {
23+
const padding = getValueFromToolsByGroupByName<SpacingTool>(
24+
toolsByGroup.value,
25+
'Logo',
26+
'Spacings',
27+
)?.padding
28+
29+
return padding?.map(i => `${i}px`).join(' ')
30+
})
31+
32+
const logoAttrs = computed(() => {
33+
if (!logoImage.value)
34+
return
35+
36+
const { src, width, height, alt } = logoImage.value
37+
38+
return {
39+
src,
40+
alt,
41+
style: {
42+
width: `${width}px`,
43+
height: `${height}px`,
44+
},
45+
} as HTMLImageElement
46+
})
47+
48+
const isShowLogo = computed(() => {
49+
return getValueFromToolsByGroupByName<ToggleTool>(toolsByGroup.value, 'Logo', 'Show / Hide')
50+
})
51+
52+
return {
53+
isShowLogo,
54+
logoAlign,
55+
logoAttrs,
56+
logoImage,
57+
logoPadding,
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { ComputedRef } from 'vue'
2+
import { computed } from 'vue'
3+
import { getValueFromToolsByGroupByName, getValueFromToolsByName } from '@/store/components/utils'
4+
import type {
5+
AlignTool,
6+
ColorPickerTool,
7+
InputNumberTool,
8+
InputTool,
9+
MultiTool,
10+
PaddingTool,
11+
SpacingTool,
12+
ToggleTool,
13+
Tool,
14+
} from '@/types/editor'
15+
import type { Menu } from '@/types/email-components/components'
16+
17+
export function useMenu(toolsByGroup: ComputedRef<Record<string, Tool[]>>) {
18+
const menuAlign = computed(() => {
19+
return getValueFromToolsByGroupByName<AlignTool>(toolsByGroup.value, 'Menu', 'Align')
20+
})
21+
22+
const menuPadding = computed(() => {
23+
const padding = getValueFromToolsByGroupByName<SpacingTool>(
24+
toolsByGroup.value,
25+
'Menu',
26+
'Spacings',
27+
)?.padding
28+
29+
return padding?.map(i => `${i}px`).join(' ')
30+
})
31+
32+
const isShowMenu = computed(() => {
33+
return getValueFromToolsByGroupByName<ToggleTool>(toolsByGroup.value, 'Menu', 'Show / Hide')
34+
})
35+
36+
const menuItems = computed(() => {
37+
const items = getValueFromToolsByGroupByName<MultiTool>(toolsByGroup.value, 'Menu', 'List')
38+
39+
return items?.map((i) => {
40+
return {
41+
text: getValueFromToolsByName<InputTool>(i.tools, 'Name'),
42+
link: getValueFromToolsByName<InputTool>(i.tools, 'Link'),
43+
color: getValueFromToolsByName<ColorPickerTool>(i.tools, 'Color'),
44+
fontSize: getValueFromToolsByName<InputNumberTool>(i.tools, 'Font Size'),
45+
}
46+
}) as Menu[]
47+
})
48+
49+
return {
50+
isShowMenu,
51+
menuAlign,
52+
menuPadding,
53+
menuItems,
54+
}
55+
}

0 commit comments

Comments
 (0)