@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.
Files changed (80) hide show
  1. package/dist-package/src/Button/Button.d.ts.map +1 -1
  2. package/dist-package/src/Button/Button.js +47 -39
  3. package/dist-package/src/Button/Button.js.map +1 -1
  4. package/dist-package/src/Button/styles.d.ts +45 -19
  5. package/dist-package/src/Button/styles.d.ts.map +1 -1
  6. package/dist-package/src/Button/styles.js +178 -160
  7. package/dist-package/src/Button/styles.js.map +1 -1
  8. package/dist-package/src/ButtonAction/ButtonAction.d.ts.map +1 -1
  9. package/dist-package/src/ButtonAction/ButtonAction.js +28 -20
  10. package/dist-package/src/ButtonAction/ButtonAction.js.map +1 -1
  11. package/dist-package/src/ButtonAction/styles.d.ts +3 -11
  12. package/dist-package/src/ButtonAction/styles.d.ts.map +1 -1
  13. package/dist-package/src/ButtonAction/styles.js +55 -36
  14. package/dist-package/src/ButtonAction/styles.js.map +1 -1
  15. package/dist-package/src/ButtonCircular/ButtonCircular.d.ts.map +1 -1
  16. package/dist-package/src/ButtonCircular/ButtonCircular.js +26 -12
  17. package/dist-package/src/ButtonCircular/ButtonCircular.js.map +1 -1
  18. package/dist-package/src/ButtonCircular/styles.d.ts +3 -15
  19. package/dist-package/src/ButtonCircular/styles.d.ts.map +1 -1
  20. package/dist-package/src/ButtonCircular/styles.js +57 -92
  21. package/dist-package/src/ButtonCircular/styles.js.map +1 -1
  22. package/dist-package/src/ButtonCompound/index.d.ts +1 -1
  23. package/dist-package/src/ButtonControlLabel/styles.d.ts +1 -1
  24. package/dist-package/src/ButtonGroup/ButtonGroup.d.ts +1 -1
  25. package/dist-package/src/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  26. package/dist-package/src/ButtonGroup/ButtonGroup.js +27 -5
  27. package/dist-package/src/ButtonGroup/ButtonGroup.js.map +1 -1
  28. package/dist-package/src/ButtonGroup/styles.d.ts +2 -1
  29. package/dist-package/src/ButtonGroup/styles.d.ts.map +1 -1
  30. package/dist-package/src/ButtonGroup/styles.js +47 -20
  31. package/dist-package/src/ButtonGroup/styles.js.map +1 -1
  32. package/dist-package/src/ButtonGroupItem/ButtonGroupItem.d.ts +1 -1
  33. package/dist-package/src/ButtonGroupItem/ButtonGroupItem.d.ts.map +1 -1
  34. package/dist-package/src/ButtonGroupItem/ButtonGroupItem.js +12 -17
  35. package/dist-package/src/ButtonGroupItem/ButtonGroupItem.js.map +1 -1
  36. package/dist-package/src/ButtonGroupItem/styles.d.ts +3 -13
  37. package/dist-package/src/ButtonGroupItem/styles.d.ts.map +1 -1
  38. package/dist-package/src/ButtonGroupItem/styles.js +17 -39
  39. package/dist-package/src/ButtonGroupItem/styles.js.map +1 -1
  40. package/dist-package/src/ButtonSplit/ButtonSplit.d.ts.map +1 -1
  41. package/dist-package/src/ButtonSplit/ButtonSplit.js +24 -28
  42. package/dist-package/src/ButtonSplit/ButtonSplit.js.map +1 -1
  43. package/dist-package/src/ButtonSplit/styles.d.ts +3 -9
  44. package/dist-package/src/ButtonSplit/styles.d.ts.map +1 -1
  45. package/dist-package/src/ButtonSplit/styles.js +50 -13
  46. package/dist-package/src/ButtonSplit/styles.js.map +1 -1
  47. package/package.json +15 -19
  48. package/src/Button/Button.tsx +100 -69
  49. package/src/Button/__snapshots__/test.tsx.snap +5 -6
  50. package/src/Button/styles.ts +221 -213
  51. package/src/Button/test.tsx +1 -3
  52. package/src/ButtonAction/ButtonAction.tsx +48 -36
  53. package/src/ButtonAction/styles.ts +57 -57
  54. package/src/ButtonCheckbox/__snapshots__/test.tsx.snap +3 -3
  55. package/src/ButtonCircular/ButtonCircular.tsx +37 -22
  56. package/src/ButtonCircular/styles.ts +75 -127
  57. package/src/ButtonGroup/ButtonGroup.tsx +44 -9
  58. package/src/ButtonGroup/__snapshots__/test.tsx.snap +7 -7
  59. package/src/ButtonGroup/styles.ts +63 -21
  60. package/src/ButtonGroupItem/ButtonGroupItem.tsx +15 -24
  61. package/src/ButtonGroupItem/styles.ts +28 -62
  62. package/src/ButtonRadio/__snapshots__/test.tsx.snap +3 -3
  63. package/src/ButtonSplit/ButtonSplit.tsx +42 -46
  64. package/src/ButtonSplit/__snapshots__/test.tsx.snap +9 -9
  65. package/src/ButtonSplit/styles.ts +56 -37
  66. package/dist-package/src/ButtonBase/ButtonBase.d.ts +0 -29
  67. package/dist-package/src/ButtonBase/ButtonBase.d.ts.map +0 -1
  68. package/dist-package/src/ButtonBase/ButtonBase.js +0 -78
  69. package/dist-package/src/ButtonBase/ButtonBase.js.map +0 -1
  70. package/dist-package/src/ButtonBase/index.d.ts +0 -5
  71. package/dist-package/src/ButtonBase/index.d.ts.map +0 -1
  72. package/dist-package/src/ButtonBase/index.js +0 -2
  73. package/dist-package/src/ButtonBase/index.js.map +0 -1
  74. package/dist-package/src/ButtonBase/styles.d.ts +0 -6
  75. package/dist-package/src/ButtonBase/styles.d.ts.map +0 -1
  76. package/dist-package/src/ButtonBase/styles.js +0 -29
  77. package/dist-package/src/ButtonBase/styles.js.map +0 -1
  78. package/src/ButtonBase/ButtonBase.tsx +0 -182
  79. package/src/ButtonBase/index.ts +0 -5
  80. package/src/ButtonBase/styles.ts +0 -36
