@bitrise/bitkit 10.19.0 → 10.21.0
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 +1 -1
- package/src/Components/Collapse/Collapse.tsx +5 -0
- package/src/Components/Dropdown/Dropdown.stories.tsx +2 -2
- package/src/Components/Dropdown/Dropdown.test.tsx +7 -0
- package/src/Components/Dropdown/Dropdown.tsx +16 -20
- package/src/Components/Dropdown/hooks/useFloatingDropdown.ts +28 -6
- package/src/Old/DatePicker/DatePickerGrid.tsx +5 -3
- package/src/Old/DatePicker/DatePickerMonth.tsx +2 -2
- package/src/Old/Placement/Placement.tsx +3 -8
- package/src/Old/Progress/ProgressBitbot.tsx +3 -3
- package/src/index.ts +3 -0
- package/src/old.ts +0 -34
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/Old/Expand/Expand.css +0 -26
- package/src/Old/Expand/Expand.test.tsx +0 -52
- package/src/Old/Expand/Expand.tsx +0 -133
- package/src/Old/Expand/__snapshots__/Expand.test.tsx.snap +0 -211
- package/src/Old/Grid/Grid.css +0 -40
- package/src/Old/Grid/Grid.test.tsx +0 -49
- package/src/Old/Grid/Grid.tsx +0 -76
- package/src/Old/Grid/__snapshots__/Grid.test.tsx.snap +0 -127
- package/src/Old/Logo/Logo.css +0 -3
- package/src/Old/Logo/Logo.tsx +0 -50
- package/src/Old/Modal/ModalContext.ts +0 -6
- package/src/Old/Status/Status500.tsx +0 -40
- package/src/Old/Table/Table.css +0 -77
- package/src/Old/Table/Table.tsx +0 -28
- package/src/Old/Table/TableBody.tsx +0 -14
- package/src/Old/Table/TableCell.tsx +0 -23
- package/src/Old/Table/TableHeader.tsx +0 -14
- package/src/Old/Table/TableHeaderCell.tsx +0 -62
- package/src/Old/Table/TableHeaderRow.tsx +0 -14
- package/src/Old/Table/TableRow.tsx +0 -23
- package/src/Old/Text/Text.css +0 -33
- package/src/Old/Text/Text.tsx +0 -87
- package/src/Old/Text/TextSizes.css +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
.Expand {
|
|
2
|
-
transition-property: margin, height, opacity;
|
|
3
|
-
transition-duration: var(--transition-duration--fast);
|
|
4
|
-
transition-timing-function: var(--transition-timing-function);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.Expand--peeked {
|
|
8
|
-
position: relative;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.Expand--peeked::after {
|
|
12
|
-
content: '';
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 0;
|
|
15
|
-
right: 0;
|
|
16
|
-
bottom: 0;
|
|
17
|
-
left: 0;
|
|
18
|
-
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 4.75%, #FFFFFF 81.95%);
|
|
19
|
-
z-index: 1;
|
|
20
|
-
transition: opacity var(--transition-duration--fast) var(--transition-timing-function);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.Expand--expanded.Expand--peeked::after {
|
|
24
|
-
opacity: 0;
|
|
25
|
-
pointer-events: none;
|
|
26
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { mount, shallow } from 'enzyme';
|
|
2
|
-
import { mountToJson, shallowToJson } from 'enzyme-to-json';
|
|
3
|
-
import { act } from 'react-dom/test-utils';
|
|
4
|
-
import Expand from './Expand';
|
|
5
|
-
|
|
6
|
-
describe('Expand', () => {
|
|
7
|
-
describe('removing children', () => {
|
|
8
|
-
test('does render children when initially expanded', () => {
|
|
9
|
-
expect(
|
|
10
|
-
shallowToJson(
|
|
11
|
-
shallow(
|
|
12
|
-
<Expand expanded removeChildren>
|
|
13
|
-
I should appear in the snapshot
|
|
14
|
-
</Expand>,
|
|
15
|
-
),
|
|
16
|
-
),
|
|
17
|
-
).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('does not render children when not initially expanded', () => {
|
|
21
|
-
expect(
|
|
22
|
-
shallowToJson(
|
|
23
|
-
shallow(
|
|
24
|
-
<Expand expanded={false} removeChildren>
|
|
25
|
-
I should not appear in the snapshot
|
|
26
|
-
</Expand>,
|
|
27
|
-
),
|
|
28
|
-
),
|
|
29
|
-
).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('does render children once expanded', () => {
|
|
33
|
-
const wrapper = mount(
|
|
34
|
-
<Expand expanded={false} removeChildren>
|
|
35
|
-
I should appear in the snapshot
|
|
36
|
-
</Expand>,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
act(() => {
|
|
40
|
-
wrapper.setProps({ expanded: true });
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(mountToJson(wrapper)).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('always renders children when removeChildren is not set', () => {
|
|
47
|
-
expect(
|
|
48
|
-
shallowToJson(shallow(<Expand expanded={false}>I should appear in the snapshot</Expand>)),
|
|
49
|
-
).toMatchSnapshot();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import { useEventListener } from '../hooks';
|
|
4
|
-
import Base, { TypeSizes } from '../Base/Base';
|
|
5
|
-
import Flex, { Props as FlexProps } from '../Flex/Flex';
|
|
6
|
-
import './Expand.css';
|
|
7
|
-
|
|
8
|
-
const { useEffect, useRef, useState } = React;
|
|
9
|
-
|
|
10
|
-
export interface Props extends FlexProps {
|
|
11
|
-
/** @Ignore */
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
/** @Ignore */
|
|
14
|
-
className?: string;
|
|
15
|
-
/** Flag that controls the expanded state of the area. */
|
|
16
|
-
expanded: boolean;
|
|
17
|
-
/** @Ignore */
|
|
18
|
-
padding?: TypeSizes;
|
|
19
|
-
/** @Ignore */
|
|
20
|
-
paddingHorizontal?: TypeSizes;
|
|
21
|
-
/** @Ignore */
|
|
22
|
-
paddingVertical?: TypeSizes;
|
|
23
|
-
/** A CSS measurement of how much of the child content to always display when collapsed. */
|
|
24
|
-
peekHeight?: string;
|
|
25
|
-
/** Flag to control whether child content is rederend when collapsed. */
|
|
26
|
-
removeChildren?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const Expand: React.FunctionComponent<Props> = (props: Props) => {
|
|
30
|
-
const {
|
|
31
|
-
children,
|
|
32
|
-
className,
|
|
33
|
-
padding,
|
|
34
|
-
paddingHorizontal,
|
|
35
|
-
paddingVertical,
|
|
36
|
-
removeChildren,
|
|
37
|
-
expanded,
|
|
38
|
-
peekHeight,
|
|
39
|
-
...rest
|
|
40
|
-
} = props;
|
|
41
|
-
|
|
42
|
-
const refOuter = useRef<HTMLElement>(null);
|
|
43
|
-
const refInner = useRef<HTMLElement>(null);
|
|
44
|
-
const refIsExpanded = useRef(expanded);
|
|
45
|
-
const frameId = useRef<number | undefined>(undefined);
|
|
46
|
-
|
|
47
|
-
const [height, setHeight] = useState<number | undefined>(expanded ? undefined : 0);
|
|
48
|
-
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
49
|
-
const [opacity, setOpacity] = useState<number | undefined>(expanded || peekHeight ? 1 : 0);
|
|
50
|
-
const [overflow, setOverflow] = useState<string | undefined>(expanded || peekHeight ? undefined : 'hidden');
|
|
51
|
-
|
|
52
|
-
useEventListener(
|
|
53
|
-
refOuter.current,
|
|
54
|
-
'transitionend',
|
|
55
|
-
() => {
|
|
56
|
-
setIsTransitioning(false);
|
|
57
|
-
|
|
58
|
-
if (expanded) {
|
|
59
|
-
setHeight(undefined);
|
|
60
|
-
setOpacity(undefined);
|
|
61
|
-
setOverflow(undefined);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
[expanded],
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
refIsExpanded.current = expanded;
|
|
69
|
-
|
|
70
|
-
if (frameId.current) {
|
|
71
|
-
window.cancelAnimationFrame(frameId.current);
|
|
72
|
-
frameId.current = undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (expanded) {
|
|
76
|
-
frameId.current = window.requestAnimationFrame(() => {
|
|
77
|
-
if (refInner.current && height === 0) {
|
|
78
|
-
setHeight(refInner.current.offsetHeight);
|
|
79
|
-
setOpacity(1);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
} else {
|
|
83
|
-
setIsTransitioning(true);
|
|
84
|
-
setOverflow('hidden');
|
|
85
|
-
frameId.current = window.requestAnimationFrame(() => {
|
|
86
|
-
if (refInner.current && height === undefined) {
|
|
87
|
-
setHeight(refInner.current.offsetHeight);
|
|
88
|
-
frameId.current = window.requestAnimationFrame(() => {
|
|
89
|
-
setHeight(0);
|
|
90
|
-
|
|
91
|
-
if (!peekHeight) {
|
|
92
|
-
setOpacity(0);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return () => {
|
|
100
|
-
if (frameId.current) {
|
|
101
|
-
window.cancelAnimationFrame(frameId.current);
|
|
102
|
-
frameId.current = undefined;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}, [expanded]);
|
|
106
|
-
|
|
107
|
-
const renderChildren = isTransitioning || peekHeight || expanded || refIsExpanded.current || !removeChildren;
|
|
108
|
-
const style = { opacity, overflow };
|
|
109
|
-
const innerStyle = { overflow };
|
|
110
|
-
const classes = classnames('Expand', {
|
|
111
|
-
'Expand--expanded': expanded,
|
|
112
|
-
'Expand--peeked': peekHeight,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const classesInner = classnames(className, 'Expand__inner');
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<Flex {...rest} className={classes} height={height} innerRef={refOuter} minHeight={peekHeight} style={style}>
|
|
119
|
-
<Base
|
|
120
|
-
className={classesInner}
|
|
121
|
-
innerRef={refInner}
|
|
122
|
-
padding={padding}
|
|
123
|
-
paddingHorizontal={paddingHorizontal}
|
|
124
|
-
paddingVertical={paddingVertical}
|
|
125
|
-
style={innerStyle}
|
|
126
|
-
>
|
|
127
|
-
{renderChildren && children}
|
|
128
|
-
</Base>
|
|
129
|
-
</Flex>
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export default Expand;
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Expand removing children always renders children when removeChildren is not set 1`] = `
|
|
4
|
-
<Flex
|
|
5
|
-
className="Expand"
|
|
6
|
-
height={0}
|
|
7
|
-
innerRef={
|
|
8
|
-
Object {
|
|
9
|
-
"current": null,
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
style={
|
|
13
|
-
Object {
|
|
14
|
-
"opacity": 0,
|
|
15
|
-
"overflow": "hidden",
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
>
|
|
19
|
-
<Base
|
|
20
|
-
className="Expand__inner"
|
|
21
|
-
innerRef={
|
|
22
|
-
Object {
|
|
23
|
-
"current": null,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
style={
|
|
27
|
-
Object {
|
|
28
|
-
"overflow": "hidden",
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
>
|
|
32
|
-
I should appear in the snapshot
|
|
33
|
-
</Base>
|
|
34
|
-
</Flex>
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
exports[`Expand removing children does not render children when not initially expanded 1`] = `
|
|
38
|
-
<Flex
|
|
39
|
-
className="Expand"
|
|
40
|
-
height={0}
|
|
41
|
-
innerRef={
|
|
42
|
-
Object {
|
|
43
|
-
"current": null,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
style={
|
|
47
|
-
Object {
|
|
48
|
-
"opacity": 0,
|
|
49
|
-
"overflow": "hidden",
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
>
|
|
53
|
-
<Base
|
|
54
|
-
className="Expand__inner"
|
|
55
|
-
innerRef={
|
|
56
|
-
Object {
|
|
57
|
-
"current": null,
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
style={
|
|
61
|
-
Object {
|
|
62
|
-
"overflow": "hidden",
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/>
|
|
66
|
-
</Flex>
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
exports[`Expand removing children does render children once expanded 1`] = `
|
|
70
|
-
<Expand
|
|
71
|
-
expanded={true}
|
|
72
|
-
removeChildren={true}
|
|
73
|
-
>
|
|
74
|
-
<Flex
|
|
75
|
-
className="Expand Expand--expanded"
|
|
76
|
-
height={0}
|
|
77
|
-
innerRef={
|
|
78
|
-
Object {
|
|
79
|
-
"current": <div
|
|
80
|
-
class="Base Flex Expand Expand--expanded"
|
|
81
|
-
style="opacity: 0; overflow: hidden; height: 0px;"
|
|
82
|
-
>
|
|
83
|
-
<div
|
|
84
|
-
class="Base Expand__inner"
|
|
85
|
-
style="overflow: hidden;"
|
|
86
|
-
>
|
|
87
|
-
I should appear in the snapshot
|
|
88
|
-
</div>
|
|
89
|
-
</div>,
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
style={
|
|
93
|
-
Object {
|
|
94
|
-
"opacity": 0,
|
|
95
|
-
"overflow": "hidden",
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
>
|
|
99
|
-
<Base
|
|
100
|
-
className="Flex Expand Expand--expanded"
|
|
101
|
-
height={0}
|
|
102
|
-
innerRef={
|
|
103
|
-
Object {
|
|
104
|
-
"current": <div
|
|
105
|
-
class="Base Flex Expand Expand--expanded"
|
|
106
|
-
style="opacity: 0; overflow: hidden; height: 0px;"
|
|
107
|
-
>
|
|
108
|
-
<div
|
|
109
|
-
class="Base Expand__inner"
|
|
110
|
-
style="overflow: hidden;"
|
|
111
|
-
>
|
|
112
|
-
I should appear in the snapshot
|
|
113
|
-
</div>
|
|
114
|
-
</div>,
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
style={
|
|
118
|
-
Object {
|
|
119
|
-
"opacity": 0,
|
|
120
|
-
"overflow": "hidden",
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
>
|
|
124
|
-
<div
|
|
125
|
-
className="Base Flex Expand Expand--expanded"
|
|
126
|
-
style={
|
|
127
|
-
Object {
|
|
128
|
-
"height": 0,
|
|
129
|
-
"maxHeight": undefined,
|
|
130
|
-
"maxWidth": undefined,
|
|
131
|
-
"minHeight": undefined,
|
|
132
|
-
"minWidth": undefined,
|
|
133
|
-
"opacity": 0,
|
|
134
|
-
"overflow": "hidden",
|
|
135
|
-
"width": undefined,
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
>
|
|
139
|
-
<Base
|
|
140
|
-
className="Expand__inner"
|
|
141
|
-
innerRef={
|
|
142
|
-
Object {
|
|
143
|
-
"current": <div
|
|
144
|
-
class="Base Expand__inner"
|
|
145
|
-
style="overflow: hidden;"
|
|
146
|
-
>
|
|
147
|
-
I should appear in the snapshot
|
|
148
|
-
</div>,
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
style={
|
|
152
|
-
Object {
|
|
153
|
-
"overflow": "hidden",
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
>
|
|
157
|
-
<div
|
|
158
|
-
className="Base Expand__inner"
|
|
159
|
-
style={
|
|
160
|
-
Object {
|
|
161
|
-
"height": undefined,
|
|
162
|
-
"maxHeight": undefined,
|
|
163
|
-
"maxWidth": undefined,
|
|
164
|
-
"minHeight": undefined,
|
|
165
|
-
"minWidth": undefined,
|
|
166
|
-
"overflow": "hidden",
|
|
167
|
-
"width": undefined,
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
>
|
|
171
|
-
I should appear in the snapshot
|
|
172
|
-
</div>
|
|
173
|
-
</Base>
|
|
174
|
-
</div>
|
|
175
|
-
</Base>
|
|
176
|
-
</Flex>
|
|
177
|
-
</Expand>
|
|
178
|
-
`;
|
|
179
|
-
|
|
180
|
-
exports[`Expand removing children does render children when initially expanded 1`] = `
|
|
181
|
-
<Flex
|
|
182
|
-
className="Expand Expand--expanded"
|
|
183
|
-
innerRef={
|
|
184
|
-
Object {
|
|
185
|
-
"current": null,
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
style={
|
|
189
|
-
Object {
|
|
190
|
-
"opacity": 1,
|
|
191
|
-
"overflow": undefined,
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
>
|
|
195
|
-
<Base
|
|
196
|
-
className="Expand__inner"
|
|
197
|
-
innerRef={
|
|
198
|
-
Object {
|
|
199
|
-
"current": null,
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
style={
|
|
203
|
-
Object {
|
|
204
|
-
"overflow": undefined,
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
>
|
|
208
|
-
I should appear in the snapshot
|
|
209
|
-
</Base>
|
|
210
|
-
</Flex>
|
|
211
|
-
`;
|
package/src/Old/Grid/Grid.css
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.Grid {
|
|
2
|
-
display: grid;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.Grid--gap-x1 { grid-gap: var(--size--x1); }
|
|
6
|
-
.Grid--gap-x2 { grid-gap: var(--size--x2); }
|
|
7
|
-
.Grid--gap-x3 { grid-gap: var(--size--x3); }
|
|
8
|
-
.Grid--gap-x4 { grid-gap: var(--size--x4); }
|
|
9
|
-
.Grid--gap-x5 { grid-gap: var(--size--x5); }
|
|
10
|
-
.Grid--gap-x6 { grid-gap: var(--size--x6); }
|
|
11
|
-
.Grid--gap-x8 { grid-gap: var(--size--x8); }
|
|
12
|
-
.Grid--gap-x10 { grid-gap: var(--size--x10); }
|
|
13
|
-
.Grid--gap-x12 { grid-gap: var(--size--x12); }
|
|
14
|
-
.Grid--gap-x16 { grid-gap: var(--size--x16); }
|
|
15
|
-
|
|
16
|
-
.Grid--gap-horizontal-x1 { grid-column-gap: var(--size--x1); }
|
|
17
|
-
.Grid--gap-horizontal-x2 { grid-column-gap: var(--size--x2); }
|
|
18
|
-
.Grid--gap-horizontal-x3 { grid-column-gap: var(--size--x3); }
|
|
19
|
-
.Grid--gap-horizontal-x4 { grid-column-gap: var(--size--x4); }
|
|
20
|
-
.Grid--gap-horizontal-x5 { grid-column-gap: var(--size--x5); }
|
|
21
|
-
.Grid--gap-horizontal-x6 { grid-column-gap: var(--size--x6); }
|
|
22
|
-
.Grid--gap-horizontal-x8 { grid-column-gap: var(--size--x8); }
|
|
23
|
-
.Grid--gap-horizontal-x10 { grid-column-gap: var(--size--x10); }
|
|
24
|
-
.Grid--gap-horizontal-x12 { grid-column-gap: var(--size--x12); }
|
|
25
|
-
.Grid--gap-horizontal-x16 { grid-column-gap: var(--size--x16); }
|
|
26
|
-
|
|
27
|
-
.Grid--gap-vertical-x1 { grid-row-gap: var(--size--x1); }
|
|
28
|
-
.Grid--gap-vertical-x2 { grid-row-gap: var(--size--x2); }
|
|
29
|
-
.Grid--gap-vertical-x3 { grid-row-gap: var(--size--x3); }
|
|
30
|
-
.Grid--gap-vertical-x4 { grid-row-gap: var(--size--x4); }
|
|
31
|
-
.Grid--gap-vertical-x5 { grid-row-gap: var(--size--x5); }
|
|
32
|
-
.Grid--gap-vertical-x6 { grid-row-gap: var(--size--x6); }
|
|
33
|
-
.Grid--gap-vertical-x8 { grid-row-gap: var(--size--x8); }
|
|
34
|
-
.Grid--gap-vertical-x10 { grid-row-gap: var(--size--x10); }
|
|
35
|
-
.Grid--gap-vertical-x12 { grid-row-gap: var(--size--x12); }
|
|
36
|
-
.Grid--gap-vertical-x16 { grid-row-gap: var(--size--x16); }
|
|
37
|
-
|
|
38
|
-
.Grid--align-start { justify-content: start; }
|
|
39
|
-
.Grid--align-middle { justify-content: center; }
|
|
40
|
-
.Grid--align-end { justify-content: end; }
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { shallow } from 'enzyme';
|
|
2
|
-
import { shallowToJson } from 'enzyme-to-json';
|
|
3
|
-
import Grid from './Grid';
|
|
4
|
-
|
|
5
|
-
describe('Grid', () => {
|
|
6
|
-
test('alignChildren', () => {
|
|
7
|
-
expect(shallowToJson(shallow(<Grid alignChildren="start">*</Grid>))).toMatchSnapshot();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('gap', () => {
|
|
11
|
-
expect(shallowToJson(shallow(<Grid gap="x1">*</Grid>))).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('gapHorizontal', () => {
|
|
15
|
-
expect(shallowToJson(shallow(<Grid gapHorizontal="x1">*</Grid>))).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('gapVertical', () => {
|
|
19
|
-
expect(shallowToJson(shallow(<Grid gapVertical="x1">*</Grid>))).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('repeat', () => {
|
|
23
|
-
expect(shallowToJson(shallow(<Grid repeat="3">*</Grid>))).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('repeatWidth', () => {
|
|
27
|
-
expect(shallowToJson(shallow(<Grid repeatWidth="1fr">*</Grid>))).toMatchSnapshot();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('repeatWidthMin', () => {
|
|
31
|
-
expect(shallowToJson(shallow(<Grid repeatWidthMin="4rem">*</Grid>))).toMatchSnapshot();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('repeatWidthMax', () => {
|
|
35
|
-
expect(
|
|
36
|
-
shallowToJson(
|
|
37
|
-
shallow(
|
|
38
|
-
<Grid repeatWidthMax="2fr" repeatWidthMin="4rem">
|
|
39
|
-
*
|
|
40
|
-
</Grid>,
|
|
41
|
-
),
|
|
42
|
-
),
|
|
43
|
-
).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('rowSize', () => {
|
|
47
|
-
expect(shallowToJson(shallow(<Grid rowSize="1fr">*</Grid>))).toMatchSnapshot();
|
|
48
|
-
});
|
|
49
|
-
});
|
package/src/Old/Grid/Grid.tsx
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import { TypeSizes } from '../Base/Base';
|
|
4
|
-
import Flex, { Props as FlexProps } from '../Flex/Flex';
|
|
5
|
-
import './Grid.css';
|
|
6
|
-
|
|
7
|
-
export interface Props extends FlexProps {
|
|
8
|
-
/** Controls the horizontal alignment of the items */
|
|
9
|
-
alignChildren?: 'start' | 'middle' | 'end';
|
|
10
|
-
/** @Ignore */
|
|
11
|
-
className?: string;
|
|
12
|
-
/** Sets the distances between items to a multiple value. E.g. 'x1'. */
|
|
13
|
-
gap?: TypeSizes;
|
|
14
|
-
/** Sets the horizontal distances between items to a multiple value. E.g. 'x1'. */
|
|
15
|
-
gapHorizontal?: TypeSizes;
|
|
16
|
-
/** Sets the vertical distances between items to a multiple value. E.g. 'x1'. */
|
|
17
|
-
gapVertical?: TypeSizes;
|
|
18
|
-
/** Sets the primary repeat value */
|
|
19
|
-
repeat?: number | string | 'auto-fill' | 'auto-fit';
|
|
20
|
-
/** Sets the explicit width the repeated items will be resized */
|
|
21
|
-
repeatWidth?: string | 'max-content' | 'min-content';
|
|
22
|
-
/** Sets the maximum width the repeated items can be resized to */
|
|
23
|
-
repeatWidthMax?: string;
|
|
24
|
-
/** Sets the minimum width the repeated items can be resized to */
|
|
25
|
-
repeatWidthMin?: string;
|
|
26
|
-
/** Sets the implicit row size */
|
|
27
|
-
rowSize?: string | 'max-content' | 'min-content';
|
|
28
|
-
/** @Ignore */
|
|
29
|
-
style?: React.CSSProperties | { [key: string]: number | string };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const Grid: React.FunctionComponent<Props> = (props: Props) => {
|
|
33
|
-
const {
|
|
34
|
-
alignChildren,
|
|
35
|
-
className,
|
|
36
|
-
gap,
|
|
37
|
-
gapHorizontal,
|
|
38
|
-
gapVertical,
|
|
39
|
-
repeat,
|
|
40
|
-
repeatWidth,
|
|
41
|
-
repeatWidthMax,
|
|
42
|
-
repeatWidthMin,
|
|
43
|
-
rowSize,
|
|
44
|
-
...rest
|
|
45
|
-
} = props;
|
|
46
|
-
|
|
47
|
-
const classes = classnames(
|
|
48
|
-
'Grid',
|
|
49
|
-
{
|
|
50
|
-
[`Grid--align-${alignChildren}`]: alignChildren,
|
|
51
|
-
[`Grid--gap-${gap}`]: gap,
|
|
52
|
-
[`Grid--gap-horizontal-${gapHorizontal}`]: gapHorizontal,
|
|
53
|
-
[`Grid--gap-vertical-${gapVertical}`]: gapVertical,
|
|
54
|
-
},
|
|
55
|
-
className,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const style = {
|
|
59
|
-
...rest.style,
|
|
60
|
-
gridTemplateColumns: `repeat(${repeat}, ${
|
|
61
|
-
repeatWidthMin ? `minmax(${repeatWidthMin}, ${repeatWidthMax})` : repeatWidth
|
|
62
|
-
})`,
|
|
63
|
-
gridAutoRows: rowSize,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
return <Flex {...rest} className={classes} style={style} />;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
Grid.defaultProps = {
|
|
70
|
-
repeat: 'auto-fit',
|
|
71
|
-
repeatWidth: 'max-content',
|
|
72
|
-
repeatWidthMax: '1fr',
|
|
73
|
-
rowSize: 'max-content',
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default Grid;
|