Compare commits

...

2 commits

Author SHA1 Message Date
c5ebdff97b fix: update LabeledInput component to use Label from UI library and adjust spacing in LoginForm
All checks were successful
docker-build / docker (pull_request) Successful in 3m11s
container-scan / Container Scan (pull_request) Successful in 5m15s
2025-05-11 13:46:40 +02:00
b198d91029 feat: add Radix UI label component and update dependencies 2025-05-11 13:46:31 +02:00
5 changed files with 46 additions and 6 deletions

View file

@ -15,6 +15,7 @@
"@fortawesome/free-regular-svg-icons": "^6.7.2", "@fortawesome/free-regular-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2", "@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.2", "@fortawesome/react-fontawesome": "^0.2.2",
"@radix-ui/react-label": "^2.1.6",
"@radix-ui/react-slot": "^1.2.2", "@radix-ui/react-slot": "^1.2.2",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",

View file

@ -1,4 +1,5 @@
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
export default function LabeledInput({ export default function LabeledInput({
type, type,
@ -11,17 +12,17 @@ export default function LabeledInput({
placeholder?: string; placeholder?: string;
value?: string; value?: string;
}) { }) {
const randomId = Math.random().toString(36).substring(2, 15); const elementId = Math.random().toString(36).substring(2, 15);
return ( return (
<div className='flex flex-col gap-2'> <div className='flex flex-col gap-1'>
<label htmlFor={randomId}>{label}</label> <Label htmlFor={elementId}>{label}</Label>
<Input <Input
type={type} type={type}
placeholder={placeholder} placeholder={placeholder}
defaultValue={value} defaultValue={value}
id={randomId} id={elementId}
/> />
</div> </div>
); );

View file

@ -0,0 +1,24 @@
'use client';
import * as React from 'react';
import * as LabelPrimitive from '@radix-ui/react-label';
import { cn } from '@/lib/utils';
function Label({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
data-slot='label'
className={cn(
'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
className,
)}
{...props}
/>
);
}
export { Label };

View file

@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button';
export default function LoginForm() { export default function LoginForm() {
return ( return (
<form className='flex flex-col gap-4 w-full'> <form className='flex flex-col gap-5 w-full'>
<LabeledInput <LabeledInput
type='email' type='email'
label='E-Mail' label='E-Mail'

View file

@ -630,7 +630,21 @@
resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.2.tgz#a2c4c47af6337048ee78ff6dc0d090b390d2bb30" resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.2.tgz#a2c4c47af6337048ee78ff6dc0d090b390d2bb30"
integrity sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg== integrity sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg==
"@radix-ui/react-slot@^1.2.2": "@radix-ui/react-label@^2.1.6":
version "2.1.6"
resolved "https://registry.yarnpkg.com/@radix-ui/react-label/-/react-label-2.1.6.tgz#45ebd1381996d0311d199781bed15a092c7978dd"
integrity sha512-S/hv1mTlgcPX2gCTJrWuTjSXf7ER3Zf7zWGtOprxhIIY93Qin3n5VgNA0Ez9AgrK/lEtlYgzLd4f5x6AVar4Yw==
dependencies:
"@radix-ui/react-primitive" "2.1.2"
"@radix-ui/react-primitive@2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-2.1.2.tgz#03f64f957719c761d22c2f92cc43ffb64bd42cc8"
integrity sha512-uHa+l/lKfxuDD2zjN/0peM/RhhSmRjr5YWdk/37EnSv1nJ88uvG85DPexSm8HdFQROd2VdERJ6ynXbkCFi+APw==
dependencies:
"@radix-ui/react-slot" "1.2.2"
"@radix-ui/react-slot@1.2.2", "@radix-ui/react-slot@^1.2.2":
version "1.2.2" version "1.2.2"
resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.2.2.tgz#18e6533e778a2051edc2ad0773da8e22f03f626a" resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.2.2.tgz#18e6533e778a2051edc2ad0773da8e22f03f626a"
integrity sha512-y7TBO4xN4Y94FvcWIOIh18fM4R1A8S4q1jhoz4PNzOoHsFcN8pogcFmZrTYAm4F9VRUrWP/Mw7xSKybIeRI+CQ== integrity sha512-y7TBO4xN4Y94FvcWIOIh18fM4R1A8S4q1jhoz4PNzOoHsFcN8pogcFmZrTYAm4F9VRUrWP/Mw7xSKybIeRI+CQ==