@zendeskgarden/react-grid 9.0.0-next.7 → 9.0.0-next.9
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/esm/elements/Col.js +72 -0
- package/dist/esm/elements/Grid.js +54 -0
- package/dist/esm/elements/Row.js +58 -0
- package/dist/esm/elements/pane/Pane.js +55 -0
- package/dist/esm/elements/pane/PaneProvider.js +197 -0
- package/dist/esm/elements/pane/components/Content.js +30 -0
- package/dist/esm/elements/pane/components/Splitter.js +128 -0
- package/dist/esm/elements/pane/components/SplitterButton.js +91 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/styled/StyledCol.js +73 -0
- package/dist/esm/styled/StyledGrid.js +33 -0
- package/dist/esm/styled/StyledRow.js +53 -0
- package/dist/esm/styled/pane/StyledPane.js +22 -0
- package/dist/esm/styled/pane/StyledPaneContent.js +22 -0
- package/dist/esm/styled/pane/StyledPaneSplitter.js +99 -0
- package/dist/esm/styled/pane/StyledPaneSplitterButton.js +48 -0
- package/dist/esm/styled/pane/StyledPaneSplitterButtonContainer.js +116 -0
- package/dist/esm/types/index.js +16 -0
- package/dist/esm/utils/useGridContext.js +16 -0
- package/dist/esm/utils/usePaneContext.js +16 -0
- package/dist/esm/utils/usePaneProviderContext.js +17 -0
- package/dist/esm/utils/usePaneSplitterContext.js +22 -0
- package/dist/index.cjs.js +22 -36
- package/package.json +7 -7
- package/dist/index.esm.js +0 -978
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
export { Col } from './elements/Col.js';
|
|
8
|
+
export { Grid } from './elements/Grid.js';
|
|
9
|
+
export { Row } from './elements/Row.js';
|
|
10
|
+
export { PaneProvider } from './elements/pane/PaneProvider.js';
|
|
11
|
+
export { Pane } from './elements/pane/Pane.js';
|
|
12
|
+
export { ALIGN_ITEMS, ALIGN_SELF, DIRECTION, JUSTIFY_CONTENT, SPACE, TEXT_ALIGN, WRAP } from './types/index.js';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'grid.col';
|
|
12
|
+
const colorStyles = props => {
|
|
13
|
+
const backgroundColor = getColorV8('primaryHue', 600, props.theme, 0.1);
|
|
14
|
+
return css(["background-clip:content-box;background-color:", ";"], backgroundColor);
|
|
15
|
+
};
|
|
16
|
+
const flexStyles = (size, alignSelf, textAlign, offset, order, props) => {
|
|
17
|
+
const margin = offset && `${math(`${offset} / ${props.columns} * 100`)}%`;
|
|
18
|
+
let flexBasis;
|
|
19
|
+
let flexGrow;
|
|
20
|
+
let maxWidth;
|
|
21
|
+
let width;
|
|
22
|
+
if (typeof size === 'boolean') {
|
|
23
|
+
flexBasis = 0;
|
|
24
|
+
flexGrow = 1;
|
|
25
|
+
maxWidth = '100%';
|
|
26
|
+
} else if (size === 'auto') {
|
|
27
|
+
flexBasis = 'auto';
|
|
28
|
+
flexGrow = 0;
|
|
29
|
+
maxWidth = '100%';
|
|
30
|
+
width = 'auto';
|
|
31
|
+
} else if (size !== undefined) {
|
|
32
|
+
flexBasis = `${math(`${size} / ${props.columns} * 100`)}%`;
|
|
33
|
+
flexGrow = 0;
|
|
34
|
+
maxWidth = flexBasis;
|
|
35
|
+
}
|
|
36
|
+
let horizontalAlign;
|
|
37
|
+
if (textAlign === 'start') {
|
|
38
|
+
horizontalAlign = props.theme.rtl ? 'right' : 'left';
|
|
39
|
+
} else if (textAlign === 'end') {
|
|
40
|
+
horizontalAlign = props.theme.rtl ? 'left' : 'right';
|
|
41
|
+
} else {
|
|
42
|
+
horizontalAlign = textAlign;
|
|
43
|
+
}
|
|
44
|
+
let flexOrder;
|
|
45
|
+
if (order === 'first') {
|
|
46
|
+
flexOrder = -1;
|
|
47
|
+
} else if (order === 'last') {
|
|
48
|
+
flexOrder = math(`${props.columns} + 1`);
|
|
49
|
+
} else {
|
|
50
|
+
flexOrder = order;
|
|
51
|
+
}
|
|
52
|
+
return css(["flex-basis:", ";flex-grow:", ";flex-shrink:", ";align-self:", ";order:", ";margin-", ":", ";width:", ";max-width:", ";text-align:", ";"], flexBasis, flexGrow, size && 0, alignSelf === 'start' || alignSelf === 'end' ? `flex-${alignSelf}` : alignSelf, flexOrder, props.theme.rtl ? 'right' : 'left', margin, width, maxWidth, horizontalAlign);
|
|
53
|
+
};
|
|
54
|
+
const mediaStyles = (minWidth, size, alignSelf, textAlign, offset, order, props) => {
|
|
55
|
+
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(size, alignSelf, textAlign, offset, order, props));
|
|
56
|
+
};
|
|
57
|
+
const sizeStyles = props => {
|
|
58
|
+
const padding = props.gutters ? math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
59
|
+
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
60
|
+
};
|
|
61
|
+
const StyledCol = styled.div.attrs({
|
|
62
|
+
'data-garden-id': COMPONENT_ID,
|
|
63
|
+
'data-garden-version': '9.0.0-next.9'
|
|
64
|
+
}).withConfig({
|
|
65
|
+
displayName: "StyledCol",
|
|
66
|
+
componentId: "sc-inuw62-0"
|
|
67
|
+
})(["box-sizing:border-box;width:100%;", ";", ";", ";", ";", ";", ";", ";", ";", ";"], props => flexStyles(!props.sizeAll && (props.xs || props.sm || props.md || props.lg || props.xl) ? undefined : props.sizeAll || false, props.alignSelf, props.textAlign, props.offset, props.order, props), props => sizeStyles(props), props => props.debug && colorStyles(props), props => mediaStyles(props.theme.breakpoints.xs, props.xs, props.alignSelfXs, props.textAlignXs, props.offsetXs, props.orderXs, props), props => mediaStyles(props.theme.breakpoints.sm, props.sm, props.alignSelfSm, props.textAlignSm, props.offsetSm, props.orderSm, props), props => mediaStyles(props.theme.breakpoints.md, props.md, props.alignSelfMd, props.textAlignMd, props.offsetMd, props.orderMd, props), props => mediaStyles(props.theme.breakpoints.lg, props.lg, props.alignSelfLg, props.textAlignLg, props.offsetLg, props.orderLg, props), props => mediaStyles(props.theme.breakpoints.xl, props.xl, props.alignSelfXl, props.textAlignXl, props.offsetXl, props.orderXl, props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
68
|
+
StyledCol.defaultProps = {
|
|
69
|
+
columns: 12,
|
|
70
|
+
theme: DEFAULT_THEME
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { StyledCol };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'grid.grid';
|
|
12
|
+
const colorStyles = props => {
|
|
13
|
+
const borderColor = getColorV8(props.theme.palette.crimson, 400, props.theme, 0.5);
|
|
14
|
+
const borderWidth = math(`${props.theme.borderWidths.sm} * 2`);
|
|
15
|
+
return css(["box-shadow:-", " 0 0 0 ", ",", " 0 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
16
|
+
};
|
|
17
|
+
const sizeStyles = props => {
|
|
18
|
+
const padding = props.gutters ? math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
19
|
+
return css(["padding-right:", ";padding-left:", ";"], padding, padding);
|
|
20
|
+
};
|
|
21
|
+
const StyledGrid = styled.div.attrs({
|
|
22
|
+
'data-garden-id': COMPONENT_ID,
|
|
23
|
+
'data-garden-version': '9.0.0-next.9'
|
|
24
|
+
}).withConfig({
|
|
25
|
+
displayName: "StyledGrid",
|
|
26
|
+
componentId: "sc-oxgg5i-0"
|
|
27
|
+
})(["direction:", ";margin-right:auto;margin-left:auto;width:100%;box-sizing:border-box;", ";", ";", ";"], props => props.theme.rtl && 'rtl', props => sizeStyles(props), props => props.debug && colorStyles(props), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
28
|
+
StyledGrid.defaultProps = {
|
|
29
|
+
gutters: 'md',
|
|
30
|
+
theme: DEFAULT_THEME
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { StyledGrid };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'grid.row';
|
|
12
|
+
const colorStyles = props => {
|
|
13
|
+
const borderColor = getColorV8(props.theme.palette.mint, 600, props.theme, 0.5);
|
|
14
|
+
const borderWidth = props.theme.borderWidths.sm;
|
|
15
|
+
return css(["box-shadow:inset 0 ", " 0 0 ", ",inset 0 -", " 0 0 ", ";"], borderWidth, borderColor, borderWidth, borderColor);
|
|
16
|
+
};
|
|
17
|
+
const flexStyles = (alignItems, justifyContent, wrap) => {
|
|
18
|
+
let flexAlignItems;
|
|
19
|
+
let flexJustifyContent;
|
|
20
|
+
if (alignItems === 'start' || alignItems === 'end') {
|
|
21
|
+
flexAlignItems = `flex-${alignItems}`;
|
|
22
|
+
} else {
|
|
23
|
+
flexAlignItems = alignItems;
|
|
24
|
+
}
|
|
25
|
+
if (justifyContent === 'start' || justifyContent === 'end') {
|
|
26
|
+
flexJustifyContent = `flex-${justifyContent}`;
|
|
27
|
+
} else if (justifyContent === 'between' || justifyContent === 'around') {
|
|
28
|
+
flexJustifyContent = `space-${justifyContent}`;
|
|
29
|
+
} else {
|
|
30
|
+
flexJustifyContent = justifyContent;
|
|
31
|
+
}
|
|
32
|
+
return css(["flex-wrap:", ";align-items:", ";justify-content:", ";"], wrap, flexAlignItems, flexJustifyContent);
|
|
33
|
+
};
|
|
34
|
+
const mediaStyles = (minWidth, alignItems, justifyContent, wrap) => {
|
|
35
|
+
return css(["@media (min-width:", "){", ";}"], minWidth, flexStyles(alignItems, justifyContent, wrap));
|
|
36
|
+
};
|
|
37
|
+
const sizeStyles = props => {
|
|
38
|
+
const margin = props.gutters ? math(`${props.theme.space[props.gutters]} / 2`) : 0;
|
|
39
|
+
return css(["margin-right:-", ";margin-left:-", ";"], margin, margin);
|
|
40
|
+
};
|
|
41
|
+
const StyledRow = styled.div.attrs({
|
|
42
|
+
'data-garden-id': COMPONENT_ID,
|
|
43
|
+
'data-garden-version': '9.0.0-next.9'
|
|
44
|
+
}).withConfig({
|
|
45
|
+
displayName: "StyledRow",
|
|
46
|
+
componentId: "sc-xjsdg1-0"
|
|
47
|
+
})(["display:flex;box-sizing:border-box;", " ", ";", ";", ";", ";", ";", ";", ";", ";"], props => flexStyles(props.alignItems, props.justifyContent, props.wrapAll), props => sizeStyles(props), props => props.debug && colorStyles(props), props => mediaStyles(props.theme.breakpoints.xs, props.alignItemsXs, props.justifyContentXs, props.wrapXs), props => mediaStyles(props.theme.breakpoints.sm, props.alignItemsSm, props.justifyContentSm, props.wrapSm), props => mediaStyles(props.theme.breakpoints.md, props.alignItemsMd, props.justifyContentMd, props.wrapMd), props => mediaStyles(props.theme.breakpoints.lg, props.alignItemsLg, props.justifyContentLg, props.wrapLg), props => mediaStyles(props.theme.breakpoints.xl, props.alignItemsXl, props.justifyContentXl, props.wrapXl), props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
48
|
+
StyledRow.defaultProps = {
|
|
49
|
+
wrapAll: 'wrap',
|
|
50
|
+
theme: DEFAULT_THEME
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { StyledRow };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'pane';
|
|
11
|
+
const StyledPane = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.9'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledPane",
|
|
16
|
+
componentId: "sc-1ltjst7-0"
|
|
17
|
+
})(["position:relative;min-width:0;min-height:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledPane.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledPane };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
|
|
10
|
+
const COMPONENT_ID = 'pane.content';
|
|
11
|
+
const StyledPaneContent = styled.div.attrs({
|
|
12
|
+
'data-garden-id': COMPONENT_ID,
|
|
13
|
+
'data-garden-version': '9.0.0-next.9'
|
|
14
|
+
}).withConfig({
|
|
15
|
+
displayName: "StyledPaneContent",
|
|
16
|
+
componentId: "sc-1b38mbh-0"
|
|
17
|
+
})(["height:100%;overflow:auto;&[hidden]{display:none;}", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
18
|
+
StyledPaneContent.defaultProps = {
|
|
19
|
+
theme: DEFAULT_THEME
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { StyledPaneContent };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { math } from 'polished';
|
|
9
|
+
import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles } from '@zendeskgarden/react-theming';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'pane.splitter';
|
|
12
|
+
const colorStyles = props => {
|
|
13
|
+
const color = getColorV8('neutralHue', 300, props.theme);
|
|
14
|
+
const hoverColor = getColorV8('primaryHue', 600, props.theme);
|
|
15
|
+
const activeColor = getColorV8('primaryHue', 800, props.theme);
|
|
16
|
+
return css(["&::before{background-color:", ";}&:hover::before{background-color:", ";}", " &:active::before{background-color:", ";}"], color, hoverColor, focusStyles({
|
|
17
|
+
theme: props.theme,
|
|
18
|
+
color: {
|
|
19
|
+
hue: hoverColor
|
|
20
|
+
},
|
|
21
|
+
styles: {
|
|
22
|
+
backgroundColor: hoverColor
|
|
23
|
+
},
|
|
24
|
+
selector: '&:focus-visible::before'
|
|
25
|
+
}), activeColor);
|
|
26
|
+
};
|
|
27
|
+
const sizeStyles = props => {
|
|
28
|
+
const size = math(`${props.theme.shadowWidths.md} * 2`);
|
|
29
|
+
const separatorSize = math(`${props.theme.borderWidths.sm} * 2`);
|
|
30
|
+
const offset = math(`-${size} / 2`);
|
|
31
|
+
let cursor;
|
|
32
|
+
let top;
|
|
33
|
+
let right;
|
|
34
|
+
let left;
|
|
35
|
+
let bottom;
|
|
36
|
+
let width;
|
|
37
|
+
let height;
|
|
38
|
+
let separatorWidth;
|
|
39
|
+
let separatorHeight;
|
|
40
|
+
switch (props.orientation) {
|
|
41
|
+
case 'top':
|
|
42
|
+
cursor = 'row-resize';
|
|
43
|
+
top = offset;
|
|
44
|
+
width = '100%';
|
|
45
|
+
height = size;
|
|
46
|
+
separatorWidth = width;
|
|
47
|
+
separatorHeight = props.theme.borderWidths.sm;
|
|
48
|
+
break;
|
|
49
|
+
case 'bottom':
|
|
50
|
+
cursor = 'row-resize';
|
|
51
|
+
bottom = offset;
|
|
52
|
+
width = '100%';
|
|
53
|
+
height = size;
|
|
54
|
+
separatorWidth = width;
|
|
55
|
+
separatorHeight = props.theme.borderWidths.sm;
|
|
56
|
+
break;
|
|
57
|
+
case 'start':
|
|
58
|
+
cursor = 'col-resize';
|
|
59
|
+
top = 0;
|
|
60
|
+
width = size;
|
|
61
|
+
height = '100%';
|
|
62
|
+
separatorWidth = props.theme.borderWidths.sm;
|
|
63
|
+
separatorHeight = height;
|
|
64
|
+
if (props.theme.rtl) {
|
|
65
|
+
right = offset;
|
|
66
|
+
} else {
|
|
67
|
+
left = offset;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case 'end':
|
|
71
|
+
default:
|
|
72
|
+
cursor = 'col-resize';
|
|
73
|
+
top = 0;
|
|
74
|
+
width = size;
|
|
75
|
+
height = '100%';
|
|
76
|
+
separatorWidth = props.theme.borderWidths.sm;
|
|
77
|
+
separatorHeight = height;
|
|
78
|
+
if (props.theme.rtl) {
|
|
79
|
+
left = offset;
|
|
80
|
+
} else {
|
|
81
|
+
right = offset;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
const dimensionProperty = width === '100%' ? 'height' : 'width';
|
|
86
|
+
return css(["top:", ";right:", ";bottom:", ";left:", ";cursor:", ";width:", ";height:", ";&::before{width:", ";height:", ";}&:hover::before{", ":", ";}&:focus::before,&:focus-visible::before{", ":", ";}&:focus-visible::before{border-radius:", ";}"], top, right, bottom, left, props.isFixed ? 'pointer' : cursor, width, height, separatorWidth, separatorHeight, dimensionProperty, separatorSize, dimensionProperty, separatorSize, props.theme.borderRadii.md);
|
|
87
|
+
};
|
|
88
|
+
const StyledPaneSplitter = styled.div.attrs({
|
|
89
|
+
'data-garden-id': COMPONENT_ID,
|
|
90
|
+
'data-garden-version': '9.0.0-next.9'
|
|
91
|
+
}).withConfig({
|
|
92
|
+
displayName: "StyledPaneSplitter",
|
|
93
|
+
componentId: "sc-jylemn-0"
|
|
94
|
+
})(["display:flex;position:absolute;align-items:center;justify-content:center;z-index:1;user-select:none;", ";", "{z-index:2;}&::before{position:absolute;transition:box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out;z-index:-1;content:'';}", ";", ";"], sizeStyles, SELECTOR_FOCUS_VISIBLE, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
95
|
+
StyledPaneSplitter.defaultProps = {
|
|
96
|
+
theme: DEFAULT_THEME
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export { StyledPaneSplitter };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
|
|
9
|
+
import { ChevronButton } from '@zendeskgarden/react-buttons';
|
|
10
|
+
|
|
11
|
+
const COMPONENT_ID = 'pane.splitter_button';
|
|
12
|
+
const getSize = theme => theme.space.base * 6;
|
|
13
|
+
const sizeStyles = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
theme
|
|
16
|
+
} = _ref;
|
|
17
|
+
const size = `${getSize(theme)}px`;
|
|
18
|
+
return css(["width:", ";min-width:", ";height:", ";"], size, size, size);
|
|
19
|
+
};
|
|
20
|
+
const transformStyles = props => {
|
|
21
|
+
let degrees = 0;
|
|
22
|
+
if (props.isRotated) {
|
|
23
|
+
degrees = props.theme.rtl ? -180 : 180;
|
|
24
|
+
}
|
|
25
|
+
if (props.orientation === 'end') {
|
|
26
|
+
degrees += props.theme.rtl ? -90 : 90;
|
|
27
|
+
} else if (props.orientation === 'start') {
|
|
28
|
+
degrees += props.theme.rtl ? 90 : -90;
|
|
29
|
+
} else if (props.orientation === 'bottom') {
|
|
30
|
+
degrees += 180;
|
|
31
|
+
}
|
|
32
|
+
return css(["& > svg{transform:rotate(", "deg);}"], degrees);
|
|
33
|
+
};
|
|
34
|
+
const StyledPaneSplitterButton = styled(ChevronButton).attrs({
|
|
35
|
+
'data-garden-id': COMPONENT_ID,
|
|
36
|
+
'data-garden-version': '9.0.0-next.9',
|
|
37
|
+
isBasic: true,
|
|
38
|
+
isPill: true,
|
|
39
|
+
size: 'small'
|
|
40
|
+
}).withConfig({
|
|
41
|
+
displayName: "StyledPaneSplitterButton",
|
|
42
|
+
componentId: "sc-zh032e-0"
|
|
43
|
+
})(["", ";", ";", ";"], sizeStyles, transformStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
44
|
+
StyledPaneSplitterButton.defaultProps = {
|
|
45
|
+
theme: DEFAULT_THEME
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { StyledPaneSplitterButton, getSize };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import styled, { css } from 'styled-components';
|
|
8
|
+
import { stripUnit, math } from 'polished';
|
|
9
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColorV8 } from '@zendeskgarden/react-theming';
|
|
10
|
+
import { StyledPaneSplitter } from './StyledPaneSplitter.js';
|
|
11
|
+
import { getSize } from './StyledPaneSplitterButton.js';
|
|
12
|
+
|
|
13
|
+
const COMPONENT_ID = 'pane.splitter_button_container';
|
|
14
|
+
const colorStyles = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
theme
|
|
17
|
+
} = _ref;
|
|
18
|
+
const backgroundColor = getColorV8('background', 600 , theme);
|
|
19
|
+
const boxShadow = theme.shadows.lg(`${theme.space.base}px`, `${theme.space.base * 2}px`, getColorV8('chromeHue', 600, theme, 0.15));
|
|
20
|
+
return css(["box-shadow:", ";background-color:", ";"], boxShadow, backgroundColor);
|
|
21
|
+
};
|
|
22
|
+
const positionStyles = props => {
|
|
23
|
+
let top;
|
|
24
|
+
let left;
|
|
25
|
+
let right;
|
|
26
|
+
let bottom;
|
|
27
|
+
const size = getSize(props.theme);
|
|
28
|
+
const inset = `-${size / 2}px`;
|
|
29
|
+
if (props.placement === 'center' || props.splitterSize < size * 3) {
|
|
30
|
+
const center = `${props.splitterSize / 2 - size / 2}px`;
|
|
31
|
+
switch (`${props.orientation}-${props.theme.rtl ? 'rtl' : 'ltr'}`) {
|
|
32
|
+
case 'top-ltr':
|
|
33
|
+
case 'top-rtl':
|
|
34
|
+
top = inset;
|
|
35
|
+
left = center;
|
|
36
|
+
break;
|
|
37
|
+
case 'start-ltr':
|
|
38
|
+
case 'end-rtl':
|
|
39
|
+
top = center;
|
|
40
|
+
left = inset;
|
|
41
|
+
break;
|
|
42
|
+
case 'end-ltr':
|
|
43
|
+
case 'start-rtl':
|
|
44
|
+
top = center;
|
|
45
|
+
right = inset;
|
|
46
|
+
break;
|
|
47
|
+
case 'bottom-ltr':
|
|
48
|
+
case 'bottom-rtl':
|
|
49
|
+
bottom = inset;
|
|
50
|
+
right = center;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
const offset = `${size}px`;
|
|
55
|
+
switch (`${props.orientation}-${props.placement}-${props.theme.rtl ? 'rtl' : 'ltr'}`) {
|
|
56
|
+
case 'top-end-ltr':
|
|
57
|
+
case 'top-end-rtl':
|
|
58
|
+
case 'top-start-rtl':
|
|
59
|
+
top = inset;
|
|
60
|
+
right = offset;
|
|
61
|
+
break;
|
|
62
|
+
case 'bottom-end-ltr':
|
|
63
|
+
case 'bottom-end-rtl':
|
|
64
|
+
case 'bottom-start-rtl':
|
|
65
|
+
bottom = inset;
|
|
66
|
+
right = offset;
|
|
67
|
+
break;
|
|
68
|
+
case 'start-start-ltr':
|
|
69
|
+
case 'end-start-rtl':
|
|
70
|
+
top = offset;
|
|
71
|
+
left = inset;
|
|
72
|
+
break;
|
|
73
|
+
case 'start-end-ltr':
|
|
74
|
+
case 'end-end-rtl':
|
|
75
|
+
bottom = offset;
|
|
76
|
+
left = inset;
|
|
77
|
+
break;
|
|
78
|
+
case 'end-start-ltr':
|
|
79
|
+
case 'start-start-rtl':
|
|
80
|
+
top = offset;
|
|
81
|
+
right = inset;
|
|
82
|
+
break;
|
|
83
|
+
case 'end-end-ltr':
|
|
84
|
+
case 'start-end-rtl':
|
|
85
|
+
bottom = offset;
|
|
86
|
+
right = inset;
|
|
87
|
+
break;
|
|
88
|
+
case 'top-start-ltr':
|
|
89
|
+
top = inset;
|
|
90
|
+
left = offset;
|
|
91
|
+
break;
|
|
92
|
+
case 'bottom-start-ltr':
|
|
93
|
+
bottom = inset;
|
|
94
|
+
left = offset;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return css(["top:", ";right:", ";bottom:", ";left:", ";"], top, right, bottom, left);
|
|
99
|
+
};
|
|
100
|
+
const sizeStyles = _ref2 => {
|
|
101
|
+
let {
|
|
102
|
+
theme
|
|
103
|
+
} = _ref2;
|
|
104
|
+
const size = getSize(theme);
|
|
105
|
+
return css(["border-radius:", "px;width:", "px;height:", "px;"], size, size, size);
|
|
106
|
+
};
|
|
107
|
+
const minimumSplitterSize = theme => stripUnit(math(`${theme.shadowWidths.md} * 2 + ${getSize(theme)}`));
|
|
108
|
+
const StyledPaneSplitterButtonContainer = styled.div.withConfig({
|
|
109
|
+
displayName: "StyledPaneSplitterButtonContainer",
|
|
110
|
+
componentId: "sc-1w84y62-0"
|
|
111
|
+
})(["display:", ";position:absolute;transition:box-shadow 0.1s ease-in-out,opacity 0.25s ease-in-out 0.1s;opacity:0;z-index:2;", ";", ";", ";&:hover,&:focus-within,", ":hover ~ &,", ":focus-visible ~ &{opacity:1;}", ";"], props => props.splitterSize <= minimumSplitterSize(props.theme) ? 'none' : undefined, positionStyles, sizeStyles, colorStyles, StyledPaneSplitter, StyledPaneSplitter, props => retrieveComponentStyles(COMPONENT_ID, props));
|
|
112
|
+
StyledPaneSplitterButtonContainer.defaultProps = {
|
|
113
|
+
theme: DEFAULT_THEME
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { StyledPaneSplitterButtonContainer };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
const ALIGN_ITEMS = ['start', 'end', 'center', 'baseline', 'stretch'];
|
|
8
|
+
const ALIGN_SELF = ['auto', ...ALIGN_ITEMS];
|
|
9
|
+
const DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
10
|
+
const JUSTIFY_CONTENT = ['start', 'end', 'center', 'between', 'around'];
|
|
11
|
+
const TEXT_ALIGN = ['start', 'end', 'center', 'justify'];
|
|
12
|
+
const SPACE = [false, 'xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
13
|
+
const WRAP = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
14
|
+
const ORIENTATION = ['top', 'bottom', 'start', 'end'];
|
|
15
|
+
|
|
16
|
+
export { ALIGN_ITEMS, ALIGN_SELF, DIRECTION, JUSTIFY_CONTENT, ORIENTATION, SPACE, TEXT_ALIGN, WRAP };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const GridContext = createContext({
|
|
10
|
+
gutters: 'md'
|
|
11
|
+
});
|
|
12
|
+
const useGridContext = () => {
|
|
13
|
+
return useContext(GridContext);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { GridContext, useGridContext as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const PaneContext = createContext({
|
|
10
|
+
setId: () => undefined
|
|
11
|
+
});
|
|
12
|
+
const usePaneContext = () => {
|
|
13
|
+
return useContext(PaneContext);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { PaneContext, usePaneContext as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const PaneProviderContext = createContext({});
|
|
10
|
+
const usePaneProviderContextData = providerId => {
|
|
11
|
+
const context = useContext(PaneProviderContext);
|
|
12
|
+
const id = providerId || context.providerId;
|
|
13
|
+
return id && context.contextData ? context.contextData[id] : undefined;
|
|
14
|
+
};
|
|
15
|
+
const usePaneProviderContext = () => useContext(PaneProviderContext);
|
|
16
|
+
|
|
17
|
+
export { PaneProviderContext, usePaneProviderContext as default, usePaneProviderContextData };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { createContext, useContext } from 'react';
|
|
8
|
+
|
|
9
|
+
const PaneSplitterContext = createContext({
|
|
10
|
+
orientation: 'start',
|
|
11
|
+
min: 0,
|
|
12
|
+
max: 0,
|
|
13
|
+
layoutKey: '',
|
|
14
|
+
valueNow: 0,
|
|
15
|
+
size: 0,
|
|
16
|
+
isRow: false
|
|
17
|
+
});
|
|
18
|
+
const usePaneSplitterContext = () => {
|
|
19
|
+
return useContext(PaneSplitterContext);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { PaneSplitterContext, usePaneSplitterContext as default };
|