Skip to content

Commit 35bcbd7

Browse files
Update ui-box, rip out glamor where possible (#1543)
1 parent 72645ad commit 35bcbd7

File tree

6 files changed

+53
-54
lines changed

6 files changed

+53
-54
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"react-fast-compare": "^3.2.0",
7878
"react-transition-group": "^4.4.1",
7979
"tinycolor2": "^1.4.1",
80-
"ui-box": "^5.1.0"
80+
"ui-box": "^5.2.1"
8181
},
8282
"peerDependencies": {
8383
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",

src/avatar/src/Avatar.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useState, memo, forwardRef, useCallback } from 'react'
22
import cx from 'classnames'
3-
import { css } from 'glamor'
43
import PropTypes from 'prop-types'
54
import Box from 'ui-box'
65
import { useStyleConfig } from '../../hooks'
@@ -22,15 +21,6 @@ const internalStyles = {
2221

2322
const isObjectFitSupported = typeof document !== 'undefined' && 'objectFit' in document.documentElement.style
2423

25-
const initialsStyleClass = css({
26-
top: 0,
27-
position: 'absolute',
28-
display: 'flex',
29-
alignItems: 'center',
30-
justifyContent: 'center',
31-
lineHeight: 1
32-
}).toString()
33-
3424
const getAvatarInitialsFontSize = (size, sizeLimitOneCharacter) => {
3525
if (size <= sizeLimitOneCharacter) {
3626
return Math.floor(size / 2.2)
@@ -86,7 +76,11 @@ const Avatar = memo(
8676
>
8777
{(imageUnavailable || forceShowInitials) && (
8878
<Text
89-
className={initialsStyleClass}
79+
top={0}
80+
position="absolute"
81+
display="flex"
82+
alignItems="center"
83+
justifyContent="center"
9084
fontSize={initialsFontSize}
9185
lineHeight={initialsFontSize}
9286
width={size}

src/badges/src/Badge.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { memo, forwardRef } from 'react'
22
import cx from 'classnames'
3-
import { css } from 'glamor'
43
import PropTypes from 'prop-types'
54
import { useStyleConfig } from '../../hooks'
65
import { Strong } from '../../typography'
@@ -13,12 +12,14 @@ const internalStyles = {
1312
verticalAlign: 'middle'
1413
}
1514

16-
const hoverClassName = css({
17-
'&:hover': {
18-
opacity: 0.8
15+
const interactiveStyles = {
16+
selectors: {
17+
'&:hover': {
18+
opacity: 0.8
19+
}
1920
},
2021
cursor: 'pointer'
21-
})
22+
}
2223

2324
const Badge = memo(
2425
forwardRef(function Badge(props, ref) {
@@ -35,7 +36,8 @@ const Badge = memo(
3536
<Strong
3637
ref={ref}
3738
size={300}
38-
className={cx(className, themedClassName, isInteractive && hoverClassName)}
39+
className={cx(className, themedClassName)}
40+
{...(isInteractive ? interactiveStyles : {})}
3941
{...styleProps}
4042
{...restProps}
4143
/>

src/table/src/SearchTableHeaderCell.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
import React, { memo, forwardRef, useCallback } from 'react'
2-
import { css } from 'glamor'
32
import PropTypes from 'prop-types'
43
import { SearchIcon } from '../../icons'
54
import { IconWrapper } from '../../icons/src/IconWrapper'
65
import { Text } from '../../typography'
76
import TableHeaderCell from './TableHeaderCell'
87

9-
const invisibleInputClass = css({
10-
border: 'none',
11-
backgroundColor: 'transparent',
12-
WebkitAppearance: 'none',
13-
MozAppearance: 'none',
14-
WebkitFontSmoothing: 'antialiased',
15-
16-
'&:focus': {
17-
outline: 'none'
18-
},
19-
20-
'&::placeholder': {
21-
color: 'rgba(67, 90, 111, 0.7)'
22-
}
23-
}).toString()
24-
258
const noop = () => {}
269

10+
/**
11+
* This prop is non-standard, macOS specific and unsupported by ui-box. We probably don't need it,
12+
* but retaining it for backwards compatibility
13+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth
14+
*/
15+
const style = {
16+
'-webkit-font-smoothing': 'antialiased'
17+
}
18+
2719
const SearchTableHeaderCell = memo(
2820
forwardRef(function SearchTableHeaderCell(props, ref) {
2921
const {
@@ -46,7 +38,18 @@ const SearchTableHeaderCell = memo(
4638
is="input"
4739
size={300}
4840
flex="1"
49-
className={invisibleInputClass}
41+
border="none"
42+
backgroundColor="transparent"
43+
appearance="none"
44+
style={style}
45+
selectors={{
46+
'&:focus': {
47+
outline: 'none'
48+
},
49+
'&::placeholder': {
50+
color: 'rgba(67, 90, 111, 0.7)'
51+
}
52+
}}
5053
value={value}
5154
onChange={handleChange}
5255
autoFocus={autoFocus}

src/toaster/src/ToastManager.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import React, { memo, useState } from 'react'
2-
import { css } from 'glamor'
32
import PropTypes from 'prop-types'
3+
import Box from 'ui-box'
44
import { StackingOrder } from '../../constants'
55
import Toast from './Toast'
66

7-
const wrapperClass = css({
8-
maxWidth: 560,
9-
margin: '0 auto',
10-
top: 0,
11-
left: 0,
12-
right: 0,
13-
position: 'fixed',
14-
zIndex: StackingOrder.TOASTER,
15-
pointerEvents: 'none'
16-
})
17-
187
const hasCustomId = settings => Object.hasOwnProperty.call(settings, 'id')
198

209
const ToastManager = memo(function ToastManager(props) {
@@ -94,15 +83,26 @@ const ToastManager = memo(function ToastManager(props) {
9483
bindCloseAll(closeAll)
9584

9685
return (
97-
<span className={wrapperClass}>
86+
<Box
87+
is="span"
88+
maxWidth={560}
89+
marginY={0}
90+
marginX="auto"
91+
top={0}
92+
left={0}
93+
right={0}
94+
position="fixed"
95+
zIndex={StackingOrder.TOASTER}
96+
pointerEvents="none"
97+
>
9898
{toasts.map(({ description, id, ...rest }) => {
9999
return (
100100
<Toast key={id} onRemove={() => removeToast(id)} {...rest}>
101101
{description}
102102
</Toast>
103103
)
104104
})}
105-
</span>
105+
</Box>
106106
)
107107
})
108108

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14012,10 +14012,10 @@ ua-parser-js@^0.7.18:
1401214012
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31"
1401314013
integrity sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==
1401414014

14015-
ui-box@^5.1.0:
14016-
version "5.1.0"
14017-
resolved "https://registry.yarnpkg.com/ui-box/-/ui-box-5.1.0.tgz#3b62d4089f0b4c3e7c5db60cff32adba0e268605"
14018-
integrity sha512-3FYTKhYKu8JaZmg1+iYzrHUpZDtrAiIdhLBbaVV/u5TL6Zfg1U7OkI00eFJNASa/D+b0SwJjt5Ph6tzmcub1RQ==
14015+
ui-box@^5.2.1:
14016+
version "5.2.1"
14017+
resolved "https://registry.yarnpkg.com/ui-box/-/ui-box-5.2.1.tgz#b38a583ed1951c6bfe547af3cdd744cb9c8da710"
14018+
integrity sha512-ZxiZSOTuvG9K3DAy+J9kcN2bBW9+pzg4pZOrMHcL8PsHu6S7MtOfJUjxqiBPaoHuGy8w5cn9W8leUC15D3Fw+A==
1401914019
dependencies:
1402014020
"@emotion/hash" "^0.7.1"
1402114021
inline-style-prefixer "^5.0.4"

0 commit comments

Comments
 (0)