@@ -1,58 +1,58 @@
1
- import type { IconPositionType } from '../ButtonBase'
1
+ import type { Theme } from '@material-ui/core/styles'
2
+ import { createStyles } from '@material-ui/core/styles'
2
3
 
3
- export const createRootClassNames = ({
4
- disabled,
5
- focused,
6
- hovered,
7
- active,
8
- loading,
9
- }: {
10
- disabled?: boolean
11
- focused?: boolean
12
- hovered?: boolean
13
- active?: boolean
14
- loading?: boolean
15
- }) => {
16
- const classNames = ['border-none', 'px-0', 'bg-transparent', 'h-[1.5em]']
17
-
18
- if (disabled) {
19
- classNames.push('opacity-[.48]')
20
- } else if (loading) {
21
- classNames.push('no-underline')
22
- classNames.push('!cursor-default')
23
- } else {
24
- classNames.push('hover:text-blue-500')
25
- classNames.push('hover:underline')
26
- classNames.push('active:text-blue-500')
27
- classNames.push('active:underline')
28
-
29
- if (hovered || active) {
30
- classNames.push('text-blue-500')
31
- classNames.push('underline')
32
- }
33
-
34
- classNames.push('focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)]')
35
- classNames.push('focus-visible:rounded-sm')
36
-
37
- if (focused) {
38
- classNames.push('shadow-[0_0_0_3px_rgba(32,78,207,0.48)]')
39
- classNames.push('rounded-sm')
40
- }
41
- }
42
-
43
- return classNames
44
- }
45
-
46
- export const createIconClassNames = ({
47
- iconPosition,
48
- }: {
49
- iconPosition?: IconPositionType
50
- }): string[] => {
51
- return [
52
- 'w-4',
53
- 'h-4',
54
- 'text-graphite-700',
55
- iconPosition === 'left' ? 'mr-[0.5rem]' : '',
56
- iconPosition === 'right' ? 'ml-[0.5rem]' : '',
57
- ]
58
- }
4
+ export default ({ palette, typography }: Theme) =>
5
+ createStyles({
6
+ root: {
7
+ border: 'none',
8
+ minWidth: 'unset',
9
+ paddingLeft: '0',
10
+ paddingRight: '0',
11
+ backgroundColor: 'transparent',
12
+ '&:active, &$active, &:hover, &$hovered': {
13
+ backgroundColor: 'transparent',
14
+ color: palette.blue.main,
15
+ textDecoration: 'underline',
16
+ },
17
+ '&$loading': {
18
+ textDecoration: 'none',
19
+ cursor: 'default',
20
+ },
21
+ '&$disabled': {
22
+ backgroundColor: 'transparent',
23
+ opacity: 0.48,
24
+ },
25
+ },
26
+ content: {
27
+ fontWeight: typography.fontWeights.semibold,
28
+ color: palette.blue.main,
29
+ },
30
+ small: {
31
+ '& $content': {
32
+ fontSize: '0.875rem',
33
+ lineHeight: '1.375rem',
34
+ },
35
+ '& $iconLeft': {
36
+ marginLeft: 0,
37
+ },
38
+ '& $iconRight': {
39
+ marginRight: 0,
40
+ },
41
+ },
42
+ icon: {
43
+ width: '1rem',
44
+ height: '1rem',
45
+ color: palette.grey.dark,
46
+ },
47
+ iconLeft: {
48
+ marginRight: '0.5rem',
49
+ },
50
+ iconRight: {
51
+ marginLeft: '0.5rem',
52
+ },
53
+ active: {},
54
+ disabled: {},
55
+ hovered: {},
56
+ focused: {},
57
+ loading: {},
58
+ })
@@ -6,14 +6,14 @@ exports[`ButtonCheckbox renders 1`] = `
6
6
  class="Picasso-root"
7
7
  >
8
8
  <label
9
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle transition-colors duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border border-solid text-black hover:border-black visited:text-black active:bg-gray active:border-black bg-white border-gray min-w h-8 py-0 px-4 PicassoButtonControlLabel-root PicassoButtonControlLabel-medium"
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 font-semibold whitespace-nowrap text-button"
16
+ class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
17
17
  >
18
18
  <span
19
19
  class="PicassoContainer-flex PicassoContainer-inline PicassoCheckbox-checkboxWrapper"
@@ -1,14 +1,17 @@
1
1
  import type { ReactElement, MouseEvent, ElementType } from 'react'
2
2
  import React, { forwardRef } from 'react'
3
3
  import cx from 'classnames'
4
+ import type { Theme } from '@material-ui/core/styles'
5
+ import { makeStyles } from '@material-ui/core/styles'
4
6
  import type {
5
7
  BaseProps,
6
8
  ButtonOrAnchorProps,
7
9
  OverridableComponent,
8
10
  } from '@toptal/picasso-shared'
11
+ import { kebabToCamelCase } from '@toptal/picasso-utils'
9
12
 
10
- import { ButtonBase } from '../ButtonBase'
11
- import { createRootClassNames, createVariantClassNames } from './styles'
13
+ import { Button } from '../Button'
14
+ import styles from './styles'
12
15
 
13
16
  export type VariantType = 'primary' | 'flat' | 'transparent'
14
17
 
@@ -37,6 +40,14 @@ export interface Props extends BaseProps, ButtonOrAnchorProps {
37
40
  responsive?: boolean
38
41
  }
39
42
 
43
+ // Using { index: -1 } to inject CSS link to the bottom of the head
44
+ // in order to prevent Button's styles to override ButtonCircular's ones
45
+ // Related Jira issue: https://toptal-core.atlassian.net/browse/FX-1520
46
+ const useStyles = makeStyles<Theme>(styles, {
47
+ name: 'PicassoButtonCircular',
48
+ index: -1,
49
+ })
50
+
40
51
  export const ButtonCircular: OverridableComponent<Props> = forwardRef<
41
52
  HTMLButtonElement,
42
53
  Props
@@ -49,35 +60,39 @@ export const ButtonCircular: OverridableComponent<Props> = forwardRef<
49
60
  hovered,
50
61
  disabled,
51
62
  responsive,
52
- loading,
53
63
  ...rest
54
64
  } = props
55
- const variantClassNames = createVariantClassNames(variant, {
56
- disabled,
57
- focused,
58
- hovered,
59
- active,
60
- })
65
+ const classes = useStyles()
61
66
 
62
- const finalClassName = cx(
63
- createRootClassNames({ responsive, active, disabled, focused, hovered }),
64
- variantClassNames,
65
- className
66
- )
67
+ const { root: rootClass, focusVisible: focusVisibleClass } = classes
68
+
69
+ const variantClassName = classes[kebabToCamelCase(variant)]
67
70
 
68
- const contentClassName = cx(
69
- 'font-semibold whitespace-nowrap',
70
- 'text-button-small',
71
- loading ? 'opacity-0' : ''
71
+ const rootClassName = cx(
72
+ {
73
+ [classes.active]: active,
74
+ [classes.focused]: focused,
75
+ [classes.hovered]: hovered,
76
+ [classes.disabled]: disabled,
77
+ [classes.responsive]: responsive,
78
+ },
79
+ variantClassName,
80
+ rootClass
72
81
  )
73
82
 
74
83
  return (
75
- <ButtonBase
84
+ <Button
76
85
  {...rest}
77
86
  ref={ref}
78
- loading={loading}
79
- className={finalClassName}
80
- contentClassName={contentClassName}
87
+ classes={{
88
+ root: rootClassName,
89
+ focusVisible: focusVisibleClass,
90
+ }}
91
+ className={className}
92
+ size='small'
93
+ active={active}
94
+ hovered={hovered}
95
+ focused={focused}
81
96
  disabled={disabled}
82
97
  />
83
98
  )
@@ -1,127 +1,75 @@
1
- import type { VariantType } from './ButtonCircular'
2
-
3
- export const createRootClassNames = ({
4
- responsive,
5
- }: {
6
- disabled?: boolean
7
- focused?: boolean
8
- hovered?: boolean
9
- active?: boolean
10
- loading?: boolean
11
- responsive?: boolean
12
- }) => {
13
- const classNames = ['rounded-full', 'p-0']
14
-
15
- if (responsive) {
16
- classNames.push('w-[2.5em] h-[2.5em] xl:w-[1.5em] xl:h-[1.5em]')
17
- } else {
18
- classNames.push('w-[1.5em] h-[1.5em]')
19
- }
20
-
21
- return classNames
22
- }
23
-
24
- export const createVariantClassNames = (
25
- variant: VariantType,
26
- {
27
- disabled,
28
- focused,
29
- hovered,
30
- active,
31
- }: {
32
- disabled?: boolean
33
- focused?: boolean
34
- hovered?: boolean
35
- active?: boolean
36
- }
37
- ): string[] => {
38
- const variantClassNames = []
39
-
40
- switch (variant) {
41
- case 'primary':
42
- variantClassNames.push('border-none')
43
- variantClassNames.push('text-white')
44
- variantClassNames.push('visited:text-white')
45
-
46
- if (disabled) {
47
- variantClassNames.push('bg-gray-400')
48
- } else {
49
- variantClassNames.push('hover:bg-[#4269D6]')
50
- variantClassNames.push('active:bg-[#1A41AB]')
51
-
52
- variantClassNames.push(
53
- 'focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)]'
54
- )
55
- if (focused) {
56
- variantClassNames.push('shadow-[0_0_0_3px_rgba(32,78,207,0.48)]')
57
- }
58
-
59
- if (hovered) {
60
- variantClassNames.push('bg-[#4269D6]')
61
- } else if (active) {
62
- variantClassNames.push('bg-[#1A41AB]')
63
- } else {
64
- variantClassNames.push('bg-blue-500')
65
- }
66
- }
67
- break
68
- case 'flat':
69
- variantClassNames.push('border-none')
70
- variantClassNames.push('text-graphite-700')
71
-
72
- if (disabled) {
73
- variantClassNames.push('text-graphite-700')
74
- variantClassNames.push('opacity-[0.48]')
75
- variantClassNames.push('bg-transparent')
76
- } else {
77
- variantClassNames.push('hover:bg-gray-200')
78
- variantClassNames.push('active:bg-gray-400')
79
-
80
- variantClassNames.push(
81
- 'focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)]'
82
- )
83
- if (focused) {
84
- variantClassNames.push('shadow-[0_0_0_3px_rgba(32,78,207,0.48)]')
85
- }
86
-
87
- if (hovered) {
88
- variantClassNames.push('bg-gray-200')
89
- } else if (active) {
90
- variantClassNames.push('bg-gray-400')
91
- } else {
92
- variantClassNames.push('bg-transparent')
93
- }
94
- }
95
- break
96
- case 'transparent':
97
- variantClassNames.push('border-none')
98
- variantClassNames.push('text-white')
99
-
100
- if (disabled) {
101
- variantClassNames.push('text-white/[0.48]')
102
- variantClassNames.push('bg-transparent')
103
- } else {
104
- variantClassNames.push('hover:bg-white/[0.08]')
105
- variantClassNames.push('active:bg-white/[0.16]')
106
-
107
- variantClassNames.push(
108
- 'focus-visible:shadow-[0_0_0_3px_rgba(255,255,255,0.48)]'
109
- )
110
- if (focused) {
111
- variantClassNames.push('shadow-[0_0_0_3px_rgba(255,255,255,0.48)]')
112
- }
113
-
114
- if (hovered) {
115
- variantClassNames.push('bg-white/[0.08]')
116
- } else if (active) {
117
- variantClassNames.push('bg-white/[0.16]')
118
- } else {
119
- variantClassNames.push('bg-transparent')
120
- }
121
- }
122
-
123
- break
124
- }
125
-
126
- return variantClassNames
127
- }
1
+ import type { Theme } from '@material-ui/core/styles'
2
+ import { createStyles } from '@material-ui/core/styles'
3
+ import { alpha, outline } from '@toptal/picasso-shared'
4
+ import { screens } from '@toptal/picasso-provider'
5
+
6
+ export default ({ palette }: Theme) =>
7
+ createStyles({
8
+ root: {
9
+ borderRadius: '50%',
10
+ padding: 0,
11
+ minWidth: 'initial',
12
+ width: '1.5em',
13
+ },
14
+
15
+ primary: {},
16
+
17
+ responsive: {
18
+ width: '2.5em',
19
+ height: '2.5em',
20
+ [screens('xl')]: {
21
+ width: '1.5em',
22
+ height: '1.5em',
23
+ },
24
+ },
25
+
26
+ flat: {
27
+ color: palette.grey.dark,
28
+ backgroundColor: 'initial',
29
+
30
+ '&:hover, &$hovered': {
31
+ backgroundColor: palette.grey.lighter2,
32
+ },
33
+
34
+ '&:active, &$active': {
35
+ backgroundColor: palette.grey.light2,
36
+ },
37
+
38
+ '&$disabled': {
39
+ opacity: 0.48,
40
+ color: palette.grey.dark,
41
+ backgroundColor: 'initial',
42
+ },
43
+
44
+ border: 'none',
45
+ },
46
+
47
+ transparent: {
48
+ border: 'none',
49
+ color: palette.common.white,
50
+ backgroundColor: 'initial',
51
+
52
+ '&$focusVisible, &$focused': {
53
+ ...outline(palette.common.white),
54
+ },
55
+
56
+ '&:hover, &$hovered': {
57
+ backgroundColor: alpha(palette.common.white, 0.08),
58
+ },
59
+
60
+ '&:active, &$active': {
61
+ backgroundColor: alpha(palette.common.white, 0.16),
62
+ },
63
+
64
+ '&$disabled': {
65
+ color: alpha(palette.common.white, 0.48),
66
+ backgroundColor: 'initial',
67
+ },
68
+ },
69
+
70
+ disabled: {},
71
+ hovered: {},
72
+ focused: {},
73
+ active: {},
74
+ focusVisible: {},
75
+ })
@@ -1,25 +1,60 @@
1
- import type { ReactNode, HTMLAttributes } from 'react'
2
- import React, { forwardRef } from 'react'
3
- import { twMerge } from 'tailwind-merge'
4
- import type { BaseProps } from '@toptal/picasso-shared'
1
+ import type { ReactNode, HTMLAttributes, ElementType } from 'react'
2
+ import React, { forwardRef, useMemo } from 'react'
3
+ import type { Theme } from '@material-ui/core/styles'
4
+ import { makeStyles } from '@material-ui/core/styles'
5
+ import cx from 'classnames'
6
+ import type { BaseProps, Classes } from '@toptal/picasso-shared'
7
+ import { addClassesToChildren } from '@toptal/picasso-shared'
5
8
 
9
+ import { Button } from '../Button'
6
10
  import { ButtonGroupItem } from '../ButtonGroupItem'
7
- import { createRootClassNames } from './styles'
11
+ import styles from './styles'
8
12
 
9
13
  export interface Props extends BaseProps, HTMLAttributes<HTMLDivElement> {
10
14
  /** List of `Button` components which you want to render as `ButtonGroup` */
11
15
  children: ReactNode
12
16
  }
13
17
 
18
+ const useStyles = makeStyles<Theme>(styles, {
19
+ name: 'PicassoButtonGroup',
20
+ })
21
+
22
+ const getChildrenClassesConfig = (
23
+ classes: Classes
24
+ ): [ElementType, Classes][] => [
25
+ [
26
+ Button,
27
+ {
28
+ root: classes.button,
29
+ active: classes.active,
30
+ focused: classes.focused,
31
+ hovered: classes.hovered,
32
+ },
33
+ ],
34
+ ]
35
+
14
36
  export const ButtonGroup = forwardRef<HTMLDivElement, Props>(
15
37
  function ButtonGroup(props, ref) {
16
38
  const { children, className, style, ...rest } = props
17
-
18
- const finalClassName = twMerge(createRootClassNames(), className)
39
+ const classes = useStyles()
40
+ const childrenWithClasses = useMemo(
41
+ () =>
42
+ addClassesToChildren({
43
+ children,
44
+ classes,
45
+ config: getChildrenClassesConfig,
46
+ }),
47
+ [children, classes]
48
+ )
19
49
 
20
50
  return (
21
- <div {...rest} ref={ref} className={finalClassName} style={style}>
22
- {children}
51
+ <div
52
+ {...rest}
53
+ ref={ref}
54
+ className={cx(classes.root, className)}
55
+ style={style}
56
+ >
57
+ {childrenWithClasses}
23
58
  </div>
24
59
  )
25
60
  }
@@ -6,40 +6,40 @@ exports[`ButtonGroup render 1`] = `
6
6
  class="Picasso-root"
