Compare commits
2 commits
402b6623dd
...
c5ebdff97b
Author | SHA1 | Date | |
---|---|---|---|
c5ebdff97b | |||
b198d91029 |
5 changed files with 46 additions and 6 deletions
|
@ -15,6 +15,7 @@
|
|||
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
||||
"@fortawesome/react-fontawesome": "^0.2.2",
|
||||
"@radix-ui/react-label": "^2.1.6",
|
||||
"@radix-ui/react-slot": "^1.2.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
export default function LabeledInput({
|
||||
type,
|
||||
|
@ -11,17 +12,17 @@ export default function LabeledInput({
|
|||
placeholder?: string;
|
||||
value?: string;
|
||||
}) {
|
||||
const randomId = Math.random().toString(36).substring(2, 15);
|
||||
const elementId = Math.random().toString(36).substring(2, 15);
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-2'>
|
||||
<label htmlFor={randomId}>{label}</label>
|
||||
<div className='flex flex-col gap-1'>
|
||||
<Label htmlFor={elementId}>{label}</Label>
|
||||
|
||||
<Input
|
||||
type={type}
|
||||
placeholder={placeholder}
|
||||
defaultValue={value}
|
||||
id={randomId}
|
||||
id={elementId}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
24
src/components/ui/label.tsx
Normal file
24
src/components/ui/label.tsx
Normal 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 };
|
|
@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button';
|
|||
|
||||
export default function LoginForm() {
|
||||
return (
|
||||
<form className='flex flex-col gap-4 w-full'>
|
||||
<form className='flex flex-col gap-5 w-full'>
|
||||
<LabeledInput
|
||||
type='email'
|
||||
label='E-Mail'
|
||||
|
|
16
yarn.lock
16
yarn.lock
|
@ -630,7 +630,21 @@
|
|||
resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.2.tgz#a2c4c47af6337048ee78ff6dc0d090b390d2bb30"
|
||||
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"
|
||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.2.2.tgz#18e6533e778a2051edc2ad0773da8e22f03f626a"
|
||||
integrity sha512-y7TBO4xN4Y94FvcWIOIh18fM4R1A8S4q1jhoz4PNzOoHsFcN8pogcFmZrTYAm4F9VRUrWP/Mw7xSKybIeRI+CQ==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue