mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 05:26:20 +00:00
First shlink-frontend-kit iteration
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
import type { FC, PropsWithChildren } from 'react';
|
||||
import type { InputType } from 'reactstrap/types/lib/Input';
|
||||
import { useDomId } from '../helpers/hooks';
|
||||
import { LabeledFormGroup } from './LabeledFormGroup';
|
||||
|
||||
export type InputFormGroupProps = PropsWithChildren<{
|
||||
value: string;
|
||||
onChange: (newValue: string) => void;
|
||||
type?: InputType;
|
||||
required?: boolean;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
labelClassName?: string;
|
||||
}>;
|
||||
|
||||
export const InputFormGroup: FC<InputFormGroupProps> = (
|
||||
{ children, value, onChange, type, required, placeholder, className, labelClassName },
|
||||
) => {
|
||||
const id = useDomId();
|
||||
|
||||
return (
|
||||
<LabeledFormGroup label={<>{children}:</>} className={className ?? ''} labelClassName={labelClassName} id={id}>
|
||||
<input
|
||||
id={id}
|
||||
className="form-control"
|
||||
type={type ?? 'text'}
|
||||
value={value}
|
||||
required={required ?? true}
|
||||
placeholder={placeholder}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
</LabeledFormGroup>
|
||||
);
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
||||
|
||||
type LabeledFormGroupProps = PropsWithChildren<{
|
||||
label: ReactNode;
|
||||
noMargin?: boolean;
|
||||
className?: string;
|
||||
labelClassName?: string;
|
||||
id?: string;
|
||||
}>;
|
||||
|
||||
/* eslint-disable jsx-a11y/label-has-associated-control */
|
||||
export const LabeledFormGroup: FC<LabeledFormGroupProps> = (
|
||||
{ children, label, className = '', labelClassName = '', noMargin = false, id },
|
||||
) => (
|
||||
<div className={`${className} ${noMargin ? '' : 'mb-3'}`}>
|
||||
<label className={`form-label ${labelClassName}`} htmlFor={id}>{label}</label>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
Reference in New Issue
Block a user