@toptal/picasso-button 1.0.10-alpha-feature-migrate-buttons-d11d10471.27 → 1.0.10-alpha-FX-5195-fix-button-css-precedence-cf39d169d.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-package/src/Button/Button.d.ts.map +1 -1
- package/dist-package/src/Button/Button.js +47 -39
- package/dist-package/src/Button/Button.js.map +1 -1
- package/dist-package/src/Button/styles.d.ts +45 -19
- package/dist-package/src/Button/styles.d.ts.map +1 -1
- package/dist-package/src/Button/styles.js +178 -160
- package/dist-package/src/Button/styles.js.map +1 -1
- package/dist-package/src/ButtonAction/ButtonAction.d.ts.map +1 -1
- package/dist-package/src/ButtonAction/ButtonAction.js +28 -20
- package/dist-package/src/ButtonAction/ButtonAction.js.map +1 -1
- package/dist-package/src/ButtonAction/styles.d.ts +3 -11
- package/dist-package/src/ButtonAction/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonAction/styles.js +55 -36
- package/dist-package/src/ButtonAction/styles.js.map +1 -1
- package/dist-package/src/ButtonCircular/ButtonCircular.d.ts.map +1 -1
- package/dist-package/src/ButtonCircular/ButtonCircular.js +26 -12
- package/dist-package/src/ButtonCircular/ButtonCircular.js.map +1 -1
- package/dist-package/src/ButtonCircular/styles.d.ts +3 -15
- package/dist-package/src/ButtonCircular/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonCircular/styles.js +57 -92
- package/dist-package/src/ButtonCircular/styles.js.map +1 -1
- package/dist-package/src/ButtonCompound/index.d.ts +1 -1
- package/dist-package/src/ButtonControlLabel/styles.d.ts +1 -1
- package/dist-package/src/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist-package/src/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist-package/src/ButtonGroup/ButtonGroup.js +27 -5
- package/dist-package/src/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist-package/src/ButtonGroup/styles.d.ts +2 -1
- package/dist-package/src/ButtonGroup/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonGroup/styles.js +47 -20
- package/dist-package/src/ButtonGroup/styles.js.map +1 -1
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.d.ts +1 -1
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.d.ts.map +1 -1
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.js +12 -17
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.js.map +1 -1
- package/dist-package/src/ButtonGroupItem/styles.d.ts +3 -13
- package/dist-package/src/ButtonGroupItem/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonGroupItem/styles.js +17 -39
- package/dist-package/src/ButtonGroupItem/styles.js.map +1 -1
- package/dist-package/src/ButtonSplit/ButtonSplit.d.ts.map +1 -1
- package/dist-package/src/ButtonSplit/ButtonSplit.js +24 -28
- package/dist-package/src/ButtonSplit/ButtonSplit.js.map +1 -1
- package/dist-package/src/ButtonSplit/styles.d.ts +3 -9
- package/dist-package/src/ButtonSplit/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonSplit/styles.js +50 -13
- package/dist-package/src/ButtonSplit/styles.js.map +1 -1
- package/package.json +15 -19
- package/src/Button/Button.tsx +100 -69
- package/src/Button/__snapshots__/test.tsx.snap +5 -6
- package/src/Button/styles.ts +221 -213
- package/src/Button/test.tsx +1 -3
- package/src/ButtonAction/ButtonAction.tsx +48 -36
- package/src/ButtonAction/styles.ts +57 -57
- package/src/ButtonCheckbox/__snapshots__/test.tsx.snap +3 -3
- package/src/ButtonCircular/ButtonCircular.tsx +37 -22
- package/src/ButtonCircular/styles.ts +75 -127
- package/src/ButtonGroup/ButtonGroup.tsx +44 -9
- package/src/ButtonGroup/__snapshots__/test.tsx.snap +7 -7
- package/src/ButtonGroup/styles.ts +63 -21
- package/src/ButtonGroupItem/ButtonGroupItem.tsx +15 -24
- package/src/ButtonGroupItem/styles.ts +28 -62
- package/src/ButtonRadio/__snapshots__/test.tsx.snap +3 -3
- package/src/ButtonSplit/ButtonSplit.tsx +42 -46
- package/src/ButtonSplit/__snapshots__/test.tsx.snap +9 -9
- package/src/ButtonSplit/styles.ts +56 -37
- package/dist-package/src/ButtonBase/ButtonBase.d.ts +0 -29
- package/dist-package/src/ButtonBase/ButtonBase.d.ts.map +0 -1
- package/dist-package/src/ButtonBase/ButtonBase.js +0 -78
- package/dist-package/src/ButtonBase/ButtonBase.js.map +0 -1
- package/dist-package/src/ButtonBase/index.d.ts +0 -5
- package/dist-package/src/ButtonBase/index.d.ts.map +0 -1
- package/dist-package/src/ButtonBase/index.js +0 -2
- package/dist-package/src/ButtonBase/index.js.map +0 -1
- package/dist-package/src/ButtonBase/styles.d.ts +0 -6
- package/dist-package/src/ButtonBase/styles.d.ts.map +0 -1
- package/dist-package/src/ButtonBase/styles.js +0 -29
- package/dist-package/src/ButtonBase/styles.js.map +0 -1
- package/src/ButtonBase/ButtonBase.tsx +0 -182
- package/src/ButtonBase/index.ts +0 -5
- package/src/ButtonBase/styles.ts +0 -36
|
@@ -1,37 +1,28 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import type { Theme } from '@material-ui/core'
|
|
3
|
+
import { makeStyles } from '@material-ui/core'
|
|
4
|
+
import cx from 'classnames'
|
|
3
5
|
|
|
4
6
|
import type { ButtonProps } from '../Button'
|
|
5
7
|
import { Button } from '../Button'
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import styles from './styles'
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles<Theme>(styles, {
|
|
11
|
+
name: 'PicassoButtonGroupItem',
|
|
12
|
+
})
|
|
10
13
|
|
|
11
14
|
export interface Props extends ButtonProps {}
|
|
12
15
|
|
|
13
|
-
const ButtonGroupItem = ({
|
|
14
|
-
|
|
15
|
-
disabled,
|
|
16
|
-
focused,
|
|
17
|
-
hovered,
|
|
18
|
-
className,
|
|
19
|
-
...rest
|
|
20
|
-
}: Props) => {
|
|
21
|
-
const finalClassName = twMerge(
|
|
22
|
-
createButtonGroupItemClassNames({ active, disabled, focused, hovered }),
|
|
23
|
-
createGroupVariantClassNames({ active, disabled, hovered }),
|
|
24
|
-
className
|
|
25
|
-
)
|
|
16
|
+
const ButtonGroupItem = (props: Props) => {
|
|
17
|
+
const classes = useStyles()
|
|
26
18
|
|
|
27
19
|
return (
|
|
28
20
|
<Button
|
|
29
|
-
{...
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
className={finalClassName}
|
|
21
|
+
{...props}
|
|
22
|
+
className={cx(props.className, classes.root, classes.group, {
|
|
23
|
+
[classes.active]: props.active,
|
|
24
|
+
[classes.disabled]: props.disabled,
|
|
25
|
+
})}
|
|
35
26
|
variant='secondary'
|
|
36
27
|
/>
|
|
37
28
|
)
|
|
@@ -1,64 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
focused,
|
|
4
|
-
hovered,
|
|
5
|
-
active,
|
|
6
|
-
}: {
|
|
7
|
-
disabled?: boolean
|
|
8
|
-
focused?: boolean
|
|
9
|
-
hovered?: boolean
|
|
10
|
-
active?: boolean
|
|
11
|
-
loading?: boolean
|
|
12
|
-
}) => {
|
|
13
|
-
const classNames = [
|
|
14
|
-
'border-solid',
|
|
15
|
-
'transition-[color,background]',
|
|
16
|
-
'active:z-[1] hover:z-[1] focus-visible:z-[1] disabled:z-[1]',
|
|
17
|
-
]
|
|
1
|
+
import type { Theme } from '@material-ui/core/styles'
|
|
2
|
+
import { createStyles } from '@material-ui/core/styles'
|
|
18
3
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
import {
|
|
5
|
+
createOutlineCommons,
|
|
6
|
+
activeGroup,
|
|
7
|
+
disabledGroup,
|
|
8
|
+
} from '../Button/styles'
|
|
22
9
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} else {
|
|
45
|
-
classNames.push('border-gray-500')
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
classNames.push(
|
|
49
|
-
'active:bg-graphite-700 active:border-graphite-700 active:text-white'
|
|
50
|
-
)
|
|
51
|
-
classNames.push('hover:border-black')
|
|
52
|
-
|
|
53
|
-
if (hovered) {
|
|
54
|
-
classNames.push('border-black text-black')
|
|
55
|
-
} else if (active) {
|
|
56
|
-
classNames.push('bg-graphite-700 border-graphite-700 text-white')
|
|
57
|
-
classNames.push('shadow-none')
|
|
58
|
-
} else {
|
|
59
|
-
classNames.push('border-gray-400 text-black')
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return classNames
|
|
64
|
-
}
|
|
10
|
+
export default (theme: Theme) =>
|
|
11
|
+
createStyles({
|
|
12
|
+
root: {
|
|
13
|
+
'&:active, &$active, &:hover, &$hovered, &:focus, &$focused, &:disabled, &$disabled':
|
|
14
|
+
{
|
|
15
|
+
// border overlap to keep proper border width, but on state change
|
|
16
|
+
// we need to move up overlapped border
|
|
17
|
+
zIndex: 1,
|
|
18
|
+
},
|
|
19
|
+
'&$group': {
|
|
20
|
+
...createOutlineCommons(theme),
|
|
21
|
+
'&:active, &$active': activeGroup(theme),
|
|
22
|
+
'&:disabled, &$disabled': disabledGroup(theme),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
active: {},
|
|
26
|
+
hovered: {},
|
|
27
|
+
focused: {},
|
|
28
|
+
disabled: {},
|
|
29
|
+
group: {},
|
|
30
|
+
})
|
|
@@ -6,14 +6,14 @@ exports[`ButtonRadio renders 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<label
|
|
9
|
-
|
|
9
|
+
aria-disabled="false"
|
|
10
|
+
class="MuiButtonBase-root PicassoButton-medium PicassoButton-secondary PicassoButton-root PicassoButtonControlLabel-root PicassoButtonControlLabel-medium"
|
|
10
11
|
data-component-type="button"
|
|
11
12
|
role="button"
|
|
12
13
|
tabindex="0"
|
|
13
|
-
type="button"
|
|
14
14
|
>
|
|
15
15
|
<span
|
|
16
|
-
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline
|
|
16
|
+
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
|
|
17
17
|
>
|
|
18
18
|
<span
|
|
19
19
|
aria-disabled="false"
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import type { ReactNode, MouseEvent, HTMLAttributes } from 'react'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
|
+
import type { Theme } from '@material-ui/core/styles'
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles'
|
|
3
5
|
import type { SizeType, BaseProps } from '@toptal/picasso-shared'
|
|
4
|
-
import
|
|
6
|
+
import cx from 'classnames'
|
|
5
7
|
import { ArrowDownMinor24, ArrowDownMinor16 } from '@toptal/picasso-icons'
|
|
6
8
|
import { Dropdown } from '@toptal/picasso-dropdown'
|
|
7
9
|
|
|
8
10
|
import type { ButtonProps } from '../Button'
|
|
9
11
|
import { Button } from '../Button'
|
|
10
12
|
import { ButtonGroup } from '../ButtonGroup'
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
createActionButtonClassNames,
|
|
14
|
-
createMenuButtonClassNames,
|
|
15
|
-
} from './styles'
|
|
13
|
+
import styles from './styles'
|
|
16
14
|
|
|
17
15
|
export interface Props
|
|
18
16
|
extends BaseProps,
|
|
@@ -37,6 +35,13 @@ export interface Props
|
|
|
37
35
|
menuButton?: string
|
|
38
36
|
}
|
|
39
37
|
}
|
|
38
|
+
// Using { index: -1 } to inject CSS link to the bottom of the head
|
|
39
|
+
// in order to prevent Button's styles to override ButtonSplit's ones
|
|
40
|
+
// Related Jira issue: https://toptal-core.atlassian.net/browse/FX-1520
|
|
41
|
+
const useStyles = makeStyles<Theme>(styles, {
|
|
42
|
+
name: 'PicassoButtonSplit',
|
|
43
|
+
index: -1,
|
|
44
|
+
})
|
|
40
45
|
|
|
41
46
|
const DropdownIcon = ({
|
|
42
47
|
size,
|
|
@@ -78,35 +83,37 @@ export const ButtonSplit = forwardRef<HTMLDivElement, Props>(
|
|
|
78
83
|
testIds = {},
|
|
79
84
|
...rest
|
|
80
85
|
} = props
|
|
86
|
+
const classes = useStyles()
|
|
81
87
|
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
hovered: menuButtonProps?.hovered,
|
|
87
|
-
disabled: menuButtonProps?.disabled || disabled,
|
|
88
|
-
focused: menuButtonProps?.focused,
|
|
89
|
-
}),
|
|
90
|
-
createMenuButtonClassNames({
|
|
91
|
-
variant,
|
|
92
|
-
size,
|
|
93
|
-
disabled: menuButtonProps?.disabled || disabled,
|
|
94
|
-
}),
|
|
95
|
-
menuButtonProps?.className
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const iconClassName = isOpen ? 'rotate-180' : ''
|
|
88
|
+
const commonClasses = cx(classes.button, {
|
|
89
|
+
[classes.primaryVariant]: variant === 'primary',
|
|
90
|
+
[classes.disabled]: disabled,
|
|
91
|
+
})
|
|
99
92
|
|
|
93
|
+
const renderMenuButton = ({
|
|
94
|
+
isOpen,
|
|
95
|
+
disabled,
|
|
96
|
+
}: {
|
|
97
|
+
isOpen: boolean
|
|
98
|
+
disabled?: boolean
|
|
99
|
+
}) => {
|
|
100
100
|
const menuButton = (
|
|
101
101
|
<Button
|
|
102
102
|
{...menuButtonProps}
|
|
103
103
|
variant={variant}
|
|
104
|
-
className={
|
|
104
|
+
className={`${commonClasses} ${classes.menuButton} ${
|
|
105
|
+
classes[`${size}Size`]
|
|
106
|
+
}`}
|
|
105
107
|
size={size}
|
|
106
108
|
disabled={disabled}
|
|
107
109
|
data-testid={testIds.menuButton}
|
|
108
110
|
>
|
|
109
|
-
<DropdownIcon
|
|
111
|
+
<DropdownIcon
|
|
112
|
+
className={cx({
|
|
113
|
+
[classes.rotated]: isOpen,
|
|
114
|
+
})}
|
|
115
|
+
size={size}
|
|
116
|
+
/>
|
|
110
117
|
</Button>
|
|
111
118
|
)
|
|
112
119
|
|
|
@@ -117,29 +124,11 @@ export const ButtonSplit = forwardRef<HTMLDivElement, Props>(
|
|
|
117
124
|
)
|
|
118
125
|
}
|
|
119
126
|
|
|
120
|
-
const actionButtonClassName = twMerge(
|
|
121
|
-
createButtonGroupItemClassNames({
|
|
122
|
-
active: actionButtonProps?.active,
|
|
123
|
-
hovered: actionButtonProps?.hovered,
|
|
124
|
-
disabled: actionButtonProps?.disabled || disabled,
|
|
125
|
-
focused: actionButtonProps?.focused,
|
|
126
|
-
}),
|
|
127
|
-
createActionButtonClassNames({
|
|
128
|
-
variant,
|
|
129
|
-
}),
|
|
130
|
-
actionButtonProps?.className
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
const dropdownClassName = twMerge(
|
|
134
|
-
'block cursor-pointer',
|
|
135
|
-
disabled && '[&>div]:cursor-auto'
|
|
136
|
-
)
|
|
137
|
-
|
|
138
127
|
return (
|
|
139
128
|
<ButtonGroup {...rest} ref={ref} style={style} className={className}>
|
|
140
129
|
<Button
|
|
141
130
|
{...actionButtonProps}
|
|
142
|
-
className={
|
|
131
|
+
className={`${commonClasses} ${classes.actionButton}`}
|
|
143
132
|
size={size}
|
|
144
133
|
variant={variant}
|
|
145
134
|
disabled={disabled}
|
|
@@ -148,8 +137,15 @@ export const ButtonSplit = forwardRef<HTMLDivElement, Props>(
|
|
|
148
137
|
>
|
|
149
138
|
{children}
|
|
150
139
|
</Button>
|
|
151
|
-
<Dropdown
|
|
152
|
-
{
|
|
140
|
+
<Dropdown
|
|
141
|
+
content={menu}
|
|
142
|
+
className={cx(classes.dropdown, {
|
|
143
|
+
[classes.disabled]: disabled,
|
|
144
|
+
})}
|
|
145
|
+
>
|
|
146
|
+
{({ isOpen }: { isOpen: boolean }) =>
|
|
147
|
+
renderMenuButton({ isOpen, disabled })
|
|
148
|
+
}
|
|
153
149
|
</Dropdown>
|
|
154
150
|
</ButtonGroup>
|
|
155
151
|
)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ButtonSplit closes menu on click to the item 1`] = `
|
|
4
4
|
<svg
|
|
5
|
-
class="PicassoSvgArrowDownMinor24-root-
|
|
5
|
+
class="PicassoSvgArrowDownMinor24-root-206"
|
|
6
6
|
style="min-width: 24px; min-height: 24px;"
|
|
7
7
|
viewBox="0 0 24 24"
|
|
8
8
|
>
|
|
@@ -18,34 +18,34 @@ exports[`ButtonSplit default render 1`] = `
|
|
|
18
18
|
class="Picasso-root"
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
21
|
-
class="
|
|
21
|
+
class="PicassoButtonGroup-root"
|
|
22
22
|
>
|
|
23
23
|
<button
|
|
24
|
-
class="
|
|
24
|
+
class="MuiButtonBase-root PicassoButton-medium PicassoButton-primary PicassoButton-root PicassoButtonSplit-primaryVariant PicassoButtonSplit-actionButton"
|
|
25
25
|
data-component-type="button"
|
|
26
26
|
tabindex="0"
|
|
27
27
|
type="button"
|
|
28
28
|
>
|
|
29
29
|
<span
|
|
30
|
-
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline
|
|
30
|
+
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
|
|
31
31
|
>
|
|
32
32
|
Action
|
|
33
33
|
</span>
|
|
34
34
|
</button>
|
|
35
35
|
<div
|
|
36
|
-
class="PicassoDropdown-root
|
|
36
|
+
class="PicassoDropdown-root PicassoButtonSplit-dropdown"
|
|
37
37
|
>
|
|
38
38
|
<div
|
|
39
39
|
class="PicassoDropdown-anchor"
|
|
40
40
|
>
|
|
41
41
|
<button
|
|
42
|
-
class="
|
|
42
|
+
class="MuiButtonBase-root PicassoButton-medium PicassoButton-primary PicassoButton-root PicassoButtonSplit-primaryVariant PicassoButtonSplit-menuButton PicassoButtonSplit-mediumSize"
|
|
43
43
|
data-component-type="button"
|
|
44
44
|
tabindex="0"
|
|
45
45
|
type="button"
|
|
46
46
|
>
|
|
47
47
|
<span
|
|
48
|
-
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline
|
|
48
|
+
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
|
|
49
49
|
>
|
|
50
50
|
<svg
|
|
51
51
|
class="PicassoSvgArrowDownMinor16-root"
|
|
@@ -67,7 +67,7 @@ exports[`ButtonSplit default render 1`] = `
|
|
|
67
67
|
|
|
68
68
|
exports[`ButtonSplit renders arrow down icon for a closed menu 1`] = `
|
|
69
69
|
<svg
|
|
70
|
-
class="PicassoSvgArrowDownMinor16-root-
|
|
70
|
+
class="PicassoSvgArrowDownMinor16-root-206"
|
|
71
71
|
style="min-width: 16px; min-height: 16px;"
|
|
72
72
|
viewBox="0 0 16 16"
|
|
73
73
|
>
|
|
@@ -79,7 +79,7 @@ exports[`ButtonSplit renders arrow down icon for a closed menu 1`] = `
|
|
|
79
79
|
|
|
80
80
|
exports[`ButtonSplit renders arrow up icon for an opened menu 1`] = `
|
|
81
81
|
<svg
|
|
82
|
-
class="PicassoSvgArrowDownMinor16-root-
|
|
82
|
+
class="PicassoSvgArrowDownMinor16-root-206 PicassoButtonSplit-rotated-12"
|
|
83
83
|
style="min-width: 16px; min-height: 16px;"
|
|
84
84
|
viewBox="0 0 16 16"
|
|
85
85
|
>
|
|
@@ -1,40 +1,59 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { Theme } from '@material-ui/core/styles'
|
|
2
|
+
import { createStyles } from '@material-ui/core/styles'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
export default ({ palette }: Theme) =>
|
|
5
|
+
createStyles({
|
|
6
|
+
actionButton: {
|
|
7
|
+
borderTopRightRadius: 0,
|
|
8
|
+
borderBottomRightRadius: 0,
|
|
9
|
+
},
|
|
10
|
+
menuButton: {
|
|
11
|
+
minWidth: '2em',
|
|
12
|
+
paddingLeft: '0.5em',
|
|
13
|
+
paddingRight: '0.5em',
|
|
14
|
+
borderTopLeftRadius: 0,
|
|
15
|
+
borderBottomLeftRadius: 0,
|
|
16
|
+
marginLeft: 0,
|
|
17
|
+
},
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
large: 'min-w-[3em] px-[0.75em]',
|
|
23
|
-
}
|
|
19
|
+
primaryVariant: {
|
|
20
|
+
'&$actionButton': {
|
|
21
|
+
borderRight: `1px solid ${palette.blue.darker}`,
|
|
22
|
+
},
|
|
23
|
+
'&$menuButton': {
|
|
24
|
+
borderLeft: `1px solid ${palette.blue.darker}`,
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
'&$disabled': {
|
|
27
|
+
borderLeftColor: palette.grey.main,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
smallSize: {
|
|
33
|
+
minWidth: '1.5em',
|
|
34
|
+
paddingLeft: '0.25em',
|
|
35
|
+
paddingRight: '0.25em',
|
|
36
|
+
},
|
|
37
|
+
mediumSize: {},
|
|
38
|
+
largeSize: {
|
|
39
|
+
minWidth: '3em',
|
|
40
|
+
paddingLeft: '0.75em',
|
|
41
|
+
paddingRight: '0.75em',
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
dropdown: {
|
|
45
|
+
display: 'block',
|
|
46
|
+
cursor: 'pointer',
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
disabled: {
|
|
50
|
+
// override dropdown anchor styles
|
|
51
|
+
'& > div': {
|
|
52
|
+
cursor: 'auto',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
rotated: {
|
|
57
|
+
transform: 'rotate(180deg)',
|
|
58
|
+
},
|
|
59
|
+
})
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { ReactNode, ReactElement, MouseEvent, ElementType } from 'react';
|
|
2
|
-
import type { StandardProps, ButtonOrAnchorProps, OverridableComponent, TextLabelProps } from '@toptal/picasso-shared';
|
|
3
|
-
export declare type IconPositionType = 'left' | 'right';
|
|
4
|
-
export interface Props extends StandardProps, TextLabelProps, ButtonOrAnchorProps {
|
|
5
|
-
as?: ElementType;
|
|
6
|
-
/** Disables button */
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
/** Content of Button component */
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
/** ClassName for the content */
|
|
11
|
-
contentClassName?: string;
|
|
12
|
-
/** Add an `<Icon />` along Button's children */
|
|
13
|
-
icon?: ReactElement;
|
|
14
|
-
/** Icon can be positioned on the left or right */
|
|
15
|
-
iconPosition?: IconPositionType;
|
|
16
|
-
/** Shows a loading indicator and disables click events */
|
|
17
|
-
loading?: boolean;
|
|
18
|
-
/** Callback invoked when component is clicked */
|
|
19
|
-
onClick?: (event: MouseEvent<HTMLButtonElement & HTMLAnchorElement>) => void;
|
|
20
|
-
/** HTML Value of Button component */
|
|
21
|
-
value?: string | number;
|
|
22
|
-
/** HTML title of Button component */
|
|
23
|
-
title?: string;
|
|
24
|
-
/** HTML type of Button component */
|
|
25
|
-
type?: 'button' | 'reset' | 'submit';
|
|
26
|
-
}
|
|
27
|
-
export declare const ButtonBase: OverridableComponent<Props>;
|
|
28
|
-
export default ButtonBase;
|
|
29
|
-
//# sourceMappingURL=ButtonBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.ts","sourceRoot":"","sources":["../../../src/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EAEZ,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAS/B,oBAAY,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAA;AAE/C,MAAM,WAAW,KACf,SAAQ,aAAa,EACnB,cAAc,EACd,mBAAmB;IACrB,EAAE,CAAC,EAAE,WAAW,CAAA;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,gCAAgC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gDAAgD;IAChD,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,kDAAkD;IAClD,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,iDAAiD;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,KAAK,IAAI,CAAA;IAC5E,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;CACrC;AAyBD,eAAO,MAAM,UAAU,EAAE,oBAAoB,CAAC,KAAK,CA4FjD,CAAA;AAcF,eAAe,UAAU,CAAA"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import React, { forwardRef } from 'react';
|
|
13
|
-
import { twMerge } from 'tailwind-merge';
|
|
14
|
-
import { useTitleCase } from '@toptal/picasso-shared';
|
|
15
|
-
import { Button as MUIButtonBase } from '@mui/base/Button';
|
|
16
|
-
import { Loader } from '@toptal/picasso-loader';
|
|
17
|
-
import { Container } from '@toptal/picasso-container';
|
|
18
|
-
import { noop, toTitleCase } from '@toptal/picasso-utils';
|
|
19
|
-
import { createCoreClassNames } from './styles';
|
|
20
|
-
const getClickHandler = (loading, handler) => loading ? noop : handler;
|
|
21
|
-
const getIcon = ({ icon }) => {
|
|
22
|
-
if (!icon) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return React.cloneElement(icon, {
|
|
26
|
-
className: twMerge('text-[1.2em] flex-1', icon.props.className),
|
|
27
|
-
key: 'button-icon',
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
const isReactComponent = (component) => {
|
|
32
|
-
return (component &&
|
|
33
|
-
(component.$$typeof === Symbol.for('react.forward_ref') ||
|
|
34
|
-
typeof component === 'function'));
|
|
35
|
-
};
|
|
36
|
-
export const ButtonBase = forwardRef(function ButtonBase(props, ref) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const { icon, iconPosition, loading, children, className, contentClassName, style, disabled, onClick, title, value, type, as = 'button', titleCase: propsTitleCase } = props, rest = __rest(props, ["icon", "iconPosition", "loading", "children", "className", "contentClassName", "style", "disabled", "onClick", "title", "value", "type", "as", "titleCase"]);
|
|
39
|
-
let RootElement = as;
|
|
40
|
-
if (isReactComponent(RootElement)) {
|
|
41
|
-
RootElement = forwardRef(
|
|
42
|
-
// We don't need to pass ownerState to the root component
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
-
(_a, rootRef) => {
|
|
45
|
-
var { ownerState } = _a, restProps = __rest(_a, ["ownerState"]);
|
|
46
|
-
const Root = as;
|
|
47
|
-
return React.createElement(Root, Object.assign({ ref: rootRef }, restProps));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const titleCase = useTitleCase(propsTitleCase);
|
|
51
|
-
const finalChildren = [titleCase ? toTitleCase(children) : children];
|
|
52
|
-
const rootElementName = as !== 'button' && ('href' in props || 'to' in props) ? 'a' : undefined;
|
|
53
|
-
if (icon) {
|
|
54
|
-
const iconComponent = getIcon({ icon });
|
|
55
|
-
if (iconPosition === 'left') {
|
|
56
|
-
finalChildren.unshift(iconComponent);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
finalChildren.push(iconComponent);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const finalClassName = twMerge(createCoreClassNames({ disabled }), className);
|
|
63
|
-
return (React.createElement(MUIButtonBase, Object.assign({}, rest, { ref: ref, onClick: getClickHandler(loading, onClick), className: finalClassName, style: style, "aria-disabled": disabled, disabled: disabled, title: title, value: value, type: type, "data-component-type": 'button', tabIndex: ((_a = rest.tabIndex) !== null && _a !== void 0 ? _a : disabled) ? -1 : 0, role: (_b = rest.role) !== null && _b !== void 0 ? _b : 'button', rootElementName: rootElementName, slots: { root: RootElement } }),
|
|
64
|
-
React.createElement(Container, { as: 'span', inline: true, flex: true, direction: 'row', alignItems: 'center', className: contentClassName }, finalChildren),
|
|
65
|
-
loading && (React.createElement(Loader, { variant: 'inherit', className: 'absolute top-1/2 left-1/2 translate-x-[-50%] translate-y-[-50%]', inline: true, size: 'small' }))));
|
|
66
|
-
});
|
|
67
|
-
ButtonBase.defaultProps = {
|
|
68
|
-
as: 'button',
|
|
69
|
-
children: null,
|
|
70
|
-
disabled: false,
|
|
71
|
-
iconPosition: 'left',
|
|
72
|
-
loading: false,
|
|
73
|
-
onClick: noop,
|
|
74
|
-
type: 'button',
|
|
75
|
-
};
|
|
76
|
-
ButtonBase.displayName = 'ButtonBase';
|
|
77
|
-
export default ButtonBase;
|
|
78
|
-
//# sourceMappingURL=ButtonBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.js","sourceRoot":"","sources":["../../../src/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;AAOA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAOxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AA+B/C,MAAM,eAAe,GAAG,CAAC,OAAiB,EAAE,OAA0B,EAAE,EAAE,CACxE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAA;AAE1B,MAAM,OAAO,GAAG,CAAC,E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B,oBAAC,SAAS,IACR,EAAE,EAAC,MAAM,EACT,MAAM,QACN,IAAI,QACJ,SAAS,EAAC,KAAK,EACf,UAAU,EAAC,QAAQ,EACnB,SAAS,EAAE,gBAAgB,IAE1B,aAAa,CACJ;QAEX,OAAO,IAAI,CACV,oBAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,iEAAiE,EAC3E,MAAM,QACN,IAAI,EAAC,OAAO,GACZ,CACH,CACa,CACjB,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,UAAU,CAAC,YAAY,GAAG;IACxB,EAAE,EAAE,QAAQ;IACZ,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,MAAM;IACpB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,QAAQ;CACf,CAAA;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAErC,eAAe,UAAU,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ButtonBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,oBAAY,eAAe,GAAG,KAAK,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ButtonBase/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/ButtonBase/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;MAO7B,MAAM,EA4BT,CAAA"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const createCoreClassNames = ({ disabled, loading, }) => {
|
|
2
|
-
const classNames = [
|
|
3
|
-
'text-lg',
|
|
4
|
-
'inline-flex',
|
|
5
|
-
'items-center',
|
|
6
|
-
'justify-center',
|
|
7
|
-
'select-none',
|
|
8
|
-
'appearance-none',
|
|
9
|
-
'm-0',
|
|
10
|
-
'relative',
|
|
11
|
-
'normal-case',
|
|
12
|
-
'align-middle',
|
|
13
|
-
'transition-colors',
|
|
14
|
-
'duration-350',
|
|
15
|
-
'ease-out',
|
|
16
|
-
'shrink-0',
|
|
17
|
-
'outline-none',
|
|
18
|
-
'[&+&]:ml-4',
|
|
19
|
-
];
|
|
20
|
-
if (!disabled && !loading) {
|
|
21
|
-
classNames.push('cursor-pointer');
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
classNames.push('cursor-default');
|
|
25
|
-
classNames.push('pointer-events-none');
|
|
26
|
-
}
|
|
27
|
-
return classNames;
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=styles.js.map
|