From 04807535812a315b15c27b190ac8dffca9521ff0 Mon Sep 17 00:00:00 2001 From: Arun Date: Mon, 22 Mar 2021 21:32:20 +0530 Subject: [PATCH] fix: Show Windows share icon for Windows users (#3306) * fix: Show Windows share icon for Windows users * move function outside t he component --- src/components/icons.tsx | 16 ++++++++++++++++ src/excalidraw-app/collab/RoomDialog.tsx | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/icons.tsx b/src/components/icons.tsx index 48fa45cd45..e8174788d4 100644 --- a/src/components/icons.tsx +++ b/src/components/icons.tsx @@ -123,6 +123,22 @@ export const shareIOS = createIcon( { width: 24, height: 24 }, ); +export const shareWindows = createIcon( + <> + + + , + { width: 64, height: 64 }, +); + // Icon imported form Storybook // Storybook is licensed under MIT https://github.com/storybookjs/storybook/blob/next/LICENSE export const resetZoom = createIcon( diff --git a/src/excalidraw-app/collab/RoomDialog.tsx b/src/excalidraw-app/collab/RoomDialog.tsx index f6b255b43c..4203fb47ad 100644 --- a/src/excalidraw-app/collab/RoomDialog.tsx +++ b/src/excalidraw-app/collab/RoomDialog.tsx @@ -7,12 +7,27 @@ import { stop, share, shareIOS, + shareWindows, } from "../../components/icons"; import { ToolButton } from "../../components/ToolButton"; import { t } from "../../i18n"; import "./RoomDialog.scss"; import Stack from "../../components/Stack"; +const getShareIcon = () => { + const navigator = window.navigator as any; + const isAppleBrowser = /Apple/.test(navigator.vendor); + const isWindowsBrowser = navigator.appVersion.indexOf("Win") !== -1; + + if (isAppleBrowser) { + return shareIOS; + } else if (isWindowsBrowser) { + return shareWindows; + } + + return share; +}; + const RoomDialog = ({ handleClose, activeRoomLink, @@ -31,8 +46,6 @@ const RoomDialog = ({ setErrorMessage: (message: string) => void; }) => { const roomLinkInput = useRef(null); - const navigator = window.navigator as any; - const isAppleBrowser = /Apple/.test(navigator.vendor); const copyRoomLink = async () => { try { @@ -93,7 +106,7 @@ const RoomDialog = ({ {"share" in navigator ? (