venice-ui 2.1.16 → 2.1.17

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.
@@ -17,6 +17,7 @@ exports.Theme = {
17
17
  accent_light: (0, polished_1.lighten)(0.2, exports.pallete.accent),
18
18
  black: "#000000",
19
19
  text: '#333333',
20
+ darkGray: ' #222222',
20
21
  gray_1: '#979797',
21
22
  gray_2: "#b7b7b7",
22
23
  gray_3: "#e3e3e3",
@@ -1,24 +1,64 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.Icon = void 0;
7
- const react_1 = __importDefault(require("react"));
27
+ const react_1 = __importStar(require("react"));
8
28
  const Theme_1 = require("../../Theme/Theme");
9
29
  const Icon_styles_1 = require("./Icon.styles");
10
30
  const IconsPath_1 = require("./IconsPath");
31
+ const Tooltip_1 = require("../Tooltip/Tooltip");
11
32
  const Icon = ({ size = 24, name = 'person', right = false, left = false, isActive = false, onClick = undefined, isDisabled = false, noPadding = false, iconColor = isDisabled ? Theme_1.mainTheme.iconDisabledColor : Theme_1.mainTheme.iconColor, iconHoverColor = Theme_1.mainTheme.iconHoverColor, iconBgColor = Theme_1.mainTheme.iconBgColor, iconBgHoverColor = isDisabled
12
33
  ? Theme_1.mainTheme.iconBgColor
13
- : Theme_1.mainTheme.iconBgHoverColor, }) => {
34
+ : Theme_1.mainTheme.iconBgHoverColor, tooltip, }) => {
14
35
  const haveAction = Boolean(onClick);
36
+ const iconRef = (0, react_1.useRef)(null);
37
+ const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
38
+ const [tooltipPos, setTooltipPos] = (0, react_1.useState)({ top: 0, left: 0 });
39
+ const [showBelow, setShowBelow] = (0, react_1.useState)(false);
40
+ (0, react_1.useEffect)(() => {
41
+ if (showTooltip && iconRef.current) {
42
+ const rect = iconRef.current.getBoundingClientRect();
43
+ const tooltipHeight = 28;
44
+ const spaceAbove = rect.top;
45
+ const spaceBelow = window.innerHeight - rect.bottom;
46
+ setShowBelow(spaceBelow < tooltipHeight && spaceAbove > tooltipHeight);
47
+ setTooltipPos({
48
+ top: showBelow ? rect.bottom : rect.top,
49
+ left: rect.left + rect.width / 2 - 16,
50
+ });
51
+ }
52
+ }, [showTooltip, showBelow]);
15
53
  const handleClick = () => {
16
54
  if (!isDisabled && !!onClick) {
17
55
  onClick();
18
56
  }
19
57
  };
20
- return (react_1.default.createElement(Icon_styles_1.IconElement, { onClick: handleClick, haveAction: haveAction, right: right, left: left, isDisabled: isDisabled, iconColor: iconColor, iconHoverColor: iconHoverColor, iconBgColor: iconBgColor, iconBgHoverColor: iconBgHoverColor, isActive: isActive, noPadding: noPadding },
21
- react_1.default.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', preserveAspectRatio: "xMidYMid meet", x: "0", y: "0", name: name },
22
- react_1.default.createElement("path", { d: IconsPath_1.iconsPath[name], fill: isActive ? iconHoverColor : iconColor }))));
58
+ return (react_1.default.createElement(react_1.default.Fragment, null,
59
+ react_1.default.createElement(Icon_styles_1.IconElement, { ref: iconRef, onClick: handleClick, haveAction: haveAction, right: right, left: left, isDisabled: isDisabled, iconColor: iconColor, iconHoverColor: iconHoverColor, iconBgColor: iconBgColor, iconBgHoverColor: iconBgHoverColor, isActive: isActive, noPadding: noPadding, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false) },
60
+ react_1.default.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', preserveAspectRatio: "xMidYMid meet", x: "0", y: "0", name: name },
61
+ react_1.default.createElement("path", { d: IconsPath_1.iconsPath[name], fill: isActive ? iconHoverColor : iconColor }))),
62
+ tooltip && showTooltip && (react_1.default.createElement(Tooltip_1.Tooltip, { text: tooltip, position: tooltipPos, showBelow: showBelow }))));
23
63
  };
