Skip to content

Commit 2636128

Browse files
committed
refactor(billing-status-badge): update badges to use buttons with icons
Change VipBadge element from div to button for better semantics and interaction. Add buttonSize getter to map size args to PrimaryButton sizes. Replace VIP and Member badges' container div/span with flex containers that include shield-check icons and consistent spacing. This improves accessibility, styling, and consistency across badges by using PrimaryButton and PrimaryLinkButton components.
1 parent bd6b223 commit 2636128

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

app/components/billing-status-badge/indirect-member-badge.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<a href="https://docs.codecrafters.io/membership/content" target="_blank" rel="noopener noreferrer" data-test-indirect-member-badge ...attributes>
22
<PrimaryButton @size={{this.linkButtonSize}}>
3-
<span class="flex items-center">
4-
Member
5-
{{svg-jar "shield-check" class="w-4 ml-1 fill-current"}}
3+
<span class="flex items-center gap-1 flex-nowrap">
4+
<span>Member</span>
5+
{{svg-jar "shield-check" class="w-4 fill-current"}}
66
</span>
77

88
<EmberTooltip @text="You have access to all CodeCrafters membership benefits. Click here to learn more." />
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<PrimaryLinkButton @size={{this.linkButtonSize}} @route="settings.billing" data-test-member-badge ...attributes>
2-
3-
<span class="flex items-center">
4-
Member
5-
{{svg-jar "shield-check" class="w-4 ml-1 fill-current"}}
6-
</span>
2+
<div class="flex items-center gap-1 flex-nowrap">
3+
<span>Member</span>
4+
{{svg-jar "shield-check" class="w-4 fill-current"}}
5+
</div>
76

87
<EmberTooltip @text="You're a CodeCrafters member. Click here to view your membership details." />
98
</PrimaryLinkButton>
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
<div
2-
class="text-white font-semibold bg-teal-500 rounded-sm flex items-center justify-center
3-
{{if (eq this.size 'small') 'text-xs px-2 py-1'}}
4-
{{if (eq this.size 'large') 'text-sm px-3 py-1.5'}}"
5-
data-test-vip-badge
6-
...attributes
7-
>
8-
VIP
9-
10-
{{svg-jar "shield-check" class="w-4 ml-1 fill-current"}}
1+
<PrimaryButton @size={{this.buttonSize}} data-test-vip-badge ...attributes>
2+
<div class="flex items-center gap-1 flex-nowrap">
3+
<span>VIP</span>
4+
{{svg-jar "shield-check" class="w-4 fill-current"}}
5+
</div>
116

127
{{#if this.currentUser.vipStatusExpiresAt}}
138
<EmberTooltip
@@ -19,4 +14,4 @@
1914
{{else}}
2015
<EmberTooltip @text="You have access to all CodeCrafters content & membership features." />
2116
{{/if}}
22-
</div>
17+
</PrimaryButton>

app/components/billing-status-badge/vip-badge.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type UserModel from 'codecrafters-frontend/models/user';
44
import type AuthenticatorService from 'codecrafters-frontend/services/authenticator';
55

66
interface Signature {
7-
Element: HTMLDivElement;
7+
Element: HTMLButtonElement;
88

99
Args: {
1010
size: 'small' | 'large';
@@ -14,6 +14,12 @@ interface Signature {
1414
export default class VipBadge extends Component<Signature> {
1515
@service declare authenticator: AuthenticatorService;
1616

17+
get buttonSize() {
18+
// arg:small -> PrimaryButton size:extra-small
19+
// arg:large -> small
20+
return this.args.size === 'large' ? 'small' : 'extra-small';
21+
}
22+
1723
get currentUser() {
1824
return this.authenticator.currentUser as UserModel;
1925
}

0 commit comments

Comments
 (0)