Skip to content

Commit 66da45f

Browse files
committed
update compiler plugin tests, components lib
1 parent 06e4487 commit 66da45f

20 files changed

Lines changed: 909 additions & 213 deletions

File tree

lang/libs/components/src/Alert.ch

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public #universal AlertInfo(props) {
172172
return <Alert {...props} variant="info">{props.children}</Alert>
173173
}
174174

175+
// Destructive variant (shadcn naming convention)
176+
public #universal AlertDestructive(props) {
177+
return <Alert {...props} variant="error">{props.children}</Alert>
178+
}
179+
175180
// Shadcn AlertAction: positioned absolutely in the top-right corner of the alert.
176181
func alert_action_styles(page : &mut HtmlPage) : *char {
177182
return #css {

lang/libs/components/src/Avatar.ch

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,10 @@ public #universal Avatar(props) {
8585
var size = props.size || "md"
8686
var out = classes + " " + ${avatar_styles(page)}
8787
var bordered = props.bordered ? "true" : "false"
88-
return <span data-size={size} data-bordered={bordered} class={out}>{
89-
props.src ? <img class={${avatar_img_styles(page)}} src={props.src} alt={props.alt} />
90-
: (props.fallback ? <span class={${avatar_fallback_styles(page)}}>{props.fallback}</span> : props.children)
91-
}</span>
92-
}
93-
94-
public #universal AvatarGroup(props) {
95-
var classes = props.class || ""
96-
if(props.className) { classes = props.className }
97-
return <div class={classes + " " + ${avatar_group_styles(page)}}>{props.children}</div>
88+
return <span data-size={size} data-bordered={bordered} class={out}>
89+
{props.src ? <img class={${avatar_img_styles(page)}} src={props.src} alt={props.alt} />
90+
: (props.fallback ? <span class={${avatar_fallback_styles(page)}}>{props.fallback}</span> : props.children)}
91+
</span>
9892
}
9993

10094
public #universal AvatarMore(props) {
@@ -104,6 +98,39 @@ public #universal AvatarMore(props) {
10498
return <span class={classes + " " + ${avatar_count_styles(page)}}>{count}</span>
10599
}
106100

101+
// Shadcn AvatarBadge: online/status indicator positioned bottom-right of avatar
102+
func avatar_badge_styles(page : &mut HtmlPage) : *char {
103+
return #css {
104+
position: absolute;
105+
bottom: 0;
106+
right: 0;
107+
width: 12px;
108+
height: 12px;
109+
border-radius: 9999px;
110+
border: 2px solid hsl(var(--background));
111+
background: hsl(var(--success));
112+
}
113+
}
114+
115+
public #universal AvatarBadge(props) {
116+
var classes = (props.className || props.class) || ""
117+
return <span class={classes + " " + ${avatar_badge_styles(page)}} aria-label={props.label || "status"}></span>
118+
}
119+
120+
// Shadcn AvatarGroup: overlapping avatar group container
121+
public #universal AvatarGroup(props) {
122+
var classes = (props.className || props.class) || ""
123+
var max = props.max || 0
124+
var children = props.children
125+
return <div class={classes + " " + ${avatar_group_styles(page)}}>{children}</div>
126+
}
127+
128+
// Shadcn AvatarGroupCount: shows +N overflow count
129+
public #universal AvatarGroupCount(props) {
130+
var classes = (props.className || props.class) || ""
131+
return <span class={classes + " " + ${avatar_count_styles(page)}}>{props.children}</span>
132+
}
133+
107134
// Legacy aliases
108135
public #universal AvatarSm(props) {
109136
return <Avatar {...props} size="sm">{props.children}</Avatar>

lang/libs/components/src/Badge.ch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ func badge_styles(page : &mut HtmlPage) : *char {
7272
color: hsl(var(--info));
7373
background: transparent;
7474
}
75+
&[data-variant="ghost"] {
76+
background: transparent;
77+
border-color: transparent;
78+
color: hsl(var(--foreground));
79+
&:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
80+
}
81+
&[data-variant="link"] {
82+
background: transparent;
83+
border-color: transparent;
84+
color: hsl(var(--primary));
85+
text-decoration: underline;
86+
text-underline-offset: 4px;
87+
cursor: pointer;
88+
&:hover { text-decoration: underline; }
89+
}
7590
&[data-size="xs"] {
7691
font-size: 0.625rem;
7792
padding: 0 0.4375rem;
@@ -134,3 +149,9 @@ public #universal BadgeInfo(props) {
134149
public #universal BadgeWarning(props) {
135150
return <Badge {...props} variant="warning">{props.children}</Badge>
136151
}
152+
public #universal BadgeGhost(props) {
153+
return <Badge {...props} variant="ghost">{props.children}</Badge>
154+
}
155+
public #universal BadgeLink(props) {
156+
return <Badge {...props} variant="link">{props.children}</Badge>
157+
}

lang/libs/components/src/Card.ch

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ func card_styles(page : &mut HtmlPage) : *char {
1919
box-shadow: var(--shadow-md);
2020
}
2121
}
22+
&[data-size="sm"] {
23+
gap: 0.25rem;
24+
padding: 0;
25+
& > [data-slot="card-header"] { padding: 0.75rem 0.75rem 0; }
26+
& > [data-slot="card-content"] { padding: 0 0.75rem; }
27+
& > [data-slot="card-footer"] { padding: 0 0.75rem 0.75rem; }
28+
}
2229
}
2330
}
2431

@@ -95,8 +102,9 @@ func card_footer_styles(page : &mut HtmlPage) : *char {
95102
public #universal Card(props) {
96103
var classes = props.class || ""
97104
if(props.className) { classes = props.className }
105+
var size = props.size || "default"
98106
var out = classes + " " + ${card_styles(page)}
99-
return <div data-interactive={props.onClick ? "true" : "false"} class={out} onClick={props.onClick}>{props.children}</div>
107+
return <div data-interactive={props.onClick ? "true" : "false"} data-size={size != "default" ? size : null} class={out} onClick={props.onClick}>{props.children}</div>
100108
}
101109

102110
public #universal CardHeader(props) {

0 commit comments

Comments
 (0)