Skip to content

Commit cc5f867

Browse files
authored
refactor: use define for evo-card (#460)
1 parent f803969 commit cc5f867

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

.changeset/fast-views-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@evo-web/marko": patch
3+
---
4+
5+
Refactor evo-card

packages/evo-marko/src/tags/evo-card/index.marko

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ export interface Input extends Omit<Marko.HTML.Span, "title"> {
2424
...htmlInput
2525
}=input>
2626

27-
<const/[tagName, extraAttrs]=((): [string, Marko.HTML.A | Marko.HTML.Button] => {
28-
if (action) {
29-
return ["span", {}];
30-
} else if (href) {
31-
return ["a", { href: disabled ? "" : href }];
32-
} else {
33-
return ["button", { type: "button", disabled }];
34-
}
35-
})()>
27+
<define/Root|input: (Marko.HTML.Span | Marko.HTML.A | Marko.HTML.Button)|>
28+
<if=action>
29+
<span ...(input as Marko.HTML.Span)/>
30+
</if>
31+
<else if=href>
32+
<a ...(input as Marko.HTML.A) href=disabled ? "" : href/>
33+
</else>
34+
<else>
35+
<button ...(input as Marko.HTML.Button) type="button" disabled=disabled/>
36+
</else>
37+
</define>
3638

37-
<${tagName} ...htmlInput ...extraAttrs class=[
39+
<Root ...htmlInput class=[
3840
"card",
3941
aspectRatio === "5:4" && "card--aspect-5-4",
4042
aspectRatio === "16:9" && "card--aspect-16-9",

0 commit comments

Comments
 (0)