7
7
  >
8
8
  <div
9
- class="flex justify-start [&>[data-component-type="button"]:hover]:z [&>[data-component-type="button"]:first-child:not(:last-child)]:rounded-r [&>[data-component-type="button"]:first-child:not(:last-child)]:ml [&>[data-component-type="button"]:not(:first-child):not(:last-child)]:rounded [&>[data-component-type="button"]:not(:first-child):not(:last-child)]:ml-[ [&>[data-component-type="button"]:last-child:not(:first-child)]:rounded-l [&>[data-component-type="button"]:last-child:not(:first-child)]:ml-[ [&_:first-child:not(:last-child)_[data-component-type="button"]]:rounded-r [&_:first-child:not(:last-child)_[data-component-type="button"]]:ml [&_:not(:first-child):not(:last-child)_[data-component-type="button"]]:rounded [&_:not(:first-child):not(:last-child)_[data-component-type="button"]]:ml-[ [&_:last-child:not(:first-child)_[data-component-type="button"]]:rounded-l [&_:last-child:not(:first-child)_[data-component-type="button"]]:ml-["
9
+ class="PicassoButtonGroup-root"
10
10
  >
11
11
  <button
12
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border bg-white min-w h-8 py-0 px-4 transition-[color,background] active:z-[1] hover:z-[1] focus-visible:z-[1] disabled:z-[1] visited:text-black border-solid active:bg-graphite active:border-graphite active:text-white hover:border-black border-gray text-black"
12
+ class="MuiButtonBase-root PicassoButton-medium PicassoButton-secondary PicassoButton-root PicassoButtonGroupItem-root PicassoButtonGroupItem-group"
13
13
  data-component-type="button"
