@toptal/picasso-tabs 1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082 → 1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-tabs",
3
- "version": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
3
+ "version": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
4
4
  "description": "Toptal UI components library - Tabs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
24
24
  "dependencies": {
25
- "@toptal/picasso-container": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
26
- "@toptal/picasso-icons": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
27
- "@toptal/picasso-shared": "13.1.3-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.25+ca4ef823d",
28
- "@toptal/picasso-typography": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
29
- "@toptal/picasso-typography-overflow": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
30
- "@toptal/picasso-user-badge": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
31
- "@toptal/picasso-utils": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d",
25
+ "@toptal/picasso-container": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
26
+ "@toptal/picasso-icons": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
27
+ "@toptal/picasso-shared": "13.1.3-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.26+25389459e",
28
+ "@toptal/picasso-typography": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
29
+ "@toptal/picasso-typography-overflow": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
30
+ "@toptal/picasso-user-badge": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
31
+ "@toptal/picasso-utils": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e",
32
32
  "ap-style-title-case": "^1.1.2",
33
33
  "classnames": "^2.3.1"
34
34
  },
@@ -46,12 +46,8 @@
46
46
  ".": "./dist-package/src/index.js"
47
47
  },
48
48
  "devDependencies": {
49
- "@toptal/picasso-provider": "3.4.3-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.44+ca4ef823d",
50
- "@toptal/picasso-test-utils": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-ca4ef823d.4082+ca4ef823d"
49
+ "@toptal/picasso-provider": "3.4.3-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.45+25389459e",
50
+ "@toptal/picasso-test-utils": "1.0.1-alpha-fx-4861-find-missing-deep-imports-in-staff-portal-25389459e.4083+25389459e"
51
51
  },
52
- "files": [
53
- "dist-package/**",
54
- "!dist-package/tsconfig.tsbuildinfo"
55
- ],
56
- "gitHead": "ca4ef823de9250ac91938e59b5156c3c35f0808c"
52
+ "gitHead": "25389459e8d238e1cadceeda472ae9cc5b53b162"
57
53
  }
