Skip to content

Commit 7ef7bcd

Browse files
authored
Merge pull request #145 from peternnadi1999/feat/ui-label-component
feat(ui): add reusable Label component
2 parents c6c7c07 + a4b08e0 commit 7ef7bcd

4 files changed

Lines changed: 48 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@radix-ui/react-slot": "^1.2.3",
2727
"@radix-ui/react-switch": "^1.3.7",
2828
"@radix-ui/react-tabs": "^1.1.13",
29+
"@radix-ui/react-label":"^2.1.15",
2930
"@radix-ui/react-tooltip": "^1.2.16",
3031
"@stellar/freighter-api": "^5.0.0",
3132
"@stellar/stellar-sdk": "^14.1.1",

src/app/register/register-client.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ export function RegisterClient() {
391391
}
392392
required
393393
/>
394+
</div>
395+
<div className="grid gap-2">
396+
<Label htmlFor="lastName">Last name</Label>
397+
<Input
398+
id="lastName"
394399
</label>
395400
<label className="grid gap-2 text-sm font-medium">
396401
Last name
@@ -401,6 +406,11 @@ export function RegisterClient() {
401406
}
402407
required
403408
/>
409+
</div>
410+
<div className="grid gap-2 sm:col-span-2">
411+
<Label htmlFor="email">Email address</Label>
412+
<Input
413+
id="email"
404414
</label>
405415
<label className="grid gap-2 text-sm font-medium sm:col-span-2">
406416
Email address
@@ -412,23 +422,23 @@ export function RegisterClient() {
412422
onChange={(event) => updateField("email", event.target.value)}
413423
required
414424
/>
415-
</label>
425+
</div>
416426
</div>
417427
) : null}
418428

419429
{step === 2 ? (
420430
<div className="grid gap-4">
421-
<label className="grid gap-2 text-sm font-medium">
422-
Business name
423-
<input
424-
className="h-11 rounded-md border bg-background px-3 text-sm outline-none focus:border-primary focus:ring-2 focus:ring-primary/20"
431+
<div className="grid gap-2">
432+
<Label htmlFor="businessName">Business name</Label>
433+
<Input
434+
id="businessName"
425435
value={values.businessName}
426436
onChange={(event) =>
427437
updateField("businessName", event.target.value)
428438
}
429439
required
430440
/>
431-
</label>
441+
</div>
432442
<label className="grid gap-2 text-sm font-medium">
433443
Business logo
434444
<input
@@ -609,4 +619,4 @@ export function RegisterClient() {
609619
</section>
610620
</main>
611621
);
612-
}
622+
}

src/components/ui/input.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
66
({ className, type, ...props }, ref) => {
77
return (
88
<input
9+
ref={ref}
10+
type={type}
11+
data-slot="input"
12+
className={cn(
13+
"h-11 w-full rounded-md border bg-background px-3 text-sm outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50",
14+
"file:mr-3 file:rounded-md file:border-0 file:bg-secondary file:px-3 file:py-2 file:text-sm file:font-semibold file:text-primary",
915
type={type}
1016
ref={ref}
1117
data-slot="input"
@@ -22,3 +28,4 @@ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
2228
Input.displayName = "Input";
2329

2430
export { Input };
31+
export { Input };

src/components/ui/label.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import * as React from "react";
2+
import * as LabelPrimitive from "@radix-ui/react-label";
3+
4+
import { cn } from "@/lib/utils";
5+
6+
const Label = React.forwardRef<
7+
React.ElementRef<typeof LabelPrimitive.Root>,
8+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
9+
>(({ className, ...props }, ref) => (
10+
<LabelPrimitive.Root
11+
ref={ref}
12+
data-slot="label"
13+
className={cn(
14+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
15+
className,
16+
)}
17+
{...props}
18+
/>
19+
));
20+
21+
Label.displayName = LabelPrimitive.Root.displayName;
22+
23+
export { Label };

0 commit comments

Comments
 (0)