14
14
  tabindex="0"
15
15
  type="button"
16
16
  >
17
17
  <span
18
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
18
+ class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
19
19
  >
20
20
  One
21
21
  </span>
22
22
  </button>
23
23
  <button
24
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline rounded-sm focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border min-w h-8 py-0 px-4 transition-[color,background] active:z-[1] hover:z-[1] focus-visible:z-[1] disabled:z-[1] z-[1] visited:text-black border-solid active:bg-graphite active:border-graphite active:text-white hover:border-black bg-graphite border-graphite text-white shadow-none"
24
+ class="MuiButtonBase-root PicassoButton-active PicassoButton-medium PicassoButton-secondary PicassoButton-root PicassoButtonGroupItem-root PicassoButtonGroupItem-group PicassoButtonGroupItem-active"
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 font-semibold whitespace-nowrap text-button"
30
+ class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
31
31
  >
32
32
  Two
33
33
  </span>
34
34
  </button>
35
35
  <button
36
- class="base-Button text-lg inline-flex items-center justify-center select-none appearance-none m-0 relative normal-case align-middle duration-350 ease-out shrink-0 outline-none [&+&]:ml-4 cursor-pointer no-underline rounded-sm shadow-none focus-visible:shadow-[0_0_0_3px_rgba(32,78,207,0.48)] border bg-white min-w h-8 py-0 px-4 transition-[color,background] active:z-[1] hover:z-[1] focus-visible:z-[1] disabled:z-[1] visited:text-black border-solid active:bg-graphite active:border-graphite active:text-white hover:border-black border-gray text-black"
36
+ class="MuiButtonBase-root PicassoButton-medium PicassoButton-secondary PicassoButton-root PicassoButtonGroupItem-root PicassoButtonGroupItem-group"
37
37
  data-component-type="button"
