Skip to content

Commit c14a872

Browse files
committed
refactor: improve the styling of the text input component
1 parent f9dde3d commit c14a872

File tree

10 files changed

+19
-20
lines changed

10 files changed

+19
-20
lines changed

packages/keybr-keyboard-ui/lib/custom/LayoutJson.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ export function LayoutJson() {
55
const { layout } = useCustomLayout();
66
return (
77
<TextField
8-
size="full"
98
type="textarea"
109
value={JSON.stringify(layout.toJSON(), null, 2)}
1110
readOnly={true}
11+
rows={20}
1212
/>
1313
);
1414
}

packages/keybr-keyboard-ui/lib/custom/LiveImport.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function LiveImport({
2222
<Field>Live import:</Field>
2323
<Field>
2424
<TextField
25-
type="text"
25+
size={6}
2626
value={String.fromCodePoint(inputData?.codePoint ?? 0x0020)}
2727
onKeyDown={(event) => {
2828
const { code } = event;

packages/keybr-widget/lib/components/textfield/TextField.module.less

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22

33
.root {
44
.is-blurred();
5-
display: inline-block;
6-
min-block-size: @field-height;
75
margin: 0;
8-
padding-inline: 1rem;
9-
padding-block: 0;
106
border: 1px solid var(--TextField__border-color);
117
color: var(--TextField__color);
128
background-color: var(--TextField__background-color);
139
font-family: var(--default-font-family);
1410
font-size: 0.85rem;
15-
font-weight: normal;
16-
font-style: normal;
17-
line-height: normal;
18-
text-align: start;
19-
text-transform: none;
2011
}
2112

2213
.root:focus {
@@ -26,7 +17,16 @@
2617
outline: none;
2718
}
2819

20+
input.root {
21+
display: inline-block;
22+
min-block-size: @field-height;
23+
padding-inline: 1rem;
24+
padding-block: 0;
25+
}
26+
2927
textarea.root {
28+
display: block;
29+
inline-size: 100%;
3030
min-block-size: 10em;
3131
padding-inline: 1rem;
3232
padding-block: 0.5rem;

packages/keybr-widget/lib/components/textfield/TextField.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const TextField = forwardRef(function TextField(
1818
name,
1919
placeholder,
2020
readOnly,
21+
rows,
2122
size,
2223
tabIndex,
2324
title,
@@ -56,6 +57,7 @@ export const TextField = forwardRef(function TextField(
5657
name={name}
5758
placeholder={placeholder}
5859
readOnly={readOnly}
60+
rows={rows}
5961
tabIndex={tabIndex}
6062
title={title}
6163
value={value}

packages/keybr-widget/lib/components/textfield/TextField.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type TextFieldProps = {
1414
readonly name?: string;
1515
readonly placeholder?: string;
1616
readonly readOnly?: boolean;
17+
readonly rows?: number;
1718
readonly size?: SizeName;
1819
readonly title?: string;
1920
readonly type?: TextFieldType;

packages/keybr-widget/lib/styles/size.less

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@
3535
}
3636

3737
.width6() {
38-
min-inline-size: 6rem !important;
38+
inline-size: 6rem !important;
3939
}
4040

4141
.width10() {
42-
min-inline-size: 10rem !important;
42+
inline-size: 10rem !important;
4343
}
4444

4545
.width16() {
46-
min-inline-size: 16rem !important;
46+
inline-size: 16rem !important;
4747
}
4848

4949
.width24() {
50-
min-inline-size: 24rem !important;
50+
inline-size: 24rem !important;
5151
}
5252

5353
.width32() {
54-
min-inline-size: 32rem !important;
54+
inline-size: 32rem !important;
5555
}

packages/page-practice/lib/settings/lesson/CustomTextLessonSettings.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ function CustomTextInput(): ReactNode {
8686
</Para>
8787
<Para>
8888
<TextField
89-
size="full"
9089
type="textarea"
9190
placeholder={formatMessage({
9291
id: "settings.customTextInput.placeholder",

packages/page-practice/lib/settings/lesson/WordListLessonSettings.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function WordListPreview({
101101
</FieldList>
102102
<Para>
103103
<TextField
104-
size="full"
105104
type="textarea"
106105
value={[...lesson.wordList].join(", ")}
107106
readOnly={true}

packages/page-typing-test/lib/components/settings/text/CommonWordsSettings.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ function Content({ wordList }: { readonly wordList: WordList }): ReactNode {
9292

9393
<Para>
9494
<TextField
95-
size="full"
9695
type="textarea"
9796
value={wordList.join(", ")}
9897
readOnly={true}

packages/page-word-count/lib/WordCountPage.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export function WordCountPage() {
2020
}
2121
/>
2222
<TextField
23-
size="full"
2423
type="textarea"
2524
placeholder={formatMessage({
2625
id: "wordCount.textInput.placeholder",

0 commit comments

Comments
 (0)