Skip to content

Commit

Permalink
fix invalid color
Browse files Browse the repository at this point in the history
  • Loading branch information
morewings committed Dec 11, 2023
1 parent 26e3e8f commit 33c34ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
14 changes: 9 additions & 5 deletions src/lib/InputCheckbox/InputCheckbox.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
width: var(--size);
}

&:focus {
--borderColor: var(--gray400);
&:invalid {
--borderColor: red;
}

&:disabled {
Expand All @@ -45,10 +45,14 @@
&:checked::before {
--size: 10px;
}

&:focus:not(:disabled, :invalid) {
--borderColor: var(--gray400);
}
}

.wrapper:hover {
.input {
.input:not(:disabled, :invalid) {
--borderColor: var(--gray400);
}
}
Expand All @@ -64,6 +68,6 @@
cursor: not-allowed;
}

.input:invalid + label {
color: var(--errorColor);
.input:invalid + .label {
color: var(--colorError);
}
5 changes: 2 additions & 3 deletions src/lib/InputCheckbox/InputCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export const InputCheckbox = forwardRef<HTMLInputElement, Props>(
defaultChecked,
id,
label,
validator = event => {
event.target.setCustomValidity('');
},
validator = () => {},
...nativeProps
},
ref
Expand All @@ -44,6 +42,7 @@ export const InputCheckbox = forwardRef<HTMLInputElement, Props>(
const handleChange = useCallback(
(event: ChangeEvent<HTMLInputElement>) => {
const nextValidationState = event.target.checkValidity() ? Validation.valid : Validation.error;
console.log('valid', event.target.checkValidity());
setValidity(nextValidationState);
onChange(event);
},
Expand Down
16 changes: 8 additions & 8 deletions src/lib/InputRadio/InputRadio.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
width: var(--size);
}

&:focus {
--borderColor: var(--gray400);
}

&:invalid {
--borderColor: red;
}
Expand All @@ -51,10 +47,14 @@
&:checked::before {
--size: 10px;
}

&:focus:not(:disabled, :invalid) {
--borderColor: var(--gray400);
}
}

.wrapper:hover {
.input {
.input:not(:disabled, :invalid) {
--borderColor: var(--gray400);
}
}
Expand All @@ -69,6 +69,6 @@
cursor: not-allowed;
}

/* .input:invalid + .label {
color: var(--errorColor);
} */
.input:invalid + .label {
color: var(--colorError);
}
4 changes: 1 addition & 3 deletions src/lib/InputRadio/InputRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export const InputRadio = forwardRef<HTMLInputElement, Props>(
defaultChecked,
id,
label,
validator = event => {
event.target.setCustomValidity('');
},
validator = () => {},
...nativeProps
},
ref
Expand Down

0 comments on commit 33c34ba

Please sign in to comment.