From 0d8606e681034ce3457246cd5b2a962259aa4d82 Mon Sep 17 00:00:00 2001 From: Cataldo Mazzilli Date: Mon, 5 Aug 2024 12:12:56 +0200 Subject: [PATCH] refactor!: remove useIsMobile hook Refs: SHELL-223 (#475) --- api-extractor/carbonio-shell-ui.api.md | 3 --- src/boot/app/app-direct-exports.ts | 2 -- src/shell/hooks/useIsMobile.ts | 16 -------------- src/shell/shell-context-provider.tsx | 30 -------------------------- src/shell/shell-context.ts | 11 ---------- src/shell/shell-view.tsx | 9 +++----- 6 files changed, 3 insertions(+), 68 deletions(-) delete mode 100644 src/shell/hooks/useIsMobile.ts delete mode 100644 src/shell/shell-context-provider.tsx delete mode 100644 src/shell/shell-context.ts diff --git a/api-extractor/carbonio-shell-ui.api.md b/api-extractor/carbonio-shell-ui.api.md index d5cf6e40..99452555 100644 --- a/api-extractor/carbonio-shell-ui.api.md +++ b/api-extractor/carbonio-shell-ui.api.md @@ -1593,9 +1593,6 @@ export const useIntegratedFunction: (id: string) => [AnyFunction, boolean]; // @public export function useIsCarbonioCE(): boolean | undefined; -// @public @deprecated (undocumented) -export function useIsMobile(): boolean; - // Warning: (ae-forgotten-export) The symbol "LocalStorageOptions" needs to be exported by the entry point lib.d.ts // // @public (undocumented) diff --git a/src/boot/app/app-direct-exports.ts b/src/boot/app/app-direct-exports.ts index adc1f9bd..f9d26ad8 100644 --- a/src/boot/app/app-direct-exports.ts +++ b/src/boot/app/app-direct-exports.ts @@ -105,8 +105,6 @@ export { getNotificationManager } from '../../notification/NotificationManager'; export { runSearch } from '../../search/run-search'; -export { useIsMobile } from '../../shell/hooks/useIsMobile'; - export { useLocalStorage } from '../../shell/hooks/useLocalStorage'; export const { diff --git a/src/shell/hooks/useIsMobile.ts b/src/shell/hooks/useIsMobile.ts deleted file mode 100644 index b0da275b..00000000 --- a/src/shell/hooks/useIsMobile.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2023 Zextras - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -import { useContext } from 'react'; - -import ShellContext from '../shell-context'; - -/** - * @deprecated Use useScreenMode hook - */ -export function useIsMobile(): boolean { - const { isMobile } = useContext(ShellContext); - return isMobile; -} diff --git a/src/shell/shell-context-provider.tsx b/src/shell/shell-context-provider.tsx deleted file mode 100644 index 34881ec6..00000000 --- a/src/shell/shell-context-provider.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Zextras - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import React, { useMemo } from 'react'; - -import { useScreenMode } from '@zextras/carbonio-design-system'; - -import ShellContext from './shell-context'; - -interface ShellContextProviderProps { - children: React.ReactNode; -} - -const ShellContextProvider = ({ children }: ShellContextProviderProps): React.JSX.Element => { - const screenMode = useScreenMode(); - - const value = useMemo( - () => ({ - isMobile: screenMode === 'mobile' - }), - [screenMode] - ); - - return {children}; -}; - -export default ShellContextProvider; diff --git a/src/shell/shell-context.ts b/src/shell/shell-context.ts deleted file mode 100644 index 882a86e7..00000000 --- a/src/shell/shell-context.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021 Zextras - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import { createContext } from 'react'; - -const ShellContext = createContext({ isMobile: true }); - -export default ShellContext; diff --git a/src/shell/shell-view.tsx b/src/shell/shell-view.tsx index b490e8cd..db3fb61f 100644 --- a/src/shell/shell-view.tsx +++ b/src/shell/shell-view.tsx @@ -12,7 +12,6 @@ import styled from 'styled-components'; import AppViewContainer from './app-view-container'; import { BoardContainer } from './boards/board-container'; -import ShellContextProvider from './shell-context-provider'; import ShellHeader from './shell-header'; import ShellPrimaryBar from './shell-primary-bar'; import ShellSecondaryBar from './shell-secondary-bar'; @@ -75,11 +74,9 @@ const ShellComponent = (): React.JSX.Element => ( ); const ShellView = (): React.JSX.Element => ( - - - - - + + + ); export default ShellView;