24
64
  exports.Icon = Icon;
@@ -9,6 +9,7 @@ const Theme_1 = require("../../Theme/Theme");
9
9
  exports.IconElement = styled_components_1.default.div `
10
10
  transition: 300ms;
11
11
  box-sizing: border-box;
12
+ position: relative;
12
13
  width: auto;
13
14
  display: inline-flex;
14
15
  border-radius: ${Theme_1.Theme.borderRadius.m};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Tooltip = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_dom_1 = require("react-dom");
9
+ const Tooltip_styles_1 = require("./Tooltip.styles");
10
+ const Tooltip = ({ text, position, showBelow }) => {
11
+ return (0, react_dom_1.createPortal)(react_1.default.createElement(Tooltip_styles_1.TooltipWrapper, { position: position, showBelow: showBelow },
12
+ text,
13
+ react_1.default.createElement(Tooltip_styles_1.TooltipPivot, { showBelow: showBelow })), document.body);
14
+ };
15
+ exports.Tooltip = Tooltip;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.TooltipPivot = exports.TooltipWrapper = void 0;
27
+ const styled_components_1 = __importStar(require("styled-components"));
28
+ const Theme_1 = require("../../Theme/Theme");
29
+ exports.TooltipWrapper = styled_components_1.default.div `
30
+ position: absolute;
31
+ top: ${(p) => (p.showBelow ? p.position.top + 8 : p.position.top - 36)}px;
32
+ left: ${(p) => p.position.left}px;
33
+ background: ${Theme_1.Theme.colors.darkGray};
34
+ color: ${Theme_1.Theme.colors.white};
35
+ padding: ${Theme_1.Theme.padding.s} ${Theme_1.Theme.padding.m};
36
+ border-radius: ${Theme_1.Theme.borderRadius.m};
37
+ font-size: ${Theme_1.Theme.fontSize.s};
38
+ z-index: 9999;
39
+ white-space: nowrap;
40
+ box-shadow: 0 2px 8px ${Theme_1.Theme.colors.overlayer};
41
+ pointer-events: none;
42
+ `;
43
+ exports.TooltipPivot = styled_components_1.default.span `
44
+ position: absolute;
45
+ left: 50%;
46
+ transform: translateX(-50%);
47
+ width: 0;
48
+ height: 0;
49
+ border-left: 7px solid transparent;
50
+ border-right: 7px solid transparent;
51
+
52
+ ${({ showBelow }) => showBelow
53
+ ? (0, styled_components_1.css) `
54
+ top: -7px;
55
+ border-bottom: 7px solid #222;
56
+ border-top: none;
57
+ `
58
+ : (0, styled_components_1.css) `
59
+ bottom: -7px;
60
+ border-top: 7px solid #222;
61
+ border-bottom: none;
62
+ `}
63
+ `;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Tooltip"), exports);
package/dist/cjs/index.js CHANGED
@@ -40,4 +40,5 @@ __exportStar(require("./components/Sort"), exports);
40
40
  __exportStar(require("./components/Table"), exports);
41
41
  __exportStar(require("./components/Tile"), exports);
42
42
  __exportStar(require("./components/Toogle"), exports);
43
+ __exportStar(require("./components/Tooltip"), exports);
43
44
  __exportStar(require("./components/Typography"), exports);
@@ -14,6 +14,7 @@ export const Theme = {
14
14
  accent_light: lighten(0.2, pallete.accent),
15
15
  black: "#000000",
16
16
  text: '#333333',
17
+ darkGray: ' #222222',
17
18
  gray_1: '#979797',
18
19
  gray_2: "#b7b7b7",
19
20
  gray_3: "#e3e3e3",
@@ -1,17 +1,37 @@
1
- import React from 'react';
1
+ import React, { useRef, useState, useEffect } from 'react';
2
2
  import { mainTheme } from '../../Theme/Theme';
3
3
  import { IconElement } from './Icon.styles';
4
4
  import { iconsPath } from './IconsPath';
5
+ import { Tooltip } from '../Tooltip/Tooltip';
5
6
  export const Icon = ({ size = 24, name = 'person', right = false, left = false, isActive = false, onClick = undefined, isDisabled = false, noPadding = false, iconColor = isDisabled ? mainTheme.iconDisabledColor : mainTheme.iconColor, iconHoverColor = mainTheme.iconHoverColor, iconBgColor = mainTheme.iconBgColor, iconBgHoverColor = isDisabled
6
7
  ? mainTheme.iconBgColor
7
- : mainTheme.iconBgHoverColor, }) => {
8
+ : mainTheme.iconBgHoverColor, tooltip, }) => {
8
9
  const haveAction = Boolean(onClick);
10
+ const iconRef = useRef(null);
11
+ const [showTooltip, setShowTooltip] = useState(false);
12
+ const [tooltipPos, setTooltipPos] = useState({ top: 0, left: 0 });
13
+ const [showBelow, setShowBelow] = useState(false);
14
+ useEffect(() => {
15
+ if (showTooltip && iconRef.current) {
16
+ const rect = iconRef.current.getBoundingClientRect();
17
+ const tooltipHeight = 28;
18
+ const spaceAbove = rect.top;
19
+ const spaceBelow = window.innerHeight - rect.bottom;
20
+ setShowBelow(spaceBelow < tooltipHeight && spaceAbove > tooltipHeight);
21
+ setTooltipPos({
22
+ top: showBelow ? rect.bottom : rect.top,
23
+ left: rect.left + rect.width / 2 - 16,
24
+ });
25
+ }
26
+ }, [showTooltip, showBelow]);
9
27
  const handleClick = () => {
10
28
  if (!isDisabled && !!onClick) {
11
29
  onClick();
12
30
  }
13
31
  };
14
- return (React.createElement(IconElement, { onClick: handleClick, haveAction: haveAction, right: right, left: left, isDisabled: isDisabled, iconColor: iconColor, iconHoverColor: iconHoverColor, iconBgColor: iconBgColor, iconBgHoverColor: iconBgHoverColor, isActive: isActive, noPadding: noPadding },
15
- React.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', preserveAspectRatio: "xMidYMid meet", x: "0", y: "0", name: name },
16
- React.createElement("path", { d: iconsPath[name], fill: isActive ? iconHoverColor : iconColor }))));
32
+ return (React.createElement(React.Fragment, null,
33
+ React.createElement(IconElement, { ref: iconRef, onClick: handleClick, haveAction: haveAction, right: right, left: left, isDisabled: isDisabled, iconColor: iconColor, iconHoverColor: iconHoverColor, iconBgColor: iconBgColor, iconBgHoverColor: iconBgHoverColor, isActive: isActive, noPadding: noPadding, onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false) },
34
+ React.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', preserveAspectRatio: "xMidYMid meet", x: "0", y: "0", name: name },
35
+ React.createElement("path", { d: iconsPath[name], fill: isActive ? iconHoverColor : iconColor }))),
36
+ tooltip && showTooltip && (React.createElement(Tooltip, { text: tooltip, position: tooltipPos, showBelow: showBelow }))));
17
37
  };
@@ -3,6 +3,7 @@ import { Theme } from '../../Theme/Theme';
3
3
  export const IconElement = styled.div `
