Skip to content

Commit c2afb98

Browse files
committed
Adjusting styles and adding CheckboxInputField
1 parent 61790c2 commit c2afb98

File tree

4 files changed

+51
-21
lines changed

4 files changed

+51
-21
lines changed

components/dashboard/src/components/forms/CheckboxInput.tsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@
55
*/
66

77
import classNames from "classnames";
8-
import { FC, useCallback } from "react";
8+
import { FC, ReactNode, useCallback } from "react";
99
import { useId } from "../../hooks/useId";
10+
import { InputField } from "./InputField";
1011
import { InputFieldHint } from "./InputFieldHint";
1112

12-
type Props = {
13+
type CheckboxInputFieldProps = {
14+
label: string;
15+
error?: ReactNode;
16+
className?: string;
17+
};
18+
export const CheckboxInputField: FC<CheckboxInputFieldProps> = ({ label, error, className, children }) => {
19+
return (
20+
<InputField label={label} className={className} error={error}>
21+
<div className="space-y-2 ml-2">{children}</div>
22+
</InputField>
23+
);
24+
};
25+
26+
type CheckboxInputProps = {
1327
id?: string;
1428
value: string;
1529
checked: boolean;
@@ -18,7 +32,15 @@ type Props = {
1832
hint?: string;
1933
onChange: (checked: boolean) => void;
2034
};
21-
export const CheckboxInput: FC<Props> = ({ id, value, label, hint, checked, disabled = false, onChange }) => {
35+
export const CheckboxInput: FC<CheckboxInputProps> = ({
36+
id,
37+
value,
38+
label,
39+
hint,
40+
checked,
41+
disabled = false,
42+
onChange,
43+
}) => {
2244
const maybeId = useId();
2345
const elementId = id || maybeId;
2446

@@ -33,9 +55,10 @@ export const CheckboxInput: FC<Props> = ({ id, value, label, hint, checked, disa
3355
<label className="flex space-x-2 justify-start items-start" htmlFor={elementId}>
3456
<input
3557
type="checkbox"
36-
// className="rounded border-2 mt-0.5 text-gray-600"
3758
className={classNames(
38-
"h-4 w-4 focus:ring-0 mt-0.5 rounded cursor-pointer bg-transparent border-2 dark:filter-invert border-gray-600 dark:border-gray-900 focus:border-gray-900 dark:focus:border-gray-800",
59+
"h-4 w-4 mt-0.5 rounded cursor-pointer border-2 dark:filter-invert",
60+
"focus:ring-2 focus:border-gray-900 ring-blue-400 dark:focus:border-gray-800",
61+
"border-gray-600 dark:border-gray-900 bg-transparent",
3962
{ "bg-gray-600 dark:bg-gray-900": checked },
4063
)}
4164
value={value}
@@ -46,16 +69,15 @@ export const CheckboxInput: FC<Props> = ({ id, value, label, hint, checked, disa
4669
/>
4770
<div className="flex flex-col">
4871
<span
49-
// className="text-gray-600 dark:text-gray-400 text-sm"
5072
className={classNames(
51-
"text-md font-semibold cursor-pointer tracking-wide",
73+
"text-sm font-semibold cursor-pointer",
5274
disabled ? "text-gray-400 dark:text-gray-400" : "text-gray-600 dark:text-gray-100",
5375
)}
5476
>
5577
{label}
5678
</span>
5779

58-
{hint && <InputFieldHint>{hint}</InputFieldHint>}
80+
{hint && <InputFieldHint disabled={disabled}>{hint}</InputFieldHint>}
5981
</div>
6082
</label>
6183
);

components/dashboard/src/components/forms/InputField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const InputField: FunctionComponent<Props> = memo(({ label, id, hint, err
2222
{label && (
2323
<label
2424
className={classNames(
25-
"text-sm font-semibold dark:text-gray-400",
25+
"text-md font-bold dark:text-gray-400",
2626
error ? "text-red-600" : "text-gray-600",
2727
)}
2828
htmlFor={id}

components/dashboard/src/components/forms/InputFieldHint.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7+
import classNames from "classnames";
78
import { FC } from "react";
89

9-
export const InputFieldHint: FC = ({ children }) => {
10-
return <span className="text-gray-500 dark:text-gray-400 text-sm">{children}</span>;
10+
type Props = {
11+
disabled?: boolean;
12+
};
13+
export const InputFieldHint: FC<Props> = ({ disabled = false, children }) => {
14+
return (
15+
<span
16+
className={classNames(
17+
"text-sm",
18+
disabled ? "text-gray-400 dark:text-gray-400" : "text-gray-500 dark:text-gray-400",
19+
)}
20+
>
21+
{children}
22+
</span>
23+
);
1124
};

components/dashboard/src/onboarding/StepOrgInfo.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
import { User } from "@gitpod/gitpod-protocol";
88
import { FC, useCallback, useMemo, useState } from "react";
9-
import { CheckboxInput } from "../components/forms/CheckboxInput";
10-
import { InputField } from "../components/forms/InputField";
9+
import { CheckboxInput, CheckboxInputField } from "../components/forms/CheckboxInput";
1110
import { SelectInputField } from "../components/forms/SelectInputField";
1211
import { TextInputField } from "../components/forms/TextInputField";
1312
import { useUpdateCurrentUserMutation } from "../data/current-user/update-mutation";
@@ -188,8 +187,7 @@ export const StepOrgInfo: FC<Props> = ({ user, onComplete }) => {
188187
onBlur={websiteError.onBlur}
189188
/>
190189

191-
<InputField label="I'm exploring Gitpod..." />
192-
<div className="mt-4 ml-2 space-y-2">
190+
<CheckboxInputField label="I'm exploring Gitpod...">
193191
{explorationReasonsOptions.map((o) => (
194192
<CheckboxInput
195193
key={o.value}
@@ -205,17 +203,14 @@ export const StepOrgInfo: FC<Props> = ({ user, onComplete }) => {
205203
}}
206204
/>
207205
))}
208-
</div>
206+
</CheckboxInputField>
209207

210-
<InputField label="I'm signing up for Gitpod to..." />
211-
<div className="mt-4 ml-2 space-y-2">
208+
<CheckboxInputField label="I'm signing up for Gitpod to...">
212209
{signupGoalsOptions.map((o) => (
213210
<CheckboxInput
214211
key={o.value}
215212
value={o.value}
216213
label={o.label}
217-
disabled
218-
hint="this is just a test"
219214
checked={signupGoals.includes(o.value)}
220215
onChange={(checked) => {
221216
if (checked) {
@@ -226,7 +221,7 @@ export const StepOrgInfo: FC<Props> = ({ user, onComplete }) => {
226221
}}
227222
/>
228223
))}
229-
</div>
224+
</CheckboxInputField>
230225

231226
{signupGoals.includes(SIGNUP_GOALS_OTHER) && (
232227
<TextInputField value={signupGoalsOther} placeholder="Please specify" onChange={setSignupGoalsOther} />

0 commit comments

Comments
 (0)