Skip to content

Commit

Permalink
refactor: form label hover on delete modal (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricio0312rev authored Oct 28, 2024
1 parent 940af54 commit 3349a92
Show file tree
Hide file tree
Showing 52 changed files with 414 additions and 421 deletions.
14 changes: 10 additions & 4 deletions src/app/components/Form/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { FormFieldProvider } from "./useFormField";

type FormFieldProperties = {
name: string;
disableHover?: boolean;
} & React.FieldsetHTMLAttributes<any>;

export const FormFieldStyled = styled.fieldset<{ isInvalid: boolean }>`
export const FormFieldStyled = styled.fieldset<{ isInvalid: boolean; disableHover: boolean }>`
&:hover .FormLabel {
${({ isInvalid }) => !isInvalid && tw`text-theme-primary-600`};
${({ isInvalid, disableHover }) => !isInvalid && !disableHover && tw`text-theme-primary-600`}
}
.FormLabel {
${({ isInvalid }) => isInvalid && tw`text-theme-danger-500`};
Expand All @@ -21,7 +22,7 @@ export const FormFieldStyled = styled.fieldset<{ isInvalid: boolean }>`
}
`;

export const FormField: React.FC<FormFieldProperties> = ({ name, ...properties }) => {
export const FormField: React.FC<FormFieldProperties> = ({ name, disableHover = false, ...properties }) => {
const FormProvider = useFormContext();
const { isInvalid, errorMessage } = React.useMemo(() => {
const error: { message: string } | undefined = get(FormProvider?.errors, name);
Expand All @@ -33,7 +34,12 @@ export const FormField: React.FC<FormFieldProperties> = ({ name, ...properties }
}, [FormProvider, name]);

return (
<FormFieldStyled isInvalid={isInvalid} className="flex min-w-0 flex-col" {...properties}>
<FormFieldStyled
isInvalid={isInvalid}
className="flex min-w-0 flex-col"
disableHover={disableHover}
{...properties}
>
<FormFieldProvider value={{ errorMessage, isInvalid, name }}>
<>{properties.children}</>
</FormFieldProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`InputDate > should render 1`] = `
<DocumentFragment>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<div
class="react-datepicker-wrapper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`PasswordValidation > should render password rules 1`] = `
<DocumentFragment>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -266,7 +266,7 @@ exports[`PasswordValidation > should render password rules 1`] = `
</div>
</div>
<fieldset
class="flex min-w-0 flex-col css-5kz4tk"
class="flex min-w-0 flex-col css-s0h7ue"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`PasswordValidation > should render password rules 1`] = `
<DocumentFragment>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -266,7 +266,7 @@ exports[`PasswordValidation > should render password rules 1`] = `
</div>
</div>
<fieldset
class="flex min-w-0 flex-col css-5kz4tk"
class="flex min-w-0 flex-col css-s0h7ue"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ exports[`WalletListItem > should disable the send button when wallet has no bala
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -944,7 +944,7 @@ exports[`WalletListItem > should render when isCompact = false 1`] = `
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -1359,7 +1359,7 @@ exports[`WalletListItem > should render when isCompact = true 1`] = `
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -2214,7 +2214,7 @@ exports[`WalletListItem > should render when isLargeScreen = true 1`] = `
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -2677,7 +2677,7 @@ exports[`WalletListItem > should render when isLargeScreen = true and wallet is
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -3092,7 +3092,7 @@ exports[`WalletListItem > should render with a N/A for fiat 1`] = `
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -3507,7 +3507,7 @@ exports[`WalletListItem > should render with default BTC as default exchangeCurr
data-testid="Form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`ContactForm > should render responsive 1`] = `
data-testid="contact-form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -37,7 +37,7 @@ exports[`ContactForm > should render responsive 1`] = `
class="!-mx-4 !mt-4 !p-4 css-1mwq138"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -158,7 +158,7 @@ exports[`ContactForm > should render responsive 1`] = `
</div>
</fieldset>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
data-testid="ContactForm__address"
>
<label
Expand Down Expand Up @@ -244,7 +244,7 @@ exports[`ContactForm > should render responsive 2`] = `
data-testid="contact-form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -274,7 +274,7 @@ exports[`ContactForm > should render responsive 2`] = `
class="!-mx-4 !mt-4 !p-4 css-1mwq138"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -395,7 +395,7 @@ exports[`ContactForm > should render responsive 2`] = `
</div>
</fieldset>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
data-testid="ContactForm__address"
>
<label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exports[`CreateContact > should render 1`] = `
data-testid="contact-form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -108,7 +108,7 @@ exports[`CreateContact > should render 1`] = `
class="!-mx-4 !mt-4 !p-4 css-1mwq138"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -229,7 +229,7 @@ exports[`CreateContact > should render 1`] = `
</div>
</fieldset>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
data-testid="ContactForm__address"
>
<label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ exports[`UpdateContact > should render responsive 1`] = `
data-testid="contact-form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -103,7 +103,7 @@ exports[`UpdateContact > should render responsive 1`] = `
class="!-mx-4 !mt-4 !p-4 css-1mwq138"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -224,7 +224,7 @@ exports[`UpdateContact > should render responsive 1`] = `
</div>
</fieldset>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
data-testid="ContactForm__address"
>
<label
Expand Down Expand Up @@ -502,7 +502,7 @@ exports[`UpdateContact > should render responsive 2`] = `
data-testid="contact-form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -532,7 +532,7 @@ exports[`UpdateContact > should render responsive 2`] = `
class="!-mx-4 !mt-4 !p-4 css-1mwq138"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -653,7 +653,7 @@ exports[`UpdateContact > should render responsive 2`] = `
</div>
</fieldset>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
data-testid="ContactForm__address"
>
<label
Expand Down Expand Up @@ -975,7 +975,7 @@ exports[`UpdateContact > should render responsive 3`] = `
data-testid="contact-form"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -1005,7 +1005,7 @@ exports[`UpdateContact > should render responsive 3`] = `
class="!-mx-4 !mt-4 !p-4 css-1mwq138"
>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
>
<label
class="FormLabel mb-2 flex text-sm font-semibold leading-[17px] text-theme-secondary-text transition-colors duration-100"
Expand Down Expand Up @@ -1126,7 +1126,7 @@ exports[`UpdateContact > should render responsive 3`] = `
</div>
</fieldset>
<fieldset
class="flex min-w-0 flex-col css-1bcidjh"
class="flex min-w-0 flex-col css-ea0il3"
data-testid="ContactForm__address"
>
<label
Expand Down
Loading

0 comments on commit 3349a92

Please sign in to comment.