Skip to content

Commit d1cf32c

Browse files
committed
Refactor clear button in FormDrawImage component for improved styling and accessibility. Replace Button component with a native button element, enhancing the user experience and aligning with design tokens for consistent styling.
1 parent 371a04a commit d1cf32c

1 file changed

Lines changed: 14 additions & 36 deletions

File tree

assets/src/js/v3/shared/components/fields/quiz/questions/FormDrawImage.tsx

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@ import { css } from '@emotion/react';
22
import { __ } from '@wordpress/i18n';
33
import { useCallback, useEffect, useRef, useState } from 'react';
44

5-
import Button from '@TutorShared/atoms/Button';
65
import ImageInput from '@TutorShared/atoms/ImageInput';
76
import SVGIcon from '@TutorShared/atoms/SVGIcon';
87

9-
import {
10-
borderRadius,
11-
Breakpoint,
12-
colorTokens,
13-
spacing,
14-
fontFamily,
15-
fontSize,
16-
fontWeight,
17-
lineHeight,
18-
letterSpacing,
19-
} from '@TutorShared/config/styles';
8+
import { borderRadius, Breakpoint, colorTokens, spacing } from '@TutorShared/config/styles';
209
import { typography } from '@TutorShared/config/typography';
2110
import Show from '@TutorShared/controls/Show';
2211
import useWPMedia from '@TutorShared/hooks/useWpMedia';
@@ -528,15 +517,10 @@ const FormDrawImage = ({ field, precisionControl }: FormDrawImageProps) => {
528517
</span>
529518
{__('Mark the correct area', __TUTOR_TEXT_DOMAIN__)}
530519
</span>
531-
<Button
532-
variant="tertiary"
533-
size="small"
534-
onClick={handleClear}
535-
icon={<SVGIcon name="eraser" width={18} height={18} style={styles.clearIcon} />}
536-
css={styles.clearButton}
537-
>
520+
<button type="button" css={styles.clearButton} onClick={handleClear}>
521+
<SVGIcon name="eraser" style={styles.clearButtonIcon} width={18} height={18} />
538522
{__('Clear', __TUTOR_TEXT_DOMAIN__)}
539-
</Button>
523+
</button>
540524
</div>
541525
<div css={styles.canvasInner} onMouseEnter={handleCanvasMouseEnter} onMouseLeave={handleCanvasMouseLeave}>
542526
<img
@@ -677,25 +661,19 @@ const styles = {
677661
`,
678662
clearButton: css`
679663
width: 94px;
680-
height: 32px;
681-
border-radius: 6px;
682664
border: none;
683-
box-shadow: none;
684-
padding: 4px 12px;
685-
gap: 4px;
665+
border-radius: ${borderRadius.input};
686666
background: ${colorTokens.action.secondary.default};
667+
${typography.caption('medium')};
668+
color: ${colorTokens.text.brand};
669+
display: flex;
670+
justify-content: center;
671+
align-items: center;
672+
gap: ${spacing[8]};
673+
padding: ${spacing[4]} 0;
674+
`,
675+
clearButtonIcon: css`
687676
color: ${colorTokens.text.brand};
688-
font-family: ${fontFamily.sfProDisplay};
689-
font-weight: ${fontWeight.medium};
690-
font-size: ${fontSize[13]};
691-
line-height: ${lineHeight[20]};
692-
letter-spacing: ${letterSpacing.normal};
693-
text-align: center;
694-
&:hover {
695-
background: ${colorTokens.action.secondary.hover};
696-
border: none;
697-
box-shadow: none;
698-
}
699677
`,
700678
clearIcon: css`
701679
color: ${colorTokens.text.brand};

0 commit comments

Comments
 (0)