Skip to content

Commit

Permalink
Use the IconButton for the close button on Dialog (#5066)
Browse files Browse the repository at this point in the history
* Use the IconButton for the close button on Dialog

* Create tidy-impalas-remain.md

* Remove Octicon import

* Update snapshots

* test(vrt): update snapshots

---------

Co-authored-by: jonrohan <jonrohan@users.noreply.github.com>
  • Loading branch information
jonrohan and jonrohan authored Oct 4, 2024
1 parent b00874c commit 702ba5c
Show file tree
Hide file tree
Showing 41 changed files with 21 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-impalas-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Use the IconButton for the close button on Dialog
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 4 additions & 16 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, {useCallback, useEffect, useRef, useState, type SyntheticEvent} from 'react'
import styled from 'styled-components'
import type {ButtonProps} from '../Button'
import {Button} from '../Button'
import {Button, IconButton} from '../Button'
import Box from '../Box'
import {get} from '../constants'
import {useOnEscapePress, useProvidedRefOrCreate} from '../hooks'
import {useFocusTrap} from '../hooks/useFocusTrap'
import type {SxProp} from '../sx'
import sx from '../sx'
import Octicon from '../Octicon'
import {XIcon} from '@primer/octicons-react'
import {useFocusZone} from '../hooks/useFocusZone'
import {FocusKeys} from '@primer/behaviors'
Expand Down Expand Up @@ -590,22 +589,11 @@ const Buttons: React.FC<React.PropsWithChildren<{buttons: DialogButtonProps[]}>>
</>
)
}
const DialogCloseButton = styled(Button)`
border-radius: 4px;
background: transparent;
border: 0;
vertical-align: middle;
color: ${get('colors.fg.muted')};
padding: ${get('space.2')};
align-self: flex-start;
line-height: normal;
box-shadow: none;
`

const CloseButton: React.FC<React.PropsWithChildren<{onClose: () => void}>> = ({onClose}) => {
return (
<DialogCloseButton aria-label="Close" onClick={onClose}>
<Octicon icon={XIcon} />
</DialogCloseButton>
// eslint-disable-next-line primer-react/a11y-remove-disable-tooltip
<IconButton unsafeDisableTooltip={true} icon={XIcon} aria-label="Close" onClick={onClose} variant="invisible" />
)
}

Expand Down
24 changes: 12 additions & 12 deletions packages/react/src/NavList/__snapshots__/NavList.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1029,12 +1029,6 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav
display: block;
}
.c9 {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.c0 {
margin: 0;
padding-inline-start: 0;
Expand Down Expand Up @@ -1313,6 +1307,12 @@ exports[`NavList.Item with NavList.SubNav does not have active styles if SubNav
text-decoration: none;
}
.c9 {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
@media (forced-colors:active) {
}
Expand Down Expand Up @@ -1534,12 +1534,6 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t
word-break: break-word;
}
.c9 {
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
.c0 {
margin: 0;
padding-inline-start: 0;
Expand Down Expand Up @@ -1839,6 +1833,12 @@ exports[`NavList.Item with NavList.SubNav has active styles if SubNav contains t
text-decoration: none;
}
.c9 {
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
@media (forced-colors:active) {
}
Expand Down

0 comments on commit 702ba5c

Please sign in to comment.