@designcrowd/library.brand-page 5.12.10-shape-1 → 5.12.10

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.
Files changed (28) hide show
  1. package/lib/src/{CreatedOnBrandCrowd-de-de-B1UmWzii.js → CreatedOnBrandCrowd-de-de-D3t60Z73.js} +1 -1
  2. package/lib/src/{CreatedOnBrandCrowd-en-us-BRK1hM-D.js → CreatedOnBrandCrowd-en-us-Cewj15yq.js} +1 -1
  3. package/lib/src/{CreatedOnBrandCrowd-es-es-CN_2N7lq.js → CreatedOnBrandCrowd-es-es-Bw58VPNx.js} +1 -1
  4. package/lib/src/{CreatedOnBrandCrowd-fr-fr-BLLKZAU4.js → CreatedOnBrandCrowd-fr-fr-CxSCS2cD.js} +1 -1
  5. package/lib/src/{CreatedOnBrandCrowd-pt-pt-Btsu98RA.js → CreatedOnBrandCrowd-pt-pt-DA6ISEa6.js} +1 -1
  6. package/lib/src/{CreatedOnDcom-de-de-t1layjdN.js → CreatedOnDcom-de-de-BCc5tNd0.js} +1 -1
  7. package/lib/src/{CreatedOnDcom-en-us-Cgr8OWqD.js → CreatedOnDcom-en-us-B81q6Uaf.js} +1 -1
  8. package/lib/src/{CreatedOnDcom-es-es-BU30p1A3.js → CreatedOnDcom-es-es-9BUXweOj.js} +1 -1
  9. package/lib/src/{CreatedOnDcom-fr-fr-0WKXggE1.js → CreatedOnDcom-fr-fr-Du01yNDg.js} +1 -1
  10. package/lib/src/{CreatedOnDcom-pt-pt-DugorNKz.js → CreatedOnDcom-pt-pt-CdiSwYCz.js} +1 -1
  11. package/lib/src/brand-page/components/background-shape/BackgroundShape.mixin.d.ts +1 -3
  12. package/lib/src/brand-page/components/background-shape/BackgroundShape.mixin.js +8 -49
  13. package/lib/src/brand-page/components/media/Shape.mixin.d.ts +2 -3
  14. package/lib/src/brand-page/components/media/Shape.mixin.js +11 -44
  15. package/lib/src/brand-page/utils/svg.util.d.ts +0 -1
  16. package/lib/src/brand-page/utils/svg.util.js +0 -3
  17. package/lib/src/css/library.brand-page-brandCrowd.min.css +5 -5
  18. package/lib/src/css/library.brand-page-brandPage.min.css +5 -5
  19. package/lib/src/css/library.brand-page-designCom.min.css +5 -5
  20. package/lib/src/css/library.brand-page-preview.min.css +5 -5
  21. package/lib/src/index.mjs +1 -1
  22. package/lib/src/{lib-CjyTfIxl.js → lib-B-mA_0dk.js} +11586 -11602
  23. package/package.json +1 -1
  24. package/src/brand-page/components/background-shape/BackgroundShape.mixin.ts +12 -64
  25. package/src/brand-page/components/background-shape/BackgroundShape.vue +12 -2
  26. package/src/brand-page/components/media/Shape.mixin.ts +17 -56
  27. package/src/brand-page/components/media/Shape.vue +7 -0
  28. package/src/brand-page/utils/svg.util.ts +0 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@designcrowd/library.brand-page",
3
3
  "description": "A collection of Maker/Designer applications",
4
- "version": "5.12.10-shape-1",
4
+ "version": "5.12.10",
5
5
  "author": "Design.com Eng",
6
6
  "license": "UNLICENSED",
7
7
  "type": "module",
@@ -6,7 +6,6 @@ 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';
10
9
 
