@toptal/picasso-tabs 3.0.2-alpha-fx-5726-create-base-preset-package-7cdb4a4dd.32 → 3.0.2-alpha-fx-null-revert-tabs-b3f67a2fa.31
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/Tab/Tab.d.ts +3 -3
- package/dist-package/src/Tab/Tab.d.ts.map +1 -1
- package/dist-package/src/Tab/Tab.js +14 -62
- package/dist-package/src/Tab/Tab.js.map +1 -1
- package/dist-package/src/Tab/styles.d.ts +4 -0
- package/dist-package/src/Tab/styles.d.ts.map +1 -0
- package/dist-package/src/Tab/styles.js +94 -0
- package/dist-package/src/Tab/styles.js.map +1 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.d.ts +12 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.d.ts.map +1 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.js +40 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.js.map +1 -0
- package/dist-package/src/TabScrollButton/index.d.ts +5 -0
- package/dist-package/src/TabScrollButton/index.d.ts.map +1 -0
- package/dist-package/src/TabScrollButton/index.js +2 -0
- package/dist-package/src/TabScrollButton/index.js.map +1 -0
- package/dist-package/src/TabScrollButton/styles.d.ts +4 -0
- package/dist-package/src/TabScrollButton/styles.d.ts.map +1 -0
- package/dist-package/src/TabScrollButton/styles.js +35 -0
- package/dist-package/src/TabScrollButton/styles.js.map +1 -0
- package/dist-package/src/Tabs/Tabs.d.ts +4 -13
- package/dist-package/src/Tabs/Tabs.d.ts.map +1 -1
- package/dist-package/src/Tabs/Tabs.js +21 -51
- package/dist-package/src/Tabs/Tabs.js.map +1 -1
- package/dist-package/src/Tabs/styles.d.ts +4 -0
- package/dist-package/src/Tabs/styles.d.ts.map +1 -0
- package/dist-package/src/Tabs/styles.js +41 -0
- package/dist-package/src/Tabs/styles.js.map +1 -0
- package/dist-package/src/Tabs/use-tab-action.d.ts +5 -0
- package/dist-package/src/Tabs/use-tab-action.d.ts.map +1 -0
- package/dist-package/src/Tabs/use-tab-action.js +21 -0
- package/dist-package/src/Tabs/use-tab-action.js.map +1 -0
- package/dist-package/src/TabsCompound/index.d.ts +2 -4
- package/dist-package/src/TabsCompound/index.d.ts.map +1 -1
- package/dist-package/src/index.d.ts +1 -0
- package/dist-package/src/index.d.ts.map +1 -1
- package/dist-package/src/index.js +1 -0
- package/dist-package/src/index.js.map +1 -1
- package/package.json +16 -16
- package/src/Tab/Tab.tsx +21 -99
- package/src/Tab/__snapshots__/test.tsx.snap +47 -32
- package/src/Tab/styles.ts +106 -0
- package/src/TabScrollButton/TabScrollButton.tsx +64 -0
- package/src/TabScrollButton/index.ts +6 -0
- package/src/TabScrollButton/styles.ts +37 -0
- package/src/Tabs/Tabs.tsx +42 -94
- package/src/Tabs/__snapshots__/test.tsx.snap +76 -61
- package/src/Tabs/styles.ts +45 -0
- package/src/Tabs/test.tsx +1 -1
- package/src/Tabs/use-tab-action.ts +27 -0
- package/src/index.ts +1 -0
@@ -1,7 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
export declare const TabsCompound: (<
|
3
|
-
|
4
|
-
}) => JSX.Element | null) & {
|
5
|
-
Tab: import("react").ForwardRefExoticComponent<import("../Tab/Tab").Props & import("react").RefAttributes<HTMLButtonElement>>;
|
2
|
+
export declare const TabsCompound: import("react").ForwardRefExoticComponent<import("../Tabs/Tabs").Props<import("../Tabs").TabsValueType> & import("react").RefAttributes<HTMLButtonElement>> & {
|
3
|
+
Tab: import("react").ForwardRefExoticComponent<import("../Tab/Tab").Props & import("react").RefAttributes<HTMLDivElement>>;
|
6
4
|
};
|
7
5
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabsCompound/index.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabsCompound/index.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;CAEvB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@toptal/picasso-tabs",
|
3
|
-
"version": "3.0.2-alpha-fx-
|
3
|
+
"version": "3.0.2-alpha-fx-null-revert-tabs-b3f67a2fa.31+b3f67a2fa",
|
4
4
|
"description": "Toptal UI components library - Tabs",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -22,14 +22,13 @@
|
|
22
22
|
},
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
24
24
|
"dependencies": {
|
25
|
-
"@
|
26
|
-
"@toptal/picasso-
|
27
|
-
"@toptal/picasso-
|
28
|
-
"@toptal/picasso-
|
29
|
-
"@toptal/picasso-typography": "
|
30
|
-
"@toptal/picasso-
|
31
|
-
"@toptal/picasso-
|
32
|
-
"@toptal/picasso-utils": "1.0.4-alpha-fx-5726-create-base-preset-package-7cdb4a4dd.125+7cdb4a4dd",
|
25
|
+
"@toptal/picasso-container": "2.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
26
|
+
"@toptal/picasso-icons": "1.6.1-alpha-fx-null-revert-tabs-b3f67a2fa.31+b3f67a2fa",
|
27
|
+
"@toptal/picasso-shared": "15.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.124+b3f67a2fa",
|
28
|
+
"@toptal/picasso-typography": "3.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
29
|
+
"@toptal/picasso-typography-overflow": "2.0.5-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
30
|
+
"@toptal/picasso-user-badge": "3.0.2-alpha-fx-null-revert-tabs-b3f67a2fa.31+b3f67a2fa",
|
31
|
+
"@toptal/picasso-utils": "1.0.4-alpha-fx-null-revert-tabs-b3f67a2fa.124+b3f67a2fa",
|
33
32
|
"ap-style-title-case": "^1.1.2",
|
34
33
|
"classnames": "^2.5.1"
|
35
34
|
},
|
@@ -38,22 +37,23 @@
|
|
38
37
|
"**/styles.js"
|
39
38
|
],
|
40
39
|
"peerDependencies": {
|
41
|
-
"@
|
42
|
-
"@toptal/picasso-
|
43
|
-
"react": ">=16.12.0 < 19.0.0"
|
40
|
+
"@material-ui/core": "4.12.4",
|
41
|
+
"@toptal/picasso-provider": "*",
|
42
|
+
"react": ">=16.12.0 < 19.0.0",
|
43
|
+
"tailwindcss": ">=3"
|
44
44
|
},
|
45
45
|
"exports": {
|
46
46
|
".": "./dist-package/src/index.js"
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
|
-
"@toptal/picasso-provider": "5.0.1-alpha-fx-
|
50
|
-
"@toptal/picasso-tailwind-merge": "1.2.1-alpha-fx-
|
51
|
-
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-
|
49
|
+
"@toptal/picasso-provider": "5.0.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
50
|
+
"@toptal/picasso-tailwind-merge": "1.2.1-alpha-fx-null-revert-tabs-b3f67a2fa.45+b3f67a2fa",
|
51
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-null-revert-tabs-b3f67a2fa.124+b3f67a2fa"
|
52
52
|
},
|
53
53
|
"files": [
|
54
54
|
"dist-package/**",
|
55
55
|
"!dist-package/tsconfig.tsbuildinfo",
|
56
56
|
"src"
|
57
57
|
],
|
58
|
-
"gitHead": "
|
58
|
+
"gitHead": "b3f67a2fa9c785bf8251fbfdcfe27163597835d0"
|
59
59
|
}
|
package/src/Tab/Tab.tsx
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
import type { ReactNode, HTMLAttributes, ReactElement } from 'react'
|
2
2
|
import React, { forwardRef, useContext } from 'react'
|
3
|
-
import type {
|
4
|
-
import {
|
3
|
+
import type { Theme } from '@material-ui/core/styles'
|
4
|
+
import { makeStyles } from '@material-ui/core/styles'
|
5
|
+
import type { TabProps } from '@material-ui/core'
|
6
|
+
import { Tab as MUITab } from '@material-ui/core'
|
5
7
|
import type { BaseProps, TextLabelProps } from '@toptal/picasso-shared'
|
6
8
|
import { useTitleCase } from '@toptal/picasso-shared'
|
7
9
|
import { UserBadge } from '@toptal/picasso-user-badge'
|
8
|
-
import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge'
|
9
10
|
|
10
|
-
import
|
11
|
+
import styles from './styles'
|
12
|
+
import { TabsOrientationContext } from '../Tabs/Tabs'
|
11
13
|
import { TabLabel } from '../TabLabel'
|
12
14
|
import { TabDescription } from '../TabDescription'
|
13
15
|
|
14
16
|
export interface Props
|
15
17
|
extends BaseProps,
|
16
18
|
TextLabelProps,
|
17
|
-
Omit<HTMLAttributes<
|
19
|
+
Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
18
20
|
/**
|
19
21
|
* If true, the tab will be disabled
|
20
22
|
* @default false
|
@@ -43,81 +45,27 @@ export interface Props
|
|
43
45
|
onClick?: TabProps['onClick']
|
44
46
|
}
|
45
47
|
|
46
|
-
const
|
47
|
-
selected: boolean,
|
48
|
-
disabled: boolean,
|
49
|
-
orientation: 'horizontal' | 'vertical'
|
50
|
-
) => {
|
51
|
-
if (disabled) {
|
52
|
-
return 'opacity-50'
|
53
|
-
}
|
54
|
-
|
55
|
-
if (selected || orientation === 'vertical') {
|
56
|
-
return 'opacity-100 '
|
57
|
-
}
|
48
|
+
const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTab' })
|
58
49
|
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
const wrapperClassesByOrientation = {
|
63
|
-
horizontal: 'inline-flex items-center flex-col justify-center',
|
64
|
-
vertical: 'block',
|
65
|
-
}
|
66
|
-
|
67
|
-
const rootClassesByOrientation = (selected: boolean) => ({
|
68
|
-
horizontal: [
|
69
|
-
'm-0 [&:not(:last-child)]:mr-8 pt-[0.5625rem] pb-[0.4375rem] px-0',
|
70
|
-
'text-center bg-transparent transition-shadow z-10 rounded-none',
|
71
|
-
selected ? 'text-black' : 'text-inheritColor',
|
72
|
-
selected && 'shadow-blue-500 shadow-[inset_0_-2px_0]',
|
73
|
-
],
|
74
|
-
vertical: [
|
75
|
-
' first:mt-4 last:mb-4 my-1 mx-0 py-2 px-4',
|
76
|
-
'text-left rounded-l-sm rounded-r-none transition-all',
|
77
|
-
'w-full overflow-hidden',
|
78
|
-
selected && 'shadow-1',
|
79
|
-
selected && [
|
80
|
-
'before:absolute',
|
81
|
-
'before:content-[""]',
|
82
|
-
'before:bottom-0',
|
83
|
-
'before:left-0',
|
84
|
-
'before:top-0',
|
85
|
-
'before:w-[3px]',
|
86
|
-
'before:bg-blue-500',
|
87
|
-
],
|
88
|
-
selected
|
89
|
-
? 'bg-gray-50 text-black'
|
90
|
-
: 'bg-gray-100 hover:bg-gray-200 text-graphite-700 hover:text-black',
|
91
|
-
],
|
92
|
-
})
|
93
|
-
|
94
|
-
const classesByVariant = {
|
95
|
-
scrollable: 'shrink-0 max-w-[264px]',
|
96
|
-
fullWidth: 'shrink flex-grow basis-0',
|
97
|
-
}
|
98
|
-
|
99
|
-
export const Tab = forwardRef<HTMLButtonElement, Props>(function Tab(
|
100
|
-
props,
|
101
|
-
ref
|
102
|
-
) {
|
50
|
+
export const Tab = forwardRef<HTMLDivElement, Props>(function Tab(props, ref) {
|
103
51
|
const {
|
104
52
|
disabled,
|
105
53
|
value,
|
106
54
|
label,
|
107
55
|
icon,
|
56
|
+
selected,
|
108
57
|
onChange,
|
109
58
|
onClick,
|
110
59
|
titleCase: propsTitleCase,
|
111
60
|
description,
|
112
61
|
avatar,
|
113
|
-
className,
|
114
62
|
...rest
|
115
63
|
} = props
|
64
|
+
const classes = useStyles()
|
116
65
|
const titleCase = useTitleCase(propsTitleCase)
|
117
|
-
const
|
118
|
-
const isHorizontal = orientation === 'horizontal'
|
66
|
+
const orientation = useContext(TabsOrientationContext)
|
119
67
|
|
120
|
-
const
|
68
|
+
const labelComponent = getLabelComponent({
|
121
69
|
avatar,
|
122
70
|
description,
|
123
71
|
disabled,
|
@@ -133,44 +81,18 @@ export const Tab = forwardRef<HTMLButtonElement, Props>(function Tab(
|
|
133
81
|
ref={ref}
|
134
82
|
tabIndex={0}
|
135
83
|
disabled={disabled}
|
84
|
+
label={labelComponent}
|
85
|
+
icon={icon}
|
136
86
|
value={value}
|
87
|
+
selected={selected}
|
137
88
|
onChange={onChange}
|
138
89
|
onClick={onClick}
|
139
|
-
|
140
|
-
root:
|
141
|
-
|
142
|
-
|
143
|
-
getOpacityClass(
|
144
|
-
ownerState.selected,
|
145
|
-
ownerState.disabled,
|
146
|
-
orientation
|
147
|
-
),
|
148
|
-
rootClassesByOrientation(ownerState.selected)[orientation],
|
149
|
-
classesByVariant[variant],
|
150
|
-
ownerState.disabled
|
151
|
-
? 'cursor-default text-gray-500'
|
152
|
-
: 'cursor-pointer',
|
153
|
-
ownerState.disabled && 'pointer-events-none',
|
154
|
-
icon && isHorizontal && 'min-h-0 pt-[0.5625rem] pr-6',
|
155
|
-
'min-w-0 sm:min-w-[160px] md:min-w-[auto]',
|
156
|
-
'border-0 cursor-pointer inline-flex outline-none',
|
157
|
-
'items-center select-none align-middle appearance-none',
|
158
|
-
'justify-center no-underline [-webkit-tap-highlight-color:transparent]',
|
159
|
-
'normal-case whitespace-normal leading-4',
|
160
|
-
'relative ',
|
161
|
-
className
|
162
|
-
),
|
163
|
-
}
|
164
|
-
},
|
90
|
+
classes={{
|
91
|
+
root: classes[orientation],
|
92
|
+
selected: classes.selected,
|
93
|
+
wrapper: classes.wrapper,
|
165
94
|
}}
|
166
|
-
|
167
|
-
<span
|
168
|
-
className={twJoin('w-full', wrapperClassesByOrientation[orientation])}
|
169
|
-
>
|
170
|
-
{renderLabel}
|
171
|
-
{icon && <span className='absolute right-0 mb-0 h-4'>{icon}</span>}
|
172
|
-
</span>
|
173
|
-
</MUITab>
|
95
|
+
/>
|
174
96
|
)
|
175
97
|
})
|
176
98
|
|
@@ -6,27 +6,30 @@ exports[`Tab Tab disabled tab 1`] = `
|
|
6
6
|
class="Picasso-root"
|
7
7
|
>
|
8
8
|
<div
|
9
|
-
class="
|
9
|
+
class="MuiTabs-root Tabs-horizontal"
|
10
10
|
>
|
11
11
|
<div
|
12
|
-
class="
|
12
|
+
class="MuiTabs-scrollable"
|
13
|
+
style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
|
14
|
+
/>
|
15
|
+
<div
|
16
|
+
class="MuiTabs-scroller MuiTabs-scrollable"
|
17
|
+
style="margin-bottom: 0px;"
|
13
18
|
>
|
14
19
|
<div
|
15
|
-
class="
|
20
|
+
class="MuiTabs-flexContainer"
|
16
21
|
role="tablist"
|
17
|
-
tabindex="-1"
|
18
22
|
>
|
19
23
|
<button
|
20
|
-
aria-disabled="true"
|
21
24
|
aria-selected="false"
|
22
|
-
class="
|
23
|
-
|
25
|
+
class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit Mui-disabled Mui-disabled"
|
26
|
+
disabled=""
|
24
27
|
role="tab"
|
25
|
-
tabindex="
|
28
|
+
tabindex="-1"
|
26
29
|
type="button"
|
27
30
|
>
|
28
31
|
<span
|
29
|
-
class="
|
32
|
+
class="MuiTab-wrapper PicassoTab-wrapper"
|
30
33
|
>
|
31
34
|
<div
|
32
35
|
class="m-0 text-sm text-inherit font-semibold"
|
@@ -36,6 +39,10 @@ exports[`Tab Tab disabled tab 1`] = `
|
|
36
39
|
</span>
|
37
40
|
</button>
|
38
41
|
</div>
|
42
|
+
<span
|
43
|
+
class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
|
44
|
+
style="left: 0px; width: 0px;"
|
45
|
+
/>
|
39
46
|
</div>
|
40
47
|
</div>
|
41
48
|
</div>
|
@@ -48,27 +55,29 @@ exports[`Tab Tab renders 1`] = `
|
|
48
55
|
class="Picasso-root"
|
49
56
|
>
|
50
57
|
<div
|
51
|
-
class="
|
58
|
+
class="MuiTabs-root Tabs-horizontal"
|
52
59
|
>
|
53
60
|
<div
|
54
|
-
class="
|
61
|
+
class="MuiTabs-scrollable"
|
62
|
+
style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
|
63
|
+
/>
|
64
|
+
<div
|
65
|
+
class="MuiTabs-scroller MuiTabs-scrollable"
|
66
|
+
style="margin-bottom: 0px;"
|
55
67
|
>
|
56
68
|
<div
|
57
|
-
class="
|
69
|
+
class="MuiTabs-flexContainer"
|
58
70
|
role="tablist"
|
59
|
-
tabindex="-1"
|
60
71
|
>
|
61
72
|
<button
|
62
|
-
aria-disabled="false"
|
63
73
|
aria-selected="false"
|
64
|
-
class="
|
65
|
-
id=":r0:"
|
74
|
+
class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit"
|
66
75
|
role="tab"
|
67
76
|
tabindex="0"
|
68
77
|
type="button"
|
69
78
|
>
|
70
79
|
<span
|
71
|
-
class="
|
80
|
+
class="MuiTab-wrapper PicassoTab-wrapper"
|
72
81
|
>
|
73
82
|
<div
|
74
83
|
class="m-0 text-sm text-inherit font-semibold"
|
@@ -78,6 +87,10 @@ exports[`Tab Tab renders 1`] = `
|
|
78
87
|
</span>
|
79
88
|
</button>
|
80
89
|
</div>
|
90
|
+
<span
|
91
|
+
class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
|
92
|
+
style="left: 0px; width: 0px;"
|
93
|
+
/>
|
81
94
|
</div>
|
82
95
|
</div>
|
83
96
|
</div>
|
@@ -90,43 +103,45 @@ exports[`Tab Tab tab with icon 1`] = `
|
|
90
103
|
class="Picasso-root"
|
91
104
|
>
|
92
105
|
<div
|
93
|
-
class="
|
106
|
+
class="MuiTabs-root Tabs-horizontal"
|
94
107
|
>
|
95
108
|
<div
|
96
|
-
class="
|
109
|
+
class="MuiTabs-scrollable"
|
110
|
+
style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
|
111
|
+
/>
|
112
|
+
<div
|
113
|
+
class="MuiTabs-scroller MuiTabs-scrollable"
|
114
|
+
style="margin-bottom: 0px;"
|
97
115
|
>
|
98
116
|
<div
|
99
|
-
class="
|
117
|
+
class="MuiTabs-flexContainer"
|
100
118
|
role="tablist"
|
101
|
-
tabindex="-1"
|
102
119
|
>
|
103
120
|
<button
|
104
|
-
aria-disabled="false"
|
105
121
|
aria-selected="false"
|
106
|
-
class="
|
107
|
-
id=":r2:"
|
122
|
+
class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit MuiTab-labelIcon"
|
108
123
|
role="tab"
|
109
124
|
tabindex="0"
|
110
125
|
type="button"
|
111
126
|
>
|
112
127
|
<span
|
113
|
-
class="
|
128
|
+
class="MuiTab-wrapper PicassoTab-wrapper"
|
114
129
|
>
|
130
|
+
<div
|
131
|
+
id="Icon"
|
132
|
+
/>
|
115
133
|
<div
|
116
134
|
class="m-0 text-sm text-inherit font-semibold"
|
117
135
|
>
|
118
136
|
Tab Label
|
119
137
|
</div>
|
120
|
-
<span
|
121
|
-
class="absolute right-0 mb-0 h-4"
|
122
|
-
>
|
123
|
-
<div
|
124
|
-
id="Icon"
|
125
|
-
/>
|
126
|
-
</span>
|
127
138
|
</span>
|
128
139
|
</button>
|
129
140
|
</div>
|
141
|
+
<span
|
142
|
+
class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
|
143
|
+
style="left: 0px; width: 0px;"
|
144
|
+
/>
|
130
145
|
</div>
|
131
146
|
</div>
|
132
147
|
</div>
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import type { Theme } from '@material-ui/core/styles'
|
2
|
+
import { createStyles } from '@material-ui/core/styles'
|
3
|
+
import { rem } from '@toptal/picasso-shared'
|
4
|
+
import { PicassoProvider } from '@toptal/picasso-provider'
|
5
|
+
|
6
|
+
PicassoProvider.override(({ breakpoints, palette }: Theme) => ({
|
7
|
+
MuiTab: {
|
8
|
+
root: {
|
9
|
+
minHeight: 0,
|
10
|
+
minWidth: 0,
|
11
|
+
lineHeight: 1,
|
12
|
+
textTransform: 'none',
|
13
|
+
padding: `${rem('9px')} 0 ${rem('7px')}`,
|
14
|
+
overflow: 'initial',
|
15
|
+
|
16
|
+
[breakpoints.up('md')]: {
|
17
|
+
padding: undefined,
|
18
|
+
},
|
19
|
+
|
20
|
+
color: palette.grey.dark,
|
21
|
+
|
22
|
+
[breakpoints.up('md')]: {
|
23
|
+
minWidth: 'auto',
|
24
|
+
fontSize: '1rem',
|
25
|
+
},
|
26
|
+
},
|
27
|
+
labelIcon: {
|
28
|
+
minHeight: 0,
|
29
|
+
paddingRight: '1.5rem',
|
30
|
+
paddingTop: rem('9px'),
|
31
|
+
'& $wrapper > *:first-child': {
|
32
|
+
position: 'absolute',
|
33
|
+
right: 0,
|
34
|
+
marginBottom: 0,
|
35
|
+
},
|
36
|
+
},
|
37
|
+
selected: {
|
38
|
+
color: palette.common.black,
|
39
|
+
},
|
40
|
+
textColorInherit: {
|
41
|
+
'&$disabled': {
|
42
|
+
color: palette.grey.main,
|
43
|
+
},
|
44
|
+
},
|
45
|
+
disabled: {},
|
46
|
+
},
|
47
|
+
}))
|
48
|
+
|
49
|
+
export default ({ sizes, palette, shadows, transitions }: Theme) =>
|
50
|
+
createStyles({
|
51
|
+
horizontal: {
|
52
|
+
'&:not(:last-child)': {
|
53
|
+
marginRight: '2em',
|
54
|
+
},
|
55
|
+
},
|
56
|
+
vertical: {
|
57
|
+
width: '100%',
|
58
|
+
borderRadius: `${sizes.borderRadius.small} 0 0 ${sizes.borderRadius.small}`,
|
59
|
+
margin: '0.25rem 0',
|
60
|
+
overflow: 'hidden',
|
61
|
+
padding: '0.5rem 1rem',
|
62
|
+
transition: `all ${transitions.duration.short}ms ${transitions.easing.easeInOut}`,
|
63
|
+
textAlign: 'left',
|
64
|
+
backgroundColor: palette.grey.lighter,
|
65
|
+
opacity: 1,
|
66
|
+
color: palette.grey.dark,
|
67
|
+
|
68
|
+
'&:first-child': {
|
69
|
+
marginTop: '1rem',
|
70
|
+
},
|
71
|
+
|
72
|
+
'&:last-child': {
|
73
|
+
marginBottom: '1rem',
|
74
|
+
},
|
75
|
+
|
76
|
+
'&:hover': {
|
77
|
+
color: palette.common.black,
|
78
|
+
},
|
79
|
+
|
80
|
+
'&:hover:not($selected)': {
|
81
|
+
backgroundColor: palette.grey.lighter2,
|
82
|
+
},
|
83
|
+
|
84
|
+
'& $wrapper': {
|
85
|
+
display: 'block',
|
86
|
+
},
|
87
|
+
},
|
88
|
+
selected: {
|
89
|
+
'&$vertical': {
|
90
|
+
color: palette.common.black,
|
91
|
+
boxShadow: shadows[1],
|
92
|
+
backgroundColor: palette.grey.lightest,
|
93
|
+
|
94
|
+
'&::before': {
|
95
|
+
content: '""',
|
96
|
+
background: palette.blue.main,
|
97
|
+
position: 'absolute',
|
98
|
+
left: 0,
|
99
|
+
top: 0,
|
100
|
+
bottom: 0,
|
101
|
+
width: '3px',
|
102
|
+
},
|
103
|
+
},
|
104
|
+
},
|
105
|
+
wrapper: {},
|
106
|
+
})
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import cx from 'classnames'
|
2
|
+
import React, { forwardRef } from 'react'
|
3
|
+
import { ButtonBase } from '@material-ui/core'
|
4
|
+
import { makeStyles } from '@material-ui/core/styles'
|
5
|
+
import type { BaseProps } from '@toptal/picasso-shared'
|
6
|
+
import { BackMinor16, ChevronMinor16 } from '@toptal/picasso-icons'
|
7
|
+
import { Container } from '@toptal/picasso-container'
|
8
|
+
|
9
|
+
import styles from './styles'
|
10
|
+
|
11
|
+
type DirectionType = 'left' | 'right'
|
12
|
+
|
13
|
+
export interface Props extends BaseProps {
|
14
|
+
/** The direction the button should indicate. */
|
15
|
+
direction: DirectionType
|
16
|
+
/** If `true`, the component is disabled. */
|
17
|
+
disabled?: boolean
|
18
|
+
}
|
19
|
+
|
20
|
+
const useStyles = makeStyles(styles, {
|
21
|
+
name: 'PicassoTabScrollButton',
|
22
|
+
})
|
23
|
+
|
24
|
+
export const TabScrollButton = forwardRef<HTMLDivElement, Props>(
|
25
|
+
function TabScrollButton(props, ref) {
|
26
|
+
const { className, style, direction, disabled, ...rest } = props
|
27
|
+
const classes = useStyles()
|
28
|
+
|
29
|
+
if (disabled) {
|
30
|
+
return null
|
31
|
+
}
|
32
|
+
|
33
|
+
return (
|
34
|
+
<Container
|
35
|
+
{...rest}
|
36
|
+
ref={ref}
|
37
|
+
className={cx(classes.root, className)}
|
38
|
+
style={style}
|
39
|
+
>
|
40
|
+
<Container
|
41
|
+
className={cx(classes.gradient, {
|
42
|
+
[classes.left]: direction === 'left',
|
43
|
+
[classes.right]: direction === 'right',
|
44
|
+
})}
|
45
|
+
>
|
46
|
+
<ButtonBase
|
47
|
+
className={cx(classes.button, {
|
48
|
+
[classes.left]: direction === 'left',
|
49
|
+
[classes.right]: direction === 'right',
|
50
|
+
})}
|
51
|
+
aria-label={`${direction} button`}
|
52
|
+
data-testid={`tab-scroll-button-${direction}`}
|
53
|
+
>
|
54
|
+
{direction === 'left' ? <BackMinor16 /> : <ChevronMinor16 />}
|
55
|
+
</ButtonBase>
|
56
|
+
</Container>
|
57
|
+
</Container>
|
58
|
+
)
|
59
|
+
}
|
60
|
+
)
|
61
|
+
|
62
|
+
TabScrollButton.displayName = 'TabScrollButton'
|
63
|
+
|
64
|
+
export default TabScrollButton
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { createStyles } from '@material-ui/core'
|
2
|
+
import type { Theme } from '@material-ui/core/styles'
|
3
|
+
import { alpha } from '@toptal/picasso-shared'
|
4
|
+
|
5
|
+
export default ({ palette }: Theme) => {
|
6
|
+
const color = palette.common.white
|
7
|
+
const colorStops = `${color} 0%, ${color} 50%, ${alpha(color, 0)} 100%`
|
8
|
+
|
9
|
+
return createStyles({
|
10
|
+
root: {
|
11
|
+
position: 'relative',
|
12
|
+
},
|
13
|
+
gradient: {
|
14
|
+
position: 'absolute',
|
15
|
+
width: '2.5rem',
|
16
|
+
height: '100%',
|
17
|
+
zIndex: 2,
|
18
|
+
'&$left': {
|
19
|
+
background: `linear-gradient(90deg, ${colorStops})`,
|
20
|
+
},
|
21
|
+
'&$right': {
|
22
|
+
background: `linear-gradient(270deg, ${colorStops})`,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
button: {
|
26
|
+
position: 'absolute',
|
27
|
+
width: '1rem',
|
28
|
+
height: '100%',
|
29
|
+
},
|
30
|
+
left: {
|
31
|
+
left: 0,
|
32
|
+
},
|
33
|
+
right: {
|
34
|
+
right: 0,
|
35
|
+
},
|
36
|
+
})
|
37
|
+
}
|