38
38
  tabindex="0"
39
39
  type="button"
40
40
  >
41
41
  <span
42
- class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline font-semibold whitespace-nowrap text-button"
42
+ class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-inline PicassoButton-content"
43
43
  >
44
44
  Three
45
45
  </span>
@@ -1,29 +1,71 @@
1
- export const createRootClassNames = () => {
2
- const classNames: string[] = [
3
- 'flex',
4
- 'justify-start',
1
+ import { createStyles } from '@material-ui/core/styles'
5
2
 
6
- '[&>[data-component-type="button"]:hover]:z-[1]',
3
+ const baseButtonProps = {
4
+ transitionProperty: 'color, background',
7
5
 
8
- '[&>[data-component-type="button"]:first-child:not(:last-child)]:rounded-r-none',
9
- '[&>[data-component-type="button"]:first-child:not(:last-child)]:ml-0',
6
+ '&:active, &$active, &:hover, &$hovered, &:focus, &$focused': {
7
+ // border overlap to keep proper border width, but on state change
8
+ // we need to move up overlapped border
9
+ zIndex: 1,
10
+ },
11
+ }
12
+
13
+ const firstButtonProps = {
14
+ borderTopRightRadius: 0,
15
+ borderBottomRightRadius: 0,
16
+ marginLeft: '0rem',
17
+ }
18
+
19
+ const middleButtonProps = {
20
+ borderRadius: 0,
21
+ // prevents border between 2 buttons to be wider then specified
22
+ marginLeft: '-1px',
23
+ }
24
+
25
+ const lastButtonProps = {
26
+ borderTopLeftRadius: 0,
27
+ borderBottomLeftRadius: 0,
28
+ // prevents border between 2 buttons to be wider then specified
29
+ marginLeft: '-1px',
30
+ }
10
31
 
11
- '[&>[data-component-type="button"]:not(:first-child):not(:last-child)]:rounded-none',
12
- '[&>[data-component-type="button"]:not(:first-child):not(:last-child)]:ml-[-1px]',
32
+ export default () =>
33
+ createStyles({
34
+ root: {
35
+ display: 'flex',
36
+ justifyContent: 'flex-start',
13
37
 
14
- '[&>[data-component-type="button"]:last-child:not(:first-child)]:rounded-l-none',
15
- '[&>[data-component-type="button"]:last-child:not(:first-child)]:ml-[-1px]',
38
+ // default case
39
+ '& [data-component-type="button"]': {
40
+ ...baseButtonProps,
16
41
 
17
- // nested buttons
18
- '[&_:first-child:not(:last-child)_[data-component-type="button"]]:rounded-r-none',
19
- '[&_:first-child:not(:last-child)_[data-component-type="button"]]:ml-0',
42
+ // first item
43
+ '&:first-child:not(:last-child)': firstButtonProps,
44
+ // middle item
45
+ '&:not(:first-child):not(:last-child)': middleButtonProps,
46
+ // last item
47
+ '&:last-child:not(:first-child)': lastButtonProps,
48
+ },
20
49
 
21
- '[&_:not(:first-child):not(:last-child)_[data-component-type="button"]]:rounded-none',
22
- '[&_:not(:first-child):not(:last-child)_[data-component-type="button"]]:ml-[-1px]',
50
+ // nested case when button is nested in first item in ButtonGroup
51
+ '& :first-child:not(:last-child) [data-component-type="button"]': {
52
+ ...baseButtonProps,
53
+ ...firstButtonProps,
54
+ },
23
55
 
24
- '[&_:last-child:not(:first-child)_[data-component-type="button"]]:rounded-l-none',
25
- '[&_:last-child:not(:first-child)_[data-component-type="button"]]:ml-[-1px]',
26
- ]
56
+ // nested case when button is nested in middle item in ButtonGroup
57
+ '& :not(:first-child):not(:last-child) [data-component-type="button"]': {
58
+ ...baseButtonProps,
59
+ ...middleButtonProps,
60
+ },
27
61
 
28
- return classNames
29
- }
62
+ // nested case when button is nested in last item in ButtonGroup
63
+ '& :last-child:not(:first-child) [data-component-type="button"]': {
64
+ ...baseButtonProps,
65
+ ...lastButtonProps,
66
+ },
67
+ },
68
+ active: {},
69
+ focused: {},
70
+ hovered: {},
71
+ })