feat(ui-toolkit): increase checkbox and radio clickable area (#4906)
This commit is contained in:
parent
6e7b87d9ef
commit
797db6ee93
@ -40,7 +40,7 @@ context.skip('Node switcher', { tags: '@regression' }, function () {
|
|||||||
const errorTypeTxt = 'Error: invalid url';
|
const errorTypeTxt = 'Error: invalid url';
|
||||||
const nodeErrorTxt = 'fakeUrl is not a valid url.';
|
const nodeErrorTxt = 'fakeUrl is not a valid url.';
|
||||||
|
|
||||||
cy.getByTestId('node-url-custom').click();
|
cy.getByTestId('node-url-custom').click({ force: true });
|
||||||
|
|
||||||
cy.getByTestId(customNodeBtn).within(() => {
|
cy.getByTestId(customNodeBtn).within(() => {
|
||||||
cy.get('input').clear().type('fakeUrl');
|
cy.get('input').clear().type('fakeUrl');
|
||||||
|
@ -310,7 +310,9 @@ context(
|
|||||||
closeStakingDialog();
|
closeStakingDialog();
|
||||||
navigateTo(navigation.validators);
|
navigateTo(navigation.validators);
|
||||||
clickOnValidatorFromList(0);
|
clickOnValidatorFromList(0);
|
||||||
cy.getByTestId(stakeRemoveStakeRadioButton, txTimeout).click();
|
cy.getByTestId(stakeRemoveStakeRadioButton, txTimeout).click({
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
cy.getByTestId(stakeTokenAmountInputBox).type('-0.1');
|
cy.getByTestId(stakeTokenAmountInputBox).type('-0.1');
|
||||||
cy.contains('Waiting for next epoch to start', epochTimeout);
|
cy.contains('Waiting for next epoch to start', epochTimeout);
|
||||||
cy.getByTestId(stakeTokenSubmitButton)
|
cy.getByTestId(stakeTokenSubmitButton)
|
||||||
@ -331,7 +333,7 @@ context(
|
|||||||
closeStakingDialog();
|
closeStakingDialog();
|
||||||
navigateTo(navigation.validators);
|
navigateTo(navigation.validators);
|
||||||
clickOnValidatorFromList(0);
|
clickOnValidatorFromList(0);
|
||||||
cy.getByTestId(stakeRemoveStakeRadioButton).click();
|
cy.getByTestId(stakeRemoveStakeRadioButton).click({ force: true });
|
||||||
cy.getByTestId(stakeTokenAmountInputBox).type('4');
|
cy.getByTestId(stakeTokenAmountInputBox).type('4');
|
||||||
cy.contains('Waiting for next epoch to start', epochTimeout);
|
cy.contains('Waiting for next epoch to start', epochTimeout);
|
||||||
cy.getByTestId(stakeTokenSubmitButton)
|
cy.getByTestId(stakeTokenSubmitButton)
|
||||||
|
@ -156,7 +156,7 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () {
|
|||||||
cy.getByTestId('subscription-cell').should('have.text', 'Yes');
|
cy.getByTestId('subscription-cell').should('have.text', 'Yes');
|
||||||
});
|
});
|
||||||
cy.getByTestId('connect').should('be.disabled');
|
cy.getByTestId('connect').should('be.disabled');
|
||||||
cy.getByTestId('node-url-custom').click();
|
cy.getByTestId('node-url-custom').click({ force: true });
|
||||||
cy.get('input').should('exist');
|
cy.get('input').should('exist');
|
||||||
cy.getByTestId('connect').should('be.disabled');
|
cy.getByTestId('connect').should('be.disabled');
|
||||||
cy.getByTestId('icon-cross').click();
|
cy.getByTestId('icon-cross').click();
|
||||||
|
@ -46,7 +46,7 @@ export function stakingValidatorPageAddStake(stake: string) {
|
|||||||
|
|
||||||
export function stakingValidatorPageRemoveStake(stake: string) {
|
export function stakingValidatorPageRemoveStake(stake: string) {
|
||||||
cy.highlight(`Removing a stake of ${stake}`);
|
cy.highlight(`Removing a stake of ${stake}`);
|
||||||
cy.get(removeStakeRadioButton, epochTimeout).click();
|
cy.get(removeStakeRadioButton, epochTimeout).click({ force: true });
|
||||||
cy.get(tokenAmountInputBox).type(stake);
|
cy.get(tokenAmountInputBox).type(stake);
|
||||||
waitForBeginningOfEpoch();
|
waitForBeginningOfEpoch();
|
||||||
cy.get(tokenSubmitButton)
|
cy.get(tokenSubmitButton)
|
||||||
@ -70,9 +70,13 @@ export function stakingPageAssociateTokens(
|
|||||||
cy.highlight(`Associating ${amount} tokens from ${type}`);
|
cy.highlight(`Associating ${amount} tokens from ${type}`);
|
||||||
cy.get(ethWalletAssociateButton).first().click();
|
cy.get(ethWalletAssociateButton).first().click();
|
||||||
if (type === 'wallet') {
|
if (type === 'wallet') {
|
||||||
cy.get(associateWalletRadioButton, { timeout: 30000 }).click();
|
cy.get(associateWalletRadioButton, { timeout: 30000 }).click({
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
} else if (type === 'contract') {
|
} else if (type === 'contract') {
|
||||||
cy.get(associateContractRadioButton, { timeout: 30000 }).click();
|
cy.get(associateContractRadioButton, { timeout: 30000 }).click({
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
cy.highlight(`${type} is not association option`);
|
cy.highlight(`${type} is not association option`);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ describe('home', { tags: '@regression' }, () => {
|
|||||||
// 0006-NETW-020
|
// 0006-NETW-020
|
||||||
cy.getByTestId(nodeHealthTrigger).click();
|
cy.getByTestId(nodeHealthTrigger).click();
|
||||||
cy.getByTestId('connect').should('be.disabled');
|
cy.getByTestId('connect').should('be.disabled');
|
||||||
cy.getByTestId('node-url-custom').click();
|
cy.getByTestId('node-url-custom').click({ force: true });
|
||||||
cy.getByTestId('connect').should('be.disabled');
|
cy.getByTestId('connect').should('be.disabled');
|
||||||
cy.get("input[placeholder='https://']")
|
cy.get("input[placeholder='https://']")
|
||||||
.focus()
|
.focus()
|
||||||
|
@ -258,22 +258,22 @@ export const TransferForm = ({
|
|||||||
)}
|
)}
|
||||||
</TradingFormGroup>
|
</TradingFormGroup>
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<TradingCheckbox
|
|
||||||
name="include-transfer-fee"
|
|
||||||
disabled={!transferAmount}
|
|
||||||
label={
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
description={t(
|
description={t(
|
||||||
`The fee will be taken from the amount you are transferring.`
|
`The fee will be taken from the amount you are transferring.`
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div>{t('Include transfer fee')}</div>
|
<div>
|
||||||
</Tooltip>
|
<TradingCheckbox
|
||||||
}
|
name="include-transfer-fee"
|
||||||
|
disabled={!transferAmount}
|
||||||
|
label={t('Include transfer fee')}
|
||||||
checked={includeFee}
|
checked={includeFee}
|
||||||
onCheckedChange={() => setIncludeFee(!includeFee)}
|
onCheckedChange={() => setIncludeFee(!includeFee)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
{transferAmount && fee && (
|
{transferAmount && fee && (
|
||||||
<TransferFee
|
<TransferFee
|
||||||
amount={transferAmount}
|
amount={transferAmount}
|
||||||
|
@ -494,16 +494,16 @@ const TimeInForce = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const ReduceOnly = () => (
|
const ReduceOnly = () => (
|
||||||
|
<Tooltip description={<span>{t(REDUCE_ONLY_TOOLTIP)}</span>}>
|
||||||
|
<div>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
name="reduce-only"
|
name="reduce-only"
|
||||||
checked={true}
|
checked={true}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
label={
|
label={t('Reduce only')}
|
||||||
<Tooltip description={<span>{t(REDUCE_ONLY_TOOLTIP)}</span>}>
|
|
||||||
<>{t('Reduce only')}</>
|
|
||||||
</Tooltip>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
);
|
);
|
||||||
|
|
||||||
const NotionalAndFees = ({
|
const NotionalAndFees = ({
|
||||||
|
@ -548,15 +548,6 @@ export const DealTicket = ({
|
|||||||
name="postOnly"
|
name="postOnly"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Checkbox
|
|
||||||
name="post-only"
|
|
||||||
checked={!disablePostOnlyCheckbox && field.value}
|
|
||||||
disabled={disablePostOnlyCheckbox}
|
|
||||||
onCheckedChange={(postOnly) => {
|
|
||||||
field.onChange(postOnly);
|
|
||||||
setValue('reduceOnly', false);
|
|
||||||
}}
|
|
||||||
label={
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
description={
|
description={
|
||||||
<span>
|
<span>
|
||||||
@ -570,25 +561,25 @@ export const DealTicket = ({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className="text-xs">{t('Post only')}</span>
|
<div>
|
||||||
</Tooltip>
|
<Checkbox
|
||||||
}
|
name="post-only"
|
||||||
|
checked={!disablePostOnlyCheckbox && field.value}
|
||||||
|
disabled={disablePostOnlyCheckbox}
|
||||||
|
onCheckedChange={(postOnly) => {
|
||||||
|
field.onChange(postOnly);
|
||||||
|
setValue('reduceOnly', false);
|
||||||
|
}}
|
||||||
|
label={t('Post only')}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Controller
|
<Controller
|
||||||
name="reduceOnly"
|
name="reduceOnly"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Checkbox
|
|
||||||
name="reduce-only"
|
|
||||||
checked={!disableReduceOnlyCheckbox && field.value}
|
|
||||||
disabled={disableReduceOnlyCheckbox}
|
|
||||||
onCheckedChange={(reduceOnly) => {
|
|
||||||
field.onChange(reduceOnly);
|
|
||||||
setValue('postOnly', false);
|
|
||||||
}}
|
|
||||||
label={
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
description={
|
description={
|
||||||
<span>
|
<span>
|
||||||
@ -600,10 +591,19 @@ export const DealTicket = ({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className="text-xs">{t('Reduce only')}</span>
|
<div>
|
||||||
</Tooltip>
|
<Checkbox
|
||||||
}
|
name="reduce-only"
|
||||||
|
checked={!disableReduceOnlyCheckbox && field.value}
|
||||||
|
disabled={disableReduceOnlyCheckbox}
|
||||||
|
onCheckedChange={(reduceOnly) => {
|
||||||
|
field.onChange(reduceOnly);
|
||||||
|
setValue('postOnly', false);
|
||||||
|
}}
|
||||||
|
label={t('Reduce only')}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -614,12 +614,6 @@ export const DealTicket = ({
|
|||||||
name="iceberg"
|
name="iceberg"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Checkbox
|
|
||||||
name="iceberg"
|
|
||||||
checked={field.value}
|
|
||||||
onCheckedChange={field.onChange}
|
|
||||||
disabled={disableIcebergCheckbox}
|
|
||||||
label={
|
|
||||||
<Tooltip
|
<Tooltip
|
||||||
description={
|
description={
|
||||||
<p>
|
<p>
|
||||||
@ -630,10 +624,16 @@ export const DealTicket = ({
|
|||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className="text-xs">{t('Iceberg')}</span>
|
<div>
|
||||||
</Tooltip>
|
<Checkbox
|
||||||
}
|
name="iceberg"
|
||||||
|
checked={field.value}
|
||||||
|
onCheckedChange={field.onChange}
|
||||||
|
disabled={disableIcebergCheckbox}
|
||||||
|
label={t('Iceberg')}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,6 +4,8 @@ import classNames from 'classnames';
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
type CheckedState = boolean | 'indeterminate';
|
type CheckedState = boolean | 'indeterminate';
|
||||||
|
export const labelClasses =
|
||||||
|
"relative before:content-[''] before:block before:absolute before:top-1/2 before:left-[0] before:right-[0] before:-translate-y-1/2 before:h-6";
|
||||||
export interface CheckboxProps {
|
export interface CheckboxProps {
|
||||||
checked?: CheckedState;
|
checked?: CheckedState;
|
||||||
label?: ReactNode;
|
label?: ReactNode;
|
||||||
@ -30,7 +32,7 @@ export const Checkbox = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-1">
|
<label className={`flex gap-1 ${labelClasses}`} htmlFor={name}>
|
||||||
<CheckboxPrimitive.Root
|
<CheckboxPrimitive.Root
|
||||||
name={name}
|
name={name}
|
||||||
id={name}
|
id={name}
|
||||||
@ -55,14 +57,13 @@ export const Checkbox = ({
|
|||||||
)}
|
)}
|
||||||
</CheckboxPrimitive.CheckboxIndicator>
|
</CheckboxPrimitive.CheckboxIndicator>
|
||||||
</CheckboxPrimitive.Root>
|
</CheckboxPrimitive.Root>
|
||||||
<label
|
<span
|
||||||
htmlFor={name}
|
|
||||||
className={classNames('text-sm flex-1', {
|
className={classNames('text-sm flex-1', {
|
||||||
'dark:text-neutral-400 text-neutral-600': disabled,
|
'dark:text-neutral-400 text-neutral-600': disabled,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@ import { forwardRef } from 'react';
|
|||||||
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
import { labelClasses } from '../checkbox';
|
||||||
|
|
||||||
export interface RadioGroupProps {
|
export interface RadioGroupProps {
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -56,7 +57,7 @@ interface RadioProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Radio = ({ id, value, label, disabled }: RadioProps) => {
|
export const Radio = ({ id, value, label, disabled }: RadioProps) => {
|
||||||
const wrapperClasses = classNames('flex items-center gap-2', {
|
const wrapperClasses = classNames('flex items-center gap-2', labelClasses, {
|
||||||
'opacity-40': disabled,
|
'opacity-40': disabled,
|
||||||
});
|
});
|
||||||
const itemClasses = classNames(
|
const itemClasses = classNames(
|
||||||
@ -71,7 +72,7 @@ export const Radio = ({ id, value, label, disabled }: RadioProps) => {
|
|||||||
'border-black dark:border-white'
|
'border-black dark:border-white'
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div className={wrapperClasses}>
|
<label className={wrapperClasses} htmlFor={id}>
|
||||||
<RadioGroupPrimitive.Item
|
<RadioGroupPrimitive.Item
|
||||||
value={value}
|
value={value}
|
||||||
className={itemClasses}
|
className={itemClasses}
|
||||||
@ -81,9 +82,7 @@ export const Radio = ({ id, value, label, disabled }: RadioProps) => {
|
|||||||
>
|
>
|
||||||
<RadioGroupPrimitive.Indicator className={indicatorClasses} />
|
<RadioGroupPrimitive.Indicator className={indicatorClasses} />
|
||||||
</RadioGroupPrimitive.Item>
|
</RadioGroupPrimitive.Item>
|
||||||
<label htmlFor={id} className={disabled ? '' : 'cursor-pointer'}>
|
<span className={disabled ? '' : 'cursor-pointer'}>{label}</span>
|
||||||
{label}
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@ import { VegaIcon, VegaIconNames } from '../icon';
|
|||||||
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
import { labelClasses } from '../checkbox';
|
||||||
|
|
||||||
type CheckedState = boolean | 'indeterminate';
|
type CheckedState = boolean | 'indeterminate';
|
||||||
export interface TradingCheckboxProps {
|
export interface TradingCheckboxProps {
|
||||||
@ -29,7 +30,10 @@ export const TradingCheckbox = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-1.5 items-center">
|
<label
|
||||||
|
htmlFor={name}
|
||||||
|
className={`flex gap-1.5 items-center ${labelClasses}`}
|
||||||
|
>
|
||||||
<CheckboxPrimitive.Root
|
<CheckboxPrimitive.Root
|
||||||
name={name}
|
name={name}
|
||||||
id={name}
|
id={name}
|
||||||
@ -50,14 +54,13 @@ export const TradingCheckbox = ({
|
|||||||
)}
|
)}
|
||||||
</CheckboxPrimitive.CheckboxIndicator>
|
</CheckboxPrimitive.CheckboxIndicator>
|
||||||
</CheckboxPrimitive.Root>
|
</CheckboxPrimitive.Root>
|
||||||
<label
|
<span
|
||||||
htmlFor={name}
|
|
||||||
className={classNames('text-xs flex-1', {
|
className={classNames('text-xs flex-1', {
|
||||||
'text-vega-clight-200 dark:text-vega-cdark-200': disabled,
|
'text-vega-clight-200 dark:text-vega-cdark-200': disabled,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@ import { forwardRef } from 'react';
|
|||||||
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
import { labelClasses } from '../checkbox';
|
||||||
|
|
||||||
export interface TradingRadioGroupProps {
|
export interface TradingRadioGroupProps {
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -59,7 +60,10 @@ interface RadioProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => {
|
export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => {
|
||||||
const wrapperClasses = classNames('flex items-center gap-1.5 text-xs');
|
const wrapperClasses = classNames(
|
||||||
|
'flex items-center gap-1.5 text-xs',
|
||||||
|
labelClasses
|
||||||
|
);
|
||||||
const itemClasses = classNames(
|
const itemClasses = classNames(
|
||||||
'flex justify-center items-center',
|
'flex justify-center items-center',
|
||||||
'w-3 h-3 rounded-full border',
|
'w-3 h-3 rounded-full border',
|
||||||
@ -74,7 +78,7 @@ export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => {
|
|||||||
'border-vega-clight-700 dark:border-vega-cdark-700'
|
'border-vega-clight-700 dark:border-vega-cdark-700'
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div className={wrapperClasses}>
|
<label className={wrapperClasses} htmlFor={id}>
|
||||||
<RadioGroupPrimitive.Item
|
<RadioGroupPrimitive.Item
|
||||||
value={value}
|
value={value}
|
||||||
className={itemClasses}
|
className={itemClasses}
|
||||||
@ -84,8 +88,7 @@ export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => {
|
|||||||
>
|
>
|
||||||
<RadioGroupPrimitive.Indicator className={indicatorClasses} />
|
<RadioGroupPrimitive.Indicator className={indicatorClasses} />
|
||||||
</RadioGroupPrimitive.Item>
|
</RadioGroupPrimitive.Item>
|
||||||
<label
|
<span
|
||||||
htmlFor={id}
|
|
||||||
className={
|
className={
|
||||||
disabled
|
disabled
|
||||||
? 'text-vega-clight-200 dark:text-vega-cdark-200'
|
? 'text-vega-clight-200 dark:text-vega-cdark-200'
|
||||||
@ -93,7 +96,7 @@ export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user