From 5a3e0b4ca3356d5327cf261799c60a14e9974300 Mon Sep 17 00:00:00 2001 From: Paulo Bernardo Date: Thu, 5 Oct 2023 12:00:30 -0300 Subject: [PATCH] feat: add tooltip into zoom control --- src/components/canvas/Canvas.module.scss | 6 ++++ src/components/canvas/Canvas.tsx | 36 +++++++++++++++--------- src/utils/index.tsx | 14 +++++++-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/components/canvas/Canvas.module.scss b/src/components/canvas/Canvas.module.scss index aa1b2ef26..a7159191d 100644 --- a/src/components/canvas/Canvas.module.scss +++ b/src/components/canvas/Canvas.module.scss @@ -115,4 +115,10 @@ $background_offset: ($grid_size / 2) + ($node_padding) + px; font-size: 18px; } } +} + +.zoom_tooltip { + position: fixed !important; + bottom: 85px !important; + left: 110px !important; } \ No newline at end of file diff --git a/src/components/canvas/Canvas.tsx b/src/components/canvas/Canvas.tsx index f8b7beb4e..231b4379e 100644 --- a/src/components/canvas/Canvas.tsx +++ b/src/components/canvas/Canvas.tsx @@ -10,14 +10,16 @@ import i18n from 'config/i18n'; import { CanvasPositions, DragSelection, MouseState } from 'store/editor'; import { addPosition } from 'store/helpers'; import { MergeEditorState } from 'store/thunks'; -import { COLLISION_FUDGE, throttle } from 'utils'; +import { COLLISION_FUDGE, getOS, throttle } from 'utils'; import styles from './Canvas.module.scss'; import nodesCopy from '../../components/copyAndPasteNodes'; import { RenderNode } from '../../store/flowContext'; +import { applyVueInReact } from 'vuereact-combined'; // @ts-ignore -import { unnnicCallAlert } from '@weni/unnnic-system'; +import { unnnicCallAlert, unnnicToolTip } from '@weni/unnnic-system'; +const UnnnicTooltip = applyVueInReact(unnnicToolTip); export const CANVAS_PADDING = 300; export const REFLOW_QUIET = 200; @@ -1017,18 +1019,26 @@ export class Canvas extends React.PureComponent { {this.panzoomInstance && ( -
-
this.handleZoomClick(0)}> - remove + +
+
this.handleZoomClick(0)}> + remove +
+
+ {this.state.currentZoom} + percent +
+
this.handleZoomClick(1)}> + add +
-
- {this.state.currentZoom} - percent -
-
this.handleZoomClick(1)}> - add -
-
+ )}
diff --git a/src/utils/index.tsx b/src/utils/index.tsx index ad57825cb..94949f9aa 100644 --- a/src/utils/index.tsx +++ b/src/utils/index.tsx @@ -325,7 +325,7 @@ export const unset = (val: any): Query => ({ $unset: val }); export const push = (arr: any[]): Query => ({ $push: arr }); // tslint:disable-next-line:array-type -export const splice = (arr: Array>): Query>> => ({ +export const splice = (arr: any[][]): Query => ({ $splice: arr }); @@ -426,7 +426,7 @@ export const copyToClipboard = (text: string) => { }; export const throttle = (func: any, timeout: any) => { - let ready: boolean = true; + let ready = true; return (...args: any) => { if (!ready) { @@ -484,3 +484,13 @@ export const desnake = (text: string): string => { export const bool = (prop: boolean) => { return prop ? 'true' : null; }; + +export const getOS = () => { + var OSName = 'Unknown OS'; + if (navigator.userAgent.indexOf('Win') !== -1) OSName = 'Windows'; + if (navigator.userAgent.indexOf('Mac') !== -1) OSName = 'Macintosh'; + if (navigator.userAgent.indexOf('Linux') !== -1) OSName = 'Linux'; + if (navigator.userAgent.indexOf('Android') !== -1) OSName = 'Android'; + + return OSName; +};