Skip to content

Commit aa110be

Browse files
committed
docs: Make TextInput work in dark mode; use in more places
1 parent 679cb5b commit aa110be

File tree

12 files changed

+67
-49
lines changed

12 files changed

+67
-49
lines changed

docs/core/api/useDebounce.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ export default function SearchIssues() {
109109
onChange={handleChange}
110110
autoFocus
111111
loading={isPending}
112-
/>
112+
large
113+
>
114+
<SearchIcon />
115+
</TextInput>
113116
<AsyncBoundary>
114117
<IssueList query={debouncedQuery} owner="facebook" repo="react" />
115118
</AsyncBoundary>

docs/core/shared/_useLoading.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,8 @@ export default function PostForm({ onSubmit, loading, error }) {
5454
};
5555
return (
5656
<form onSubmit={handleSubmit}>
57-
<label>
58-
Title:
59-
<br />
60-
<input type="text" name="title" defaultValue="My New Post"
57+
<TextInput label="Title" name="title" defaultValue="My New Post"
6158
required />
62-
</label>
63-
<br />
6459
<label>
6560
Body:
6661
<br />

website/src/components/Demo/code/profile-edit/graphql/PostList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function PostList() {
99
<div>
1010
<ProfileEdit id={userId} />
1111
<br />
12-
<br />
1312
{posts.map(post => (
1413
<PostItem key={post.pk()} post={post} />
1514
))}

website/src/components/Demo/code/profile-edit/graphql/ProfileEdit.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ export default function ProfileEdit({ id }: { id: number }) {
88
controller.fetch(UserResource.update, { id, name });
99

1010
return (
11-
<label>
12-
Name:{' '}
13-
<input type="text" value={user.name} onChange={handleChange} />
14-
</label>
11+
<TextInput
12+
label="Name"
13+
value={user.name}
14+
onChange={handleChange}
15+
/>
1516
);
1617
}

website/src/components/Demo/code/profile-edit/rest/PostList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function PostList() {
99
<div>
1010
<ProfileEdit id={userId} />
1111
<br />
12-
<br />
1312
{posts.map(post => (
1413
<PostItem key={post.pk()} post={post} />
1514
))}

website/src/components/Demo/code/profile-edit/rest/ProfileEdit.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ export default function ProfileEdit({ id }: { id: number }) {
88
controller.fetch(UserResource.partialUpdate, { id }, { name });
99

1010
return (
11-
<label>
12-
Name:{' '}
13-
<input type="text" value={user.name} onChange={handleChange} />
14-
</label>
11+
<TextInput
12+
label="Name"
13+
value={user.name}
14+
onChange={handleChange}
15+
/>
1516
);
1617
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export function SearchIcon() {
2+
return (
3+
<div className="rt-SearchIcon">
4+
<svg
5+
width="16"
6+
height="16"
7+
viewBox="0 0 15 15"
8+
fill="none"
9+
xmlns="http://www.w3.org/2000/svg"
10+
>
11+
<path
12+
d="M10 6.5C10 8.433 8.433 10 6.5 10C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5ZM9.30884 10.0159C8.53901 10.6318 7.56251 11 6.5 11C4.01472 11 2 8.98528 2 6.5C2 4.01472 4.01472 2 6.5 2C8.98528 2 11 4.01472 11 6.5C11 7.56251 10.6318 8.53901 10.0159 9.30884L12.8536 12.1464C13.0488 12.3417 13.0488 12.6583 12.8536 12.8536C12.6583 13.0488 12.3417 13.0488 12.1464 12.8536L9.30884 10.0159Z"
13+
fill="currentColor"
14+
fillRule="evenodd"
15+
clipRule="evenodd"
16+
></path>
17+
</svg>
18+
</div>
19+
);
20+
}

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1+
import classnames from 'clsx';
12
import React, { type InputHTMLAttributes } from 'react';
23

34
export function TextInput({
45
loading = false,
56
label,
7+
children,
8+
large = false,
69
...props
710
}: InputHTMLAttributes<HTMLInputElement> & {
11+
children?: React.ReactNode;
812
label?: React.ReactNode;
913
loading?: boolean;
14+
large?: boolean;
1015
}) {
1116
return (
12-
<div className="rt-TextFieldRoot">
13-
<div className="rt-TextFieldSlot">
14-
<svg
15-
width="16"
16-
height="16"
17-
viewBox="0 0 15 15"
18-
fill="none"
19-
xmlns="http://www.w3.org/2000/svg"
20-
>
21-
<path
22-
d="M10 6.5C10 8.433 8.433 10 6.5 10C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5ZM9.30884 10.0159C8.53901 10.6318 7.56251 11 6.5 11C4.01472 11 2 8.98528 2 6.5C2 4.01472 4.01472 2 6.5 2C8.98528 2 11 4.01472 11 6.5C11 7.56251 10.6318 8.53901 10.0159 9.30884L12.8536 12.1464C13.0488 12.3417 13.0488 12.6583 12.8536 12.8536C12.6583 13.0488 12.3417 13.0488 12.1464 12.8536L9.30884 10.0159Z"
23-
fill="currentColor"
24-
fillRule="evenodd"
25-
clipRule="evenodd"
26-
></path>
27-
</svg>
28-
</div>
17+
<div className={classnames('rt-TextFieldRoot', { large })}>
18+
{children}
2919
<input spellCheck="false" className="rt-TextFieldInput" {...props} />
3020
{label ?
3121
<label className="rt-TextFieldLabel">{label}</label>

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,42 @@
44
align-items: center;
55
width: 100%;
66
padding: 0.5em;
7-
background-color: white;
8-
border: 1px solid #ccc;
7+
background-color: var(--ifm-color-emphasis-0);
8+
border: 1px solid var(--ifm-color-emphasis-400);
99
border-radius: 4px;
1010
position: relative;
11+
font-size: 14px;
1112
}
1213

1314
/* The slot element (left side) */
14-
.rt-TextFieldSlot {
15+
.rt-SearchIcon {
1516
display: flex;
1617
align-items: center;
17-
color: #666;
18+
color: var(--ifm-color-emphasis-700);
1819
}
1920

2021
/* The input element inside the text field */
2122
.rt-TextFieldInput {
2223
flex: 1;
2324
border: none;
2425
outline: none;
25-
font-size: 1em;
26-
color: #333;
26+
color: var(--ifm-color-content);
2727
background: transparent;
28+
font-size: 14px;
2829
}
2930

3031
/* Spinner container (right side) */
3132
.rt-TextFieldSpinner {
3233
display: flex;
3334
align-items: center;
34-
color: #666;
35+
color: var(--ifm-color-emphasis-700);
3536
}
3637

3738
/* Spinner styles */
3839
.rt-Spinner {
3940
width: 16px;
4041
height: 16px;
41-
border: 2px solid #ccc;
42+
border: 2px solid var(--ifm-color-emphasis-400);
4243
border-top-color: #007AFF;
4344
border-radius: 50%;
4445
animation: rt-spin 1s linear infinite;
@@ -56,10 +57,10 @@
5657
position: absolute;
5758
top: -0.75em;
5859
left: 0.75em;
59-
background-color: white;
60+
background-color: var(--ifm-color-emphasis-0);
6061
padding: 0 0.25em;
61-
font-size: 0.75em;
62-
color: #666;
62+
font-size: 0.70rem;
63+
color: var(--ifm-color-emphasis-700);
6364
pointer-events: none;
6465
}
6566

@@ -72,3 +73,11 @@
7273
.rt-TextFieldRoot:focus-within {
7374
border-color: #007AFF;
7475
}
76+
77+
78+
.large.rt-TextFieldRoot {
79+
font-size: 16px;
80+
}
81+
.large .rt-TextFieldInput {
82+
font-size: 16px;
83+
}

website/src/components/Playground/DesignSystem/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export { Avatar } from './Avatar';
44
export { Formatted } from './Formatted';
55
import './design-system.css';
66
export { TextInput } from './TextInput';
7+
export { SearchIcon } from './SearchIcon';

0 commit comments

Comments
 (0)