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
7 changes: 7 additions & 0 deletions .changeset/dirty-hats-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@shopware/cms-base-layer": patch
---

Anchor tags with "btn btn-primary" classes from the API were not being
transformed to Tailwind utility classes due to condition matching issues
in the html-to-vue renderer.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CmsTextRender = defineComponent({
return (
node.type === "tag" &&
node.name === "a" &&
!node.attrs?.class?.match(/btn\s?/)
!node.attrs?.class?.includes("btn")
);
},
renderer(
Expand All @@ -61,7 +61,7 @@ const CmsTextRender = defineComponent({
return (
node.type === "tag" &&
node.name === "a" &&
node.attrs?.class?.match(/btn\s?/)
!!node.attrs?.class?.includes("btn")
);
},
renderer(
Expand All @@ -75,14 +75,16 @@ const CmsTextRender = defineComponent({
"rounded-md inline-block my-2 py-2 px-4 border border-transparent text-sm font-medium focus:outline-none disabled:opacity-75";

_class = node.attrs.class
.replace(/\bbtn\s+/, "")
.replace(
"btn-secondary",
`${btnClass} bg-brand-secondary text-brand-on-secondary hover:bg-brand-secondary-hover`,
)
.replace(
"btn-primary",
`${btnClass} bg-brand-primary text-brand-on-primary hover:bg-brand-primary-hover`,
);
)
.trim();
Comment on lines 77 to +87
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of replacements can lead to incomplete transformation. If the class attribute contains "btn" without a trailing space (e.g., "btn-primary btn" or just "btn"), the first replacement won't match, leaving "btn" in the final output. Consider replacing specific variants (btn-primary, btn-secondary) first, then removing any remaining "btn" word with a global word-boundary regex like /\bbtn\b/g to handle all cases regardless of position.

Copilot uses AI. Check for mistakes.
}

return createElement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function renderer(ast, config, createElement, context, resolveUrl) {
if (typeof config.extraComponentsMap[node.name] !== "undefined") {
return config.extraComponentsMap[node.name].renderer.call(
this,
transformedNode,
node,
children,
h,
context,
Expand Down
1 change: 1 addition & 0 deletions templates/vue-demo-store/uno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const templateConfig: ConfigBase = {
"warning-900": "#713f12",
// Surface Colors (example for the transformer)
"surface-surface": "#ffffff",
"surface-surface-primary": "#f0f8ff",
"surface-surface-variant": "#f5f5f5",
"surface-container": "#f0f0f0",
"surface-container-high": "#e8e8e8",
Expand Down