4
4
  transition: 300ms;
5
5
  box-sizing: border-box;
6
+ position: relative;
6
7
  width: auto;
7
8
  display: inline-flex;
8
9
  border-radius: ${Theme.borderRadius.m};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { TooltipPivot, TooltipWrapper } from './Tooltip.styles';
4
+ export const Tooltip = ({ text, position, showBelow }) => {
5
+ return createPortal(React.createElement(TooltipWrapper, { position: position, showBelow: showBelow },
6
+ text,
7
+ React.createElement(TooltipPivot, { showBelow: showBelow })), document.body);
8
+ };
@@ -0,0 +1,37 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { Theme } from '../../Theme/Theme';
3
+ export const TooltipWrapper = styled.div `
4
+ position: absolute;
5
+ top: ${(p) => (p.showBelow ? p.position.top + 8 : p.position.top - 36)}px;
6
+ left: ${(p) => p.position.left}px;
7
+ background: ${Theme.colors.darkGray};
8
+ color: ${Theme.colors.white};
9
+ padding: ${Theme.padding.s} ${Theme.padding.m};
10
+ border-radius: ${Theme.borderRadius.m};
11
+ font-size: ${Theme.fontSize.s};
12
+ z-index: 9999;
13
+ white-space: nowrap;
14
+ box-shadow: 0 2px 8px ${Theme.colors.overlayer};
15
+ pointer-events: none;
16
+ `;
17
+ export const TooltipPivot = styled.span `
18
+ position: absolute;
19
+ left: 50%;
20
+ transform: translateX(-50%);
21
+ width: 0;
22
+ height: 0;
23
+ border-left: 7px solid transparent;
24
+ border-right: 7px solid transparent;
25
+
26
+ ${({ showBelow }) => showBelow
27
+ ? css `
28
+ top: -7px;
29
+ border-bottom: 7px solid #222;
30
+ border-top: none;
31
+ `
32
+ : css `
33
+ bottom: -7px;
34
+ border-top: 7px solid #222;
35
+ border-bottom: none;
36
+ `}
37
+ `;
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
package/dist/esm/index.js CHANGED
@@ -24,4 +24,5 @@ export * from './components/Sort';
24
24
  export * from './components/Table';
