@via-profit/ui-kit 0.1.0-rc.17 → 0.1.0-rc.18
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/Button/ButtonBase.d.ts +11 -0
- package/Button/ButtonBase.js +2 -2
- package/Button/ButtonContainer.d.ts +22 -0
- package/Button/ButtonContainer.js +9 -0
- package/README.md +2 -2
- package/package.json +1 -1
package/Button/ButtonBase.d.ts
CHANGED
|
@@ -24,6 +24,17 @@ export interface ButtonBaseProps extends Omit<ButtonNativeProps, 'color'> {
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
readonly endIcon?: JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* If true, then expect SVG icon as children. The button will be rendered as icon button
|
|
29
|
+
* Example:
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <Button iconOnly>
|
|
32
|
+
* <MyIconSVG />
|
|
33
|
+
* </Button>
|
|
34
|
+
* ```
|
|
35
|
+
`
|
|
36
|
+
*/
|
|
37
|
+
readonly iconOnly?: ButtonContainerProps['iconOnly'];
|
|
27
38
|
/**
|
|
28
39
|
* You can pass the primary, default, secondary name of the colors or your specified color value
|
|
29
40
|
*/
|
package/Button/ButtonBase.js
CHANGED
|
@@ -19,11 +19,11 @@ const ButtonIconWrapper_1 = __importDefault(require("./ButtonIconWrapper"));
|
|
|
19
19
|
const ButtonTextWrapper_1 = __importDefault(require("./ButtonTextWrapper"));
|
|
20
20
|
const ButtonContainer_1 = __importDefault(require("./ButtonContainer"));
|
|
21
21
|
const ButtonBase = (props, ref) => {
|
|
22
|
-
const { children, startIcon, endIcon, color, overrides } = props, nativeProps = __rest(props, ["children", "startIcon", "endIcon", "color", "overrides"]);
|
|
22
|
+
const { children, startIcon, endIcon, color, overrides, iconOnly } = props, nativeProps = __rest(props, ["children", "startIcon", "endIcon", "color", "overrides", "iconOnly"]);
|
|
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
|
-
return (react_1.default.createElement(overridesMap.Container, Object.assign({}, nativeProps, { ref: ref }),
|
|
26
|
+
return (react_1.default.createElement(overridesMap.Container, Object.assign({}, nativeProps, { color: color, iconOnly: iconOnly, ref: ref }),
|
|
27
27
|
typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(overridesMap.IconWrapper, { position: "start" }, startIcon)),
|
|
28
28
|
react_1.default.createElement(overridesMap.TextWrapper, null, children),
|
|
29
29
|
typeof endIcon !== 'undefined' && endIcon !== null && (react_1.default.createElement(overridesMap.IconWrapper, { position: "end" }, endIcon))));
|
|
@@ -4,11 +4,33 @@ export type ButtonContainerProps = React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
4
4
|
* You can pass the primary, default, secondary name of the colors or your specified color value
|
|
5
5
|
*/
|
|
6
6
|
readonly color?: 'default' | 'primary' | 'secondary' | string;
|
|
7
|
+
/**
|
|
8
|
+
* If true, then expect SVG icon as children. The button will be rendered as icon button
|
|
9
|
+
* Example:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Button iconOnly>
|
|
12
|
+
* <MyIconSVG />
|
|
13
|
+
* </Button>
|
|
14
|
+
* ```
|
|
15
|
+
`
|
|
16
|
+
*/
|
|
17
|
+
readonly iconOnly?: boolean;
|
|
7
18
|
};
|
|
8
19
|
declare const _default: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
9
20
|
/**
|
|
10
21
|
* You can pass the primary, default, secondary name of the colors or your specified color value
|
|
11
22
|
*/
|
|
12
23
|
readonly color?: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* If true, then expect SVG icon as children. The button will be rendered as icon button
|
|
26
|
+
* Example:
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <Button iconOnly>
|
|
29
|
+
* <MyIconSVG />
|
|
30
|
+
* </Button>
|
|
31
|
+
* ```
|
|
32
|
+
`
|
|
33
|
+
*/
|
|
34
|
+
readonly iconOnly?: boolean | undefined;
|
|
13
35
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
14
36
|
export default _default;
|
|
@@ -16,6 +16,7 @@ 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 StyledButton = styled_1.default.button `
|
|
20
21
|
border-radius: ${({ theme }) => theme.shape.radiusFactor * 2}em;
|
|
21
22
|
padding: 0.8em 1em;
|
|
@@ -39,6 +40,14 @@ const StyledButton = styled_1.default.button `
|
|
|
39
40
|
return theme.color.textPrimary.toString();
|
|
40
41
|
}
|
|
41
42
|
}};
|
|
43
|
+
${({ iconOnly, theme }) => iconOnly &&
|
|
44
|
+
(0, react_2.css) `
|
|
45
|
+
padding: 1em;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
width: 2.6em;
|
|
48
|
+
height: 2.6em;
|
|
49
|
+
border-radius: ${theme.shape.radiusFactor * 3}em;
|
|
50
|
+
`}
|
|
42
51
|
`;
|
|
43
52
|
const ButtonContainer = (props, ref) => {
|
|
44
53
|
const { children } = props, nativeProps = __rest(props, ["children"]);
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Установка.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Для работы требуются следующие модули:
|
|
4
4
|
|
|
5
5
|
- react
|
|
6
6
|
- react-dom
|
|
@@ -16,4 +16,4 @@ $ npm install @emotion/react @emotion/styled react react-dom react-modal react-p
|
|
|
16
16
|
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
## Документация [здесь](./docs/
|
|
19
|
+
## Документация [здесь](./docs/README.md)
|