Skip to content

Commit 9b393ae

Browse files
authored
fix custom tw colors opacity. replace Input css module with tw (#1906)
* fix custom tw colors opacity. replace Input css module with tw * type cast hslWithOpacity values to string * remove arbitrary values
1 parent 388edca commit 9b393ae

File tree

10 files changed

+161
-184
lines changed

10 files changed

+161
-184
lines changed

common/styles/globals.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
@tailwind base;
66
@tailwind components;
77
@tailwind utilities;
8+
9+
@layer base {
10+
:root {
11+
--primary-rgb: 62 214 240;
12+
--secondary-rgb: 37 46 62;
13+
--gray-rgb: 226 226 226;
14+
--white-rgb: 247 247 247;
15+
--burnt-orange-hsl: 14 55% 45%;
16+
--success-hsl: 132 35% 88%;
17+
--success-deep-hsl: 132 60% 23%;
18+
--warning-hsl: 46 100% 90%;
19+
--warning-deep-hsl: 39 80% 31%;
20+
--error-hsl: 355 70% 91%;
21+
--error-deep-hsl: 355 63% 34%;
22+
}
23+
}
824
/* stylelint-enable at-rule-no-unknown */
925

1026
/* Global Styles */

components/Form/Checkbox/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ function Checkbox({
1616
id,
1717
label,
1818
}: CheckboxProps) {
19-
const hasErrors = errors[name];
19+
const hasErrors = Boolean(errors[name]);
2020
return (
2121
<div className="relative m-4" data-testid={CHECKBOX}>
2222
<Label for={name} isHidden={false}>
2323
<input
2424
{...field}
25-
className="border border-secondary/5 rounded-[3px] text-lg p-2 scale-150 mr-3 disabled:opacity-60 hover:disabled:cursor-not-allowed"
25+
className="border border-secondary/5 rounded-sm text-lg p-2 scale-150 mr-3 disabled:opacity-60 hover:disabled:cursor-not-allowed"
2626
id={id || name}
2727
name={name}
2828
type="checkbox"

components/Form/Input/Input.module.css

Lines changed: 0 additions & 81 deletions
This file was deleted.

components/Form/Input/Input.tsx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { InputHTMLAttributes } from 'react';
55
import { cx } from 'common/utils/cva';
66
import Label from 'components/Form/Label/Label';
77
import Alert from 'components/Alert/Alert';
8-
import styles from './Input.module.css';
98

109
/** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes_common_to_all_input_types */
1110
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'disabled' | 'form'> {
@@ -34,21 +33,31 @@ function Input({
3433
const isLabelBeforeInput = !isLabelAfterInput;
3534

3635
return (
37-
<div className={cx(className, styles.field)} data-testid={INPUT}>
36+
<div className={cx('m-4', className)} data-testid={INPUT}>
3837
{isLabelBeforeInput && (
3938
<Label for={name} isHidden={isLabelHidden}>
4039
{label}
4140
</Label>
4241
)}
4342

44-
<div className={styles.inputFeedbackGrouping} data-testid={INPUT_FEEDBACK_GROUPING}>
43+
<div
44+
className="flex flex-col items-stretch lg:relative"
45+
data-testid={INPUT_FEEDBACK_GROUPING}
46+
>
4547
<input
4648
{...field}
4749
{...props}
48-
className={cx(styles.Input, hasValidationStyling, {
49-
[styles.valid]: touched[name] && !hasErrors && hasValidationStyling,
50-
[styles.invalid]: touched[name] && hasErrors && hasValidationStyling,
51-
})}
50+
className={cx(
51+
'border border-secondary/50 rounded-sm text-lg p-2',
52+
'disabled:opacity-60 hover:disabled:cursor-not-allowed min-w-48',
53+
'focus-visible:border-primary/50 focus-visible:shadow-xs focus-visible:shadow-primary/75 focus-visible:outline-none',
54+
{
55+
'border-success-deep shadow-xs shadow-success-deep outline-none':
56+
touched[name] && !hasErrors && hasValidationStyling,
57+
'border-error-deep shadow-xs shadow-error-deep':
58+
touched[name] && hasErrors && hasValidationStyling,
59+
},
60+
)}
5261
disabled={isDisabled}
5362
id={id || name}
5463
name={name}
@@ -59,7 +68,16 @@ function Input({
5968
<ErrorMessage name={name}>
6069
{(message: string) => {
6170
return hasErrors ? (
62-
<Alert className={styles.errorMessage} data-testid={INPUT_ERROR} type="error">
71+
<Alert
72+
className={cx([
73+
'mt-2 flex-1 text-center max-w-full -mx-0.5',
74+
'lg:mt-0 lg:ml-4 lg:absolute lg:-top-0.5 lg:left-full',
75+
'lg:min-w-36 lg:max-w-72 lg:w-auto',
76+
'lg:py-0 lg:px-2.5 lg:min-h-full lg:flex lg:items-center lg:justify-center',
77+
])}
78+
data-testid={INPUT_ERROR}
79+
type="error"
80+
>
6381
{message}
6482
</Alert>
6583
) : null;
@@ -68,7 +86,7 @@ function Input({
6886
</div>
6987

7088
{isLabelAfterInput && (
71-
<Label for={name} isHidden={isLabelHidden} className={styles.labelAfterInput}>
89+
<Label for={name} isHidden={isLabelHidden}>
7290
{label}
7391
</Label>
7492
)}

components/Form/Input/__tests__/__snapshots__/Input.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Input > should render with required props 1`] = `
44
<div
5-
className="field"
5+
className="m-4"
66
data-testid="INPUT"
77
>
88
<label
@@ -13,11 +13,11 @@ exports[`Input > should render with required props 1`] = `
1313
Some Input:
1414
</label>
1515
<div
16-
className="inputFeedbackGrouping"
16+
className="flex flex-col items-stretch lg:relative"
1717
data-testid="INPUT_FEEDBACK_GROUPING"
1818
>
1919
<input
20-
className="Input"
20+
className="border border-secondary/50 rounded-sm text-lg p-2 disabled:opacity-60 hover:disabled:cursor-not-allowed min-w-48 focus-visible:border-primary/50 focus-visible:shadow-xs focus-visible:shadow-primary/75 focus-visible:outline-none"
2121
disabled={false}
2222
id="someInputName"
2323
name="someInputName"

0 commit comments

Comments
 (0)