Skip to content

Commit

Permalink
Move secondary ButtonIcon tone to icons (#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto committed Jun 14, 2024
1 parent 14fd45f commit 50f9888
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
18 changes: 18 additions & 0 deletions .changeset/slow-pears-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'braid-design-system': patch
---

---
updated:
- Autosuggest
- Dialog
- Drawer
- PasswordField
- Tag
- TextField
- useToast
---

Move secondary ButtonIcon tone to icons

Following the deprecation of the `secondary` tone of `ButtonIcon`, this updates all internal usages to apply the `secondary` tone directly to the icon.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ function SuggestionItem({
>
<ButtonIcon
id={`${id}-clear`}
icon={<IconClear />}
tone="secondary"
icon={<IconClear tone="secondary" />}
tabIndex={-1}
size="small"
label={clearLabel || 'Clear suggestion'}
Expand Down
3 changes: 1 addition & 2 deletions packages/braid-design-system/src/lib/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ export const Tag = ({
// @ts-expect-error With no id, ButtonIcon will fallback from Tooltip to title internally.
// ID will no longer be required when React 18 has sufficient adoption and we can safely `useId()`
id={id ? `${id}-clear` : undefined}
icon={<IconClear />}
icon={<IconClear tone="secondary" />}
label={clearLabel}
tone="secondary"
size="small"
variant="transparent"
onClick={onClear}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React, { type MouseEvent, useCallback, forwardRef } from 'react';
import React, {
type MouseEvent,
useCallback,
forwardRef,
cloneElement,
} from 'react';
import { type ButtonIconProps, ButtonIcon } from '../../ButtonIcon/ButtonIcon';

export const FieldButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(
({ label, onClick, onMouseDown, ...restProps }, forwardedRef) => {
({ label, onClick, onMouseDown, icon, ...restProps }, forwardedRef) => {
const handleMouseDown = useCallback(
(event: MouseEvent<HTMLButtonElement>) => {
if (typeof onMouseDown !== 'function') {
Expand Down Expand Up @@ -32,7 +37,7 @@ export const FieldButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(
<ButtonIcon
ref={forwardedRef}
label={label}
tone="secondary"
icon={cloneElement(icon, { tone: icon.props.tone || 'secondary' })}
variant="transparent"
size="small"
onClick={onClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ export const ModalContent = ({
<ButtonIcon
id={`${id}-close`}
label={closeLabel}
icon={<IconClear />}
tone="secondary"
icon={<IconClear tone="secondary" />}
variant="transparent"
size="large"
onClick={onClose}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ const Toast = React.forwardRef<HTMLDivElement, ToastProps>(
>
<ButtonIcon
id={`${dedupeKey}-clear`}
icon={<IconClear />}
tone="secondary"
icon={<IconClear tone="secondary" />}
variant="transparent"
onClick={remove}
label={closeLabel}
Expand Down
9 changes: 3 additions & 6 deletions site/src/App/routes/gallery/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -600,19 +600,17 @@ const GalleryInternal = () => {
<ButtonIcon
id="fitToScreen"
label="Fit to screen"
tone="secondary"
variant="transparent"
onClick={fitToScreen}
icon={<IconFitToScreen />}
icon={<IconFitToScreen tone="secondary" />}
/>
<ButtonIcon
id="zoomOut"
ref={zoomOutRef}
label="Zoom Out"
tone="secondary"
variant="transparent"
onClick={zoomOut}
icon={<IconMinus />}
icon={<IconMinus tone="secondary" />}
/>
<TooltipRenderer
id="zoomToActual"
Expand All @@ -635,10 +633,9 @@ const GalleryInternal = () => {
id="zoomIn"
ref={zoomInRef}
label="Zoom In"
tone="secondary"
variant="transparent"
onClick={zoomIn}
icon={<IconAdd />}
icon={<IconAdd tone="secondary" />}
/>
</Inline>
</Box>
Expand Down

0 comments on commit 50f9888

Please sign in to comment.