Skip to content

Commit c6b88b7

Browse files
authored
fix(cms-base-layer): render CMS button links with correct styling (#2210)
* fix(cms-base-layer): render CMS button links with correct styling * fix(templates): add missing surface-surface-primary for vue-demo-store
1 parent 96ec1be commit c6b88b7

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.changeset/dirty-hats-cry.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@shopware/cms-base-layer": patch
3+
---
4+
5+
Anchor tags with "btn btn-primary" classes from the API were not being
6+
transformed to Tailwind utility classes due to condition matching issues
7+
in the html-to-vue renderer.

packages/cms-base-layer/app/components/public/cms/element/CmsElementText.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const CmsTextRender = defineComponent({
3737
return (
3838
node.type === "tag" &&
3939
node.name === "a" &&
40-
!node.attrs?.class?.match(/btn\s?/)
40+
!node.attrs?.class?.includes("btn")
4141
);
4242
},
4343
renderer(
@@ -61,7 +61,7 @@ const CmsTextRender = defineComponent({
6161
return (
6262
node.type === "tag" &&
6363
node.name === "a" &&
64-
node.attrs?.class?.match(/btn\s?/)
64+
!!node.attrs?.class?.includes("btn")
6565
);
6666
},
6767
renderer(
@@ -75,14 +75,16 @@ const CmsTextRender = defineComponent({
7575
"rounded-md inline-block my-2 py-2 px-4 border border-transparent text-sm font-medium focus:outline-none disabled:opacity-75";
7676
7777
_class = node.attrs.class
78+
.replace(/\bbtn\s+/, "")
7879
.replace(
7980
"btn-secondary",
8081
`${btnClass} bg-brand-secondary text-brand-on-secondary hover:bg-brand-secondary-hover`,
8182
)
8283
.replace(
8384
"btn-primary",
8485
`${btnClass} bg-brand-primary text-brand-on-primary hover:bg-brand-primary-hover`,
85-
);
86+
)
87+
.trim();
8688
}
8789
8890
return createElement(

packages/cms-base-layer/app/helpers/html-to-vue/renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function renderer(ast, config, createElement, context, resolveUrl) {
3939
if (typeof config.extraComponentsMap[node.name] !== "undefined") {
4040
return config.extraComponentsMap[node.name].renderer.call(
4141
this,
42-
transformedNode,
42+
node,
4343
children,
4444
h,
4545
context,

templates/vue-demo-store/uno.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ const templateConfig: ConfigBase = {
9898
"warning-900": "#713f12",
9999
// Surface Colors (example for the transformer)
100100
"surface-surface": "#ffffff",
101+
"surface-surface-primary": "#f0f8ff",
101102
"surface-surface-variant": "#f5f5f5",
102103
"surface-container": "#f0f0f0",
103104
"surface-container-high": "#e8e8e8",

0 commit comments

Comments
 (0)