fix text field multiline

This commit is contained in:
Sebastian 2022-06-22 14:44:14 -03:00
parent ea0baf2508
commit b06ae62de0
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
5 changed files with 41 additions and 42 deletions

View File

@ -37,7 +37,7 @@ const Container = styled.div`
} }
`; `;
const BasicExample = (variant: Props["variant"]): VNode => { const Input = (variant: Props["variant"]): VNode => {
const [value, onChange] = useState(""); const [value, onChange] = useState("");
return ( return (
<Container> <Container>
@ -80,9 +80,8 @@ const BasicExample = (variant: Props["variant"]): VNode => {
); );
}; };
export const Standard = (): VNode => BasicExample("standard"); export const InputStandard = (): VNode => Input("standard");
export const Filled = (): VNode => BasicExample("filled"); export const InputFilled = (): VNode => Input("filled");
export const Outlined = (): VNode => BasicExample("outlined");
export const Color = (): VNode => { export const Color = (): VNode => {
const [value, onChange] = useState(""); const [value, onChange] = useState("");
@ -92,40 +91,53 @@ export const Color = (): VNode => {
variant="standard" variant="standard"
label="Outlined secondary" label="Outlined secondary"
color="secondary" color="secondary"
{...{ value, onChange }}
/>
<TextField
label="Filled success"
variant="standard"
color="success"
{...{ value, onChange }}
/>
<TextField
label="Standard warning"
variant="standard"
color="warning"
{...{ value, onChange }}
/> />
<TextField label="Filled success" variant="standard" color="success" />
<TextField label="Standard warning" variant="standard" color="warning" />
</Container> </Container>
); );
}; };
export const Multiline = (): VNode => { const Multiline = (variant: Props["variant"]): VNode => {
const [value, onChange] = useState(""); const [value, onChange] = useState("");
return ( return (
<Container> <Container>
<TextField <TextField
{...{ value, onChange }} {...{ value, onChange }}
label="Multiline" label="Multiline"
variant="standard" variant={variant}
multiline multiline
/> />
<TextField <TextField
{...{ value, onChange }} {...{ value, onChange }}
label="Max row 4" label="Max row 4"
variant="standard" variant={variant}
multiline multiline
maxRows={4} maxRows={4}
/> />
<TextField <TextField
{...{ value, onChange }} {...{ value, onChange }}
label="Row 10" label="Row 10"
variant="standard" variant={variant}
multiline multiline
rows={10} rows={10}
/> />
</Container> </Container>
); );
}; };
export const MultilineStandard = (): VNode => Multiline("standard");
export const MultilineFilled = (): VNode => Multiline("filled");
export const Select = (): VNode => { export const Select = (): VNode => {
const [value, onChange] = useState(""); const [value, onChange] = useState("");

View File

@ -18,7 +18,6 @@ import { FormControl } from "./input/FormControl.js";
import { FormHelperText } from "./input/FormHelperText.js"; import { FormHelperText } from "./input/FormHelperText.js";
import { InputFilled } from "./input/InputFilled.js"; import { InputFilled } from "./input/InputFilled.js";
import { InputLabel } from "./input/InputLabel.js"; import { InputLabel } from "./input/InputLabel.js";
import { InputOutlined } from "./input/InputOutlined.js";
import { InputStandard } from "./input/InputStandard.js"; import { InputStandard } from "./input/InputStandard.js";
import { SelectFilled } from "./input/SelectFilled.js"; import { SelectFilled } from "./input/SelectFilled.js";
import { SelectOutlined } from "./input/SelectOutlined.js"; import { SelectOutlined } from "./input/SelectOutlined.js";
@ -57,13 +56,13 @@ export interface Props {
const inputVariant = { const inputVariant = {
standard: InputStandard, standard: InputStandard,
filled: InputFilled, filled: InputFilled,
outlined: InputOutlined, outlined: InputStandard,
}; };
const selectVariant = { const selectVariant = {
standard: SelectStandard, standard: SelectStandard,
filled: SelectFilled, filled: SelectFilled,
outlined: SelectOutlined, outlined: SelectStandard,
}; };
export function TextField({ export function TextField({

View File

@ -34,10 +34,6 @@ const rootStyle = css`
cursor: text; cursor: text;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
[data-multiline] {
padding: 4px 0 5px;
}
`; `;
const rootDisabledStyle = css` const rootDisabledStyle = css`
color: ${theme.palette.text.disabled}; color: ${theme.palette.text.disabled};
@ -64,6 +60,7 @@ export function InputBaseRoot({
<div <div
data-disabled={disabled} data-disabled={disabled}
data-focused={focused} data-focused={focused}
data-multiline={multiline}
data-error={error} data-error={error}
class={[ class={[
_class, _class,
@ -485,7 +482,7 @@ export function TextareaAutoSize({
class={[ class={[
componentStyle, componentStyle,
componentMultilineStyle, componentMultilineStyle,
// _class, _class,
disabled && componentDisabledStyle, disabled && componentDisabledStyle,
// size === "small" && componentSmallStyle, // size === "small" && componentSmallStyle,
multiline && componentMultilineStyle, multiline && componentMultilineStyle,
@ -503,7 +500,7 @@ export function TextareaAutoSize({
overflow: state.overflow ? "hidden" : null, overflow: state.overflow ? "hidden" : null,
...style, ...style,
}} }}
// {...props} {...props}
/> />
<textarea <textarea

View File

@ -99,12 +99,15 @@ const filledRootStyle = css`
background-color: ${backgroundColor}; background-color: ${backgroundColor};
} }
} }
[data-focused] { &[data-focused] {
background-color: ${backgroundColor}; background-color: ${backgroundColor};
} }
[data-disabled] { &[data-disabled] {
background-color: ${backgroundColorDisabled}; background-color: ${backgroundColorDisabled};
} }
&[data-multiline] {
padding: 25px 12px 8px;
}
`; `;
const underlineStyle = css` const underlineStyle = css`
@ -159,12 +162,20 @@ const underlineStyle = css`
} }
`; `;
function Root({ fullWidth, disabled, focused, error, children }: any): VNode { function Root({
fullWidth,
disabled,
focused,
error,
children,
multiline,
}: any): VNode {
return ( return (
<InputBaseRoot <InputBaseRoot
disabled={disabled} disabled={disabled}
focused={focused} focused={focused}
fullWidth={fullWidth} fullWidth={fullWidth}
multiline={multiline}
error={error} error={error}
class={[filledRootStyle, underlineStyle].join(" ")} class={[filledRootStyle, underlineStyle].join(" ")}
> >

View File

@ -1,20 +0,0 @@
/*
This file is part of GNU Taler
(C) 2022 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
import { h, VNode } from "preact";
export function InputOutlined(): VNode {
return <div />;
}