@@ -0,0 +1,153 @@
1
+ import type { ReactNode, HTMLAttributes, ReactElement } from 'react'
2
+ import React, { forwardRef, useContext } from 'react'
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'
7
+ import type { BaseProps, TextLabelProps } from '@toptal/picasso-shared'
8
+ import { useTitleCase } from '@toptal/picasso-shared'
9
+ import { UserBadge } from '@toptal/picasso-user-badge'
10
+
11
+ import styles from './styles'
12
+ import { TabsOrientationContext } from '../Tabs/Tabs'
13
+ import { TabLabel } from '../TabLabel'
14
+ import { TabDescription } from '../TabDescription'
15
+
16
+ export interface Props
17
+ extends BaseProps,
18
+ TextLabelProps,
19
+ Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
20
+ /**
21
+ * If true, the tab will be disabled
22
+ * @default false
23
+ */
24
+ disabled?: boolean
25
+
26
+ /** You can provide your own value. Otherwise, we fallback to the child position index */
27
+ value?: TabProps['value']
28
+
29
+ /** The label element */
30
+ label?: ReactNode
31
+
32
+ /** The Icon element */
33
+ icon?: ReactElement
34
+
35
+ /** Image URL */
36
+ avatar?: string | null
37
+
38
+ /** Description */
39
+ description?: string
40
+
41
+ // Properties below are managed by Tabs component
42
+
43
+ selected?: boolean
44
+ onChange?: TabProps['onChange']
45
+ onClick?: TabProps['onClick']
46
+ }
47
+
48
+ const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTab' })
49
+
50
+ export const Tab = forwardRef<HTMLDivElement, Props>(function Tab(props, ref) {
51
+ const {
52
+ disabled,
53
+ value,
54
+ label,
55
+ icon,
56
+ selected,
57
+ onChange,
58
+ onClick,
59
+ titleCase: propsTitleCase,
60
+ description,
61
+ avatar,
62
+ ...rest
63
+ } = props
64
+ const classes = useStyles()
65
+ const titleCase = useTitleCase(propsTitleCase)
66
+ const orientation = useContext(TabsOrientationContext)
67
+
68
+ const labelComponent = getLabelComponent({
69
+ avatar,
70
+ description,
71
+ disabled,
72
+ label,
73
+ orientation,
74
+ titleCase,
75
+ })
76
+
77
+ return (
78
+ <MUITab
79
+ {...rest}
80
+ ref={ref}
81
+ tabIndex={0}
82
+ disabled={disabled}
83
+ label={labelComponent}
84
+ icon={icon}
85
+ value={value}
86
+ selected={selected}
87
+ onChange={onChange}
88
+ onClick={onClick}
89
+ classes={{
90
+ root: classes[orientation],
91
+ selected: classes.selected,
92
+ wrapper: classes.wrapper,
93
+ }}
94
+ />
95
+ )
96
+ })
97
+
98
+ Tab.defaultProps = {}
99
+
100
+ Tab.displayName = 'Tab'
101
+
102
+ type GetLabelComponentProps = {
103
+ avatar?: string | null
104
+ description?: string
105
+ disabled?: boolean
106
+ label?: React.ReactNode
107
+ orientation: 'horizontal' | 'vertical'
108
+ titleCase?: boolean
109
+ }
110
+ const getLabelComponent = ({
111
+ avatar,
112
+ description,
113
+ disabled,
114
+ label,
115
+ orientation,
116
+ titleCase,
117
+ }: GetLabelComponentProps): React.ReactNode => {
118
+ if (!label) {
119
+ return null
120
+ }
121
+
122
+ const isHorizontal = orientation === 'horizontal'
123
+ const isCustomLabel = typeof label !== 'string'
124
+
125
+ const Label = () => (
126
+ <TabLabel titleCase={titleCase} label={label} orientation={orientation} />
127
+ )
128
+
129
+ if (isHorizontal || isCustomLabel) {
130
+ return <Label />
131
+ }
132
+
133
+ if (typeof avatar === 'undefined') {
134
+ return (
135
+ <>
136
+ <Label />
137
+ {description && (
138
+ <TabDescription disabled={disabled}>{description}</TabDescription>
139
+ )}
140
+ </>
141
+ )
142
+ }
143
+
144
+ return (
145
+ <UserBadge renderName={Label} name={label} avatar={avatar}>
146
+ {description && (
147
+ <TabDescription disabled={disabled}>{description}</TabDescription>
148
+ )}
149
+ </UserBadge>
150
+ )
151
+ }
152
+
153
+ export default Tab
@@ -0,0 +1,80 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Tab Tab disabled tab 1`] = `
4
+ <div>
5
+ <div
6
+ class="Picasso-root"
7
+ >
8
+ <button
9
+ class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit Mui-disabled Mui-disabled"
10
+ disabled=""
11
+ role="tab"
12
+ tabindex="-1"
13
+ type="button"
14
+ >
15
+ <span
16
+ class="MuiTab-wrapper PicassoTab-wrapper"
17
+ >
18
+ <div
19
+ class="MuiTypography-root PicassoTypography-bodySmall PicassoTypography-inherit PicassoTypography-semibold MuiTypography-body1"
20
+ >
21
+ Tab Label
22
+ </div>
23
+ </span>
24
+ </button>
25
+ </div>
26
+ </div>
27
+ `;
28
+
29
+ exports[`Tab Tab renders 1`] = `
30
+ <div>
31
+ <div
32
+ class="Picasso-root"
33
+ >
34
+ <button
35
+ class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit"
36
+ role="tab"
37
+ tabindex="0"
38
+ type="button"
39
+ >
40
+ <span
41
+ class="MuiTab-wrapper PicassoTab-wrapper"
42
+ >
43
+ <div
44
+ class="MuiTypography-root PicassoTypography-bodySmall PicassoTypography-inherit PicassoTypography-semibold MuiTypography-body1"
45
+ >
46
+ Tab Label
47
+ </div>
48
+ </span>
49
+ </button>
50
+ </div>
51
+ </div>
52
+ `;
53
+
54
+ exports[`Tab Tab tab with icon 1`] = `
55
+ <div>
56
+ <div
57
+ class="Picasso-root"
58
+ >
59
+ <button
60
+ class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit MuiTab-labelIcon"
61
+ role="tab"
62
+ tabindex="0"
63
+ type="button"
64
+ >
65
+ <span
66
+ class="MuiTab-wrapper PicassoTab-wrapper"
67
+ >
68
+ <div
69
+ id="Icon"
70
+ />
71
+ <div
72
+ class="MuiTypography-root PicassoTypography-bodySmall PicassoTypography-inherit PicassoTypography-semibold MuiTypography-body1"
73
+ >
74
+ Tab Label
75
+ </div>
76
+ </span>
77
+ </button>
78
+ </div>
79
+ </div>
80
+ `;
@@ -0,0 +1,6 @@
1
+ import type { OmitInternalProps } from '@toptal/picasso-shared'
2
+
3
+ import type { Props } from './Tab'
4
+
5
+ export { default as Tab } from './Tab'
6
+ export type TabProps = OmitInternalProps<Props>
@@ -0,0 +1,29 @@
1
+ import React from 'react'
2
+ import { Container, Tabs } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+
5
+ type Value = number | string | boolean
6
+
7
+ const Example = () => {
8
+ const [value, setValue] = React.useState<Value>(false)
9
+
10
+ const handleChange = (_: React.ChangeEvent<{}>, newValue: Value) => {
11
+ setValue(newValue)
12
+ }
13
+
14
+ return (
15
+ <div>
16
+ <Tabs value={value} onChange={handleChange}>
17
+ <Tabs.Tab value='jobs' label='Jobs' />
18
+ <Tabs.Tab value='engagements' label='Engagements' />
19
+ <Tabs.Tab value='interviews' label='Interviews' />
20
+ </Tabs>
21
+
22
+ <Container top={SPACING_4}>
23
+ Current <i>value</i> is equal <code>{JSON.stringify(value)}</code>
24
+ </Container>
25
+ </div>
26
+ )
27
+ }
28
+
29
+ export default Example
@@ -0,0 +1,33 @@
1
+ import React from 'react'
2
+ import { Container, Tabs } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+
5
+ const Example = () => {
6
+ const [value, setValue] = React.useState(0)
7
+
8
+ const handleChange = (_: React.ChangeEvent<{}>, newValue: number) => {
9
+ setValue(newValue)
10
+ }
11
+
12
+ return (
13
+ <div>
14
+ <Tabs value={value} onChange={handleChange}>
15
+ <Tabs.Tab label='Label' />
16
+ <Tabs.Tab label='Label' disabled />
17
+ <Tabs.Tab label='Label' />
18
+ </Tabs>
19
+
20
+ {value === 0 && (
21
+ <Container top={SPACING_4}>Content of the first tab</Container>
22
+ )}
23
+ {value === 1 && (
24
+ <Container top={SPACING_4}>Content of the second tab</Container>
25
+ )}
26
+ {value === 2 && (
27
+ <Container top={SPACING_4}>Content of the third tab</Container>
28
+ )}
29
+ </div>
30
+ )
31
+ }
32
+
33
+ export default Example
@@ -0,0 +1,52 @@
1
+ import React from 'react'
2
+ import { Container, Tabs, Tooltip } from '@toptal/picasso'
3
+ import { SPACING_4 } from '@toptal/picasso-utils'
4
+ import { Exclamation16 } from '@toptal/picasso-icons'
5
+
6
+ const Example = () => {
7
+ const [value, setValue] = React.useState(0)
8
+
9
+ const handleChange = (_: React.ChangeEvent<{}>, newValue: number) => {
10
+ setValue(newValue)
11
+ }
12
+
13
+ return (
14
+ <div>
15
+ <Tabs value={value} onChange={handleChange}>
16
+ <Tabs.Tab
17
+ label='Label'
18
+ icon={
19
+ <Tooltip content='Some content...' placement='top'>
20
+ <span>
21
+ <Exclamation16 color='red' />
22
+ </span>
23
+ </Tooltip>
24
+ }
25
+ />
26
+ <Tabs.Tab label='Label' />
27
+ <Tabs.Tab
28
+ label='Label'
29
+ icon={
30
+ <Tooltip content='Some content...' placement='top'>
31
+ <span>
32
+ <Exclamation16 color='red' />
33
+ </span>
34
+ </Tooltip>
35
+ }
36
+ />
37
+ </Tabs>
38
+
39
+ {value === 0 && (
40
+ <Container top={SPACING_4}>Content of the first tab</Container>
41
+ )}
42
+ {value === 1 && (
43
+ <Container top={SPACING_4}>Content of the second tab</Container>
44
+ )}
45
+ {value === 2 && (
46
+ <Container top={SPACING_4}>Content of the third tab</Container>
47
+ )}
48
+ </div>
49
+ )
50
+ }
51
+
52
+ export default Example
@@ -0,0 +1,83 @@
1
+ import React from 'react'
2
+ import { Container, Tabs, Typography } from '@toptal/picasso'
3
+ import { SPACING_8, SPACING_4, palette } from '@toptal/picasso-utils'
4
+
5
+ const Example = () => {
6
+ return (
7
+ <Container flex gap={SPACING_8} padded={SPACING_4}>
8
+ <ExampleDecorator title='With Title'>
9
+ <Tabs value={0} orientation='vertical'>
10
+ <Tabs.Tab label='Label' />
11
+ <Tabs.Tab label='Label' disabled />
12
+ <Tabs.Tab label='Label' />
13
+ <Tabs.Tab label='Very long label that truncated' />
14
+ </Tabs>
15
+ </ExampleDecorator>
16
+ <ExampleDecorator title='With Title & Description'>
17
+ <Tabs value={0} orientation='vertical'>
18
+ <Tabs.Tab label='Label' description='Description' />
19
+ <Tabs.Tab label='Label' description='Description' disabled />
20
+ <Tabs.Tab label='Label' description='Description' />
21
+ <Tabs.Tab
22
+ label='Very long label that truncated'
23
+ description='Description'
24
+ />
25
+ <Tabs.Tab
26
+ label='Label'
27
+ description='Very long description that truncated'
28
+ />
29
+ </Tabs>
30
+ </ExampleDecorator>
31
+ <ExampleDecorator title='With UserBadge'>
32
+ <Tabs value={0} orientation='vertical'>
33
+ <Tabs.Tab label='Label' description='Description' avatar={null} />
34
+ <Tabs.Tab
35
+ label='Label'
36
+ disabled
37
+ description='Description'
38
+ avatar='./jacqueline-with-flowers-1954-square.jpg'
39
+ />
40
+ <Tabs.Tab
41
+ label='Label'
42
+ description='Description'
43
+ avatar='./jacqueline-with-flowers-1954-square.jpg'
44
+ />
45
+ <Tabs.Tab
46
+ label='Very long label that truncated'
47
+ description='Description'
48
+ avatar='./jacqueline-with-flowers-1954-square.jpg'
49
+ />
50
+ <Tabs.Tab
51
+ label='Label'
52
+ description='Very long description that truncated'
53
+ avatar='./jacqueline-with-flowers-1954-square.jpg'
54
+ />
55
+ <Tabs.Tab
56
+ label='Label'
57
+ avatar='./jacqueline-with-flowers-1954-square.jpg'
58
+ />
59
+ </Tabs>
60
+ </ExampleDecorator>
61
+ </Container>
62
+ )
63
+ }
64
+
65
+ type Props = {
66
+ children: React.ReactNode
67
+ title: string
68
+ }
69
+
70
+ const ExampleDecorator = ({ children, title }: Props) => {
71
+ const style: React.CSSProperties = { backgroundColor: palette.grey.lighter }
72
+
73
+ return (
74
+ <Container>
75
+ <Typography variant='heading' size='small'>
76
+ {title}
77
+ </Typography>
78
+ <Container style={style}>{children}</Container>
79
+ </Container>
80
+ )
81
+ }
82
+
83
+ export default Example
@@ -0,0 +1,29 @@
1
+ import { Tab } from '../Tab'
2
+ import PicassoBook from '~/.storybook/components/PicassoBook'
3
+
4
+ const componentDocs = PicassoBook.createComponentDocs(Tab, 'Tabs.Tab')
5
+
6
+ const chapter = PicassoBook.connectToPage(page => {
7
+ page
8
+ .createChapter('Tabs.Tab')
9
+ .addExample(
10
+ 'Tab/story/Vertical.example.tsx',
11
+ {
12
+ title: 'Vertical tab',
13
+ takeScreenshot: false,
14
+ },
15
+ 'base/Tabs'
16
+ )
17
+ .addExample('Tab/story/Disabled.example.tsx', 'Disabled tab', 'base/Tabs')
18
+ .addExample(
19
+ 'Tab/story/CustomValue.example.tsx',
20
+ 'Using custom value',
21
+ 'base/Tabs'
22
+ )
23
+ .addExample('Tab/story/Icon.example.tsx', 'With Icon', 'base/Tabs')
24
+ })
25
+
26
+ export default {
27
+ chapter,
28
+ componentDocs,
29
+ }
@@ -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
+ })