refactor: summarized components in FormElements

This commit is contained in:
robin committed 2026-07-25 18:50:55 +02:00
1 parent b97e5ea7bb
commit 9aa5443229
3 files changed
+20 -10

No files matched your search

+5 -5
View File
@@ -4,7 +4,7 @@ import { uploadCSVAction } from "./actions";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Card from "@/components/Card" import Card from "@/components/Card"
import Textfield from "@/components/Textfield"; import { Input } from "@/components/FormElements";
interface Songbook { interface Songbook {
id: number; id: number;
@@ -122,7 +122,7 @@ export default function AdminPage() {
<div className="space-y-4"> <div className="space-y-4">
<div> <div>
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Name des Buchs</label> <label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Name des Buchs</label>
<Textfield <Input.Text
type="text" type="text"
placeholder="z.B. Gesangbuch" placeholder="z.B. Gesangbuch"
value={newBookName} value={newBookName}
@@ -131,7 +131,7 @@ export default function AdminPage() {
</div> </div>
<div> <div>
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Sprache (Optional)</label> <label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Sprache (Optional)</label>
<Textfield <Input.Text
type="text" type="text"
placeholder="z.B. Deutsch" placeholder="z.B. Deutsch"
value={newBookLanguage} value={newBookLanguage}
@@ -167,7 +167,7 @@ export default function AdminPage() {
<div className="grid grid-cols-3 gap-2"> <div className="grid grid-cols-3 gap-2">
<div className="col-span-1"> <div className="col-span-1">
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Nummer</label> <label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Nummer</label>
<Textfield <Input.Text
type="text" type="text"
placeholder="12a" placeholder="12a"
value={number} value={number}
@@ -176,7 +176,7 @@ export default function AdminPage() {
</div> </div>
<div className="col-span-2"> <div className="col-span-2">
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Liedtitel</label> <label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Liedtitel</label>
<Textfield <Input.Text
type="text" type="text"
placeholder="Großer Gott, wir..." placeholder="Großer Gott, wir..."
value={title} value={title}
+2 -2
View File
@@ -2,7 +2,7 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import Textfield from "@/components/Textfield"; import { Input } from "@/components/FormElements";
interface Songbook { interface Songbook {
id: number; id: number;
@@ -96,7 +96,7 @@ export default function SenderPage() {
</h2> </h2>
<div className="mb-4"> <div className="mb-4">
<Textfield <Input.Text
type="text" type="text"
placeholder="Nach Songtitel oder Nummer suchen..." placeholder="Nach Songtitel oder Nummer suchen..."
value={song_search_name} value={song_search_name}
@@ -3,14 +3,24 @@ import { ComponentPropsWithoutRef } from "react";
interface TextfieldProps extends ComponentPropsWithoutRef<"input"> {} interface TextfieldProps extends ComponentPropsWithoutRef<"input"> {}
export default function Textfield({value, onChange, placeholder}: TextfieldProps) { function Textfield({value, onChange, placeholder}: TextfieldProps) {
return ( return (
<input <input
type="text"
placeholder="Nach Songtitel oder Nummer suchen..."
className="w-full border border-neutral-700 rounded-lg px-4 py-2.5 placeholder-neutral-500 focus:outline-none focus:border-blue-400 text-sm" className="w-full border border-neutral-700 rounded-lg px-4 py-2.5 placeholder-neutral-500 focus:outline-none focus:border-blue-400 text-sm"
value={value} value={value}
onChange={onChange} onChange={onChange}
placeholder={placeholder}
/> />
) )
} }
function Dropdown() {
return (
<p></p>
)
}
export const Input = {
Text: Textfield,
Select: Dropdown,
};