@designcrowd/library.brand-page 5.12.9 → 5.12.10-shape-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/{CreatedOnBrandCrowd-de-de-BSa_oMUS.js → CreatedOnBrandCrowd-de-de-B1UmWzii.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-CrDm6Zsd.js → CreatedOnBrandCrowd-en-us-BRK1hM-D.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-D_osPiN2.js → CreatedOnBrandCrowd-es-es-CN_2N7lq.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-B6KRVAx0.js → CreatedOnBrandCrowd-fr-fr-BLLKZAU4.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-DflhU2ts.js → CreatedOnBrandCrowd-pt-pt-Btsu98RA.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-CMxzzUpC.js → CreatedOnDcom-de-de-t1layjdN.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-Cgau0pJ6.js → CreatedOnDcom-en-us-Cgr8OWqD.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-7mE5DRiG.js → CreatedOnDcom-es-es-BU30p1A3.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-D2Q_bKeL.js → CreatedOnDcom-fr-fr-0WKXggE1.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-CdsDaHLJ.js → CreatedOnDcom-pt-pt-DugorNKz.js} +1 -1
- package/lib/src/brand-page/components/background-shape/BackgroundShape.mixin.d.ts +3 -1
- package/lib/src/brand-page/components/background-shape/BackgroundShape.mixin.js +49 -8
- package/lib/src/brand-page/components/media/Shape.mixin.d.ts +3 -2
- package/lib/src/brand-page/components/media/Shape.mixin.js +44 -11
- package/lib/src/brand-page/utils/svg.util.d.ts +1 -0
- package/lib/src/brand-page/utils/svg.util.js +3 -0
- package/lib/src/css/library.brand-page-brandCrowd.min.css +5 -5
- package/lib/src/css/library.brand-page-brandPage.min.css +5 -5
- package/lib/src/css/library.brand-page-designCom.min.css +5 -5
- package/lib/src/css/library.brand-page-preview.min.css +5 -5
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-C0TzGTrm.js → lib-CjyTfIxl.js} +11607 -11586
- package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.js +5 -0
- package/package.json +1 -1
- package/src/brand-page/components/background-shape/BackgroundShape.mixin.ts +64 -12
- package/src/brand-page/components/background-shape/BackgroundShape.vue +2 -12
- package/src/brand-page/components/media/Shape.mixin.ts +56 -17
- package/src/brand-page/components/media/Shape.vue +0 -7
- package/src/brand-page/utils/svg.util.ts +4 -0
- package/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.ts +5 -0
package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.js
CHANGED
|
@@ -125,6 +125,11 @@ export default defineComponent({
|
|
|
125
125
|
CUSTOM_DOMAIN_STATUSES.active);
|
|
126
126
|
},
|
|
127
127
|
},
|
|
128
|
+
watch: {
|
|
129
|
+
customDomain(newCustomDomain) {
|
|
130
|
+
this.selectedDomain = newCustomDomain;
|
|
131
|
+
},
|
|
132
|
+
},
|
|
128
133
|
methods: {
|
|
129
134
|
closeModal() {
|
|
130
135
|
this.$emit('on-close');
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import axios from 'axios';
|
|
|
6
6
|
import { applyColorToSvgString } from '../../utils/svg-color.util';
|
|
7
7
|
import { isURL } from '../../../utils/validator.util';
|
|
8
8
|
import { PROXY_SHAPE_URL_REGEX } from '../../../brand-page/constants';
|
|
9
|
+
import { getRegexToMatchAttributeInSvgTag } from '../../../brand-page/utils/svg.util';
|
|
9
10
|
|
|
10
11
|
const SUPPORTED_SHAPE_HOSTS = [
|
|
11
12
|
'https://bc-user-uploads.brandcrowd.com/public',
|
|
@@ -21,7 +22,7 @@ export default defineComponent({
|
|
|
21
22
|
},
|
|
22
23
|
},
|
|
23
24
|
data() {
|
|
24
|
-
return { svgData: '', originalSvgData: '' };
|
|
25
|
+
return { svgData: '', svgDataObjectUrl: '', originalSvgData: '' };
|
|
25
26
|
},
|
|
26
27
|
computed: {
|
|
27
28
|
useObjectElement(): boolean {
|
|
@@ -39,15 +40,12 @@ export default defineComponent({
|
|
|
39
40
|
);
|
|
40
41
|
},
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this.isFullBackground) {
|
|
46
|
-
attributes.push('preserveAspectRatio="xMidYMid slice"');
|
|
47
|
-
attributes.push('style="width: 100%; height: 100%;"');
|
|
43
|
+
objectUrl(): string {
|
|
44
|
+
if (!this.useObjectElement) {
|
|
45
|
+
return this.svgDataObjectUrl;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
return
|
|
48
|
+
return this.viewModel.name;
|
|
51
49
|
},
|
|
52
50
|
},
|
|
53
51
|
watch: {
|
|
@@ -74,6 +72,49 @@ export default defineComponent({
|
|
|
74
72
|
);
|
|
75
73
|
},
|
|
76
74
|
|
|
75
|
+
applySvgAttributes(svgData: string): string {
|
|
76
|
+
const attributes: string[] = [];
|
|
77
|
+
|
|
78
|
+
if (this.isFullBackground) {
|
|
79
|
+
const widthRegex = getRegexToMatchAttributeInSvgTag('width');
|
|
80
|
+
|
|
81
|
+
if (svgData.match(widthRegex)) {
|
|
82
|
+
svgData = svgData.replace(widthRegex, `$1width="100%"`);
|
|
83
|
+
} else {
|
|
84
|
+
attributes.push(`width="100%"`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const heightRegex = getRegexToMatchAttributeInSvgTag('height');
|
|
88
|
+
|
|
89
|
+
if (svgData.match(heightRegex)) {
|
|
90
|
+
svgData = svgData.replace(heightRegex, `$1height="100%"`);
|
|
91
|
+
} else {
|
|
92
|
+
attributes.push(`height="100%"`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const preserveAspectRatioRegex = getRegexToMatchAttributeInSvgTag(
|
|
96
|
+
'preserveAspectRatio',
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (svgData.match(preserveAspectRatioRegex)) {
|
|
100
|
+
svgData = svgData.replace(
|
|
101
|
+
preserveAspectRatioRegex,
|
|
102
|
+
`$1preserveAspectRatio="xMidYMid slice"`,
|
|
103
|
+
);
|
|
104
|
+
} else {
|
|
105
|
+
attributes.push(`preserveAspectRatio="xMidYMid slice"`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const svgAttributes = attributes.join(' ');
|
|
110
|
+
|
|
111
|
+
if (svgAttributes) {
|
|
112
|
+
svgData = svgData.replace('<svg ', `<svg ${svgAttributes} `);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return svgData;
|
|
116
|
+
},
|
|
117
|
+
|
|
77
118
|
async render() {
|
|
78
119
|
if (this.useObjectElement) {
|
|
79
120
|
return;
|
|
@@ -96,12 +137,23 @@ export default defineComponent({
|
|
|
96
137
|
this.originalSvgData,
|
|
97
138
|
this.viewModel.style.color,
|
|
98
139
|
);
|
|
140
|
+
} else {
|
|
141
|
+
this.svgData = this.originalSvgData;
|
|
99
142
|
}
|
|
100
143
|
|
|
101
|
-
this.svgData = this.svgData
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
144
|
+
this.svgData = this.applySvgAttributes(this.svgData);
|
|
145
|
+
|
|
146
|
+
const blob = new Blob([this.svgData], { type: 'image/svg+xml' });
|
|
147
|
+
|
|
148
|
+
const oldSvgDataObjectUrl = this.svgDataObjectUrl;
|
|
149
|
+
|
|
150
|
+
// Create an Object URL
|
|
151
|
+
this.svgDataObjectUrl = URL.createObjectURL(blob);
|
|
152
|
+
|
|
153
|
+
if (oldSvgDataObjectUrl) {
|
|
154
|
+
// clean up previous Object URL
|
|
155
|
+
URL.revokeObjectURL(oldSvgDataObjectUrl);
|
|
156
|
+
}
|
|
105
157
|
},
|
|
106
158
|
},
|
|
107
159
|
});
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="c-shape-background">
|
|
3
|
-
<div
|
|
4
|
-
|
|
5
|
-
:style="backgroundShapesStyle"
|
|
6
|
-
class="c-shape c-shape-object"
|
|
7
|
-
>
|
|
8
|
-
<object class="tw-w-full tw-h-full" :data="viewModel.name" />
|
|
3
|
+
<div :style="backgroundShapesStyle" class="c-shape c-shape-object">
|
|
4
|
+
<object class="tw-w-full tw-h-full" :data="objectUrl" />
|
|
9
5
|
</div>
|
|
10
|
-
<div
|
|
11
|
-
v-else
|
|
12
|
-
:style="backgroundShapesStyle"
|
|
13
|
-
class="c-shape"
|
|
14
|
-
v-html="svgData"
|
|
15
|
-
/>
|
|
16
6
|
</div>
|
|
17
7
|
</template>
|
|
18
8
|
<script>
|
|
@@ -5,6 +5,7 @@ import ComponentCommonMixin from '../mixins/component-common.mixin';
|
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { applyColorReplacementsToSvgString } from '../../utils/svg-color.util';
|
|
7
7
|
import { PROXY_SHAPE_URL_REGEX } from '../../../brand-page/constants';
|
|
8
|
+
import { getRegexToMatchAttributeInSvgTag } from '../../../brand-page/utils/svg.util';
|
|
8
9
|
|
|
9
10
|
export default defineComponent({
|
|
10
11
|
mixins: [ComponentCommonMixin],
|
|
@@ -34,7 +35,7 @@ export default defineComponent({
|
|
|
34
35
|
},
|
|
35
36
|
},
|
|
36
37
|
data() {
|
|
37
|
-
return { svgData: '', originalSvgData: '' };
|
|
38
|
+
return { svgData: '', svgDataObjectUrl: '', originalSvgData: '' };
|
|
38
39
|
},
|
|
39
40
|
computed: {
|
|
40
41
|
useObjectElement(): boolean {
|
|
@@ -53,6 +54,10 @@ export default defineComponent({
|
|
|
53
54
|
},
|
|
54
55
|
|
|
55
56
|
objectUrl() {
|
|
57
|
+
if (!this.useObjectElement) {
|
|
58
|
+
return this.svgDataObjectUrl;
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
let dimensionQuery = ``;
|
|
57
62
|
|
|
58
63
|
if (this.size) {
|
|
@@ -63,21 +68,17 @@ export default defineComponent({
|
|
|
63
68
|
|
|
64
69
|
return `${this.imageUrl}${dimensionQuery}`;
|
|
65
70
|
},
|
|
66
|
-
|
|
67
|
-
svgAttributes(): string {
|
|
68
|
-
const attributes: string[] = [];
|
|
69
|
-
|
|
70
|
-
if (this.size) {
|
|
71
|
-
attributes.push(`height=${this.size} width=${this.size}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return attributes.join(' ');
|
|
75
|
-
},
|
|
76
71
|
},
|
|
77
72
|
watch: {
|
|
78
73
|
colorReplacements: {
|
|
79
|
-
handler() {
|
|
80
|
-
|
|
74
|
+
handler(newVal, oldVal) {
|
|
75
|
+
if (
|
|
76
|
+
newVal &&
|
|
77
|
+
oldVal &&
|
|
78
|
+
JSON.stringify(newVal) !== JSON.stringify(oldVal)
|
|
79
|
+
) {
|
|
80
|
+
this.renderAsInnerHtml();
|
|
81
|
+
}
|
|
81
82
|
},
|
|
82
83
|
deep: true,
|
|
83
84
|
},
|
|
@@ -120,6 +121,35 @@ export default defineComponent({
|
|
|
120
121
|
}
|
|
121
122
|
},
|
|
122
123
|
methods: {
|
|
124
|
+
applySvgAttributes(svgData: string): string {
|
|
125
|
+
const attributes: string[] = [];
|
|
126
|
+
|
|
127
|
+
if (this.size) {
|
|
128
|
+
const widthRegex = getRegexToMatchAttributeInSvgTag('width');
|
|
129
|
+
|
|
130
|
+
if (svgData.match(widthRegex)) {
|
|
131
|
+
svgData = svgData.replace(widthRegex, `$1width="${this.size}"`);
|
|
132
|
+
} else {
|
|
133
|
+
attributes.push(`width="${this.size}"`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const heightRegex = getRegexToMatchAttributeInSvgTag('height');
|
|
137
|
+
|
|
138
|
+
if (svgData.match(heightRegex)) {
|
|
139
|
+
svgData = svgData.replace(heightRegex, `$1height="${this.size}"`);
|
|
140
|
+
} else {
|
|
141
|
+
attributes.push(`height="${this.size}"`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const svgAttributes = attributes.join(' ');
|
|
146
|
+
|
|
147
|
+
if (svgAttributes) {
|
|
148
|
+
svgData = svgData.replace('<svg ', `<svg ${svgAttributes} `);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return svgData;
|
|
152
|
+
},
|
|
123
153
|
async renderAsInnerHtml() {
|
|
124
154
|
if (!this.originalSvgData) {
|
|
125
155
|
return;
|
|
@@ -130,10 +160,19 @@ export default defineComponent({
|
|
|
130
160
|
this.colorReplacements,
|
|
131
161
|
);
|
|
132
162
|
|
|
133
|
-
this.svgData = this.svgData
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
163
|
+
this.svgData = this.applySvgAttributes(this.svgData);
|
|
164
|
+
|
|
165
|
+
const blob = new Blob([this.svgData], { type: 'image/svg+xml' });
|
|
166
|
+
|
|
167
|
+
const oldSvgDataObjectUrl = this.svgDataObjectUrl;
|
|
168
|
+
|
|
169
|
+
// Create an Object URL
|
|
170
|
+
this.svgDataObjectUrl = URL.createObjectURL(blob);
|
|
171
|
+
|
|
172
|
+
if (oldSvgDataObjectUrl) {
|
|
173
|
+
// clean up previous Object URL
|
|
174
|
+
URL.revokeObjectURL(oldSvgDataObjectUrl);
|
|
175
|
+
}
|
|
137
176
|
},
|
|
138
177
|
},
|
|
139
178
|
});
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="imgClasses">
|
|
3
3
|
<div
|
|
4
|
-
v-if="useObjectElement"
|
|
5
4
|
class="c-shape c-shape-object"
|
|
6
5
|
:class="{ 'tw-flex tw-justify-center tw-items-center': size }"
|
|
7
6
|
>
|
|
8
7
|
<object :style="objectStyle" :data="objectUrl" />
|
|
9
8
|
</div>
|
|
10
|
-
<div
|
|
11
|
-
v-else
|
|
12
|
-
class="c-shape"
|
|
13
|
-
:class="{ 'tw-flex tw-justify-center tw-items-center': size }"
|
|
14
|
-
v-html="svgData"
|
|
15
|
-
/>
|
|
16
9
|
</div>
|
|
17
10
|
</template>
|
|
18
11
|
<script>
|
|
@@ -24,3 +24,7 @@ export const setSvgCssStyle = (svgData: string, cssStyle: string): string => {
|
|
|
24
24
|
export const appendSvgIdSuffix = (svgData: string, svgIdSuffix: string) => {
|
|
25
25
|
return svgData.replace(/(SVGID(?:_\d+)+)/g, `$1_${svgIdSuffix}`);
|
|
26
26
|
};
|
|
27
|
+
|
|
28
|
+
export const getRegexToMatchAttributeInSvgTag = (attribute: string) => {
|
|
29
|
+
return new RegExp(`(<svg\\b[^>]*?)${attribute}="[^"]*"`, 'i');
|
|
30
|
+
};
|