@primer/components 0.0.0-20219256296 → 0.0.0-20219265511
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/CHANGELOG.md +1 -1
- package/lib/NewButton/button.d.ts +10 -6
- package/lib/NewButton/button.js +18 -9
- package/lib/NewButton/counter.d.ts +6 -0
- package/lib/NewButton/{visual.js → counter.js} +15 -10
- package/lib-esm/NewButton/button.d.ts +10 -6
- package/lib-esm/NewButton/button.js +14 -10
- package/lib-esm/NewButton/counter.d.ts +6 -0
- package/lib-esm/NewButton/counter.js +21 -0
- package/package.json +1 -1
- package/lib/NewButton/visual.d.ts +0 -6
- package/lib-esm/NewButton/visual.d.ts +0 -6
- package/lib-esm/NewButton/visual.js +0 -17
package/CHANGELOG.md
CHANGED
@@ -9,10 +9,14 @@ export declare type ButtonProps = {
|
|
9
9
|
size: 'small' | 'medium' | 'large';
|
10
10
|
icon?: React.FunctionComponent<IconProps>;
|
11
11
|
} & SxProp & FontSizeProps;
|
12
|
-
declare const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
declare const NewButton: React.ForwardRefExoticComponent<{
|
13
|
+
children: ReactNode;
|
14
|
+
variant: Variant;
|
15
|
+
size: 'small' | 'medium' | 'large';
|
16
|
+
icon?: React.FunctionComponent<IconProps> | undefined;
|
17
|
+
} & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
|
18
|
+
Counter: ({ count }: {
|
19
|
+
count: number;
|
20
|
+
}) => JSX.Element;
|
17
21
|
};
|
18
|
-
export default
|
22
|
+
export default NewButton;
|
package/lib/NewButton/button.js
CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
-
var _react =
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
10
|
var _Box = _interopRequireDefault(require("../Box"));
|
11
11
|
|
@@ -19,10 +19,14 @@ var _constants = require("../constants");
|
|
19
19
|
|
20
20
|
var _ButtonStyles = _interopRequireDefault(require("../Button/ButtonStyles"));
|
21
21
|
|
22
|
-
var
|
22
|
+
var _counter = _interopRequireDefault(require("./counter"));
|
23
23
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
25
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
27
|
+
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
29
|
+
|
26
30
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
27
31
|
|
28
32
|
const sizes = (0, _styledSystem.variant)({
|
@@ -245,9 +249,9 @@ const ButtonBase = _styledComponents.default.button.withConfig({
|
|
245
249
|
componentId: "sc-15k5iqk-0"
|
246
250
|
})(["", " ", " ", " ", " ", " ", ""], _ButtonStyles.default, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', _sx.default, _styledSystem.fontSize);
|
247
251
|
|
248
|
-
const Button = ({
|
249
|
-
children,
|
252
|
+
const Button = /*#__PURE__*/(0, _react.forwardRef)(({
|
250
253
|
icon: Icon,
|
254
|
+
children,
|
251
255
|
...props
|
252
256
|
}) => {
|
253
257
|
let iconOnly = false;
|
@@ -265,11 +269,16 @@ const Button = ({
|
|
265
269
|
return /*#__PURE__*/_react.default.createElement(ButtonBase, _extends({}, props, {
|
266
270
|
iconOnly: iconOnly
|
267
271
|
}), Icon && /*#__PURE__*/_react.default.createElement(_Box.default, {
|
268
|
-
sx: iconWrapStyles
|
272
|
+
sx: iconWrapStyles,
|
273
|
+
"aria-hidden": !iconOnly
|
269
274
|
}, /*#__PURE__*/_react.default.createElement(Icon, null)), children);
|
275
|
+
});
|
276
|
+
Button.displayName = 'Button';
|
277
|
+
Button.defaultProps = {
|
278
|
+
size: 'medium'
|
270
279
|
};
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
var _default =
|
280
|
+
const NewButton = Object.assign(Button, {
|
281
|
+
Counter: _counter.default
|
282
|
+
});
|
283
|
+
var _default = NewButton;
|
275
284
|
exports.default = _default;
|
@@ -11,18 +11,23 @@ var _Box = _interopRequireDefault(require("../Box"));
|
|
11
11
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
|
14
|
-
const
|
15
|
-
|
16
|
-
|
14
|
+
const styles = {
|
15
|
+
display: 'inline-block',
|
16
|
+
padding: '0px 6px',
|
17
|
+
backgroundColor: 'neutral.muted',
|
18
|
+
borderRadius: '50%',
|
19
|
+
marginLeft: '8px'
|
20
|
+
};
|
21
|
+
|
22
|
+
const Counter = ({
|
23
|
+
count
|
17
24
|
}) => {
|
25
|
+
// get this to announce new count. How? Change aria property for every render? or aria-live?
|
18
26
|
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
19
|
-
sx:
|
20
|
-
|
21
|
-
...sx
|
22
|
-
}
|
23
|
-
}, children);
|
27
|
+
sx: styles
|
28
|
+
}, count);
|
24
29
|
};
|
25
30
|
|
26
|
-
|
27
|
-
var _default =
|
31
|
+
Counter.displayName = "Counter";
|
32
|
+
var _default = Counter;
|
28
33
|
exports.default = _default;
|
@@ -9,10 +9,14 @@ export declare type ButtonProps = {
|
|
9
9
|
size: 'small' | 'medium' | 'large';
|
10
10
|
icon?: React.FunctionComponent<IconProps>;
|
11
11
|
} & SxProp & FontSizeProps;
|
12
|
-
declare const
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
declare const NewButton: React.ForwardRefExoticComponent<{
|
13
|
+
children: ReactNode;
|
14
|
+
variant: Variant;
|
15
|
+
size: 'small' | 'medium' | 'large';
|
16
|
+
icon?: React.FunctionComponent<IconProps> | undefined;
|
17
|
+
} & SxProp & FontSizeProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>> & {
|
18
|
+
Counter: ({ count }: {
|
19
|
+
count: number;
|
20
|
+
}) => JSX.Element;
|
17
21
|
};
|
18
|
-
export default
|
22
|
+
export default NewButton;
|
@@ -1,13 +1,13 @@
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
2
|
|
3
|
-
import React from 'react';
|
3
|
+
import React, { forwardRef } from 'react';
|
4
4
|
import Box from '../Box';
|
5
5
|
import { fontSize, variant } from 'styled-system';
|
6
6
|
import styled from 'styled-components';
|
7
7
|
import sx from '../sx';
|
8
8
|
import { get } from '../constants';
|
9
9
|
import buttonBaseStyles from '../Button/ButtonStyles';
|
10
|
-
import
|
10
|
+
import Counter from './counter';
|
11
11
|
const sizes = variant({
|
12
12
|
prop: 'size',
|
13
13
|
variants: {
|
@@ -227,10 +227,9 @@ const ButtonBase = styled.button.withConfig({
|
|
227
227
|
displayName: "button__ButtonBase",
|
228
228
|
componentId: "sc-15k5iqk-0"
|
229
229
|
})(["", " ", " ", " ", " ", " ", ""], buttonBaseStyles, props => getVariantStyles(props.theme, props.variant), sizes, props => props.iconOnly ? `padding: 4px 6px;` : '', sx, fontSize);
|
230
|
-
|
231
|
-
const Button = ({
|
232
|
-
children,
|
230
|
+
const Button = /*#__PURE__*/forwardRef(({
|
233
231
|
icon: Icon,
|
232
|
+
children,
|
234
233
|
...props
|
235
234
|
}) => {
|
236
235
|
let iconOnly = false;
|
@@ -248,10 +247,15 @@ const Button = ({
|
|
248
247
|
return /*#__PURE__*/React.createElement(ButtonBase, _extends({}, props, {
|
249
248
|
iconOnly: iconOnly
|
250
249
|
}), Icon && /*#__PURE__*/React.createElement(Box, {
|
251
|
-
sx: iconWrapStyles
|
250
|
+
sx: iconWrapStyles,
|
251
|
+
"aria-hidden": !iconOnly
|
252
252
|
}, /*#__PURE__*/React.createElement(Icon, null)), children);
|
253
|
+
});
|
254
|
+
Button.displayName = 'Button';
|
255
|
+
Button.defaultProps = {
|
256
|
+
size: 'medium'
|
253
257
|
};
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
export default
|
258
|
+
const NewButton = Object.assign(Button, {
|
259
|
+
Counter
|
260
|
+
});
|
261
|
+
export default NewButton;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import Box from '../Box';
|
3
|
+
const styles = {
|
4
|
+
display: 'inline-block',
|
5
|
+
padding: '0px 6px',
|
6
|
+
backgroundColor: 'neutral.muted',
|
7
|
+
borderRadius: '50%',
|
8
|
+
marginLeft: '8px'
|
9
|
+
};
|
10
|
+
|
11
|
+
const Counter = ({
|
12
|
+
count
|
13
|
+
}) => {
|
14
|
+
// get this to announce new count. How? Change aria property for every render? or aria-live?
|
15
|
+
return /*#__PURE__*/React.createElement(Box, {
|
16
|
+
sx: styles
|
17
|
+
}, count);
|
18
|
+
};
|
19
|
+
|
20
|
+
Counter.displayName = "Counter";
|
21
|
+
export default Counter;
|
package/package.json
CHANGED
@@ -1,17 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import Box from '../Box';
|
3
|
-
|
4
|
-
const Visual = ({
|
5
|
-
children,
|
6
|
-
sx
|
7
|
-
}) => {
|
8
|
-
return /*#__PURE__*/React.createElement(Box, {
|
9
|
-
sx: {
|
10
|
-
display: 'inline-block',
|
11
|
-
...sx
|
12
|
-
}
|
13
|
-
}, children);
|
14
|
-
};
|
15
|
-
|
16
|
-
Visual.displayName = "Visual";
|
17
|
-
export default Visual;
|