Skip to content

Commit 65b5b37

Browse files
committed
docs: Improved new todo input style
1 parent 966341e commit 65b5b37

File tree

5 files changed

+52
-12
lines changed

5 files changed

+52
-12
lines changed

docs/core/api/useDebounce.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default function SearchIssues() {
108108
onChange={handleChange}
109109
loading={isPending}
110110
autoFocus
111-
large
111+
size="large"
112112
>
113113
<SearchIcon />
114114
</TextInput>

website/src/components/Demo/code/todo-app/rest/NewTodo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function NewTodo({ userId }: { userId: number }) {
1515
<div className="listItem nogap">
1616
<label>
1717
<input type="checkbox" name="new" checked={false} disabled />
18-
<input type="text" onKeyDown={handleKeyDown} />
18+
<TextInput size="small" onKeyDown={handleKeyDown} />
1919
</label>
2020
<CancelButton />
2121
</div>

website/src/components/Playground/DesignSystem/TextInput.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ import classnames from 'clsx';
22
import React, { type InputHTMLAttributes } from 'react';
33

44
export function TextInput({
5-
loading = false,
65
label,
76
children,
8-
large = false,
7+
loading = false,
8+
size = 'medium',
99
...props
10-
}: InputHTMLAttributes<HTMLInputElement> & {
10+
}: Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
1111
children?: React.ReactNode;
1212
label?: React.ReactNode;
1313
loading?: boolean;
14-
large?: boolean;
14+
size?: 'large' | 'medium' | 'small';
1515
}) {
1616
return (
17-
<div className={classnames('rt-TextFieldRoot', { large })}>
17+
<span
18+
className={classnames('rt-TextFieldRoot', {
19+
large: size === 'large',
20+
medium: size === 'medium',
21+
small: size === 'small',
22+
})}
23+
>
1824
{children}
1925
<input spellCheck="false" className="rt-TextFieldInput" {...props} />
2026
{label ?
@@ -25,6 +31,6 @@ export function TextInput({
2531
<div className="rt-Spinner"></div>
2632
</div>
2733
: null}
28-
</div>
34+
</span>
2935
);
3036
}

website/src/components/Playground/DesignSystem/design-system.css

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ html[data-theme='dark'] .playground-preview {
1515
border: 1px solid var(--ifm-color-emphasis-400);
1616
border-radius: 4px;
1717
position: relative;
18-
font-size: 14px;
1918
}
20-
html[data-theme='dark'] .rt-TextFieldRoot {
19+
html[data-theme='dark'] .rt-TextFieldRoot,
20+
html[data-theme='dark'] .small.rt-TextFieldRoot:hover,
21+
html[data-theme='dark'] .small.rt-TextFieldRoot:focus-within {
2122
background-color: var(--ifm-color-emphasis-100);
2223
}
2324

@@ -35,7 +36,6 @@ html[data-theme='dark'] .rt-TextFieldRoot {
3536
outline: none;
3637
color: var(--ifm-color-content);
3738
background: transparent;
38-
font-size: 14px;
3939
}
4040

4141
/* Spinner container (right side) */
@@ -90,4 +90,38 @@ html[data-theme='dark'] .rt-TextFieldRoot {
9090
}
9191
.large .rt-TextFieldInput {
9292
font-size: 16px;
93+
}
94+
.medium.rt-TextFieldRoot {
95+
font-size: 14px;
96+
}
97+
.medium .rt-TextFieldInput {
98+
font-size: 14px;
99+
}
100+
.small.rt-TextFieldRoot {
101+
display: inline-flex;
102+
border: 1px solid transparent; /* Transparent borders on all sides */
103+
border-bottom-color: var(--ifm-color-emphasis-500); /* Visible bottom border */
104+
background: none;
105+
outline: none;
106+
padding: 5px; /* Consistent padding */
107+
height: 30px; /* Fixed height to prevent shifting */
108+
box-sizing: border-box; /* Include padding and border in element's size */
109+
transition: all 0.2s ease-in-out; /* Quick animation for transitions */
110+
border-radius: 0;
111+
}
112+
html[data-theme='dark'] .small.rt-TextFieldRoot {
113+
background: none;
114+
}
115+
.small.rt-TextFieldRoot:hover,
116+
.small.rt-TextFieldRoot:focus-within {
117+
background-color: var(--ifm-color-emphasis-0);
118+
border-color: var(--ifm-color-emphasis-400); /* Make all borders visible */
119+
border-radius: 4px;
120+
}
121+
.small.rt-TextFieldRoot:focus-within {
122+
border-color: var(--ifm-color-formfield-active); /* Make all borders visible */
123+
}
124+
125+
.listItem .rt-TextFieldRoot {
126+
width: calc(100% - 21px);
93127
}

website/src/components/Playground/monaco-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ if (
266266
declare function Avatar(props: { src: string }):JSX.Element;
267267
declare function Formatted({ downColor, formatter, formatterFn, timeout, transition, transitionLength, upColor, value, stylePrefix, }: NumberProps):JSX.Element
268268
declare function ResetableErrorBoundary(props: { children: React.ReactNode }):JSX.Element;
269-
declare function TextInput(props:React.InputHTMLAttributes<HTMLInputElement> & { label?: React.ReactNode; loading?: boolean; large?: boolean; }):JSX.Element;
269+
declare function TextInput(props:Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & { label?: React.ReactNode; loading?: boolean; size?: 'large' | 'medium' | 'small'; }):JSX.Element;
270270
declare function SearchIcon():JSX.Element;
271271
declare function randomFloatInRange(min: number, max: number, decimals?: number): number;
272272
declare interface NumberProps {

0 commit comments

Comments
 (0)