@planningcenter/tapestry-react 2.1.1 → 2.1.2
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/cjs/Avatar/Avatar.js +11 -9
- package/dist/cjs/Pagination/Pagination.js +17 -11
- package/dist/cjs/system/box-sizes.js +3 -3
- package/dist/esm/Avatar/Avatar.js +11 -7
- package/dist/esm/Pagination/Pagination.js +16 -11
- package/dist/esm/system/box-sizes.js +3 -3
- package/dist/types/Button/Button.d.ts +4 -0
- package/package.json +1 -1
- package/src/Avatar/Avatar.tsx +15 -8
- package/src/Button/Button.tsx +5 -0
- package/src/Pagination/Pagination.tsx +22 -12
- package/src/system/box-sizes.js +3 -3
|
@@ -14,8 +14,14 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
14
14
|
|
|
15
15
|
var _Box = _interopRequireDefault(require("../Box"));
|
|
16
16
|
|
|
17
|
-
var
|
|
18
|
-
|
|
17
|
+
var avatarSizes = {
|
|
18
|
+
xs: 2.5,
|
|
19
|
+
sm: 3,
|
|
20
|
+
md: 4.5,
|
|
21
|
+
lg: 6,
|
|
22
|
+
xl: 9,
|
|
23
|
+
xxl: 14
|
|
24
|
+
};
|
|
19
25
|
var borderSizes = {
|
|
20
26
|
xs: 2,
|
|
21
27
|
sm: 2,
|
|
@@ -34,16 +40,12 @@ function Avatar(_ref) {
|
|
|
34
40
|
source = _ref.source,
|
|
35
41
|
status = _ref.status,
|
|
36
42
|
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["size", "source", "status"]);
|
|
37
|
-
|
|
38
|
-
var _useBoxSize = (0, _system.useBoxSize)(size),
|
|
39
|
-
boxSize = _useBoxSize.boxSize;
|
|
40
|
-
|
|
41
43
|
return /*#__PURE__*/_react["default"].createElement(_Box["default"], (0, _extends2["default"])({
|
|
42
44
|
as: "img",
|
|
43
45
|
src: source,
|
|
44
|
-
width:
|
|
45
|
-
height:
|
|
46
|
-
flexBasis:
|
|
46
|
+
width: avatarSizes[size],
|
|
47
|
+
height: avatarSizes[size],
|
|
48
|
+
flexBasis: avatarSizes[size],
|
|
47
49
|
flexShrink: 0,
|
|
48
50
|
flexGrow: 0,
|
|
49
51
|
objectFit: "cover",
|
|
@@ -23,6 +23,8 @@ var _StackView = _interopRequireDefault(require("../StackView"));
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("../utils");
|
|
25
25
|
|
|
26
|
+
var _utils2 = require("../system/utils");
|
|
27
|
+
|
|
26
28
|
var _windowSize = require("@react-hook/window-size");
|
|
27
29
|
|
|
28
30
|
var _system = require("../system");
|
|
@@ -100,28 +102,32 @@ function Pagination(_ref2) {
|
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
function renderPageLink(number) {
|
|
103
|
-
var
|
|
105
|
+
var isCurrentPage = currentPage === number;
|
|
106
|
+
var activeBackgroundColor = (0, _utils2.parseColor)({
|
|
107
|
+
base: activeColor,
|
|
108
|
+
alpha: 0.1
|
|
109
|
+
});
|
|
104
110
|
var outlineStyle = {
|
|
105
|
-
border:
|
|
106
|
-
color: '#
|
|
111
|
+
border: "1px solid " + activeColor,
|
|
112
|
+
color: isCurrentPage ? '#fff' : activeColor
|
|
107
113
|
};
|
|
108
114
|
return /*#__PURE__*/_react["default"].createElement(_Button["default"], (0, _extends2["default"])({
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
backgroundColor: '#f4f8fd'
|
|
115
|
+
active: _objectSpread({
|
|
116
|
+
backgroundColor: isCurrentPage ? activeColor : activeBackgroundColor
|
|
112
117
|
}, outlineStyle),
|
|
118
|
+
key: number,
|
|
113
119
|
fontWeight: 500,
|
|
114
120
|
hover: _objectSpread({
|
|
115
|
-
backgroundColor: '#
|
|
121
|
+
backgroundColor: isCurrentPage ? activeColor : '#fff'
|
|
116
122
|
}, outlineStyle),
|
|
117
123
|
onClick: onPageChange.bind(null, number),
|
|
118
124
|
shrink: 0,
|
|
119
125
|
square: true,
|
|
120
126
|
title: number,
|
|
121
|
-
variant:
|
|
122
|
-
},
|
|
123
|
-
backgroundColor:
|
|
124
|
-
color: '
|
|
127
|
+
variant: isCurrentPage ? 'fill' : 'naked'
|
|
128
|
+
}, isCurrentPage && {
|
|
129
|
+
backgroundColor: activeColor,
|
|
130
|
+
color: '#fff'
|
|
125
131
|
}));
|
|
126
132
|
}
|
|
127
133
|
|
|
@@ -23,7 +23,7 @@ var boxSizes = {
|
|
|
23
23
|
radius: 3
|
|
24
24
|
},
|
|
25
25
|
md: {
|
|
26
|
-
boxSize: 4
|
|
26
|
+
boxSize: 4,
|
|
27
27
|
fontSize: 4,
|
|
28
28
|
lineHeight: 3,
|
|
29
29
|
paddingHorizontalDense: 1,
|
|
@@ -32,7 +32,7 @@ var boxSizes = {
|
|
|
32
32
|
radius: 4
|
|
33
33
|
},
|
|
34
34
|
lg: {
|
|
35
|
-
boxSize:
|
|
35
|
+
boxSize: 5,
|
|
36
36
|
fontSize: 3,
|
|
37
37
|
lineHeight: 4,
|
|
38
38
|
paddingHorizontalDense: 1,
|
|
@@ -41,7 +41,7 @@ var boxSizes = {
|
|
|
41
41
|
radius: 5
|
|
42
42
|
},
|
|
43
43
|
xl: {
|
|
44
|
-
boxSize:
|
|
44
|
+
boxSize: 8,
|
|
45
45
|
fontSize: 1,
|
|
46
46
|
lineHeight: 5,
|
|
47
47
|
paddingHorizontalDense: 2,
|
|
@@ -2,7 +2,14 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Box from '../Box';
|
|
5
|
-
|
|
5
|
+
var avatarSizes = {
|
|
6
|
+
xs: 2.5,
|
|
7
|
+
sm: 3,
|
|
8
|
+
md: 4.5,
|
|
9
|
+
lg: 6,
|
|
10
|
+
xl: 9,
|
|
11
|
+
xxl: 14
|
|
12
|
+
};
|
|
6
13
|
var borderSizes = {
|
|
7
14
|
xs: 2,
|
|
8
15
|
sm: 2,
|
|
@@ -22,15 +29,12 @@ export function Avatar(_ref) {
|
|
|
22
29
|
status = _ref.status,
|
|
23
30
|
restProps = _objectWithoutPropertiesLoose(_ref, ["size", "source", "status"]);
|
|
24
31
|
|
|
25
|
-
var _useBoxSize = useBoxSize(size),
|
|
26
|
-
boxSize = _useBoxSize.boxSize;
|
|
27
|
-
|
|
28
32
|
return /*#__PURE__*/React.createElement(Box, _extends({
|
|
29
33
|
as: "img",
|
|
30
34
|
src: source,
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
33
|
-
flexBasis:
|
|
35
|
+
width: avatarSizes[size],
|
|
36
|
+
height: avatarSizes[size],
|
|
37
|
+
flexBasis: avatarSizes[size],
|
|
34
38
|
flexShrink: 0,
|
|
35
39
|
flexGrow: 0,
|
|
36
40
|
objectFit: "cover",
|
|
@@ -12,6 +12,7 @@ import Button from '../Button';
|
|
|
12
12
|
import Group from '../Group';
|
|
13
13
|
import StackView from '../StackView';
|
|
14
14
|
import { range } from '../utils';
|
|
15
|
+
import { parseColor } from '../system/utils';
|
|
15
16
|
import { useWindowWidth } from '@react-hook/window-size';
|
|
16
17
|
import { useThemeValue } from '../system';
|
|
17
18
|
|
|
@@ -85,28 +86,32 @@ export default function Pagination(_ref2) {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
function renderPageLink(number) {
|
|
88
|
-
var
|
|
89
|
+
var isCurrentPage = currentPage === number;
|
|
90
|
+
var activeBackgroundColor = parseColor({
|
|
91
|
+
base: activeColor,
|
|
92
|
+
alpha: 0.1
|
|
93
|
+
});
|
|
89
94
|
var outlineStyle = {
|
|
90
|
-
border:
|
|
91
|
-
color: '#
|
|
95
|
+
border: "1px solid " + activeColor,
|
|
96
|
+
color: isCurrentPage ? '#fff' : activeColor
|
|
92
97
|
};
|
|
93
98
|
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
backgroundColor: '#f4f8fd'
|
|
99
|
+
active: _objectSpread({
|
|
100
|
+
backgroundColor: isCurrentPage ? activeColor : activeBackgroundColor
|
|
97
101
|
}, outlineStyle),
|
|
102
|
+
key: number,
|
|
98
103
|
fontWeight: 500,
|
|
99
104
|
hover: _objectSpread({
|
|
100
|
-
backgroundColor: '#
|
|
105
|
+
backgroundColor: isCurrentPage ? activeColor : '#fff'
|
|
101
106
|
}, outlineStyle),
|
|
102
107
|
onClick: onPageChange.bind(null, number),
|
|
103
108
|
shrink: 0,
|
|
104
109
|
square: true,
|
|
105
110
|
title: number,
|
|
106
|
-
variant:
|
|
107
|
-
},
|
|
108
|
-
backgroundColor:
|
|
109
|
-
color: '
|
|
111
|
+
variant: isCurrentPage ? 'fill' : 'naked'
|
|
112
|
+
}, isCurrentPage && {
|
|
113
|
+
backgroundColor: activeColor,
|
|
114
|
+
color: '#fff'
|
|
110
115
|
}));
|
|
111
116
|
}
|
|
112
117
|
|
|
@@ -18,7 +18,7 @@ export var boxSizes = {
|
|
|
18
18
|
radius: 3
|
|
19
19
|
},
|
|
20
20
|
md: {
|
|
21
|
-
boxSize: 4
|
|
21
|
+
boxSize: 4,
|
|
22
22
|
fontSize: 4,
|
|
23
23
|
lineHeight: 3,
|
|
24
24
|
paddingHorizontalDense: 1,
|
|
@@ -27,7 +27,7 @@ export var boxSizes = {
|
|
|
27
27
|
radius: 4
|
|
28
28
|
},
|
|
29
29
|
lg: {
|
|
30
|
-
boxSize:
|
|
30
|
+
boxSize: 5,
|
|
31
31
|
fontSize: 3,
|
|
32
32
|
lineHeight: 4,
|
|
33
33
|
paddingHorizontalDense: 1,
|
|
@@ -36,7 +36,7 @@ export var boxSizes = {
|
|
|
36
36
|
radius: 5
|
|
37
37
|
},
|
|
38
38
|
xl: {
|
|
39
|
-
boxSize:
|
|
39
|
+
boxSize: 8,
|
|
40
40
|
fontSize: 1,
|
|
41
41
|
lineHeight: 5,
|
|
42
42
|
paddingHorizontalDense: 2,
|
|
@@ -11,6 +11,10 @@ declare type ButtonProps = {
|
|
|
11
11
|
* Opens the linked destination in a new window or tab.
|
|
12
12
|
*/
|
|
13
13
|
external?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Pass styles for when the button is active.
|
|
16
|
+
*/
|
|
17
|
+
active?: object;
|
|
14
18
|
/**
|
|
15
19
|
* Pass styles for when the button is focused.
|
|
16
20
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A collection of flexible React components to help you build resilient, accessible user interfaces quickly and effectively.",
|
|
5
5
|
"author": "Front End Systems Engineering <frontend@pco.bz>",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
package/src/Avatar/Avatar.tsx
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
3
|
import Box from '../Box'
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const avatarSizes = {
|
|
6
|
+
xs: 2.5,
|
|
7
|
+
sm: 3,
|
|
8
|
+
md: 4.5,
|
|
9
|
+
lg: 6,
|
|
10
|
+
xl: 9,
|
|
11
|
+
xxl: 14,
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
const borderSizes = {
|
|
7
15
|
xs: 2,
|
|
@@ -16,15 +24,15 @@ type AvatarProps = {
|
|
|
16
24
|
/**
|
|
17
25
|
* Controls the size of the avatar.
|
|
18
26
|
*/
|
|
19
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
|
|
27
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
|
|
20
28
|
/**
|
|
21
29
|
* The source of the image to display.
|
|
22
30
|
*/
|
|
23
|
-
source?: string
|
|
31
|
+
source?: string
|
|
24
32
|
/**
|
|
25
33
|
* Adds a colored ring with padding around the avatar. Accepts a valid color string.
|
|
26
34
|
*/
|
|
27
|
-
status?: string
|
|
35
|
+
status?: string
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
/**
|
|
@@ -36,14 +44,13 @@ export function Avatar({
|
|
|
36
44
|
status,
|
|
37
45
|
...restProps
|
|
38
46
|
}: AvatarProps) {
|
|
39
|
-
const { boxSize } = useBoxSize(size)
|
|
40
47
|
return (
|
|
41
48
|
<Box
|
|
42
49
|
as="img"
|
|
43
50
|
src={source}
|
|
44
|
-
width={
|
|
45
|
-
height={
|
|
46
|
-
flexBasis={
|
|
51
|
+
width={avatarSizes[size]}
|
|
52
|
+
height={avatarSizes[size]}
|
|
53
|
+
flexBasis={avatarSizes[size]}
|
|
47
54
|
flexShrink={0}
|
|
48
55
|
flexGrow={0}
|
|
49
56
|
objectFit="cover"
|
package/src/Button/Button.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import Button from '../Button'
|
|
|
5
5
|
import Group from '../Group'
|
|
6
6
|
import StackView from '../StackView'
|
|
7
7
|
import { range } from '../utils'
|
|
8
|
+
import { parseColor } from '../system/utils'
|
|
8
9
|
import { useWindowWidth } from '@react-hook/window-size'
|
|
9
10
|
import { useThemeValue } from '../system'
|
|
10
11
|
|
|
@@ -39,27 +40,27 @@ export type PaginationProps = {
|
|
|
39
40
|
/**
|
|
40
41
|
* Change the color of the active page
|
|
41
42
|
*/
|
|
42
|
-
activeColor: string
|
|
43
|
+
activeColor: string
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* Current visible page number
|
|
46
47
|
*/
|
|
47
|
-
currentPage: number
|
|
48
|
+
currentPage: number
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* Callback when new page is requested
|
|
51
52
|
*/
|
|
52
|
-
onPageChange: (nextPage: number) => undefined
|
|
53
|
+
onPageChange: (nextPage: number) => undefined
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* Total available pages
|
|
56
57
|
*/
|
|
57
|
-
totalPages: number
|
|
58
|
+
totalPages: number
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* Amount of visible pages
|
|
61
62
|
*/
|
|
62
|
-
visiblePages?: number
|
|
63
|
+
visiblePages?: number
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const NavButton = ({ disabled, iconName, ...props }) => {
|
|
@@ -98,22 +99,31 @@ export default function Pagination({
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
function renderPageLink(number) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const outlineStyle = {
|
|
102
|
+
const isCurrentPage = currentPage === number
|
|
103
|
+
const activeBackgroundColor = parseColor({ base: activeColor, alpha: 0.1 })
|
|
104
|
+
const outlineStyle = {
|
|
105
|
+
border: `1px solid ${activeColor}`,
|
|
106
|
+
color: isCurrentPage ? '#fff' : activeColor,
|
|
107
|
+
}
|
|
104
108
|
|
|
105
109
|
return (
|
|
106
110
|
<Button
|
|
111
|
+
active={{
|
|
112
|
+
backgroundColor: isCurrentPage ? activeColor : activeBackgroundColor,
|
|
113
|
+
...outlineStyle,
|
|
114
|
+
}}
|
|
107
115
|
key={number}
|
|
108
|
-
focus={{ backgroundColor: '#f4f8fd', ...outlineStyle }}
|
|
109
116
|
fontWeight={500}
|
|
110
|
-
hover={{
|
|
117
|
+
hover={{
|
|
118
|
+
backgroundColor: isCurrentPage ? activeColor : '#fff',
|
|
119
|
+
...outlineStyle,
|
|
120
|
+
}}
|
|
111
121
|
onClick={onPageChange.bind(null, number)}
|
|
112
122
|
shrink={0}
|
|
113
123
|
square
|
|
114
124
|
title={number}
|
|
115
|
-
variant={
|
|
116
|
-
{...(
|
|
125
|
+
variant={isCurrentPage ? 'fill' : 'naked'}
|
|
126
|
+
{...(isCurrentPage && { backgroundColor: activeColor, color: '#fff' })}
|
|
117
127
|
/>
|
|
118
128
|
)
|
|
119
129
|
}
|
package/src/system/box-sizes.js
CHANGED
|
@@ -18,7 +18,7 @@ export const boxSizes = {
|
|
|
18
18
|
radius: 3,
|
|
19
19
|
},
|
|
20
20
|
md: {
|
|
21
|
-
boxSize: 4
|
|
21
|
+
boxSize: 4,
|
|
22
22
|
fontSize: 4,
|
|
23
23
|
lineHeight: 3,
|
|
24
24
|
paddingHorizontalDense: 1,
|
|
@@ -27,7 +27,7 @@ export const boxSizes = {
|
|
|
27
27
|
radius: 4,
|
|
28
28
|
},
|
|
29
29
|
lg: {
|
|
30
|
-
boxSize:
|
|
30
|
+
boxSize: 5,
|
|
31
31
|
fontSize: 3,
|
|
32
32
|
lineHeight: 4,
|
|
33
33
|
paddingHorizontalDense: 1,
|
|
@@ -36,7 +36,7 @@ export const boxSizes = {
|
|
|
36
36
|
radius: 5,
|
|
37
37
|
},
|
|
38
38
|
xl: {
|
|
39
|
-
boxSize:
|
|
39
|
+
boxSize: 8,
|
|
40
40
|
fontSize: 1,
|
|
41
41
|
lineHeight: 5,
|
|
42
42
|
paddingHorizontalDense: 2,
|