1
1
import { LockIcon } from '@sanity/icons'
2
2
import {
3
3
type BadgeTone ,
4
- Box ,
5
4
Button , // eslint-disable-line no-restricted-imports
6
- Flex ,
7
- Text ,
8
5
useClickOutsideEvent ,
9
6
useGlobalKeyDown ,
10
7
useToast ,
11
8
} from '@sanity/ui'
12
- // eslint-disable-next-line camelcase
13
9
import {
14
10
memo ,
15
11
type MouseEvent ,
@@ -20,7 +16,7 @@ import {
20
16
useRef ,
21
17
useState ,
22
18
} from 'react'
23
- import { css , styled } from 'styled-components'
19
+ import { styled } from 'styled-components'
24
20
25
21
import { Popover , Tooltip } from '../../../../ui-components'
26
22
import { useTranslation } from '../../../i18n/hooks/useTranslation'
@@ -30,37 +26,21 @@ import {useVersionOperations} from '../../hooks/useVersionOperations'
30
26
import { type ReleaseDocument , type ReleaseState } from '../../store/types'
31
27
import { getReleaseIdFromReleaseDocumentId } from '../../util/getReleaseIdFromReleaseDocumentId'
32
28
import { DiscardVersionDialog } from '../dialog/DiscardVersionDialog'
33
- import { ReleaseAvatar } from '../ReleaseAvatar'
29
+ import { ReleaseAvatarIcon } from '../ReleaseAvatar'
34
30
import { VersionContextMenu } from './contextMenu/VersionContextMenu'
35
31
import { CopyToNewReleaseDialog } from './dialog/CopyToNewReleaseDialog'
36
32
37
- interface ChipStyleProps {
38
- $isArchived ?: boolean
39
- }
33
+ const ChipButtonContainer = styled . span `
34
+ display: inline-flex;
35
+ --border-color: var(--card-border-color);
36
+ `
40
37
41
- const ChipButton = styled ( Button ) < ChipStyleProps > ( ( { $isArchived} ) => {
42
- return css `
43
- flex : none;
44
- transition : none;
45
- cursor : pointer;
46
-
47
- // target enabled state
48
- & : not ([data-disabled = 'true' ]) {
49
- --card-border-color : var (--card-badge-default-bg-color );
50
- }
51
-
52
- & [data-disabled = 'true' ] {
53
- color : var (--card-muted-fg-color );
54
- cursor : default;
55
-
56
- // archived will be disabled but should have bg color
57
- ${ $isArchived &&
58
- css `
59
- background-color : var (--card-badge-default-bg-color );
60
- ` }
61
- }
62
- `
63
- } )
38
+ const ChipButton = styled ( Button ) `
39
+ flex: none;
40
+ transition: none;
41
+ cursor: pointer;
42
+ --card-border-color: var(--border-color);
43
+ `
64
44
65
45
/**
66
46
* @internal
@@ -208,35 +188,26 @@ export const VersionChip = memo(function VersionChip(props: {
208
188
< >
209
189
< Tooltip content = { tooltipContent } fallbackPlacements = { [ ] } portal placement = "bottom" >
210
190
{ /* This span is needed to make the tooltip work in disabled buttons */ }
211
- < span style = { { display : 'inline-flex' } } >
191
+ < ChipButtonContainer >
212
192
< ChipButton
213
193
data-testid = { `document-header-${ text . replaceAll ( ' ' , '-' ) } -chip` }
214
194
ref = { chipRef }
215
195
disabled = { disabled }
216
- mode = " bleed"
196
+ mode = { disabled ? 'ghost' : ' bleed' }
217
197
onClick = { onClick }
218
198
selected = { selected }
219
199
tone = { tone }
220
200
onContextMenu = { contextMenuHandler }
221
- padding = { 2 }
201
+ paddingY = { 2 }
202
+ paddingLeft = { 2 }
222
203
paddingRight = { 3 }
204
+ space = { 2 }
223
205
radius = "full"
224
- $isArchived = { releaseState === 'archived' }
225
- text = {
226
- < Flex align = "center" gap = { 1 } >
227
- < ReleaseAvatar padding = { 1 } tone = { tone } />
228
- < Box flex = "none" padding = { 1 } >
229
- < Text size = { 1 } > { text } </ Text >
230
- </ Box >
231
- { locked && (
232
- < Box paddingRight = { 1 } >
233
- < LockIcon />
234
- </ Box >
235
- ) }
236
- </ Flex >
237
- }
206
+ icon = { < ReleaseAvatarIcon tone = { tone } /> }
207
+ iconRight = { locked && < LockIcon /> }
208
+ text = { text }
238
209
/>
239
- </ span >
210
+ </ ChipButtonContainer >
240
211
</ Tooltip >
241
212
242
213
< Popover
0 commit comments