@via-profit/ui-kit 0.1.0-rc.18 → 0.1.0-rc.19

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.
@@ -23,9 +23,14 @@ const ButtonBase = (props, ref) => {
23
23
  const overridesMap = react_1.default.useMemo(() => (Object.assign({ TextWrapper: ButtonTextWrapper_1.default,
24
24
  IconWrapper: ButtonIconWrapper_1.default,
25
25
  Container: ButtonContainer_1.default }, overrides)), [overrides]);
26
+ if (iconOnly &&
27
+ ((typeof startIcon !== 'undefined' && startIcon !== null) ||
28
+ (typeof endIcon !== 'undefined' && endIcon !== null))) {
29
+ console.warn('The «iconOnly» property should not be used simultaneously with «startIcon» and/or «endIcon»');
30
+ }
26
31
  return (react_1.default.createElement(overridesMap.Container, Object.assign({}, nativeProps, { color: color, iconOnly: iconOnly, ref: ref }),
27
32
  typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(overridesMap.IconWrapper, { position: "start" }, startIcon)),
28
- react_1.default.createElement(overridesMap.TextWrapper, null, children),
33
+ react_1.default.createElement(overridesMap.TextWrapper, { iconOnly: iconOnly }, children),
29
34
  typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(overridesMap.IconWrapper, { position: "end" }, endIcon))));
30
35
  };
31
36
  exports.default = react_1.default.forwardRef(ButtonBase);
@@ -1,4 +1,29 @@
1
1
  import React from 'react';
2
- export type ButtonTextWrapperProps = React.HTMLAttributes<HTMLSpanElement>;
3
- declare const _default: React.ForwardRefExoticComponent<ButtonTextWrapperProps & React.RefAttributes<HTMLSpanElement>>;
2
+ import type { ButtonContainerProps } from './ButtonContainer';
3
+ export type ButtonTextWrapperProps = React.HTMLAttributes<HTMLSpanElement> & {
4
+ /**
5
+ * If true, then expect SVG icon as children. The button will be rendered as icon button
6
+ * Example:
7
+ * ```tsx
8
+ * <Button iconOnly>
9
+ * <MyIconSVG />
10
+ * </Button>
11
+ * ```
12
+ `
13
+ */
14
+ readonly iconOnly?: ButtonContainerProps['iconOnly'];
15
+ };
16
+ declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
17
+ /**
18
+ * If true, then expect SVG icon as children. The button will be rendered as icon button
19
+ * Example:
20
+ * ```tsx
21
+ * <Button iconOnly>
22
+ * <MyIconSVG />
23
+ * </Button>
24
+ * ```
25
+ `
26
+ */
27
+ readonly iconOnly?: boolean | undefined;
28
+ } & React.RefAttributes<HTMLSpanElement>>;
4
29
  export default _default;
@@ -16,11 +16,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const react_1 = __importDefault(require("react"));
18
18
  const styled_1 = __importDefault(require("@emotion/styled"));
19
+ const react_2 = require("@emotion/react");
19
20
  const TextWrapper = styled_1.default.span `
20
21
  font-size: 0.86em;
21
22
  display: flex;
22
23
  align-items: center;
23
24
  user-select: none;
25
+ ${({ iconOnly }) => iconOnly &&
26
+ (0, react_2.css) `
27
+ font-size: 1em;
28
+ justify-content: center;
29
+ `}
24
30
  `;
25
31
  const ButtonTextWrapper = (props, ref) => {
26
32
  const { children } = props, nativeProps = __rest(props, ["children"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.1.0-rc.18",
3
+ "version": "0.1.0-rc.19",
4
4
  "description": "UI Kit",
5
5
  "repository": {
6
6
  "type": "git",