enhancement: update input component dynamic text alignment (#2712)
This commit is contained in:
parent
09fcdac75c
commit
1619478250
@ -20,6 +20,7 @@ export type InputComponentProps = {
|
|||||||
placeholder: string
|
placeholder: string
|
||||||
value: string
|
value: string
|
||||||
type?: InputType
|
type?: InputType
|
||||||
|
textAlign?: 'left' | 'right'
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SliderComponentProps = {
|
export type SliderComponentProps = {
|
||||||
|
|||||||
@ -15,7 +15,8 @@
|
|||||||
"controllerType": "input",
|
"controllerType": "input",
|
||||||
"controllerProps": {
|
"controllerProps": {
|
||||||
"value": "120000",
|
"value": "120000",
|
||||||
"placeholder": "Interval in milliseconds. E.g. 120000"
|
"placeholder": "Interval in milliseconds. E.g. 120000",
|
||||||
|
"textAlign": "right"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -2,14 +2,20 @@ import { forwardRef } from 'react'
|
|||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
export interface InputProps
|
export interface InputProps
|
||||||
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||||
|
textAlign?: 'left' | 'right'
|
||||||
|
}
|
||||||
|
|
||||||
const Input = forwardRef<HTMLInputElement, InputProps>(
|
const Input = forwardRef<HTMLInputElement, InputProps>(
|
||||||
({ className, type, ...props }, ref) => {
|
({ className, type, textAlign, ...props }, ref) => {
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type={type}
|
type={type}
|
||||||
className={twMerge('input', className)}
|
className={twMerge(
|
||||||
|
'input',
|
||||||
|
className,
|
||||||
|
textAlign === 'right' && 'text-right'
|
||||||
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -3,4 +3,7 @@
|
|||||||
@apply disabled:text-muted-foreground disabled:cursor-not-allowed disabled:bg-zinc-100 disabled:dark:bg-zinc-800 disabled:dark:text-zinc-600;
|
@apply disabled:text-muted-foreground disabled:cursor-not-allowed disabled:bg-zinc-100 disabled:dark:bg-zinc-800 disabled:dark:text-zinc-600;
|
||||||
@apply focus-within:outline-none focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1;
|
@apply focus-within:outline-none focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-1;
|
||||||
@apply file:border-0 file:bg-transparent file:font-medium;
|
@apply file:border-0 file:bg-transparent file:font-medium;
|
||||||
|
&.text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,7 @@ const SliderRightPanel: React.FC<Props> = ({
|
|||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
value={String(value)}
|
value={String(value)}
|
||||||
|
textAlign="right"
|
||||||
disabled={!enabled}
|
disabled={!enabled}
|
||||||
onBlur={(e) => {
|
onBlur={(e) => {
|
||||||
if (Number(e.target.value) > Number(max)) {
|
if (Number(e.target.value) > Number(max)) {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ const SettingDetailTextInputItem: React.FC<Props> = ({
|
|||||||
settingProps,
|
settingProps,
|
||||||
onValueChanged,
|
onValueChanged,
|
||||||
}) => {
|
}) => {
|
||||||
const { value, type, placeholder } =
|
const { value, type, placeholder, textAlign } =
|
||||||
settingProps.controllerProps as InputComponentProps
|
settingProps.controllerProps as InputComponentProps
|
||||||
|
|
||||||
const description = marked.parse(settingProps.description ?? '', {
|
const description = marked.parse(settingProps.description ?? '', {
|
||||||
@ -43,6 +43,7 @@ const SettingDetailTextInputItem: React.FC<Props> = ({
|
|||||||
<Input
|
<Input
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
type={type}
|
type={type}
|
||||||
|
textAlign={textAlign}
|
||||||
value={value}
|
value={value}
|
||||||
className="ml-4 w-[360px]"
|
className="ml-4 w-[360px]"
|
||||||
onChange={(e) => onValueChanged?.(e.target.value)}
|
onChange={(e) => onValueChanged?.(e.target.value)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user