25
25
  export * from './components/Tile';
26
26
  export * from './components/Toogle';
27
+ export * from './components/Tooltip';
27
28
  export * from './components/Typography';
@@ -13,6 +13,7 @@ export declare const Theme: {
13
13
  accent_light: string;
14
14
  black: string;
15
15
  text: string;
16
+ darkGray: string;
16
17
  gray_1: string;
17
18
  gray_2: string;
18
19
  gray_3: string;
@@ -12,5 +12,6 @@ export interface IIconActionProps {
12
12
  isDisabled?: boolean;
13
13
  isActive?: boolean;
14
14
  noPadding?: boolean;
15
+ tooltip?: string;
15
16
  }
16
17
  export declare const Icon: FC<IIconActionProps>;
@@ -0,0 +1,11 @@
1
+ import { FC } from 'react';
2
+ interface ITooltipProps {
3
+ text: string;
4
+ position: {
5
+ top: number;
6
+ left: number;
7
+ };
8
+ showBelow: boolean;
9
+ }
10
+ export declare const Tooltip: FC<ITooltipProps>;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ interface ITooltipWrapperProps {
2
+ position: {
3
+ top: number;
4
+ left: number;
5
+ };
6
+ showBelow: boolean;
7
+ }
8
+ export declare const TooltipWrapper: import("styled-components").StyledComponent<"div", any, ITooltipWrapperProps, never>;
9
+ interface ITooltipPivotProps {
10
+ showBelow: boolean;
11
+ }
12
+ export declare const TooltipPivot: import("styled-components").StyledComponent<"span", any, ITooltipPivotProps, never>;
13
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -24,4 +24,5 @@ export * from './components/Sort';
24
24
  export * from './components/Table';
25
25
  export * from './components/Tile';
26
26
  export * from './components/Toogle';
27
+ export * from './components/Tooltip';
27
28
  export * from './components/Typography';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venice-ui",
3
- "version": "2.1.16",
3
+ "version": "2.1.17",
4
4
  "description": "Component library",
5
5
  "main": "index.js",
6
6
  "module": "./dist/esm/index.js",