11
10
  const SUPPORTED_SHAPE_HOSTS = [
12
11
  'https://bc-user-uploads.brandcrowd.com/public',
@@ -22,7 +21,7 @@ export default defineComponent({
22
21
  },
23
22
  },
24
23
  data() {
25
- return { svgData: '', svgDataObjectUrl: '', originalSvgData: '' };
24
+ return { svgData: '', originalSvgData: '' };
26
25
  },
27
26
  computed: {
28
27
  useObjectElement(): boolean {
@@ -40,12 +39,15 @@ export default defineComponent({
40
39
  );
41
40
  },
42
41
 
43
- objectUrl(): string {
44
- if (!this.useObjectElement) {
45
- return this.svgDataObjectUrl;
42
+ svgAttributes(): string {
43
+ const attributes: string[] = [];
44
+
45
+ if (this.isFullBackground) {
46
+ attributes.push('preserveAspectRatio="xMidYMid slice"');
47
+ attributes.push('style="width: 100%; height: 100%;"');
46
48
  }
47
49
 
48
- return this.viewModel.name;
50
+ return attributes.join(' ');
49
51
  },
50
52
  },
51
53
  watch: {
@@ -72,49 +74,6 @@ export default defineComponent({
72
74
  );
73
75
  },
74
76
 
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
-
118
77
  async render() {
119
78
  if (this.useObjectElement) {
120
79
  return;
@@ -137,23 +96,12 @@ export default defineComponent({
137
96
  this.originalSvgData,
138
97
  this.viewModel.style.color,
139
98
  );
140
- } else {
141
- this.svgData = this.originalSvgData;
142
99
  }
143
100
 
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
- }
101
+ this.svgData = this.svgData.replace(
102
+ '<svg ',
103
+ `<svg ${this.svgAttributes} `,
104
+ );
157
105
  },
158
106
  },
159
107
  });
@@ -1,8 +1,18 @@
1
1
  <template>
2
2
  <div class="c-shape-background">
3
- <div :style="backgroundShapesStyle" class="c-shape c-shape-object">
4
- <object class="tw-w-full tw-h-full" :data="objectUrl" />
3
+ <div
4
+ v-if="useObjectElement"
5
+ :style="backgroundShapesStyle"
6
+ class="c-shape c-shape-object"
7
+ >
8
+ <object class="tw-w-full tw-h-full" :data="viewModel.name" />
5
9
  </div>
10
+ <div
11
+ v-else
12
+ :style="backgroundShapesStyle"
13
+ class="c-shape"
14
+ v-html="svgData"
15
+ />
6
16
  </div>
7
17
  </template>
8
18
  <script>
@@ -5,7 +5,6 @@ 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';
9
8
 
10
9
  export default defineComponent({
11
10
  mixins: [ComponentCommonMixin],
@@ -35,7 +34,7 @@ export default defineComponent({
35
34
  },
36
35
  },
37
36
  data() {
38
- return { svgData: '', svgDataObjectUrl: '', originalSvgData: '' };
37
+ return { svgData: '', originalSvgData: '' };
39
38
  },
40
39
  computed: {
41
40
  useObjectElement(): boolean {
@@ -54,10 +53,6 @@ export default defineComponent({
54
53
  },
55
54
 
56
55
  objectUrl() {
57
- if (!this.useObjectElement) {
58
- return this.svgDataObjectUrl;
59
- }
60
-
61
56
  let dimensionQuery = ``;
62
57
 
63
58
  if (this.size) {
@@ -68,17 +63,21 @@ export default defineComponent({
68
63
 
69
64
  return `${this.imageUrl}${dimensionQuery}`;
70
65
  },
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
+ },
71
76
  },
72
77
  watch: {
73
78
  colorReplacements: {
74
- handler(newVal, oldVal) {
75
- if (
76
- newVal &&
77
- oldVal &&
78
- JSON.stringify(newVal) !== JSON.stringify(oldVal)
79
- ) {
80
- this.renderAsInnerHtml();
81
- }
79
+ handler() {
80
+ this.renderAsInnerHtml();
82
81
  },
83
82
  deep: true,
84
83
  },
@@ -121,35 +120,6 @@ export default defineComponent({
121
120
  }
122
121
  },
123
122
  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
- },
153
123
  async renderAsInnerHtml() {
154
124
  if (!this.originalSvgData) {
155
125
  return;
@@ -160,19 +130,10 @@ export default defineComponent({
160
130
  this.colorReplacements,
161
131
  );
162
132
 
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
- }
133
+ this.svgData = this.svgData.replace(
134
+ '<svg ',
135
+ `<svg ${this.svgAttributes} `,
136
+ );
176
137
  },
177
138
  },
178
139
  });
@@ -1,11 +1,18 @@
1
1
  <template>
2
2
  <div :class="imgClasses">
3
3
  <div
4
+ v-if="useObjectElement"
4
5
  class="c-shape c-shape-object"
5
6
  :class="{ 'tw-flex tw-justify-center tw-items-center': size }"
6
7
  >
7
8
  <object :style="objectStyle" :data="objectUrl" />
8
9
  </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
+ />
9
16
  </div>
10
17
  </template>
11
18
  <script>
@@ -24,7 +24,3 @@ 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
- };