Skip to content

Commit

Permalink
Update input UI
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Nov 20, 2024
1 parent 0580257 commit 034f9f8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion web/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"v3xlabs"
],
"env": {
"node": true
"browser": true
},
"rules": {}
}
36 changes: 36 additions & 0 deletions web/src/components/ui/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { cx } from 'class-variance-authority';
import type { InputHTMLAttributes } from 'react';
import { forwardRef, useId } from 'react';

type InputProperties = InputHTMLAttributes<HTMLInputElement>;

export const Input = forwardRef<HTMLInputElement, InputProperties>(
({ className, 'aria-label': ariaLabel, ...properties }, reference) => {
const labelId = useId();

return (
<>
<label
className="flex flex-col gap-1"
id={'l' + labelId}
htmlFor={'i' + labelId}
>
<span className="text-sm text-text-secondary">
{ariaLabel}
</span>
<input
ref={reference}
aria-label={ariaLabel}
aria-labelledby={'l' + labelId}
id={'i' + labelId}
className={cx(
'text-base font-sans px-2 py-1',
className
)}
{...properties}
/>
</label>
</>
);
}
);
13 changes: 12 additions & 1 deletion web/src/routes/configure/_layout.instance/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { createFileRoute } from '@tanstack/react-router';

import { Button } from '../../../components/ui/Button';
import { Input } from '../../../components/ui/Input';

export const Route = createFileRoute('/configure/_layout/instance/')({
component: () => <div>Hello /configure/instance/!</div>,
component: () => (
<div className="space-y-2 flex flex-col">
<Input
placeholder="http://localhost:8000"
aria-label="Instance URL"
/>
<Button>Save</Button>
</div>
),
});

0 comments on commit 034f9f8

Please sign in to comment.