From 1cf3c1b1a0387ee12bc648811e8f45d50bdc0d71 Mon Sep 17 00:00:00 2001 From: Danilo Woznica Date: Mon, 23 May 2022 17:19:17 +0100 Subject: [PATCH] chore(sandpack): remove unused code (#4674) --- beta/src/components/MDX/Sandpack/Preview.tsx | 6 +-- .../MDX/Sandpack/computeViewportSize.ts | 46 ------------------- 2 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 beta/src/components/MDX/Sandpack/computeViewportSize.ts diff --git a/beta/src/components/MDX/Sandpack/Preview.tsx b/beta/src/components/MDX/Sandpack/Preview.tsx index c77d8f30..d0836c9c 100644 --- a/beta/src/components/MDX/Sandpack/Preview.tsx +++ b/beta/src/components/MDX/Sandpack/Preview.tsx @@ -6,10 +6,8 @@ import * as React from 'react'; import {useSandpack, LoadingOverlay} from '@codesandbox/sandpack-react'; import cn from 'classnames'; - import {Error} from './Error'; -import {computeViewportSize} from './computeViewportSize'; -import type {LintDiagnostic} from './useSandpackLint'; +import type {LintDiagnostic} from './utils'; const generateRandomId = (): string => Math.floor(Math.random() * 10000).toString(); @@ -119,7 +117,6 @@ export function Preview({ [status === 'idle'] ); - const viewportStyle = computeViewportSize('auto', 'portrait'); const overrideStyle = error ? { // Don't collapse errors @@ -149,7 +146,6 @@ export function Preview({ style={{ // TODO: clean up this mess. ...customStyle, - ...viewportStyle, ...overrideStyle, }}>
= { - 'iPhone X': {x: 375, y: 812}, - iPad: {x: 768, y: 1024}, - 'Pixel 2': {x: 411, y: 731}, - 'Moto G4': {x: 360, y: 640}, - 'Surface Duo': {x: 540, y: 720}, -}; - -export const computeViewportSize = ( - viewport: ViewportSize, - orientation: ViewportOrientation -): {width?: number; height?: number} => { - if (viewport === 'auto') { - return {}; - } - - if (typeof viewport === 'string') { - const {x, y} = VIEWPORT_SIZE_PRESET_MAP[viewport]; - return orientation === 'portrait' - ? {width: x, height: y} - : {width: y, height: x}; - } - - return viewport; -};