Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.9 KB
Raw Blame
import type { BrowserViewportOverride, BrowserViewportPresetId } from './browser-workspace-types'

export type BrowserViewportPreset = {
  id: BrowserViewportPresetId
  label: string
  width: number
  height: number
  deviceScaleFactor: number
  mobile: boolean
}

// Match Chrome DevTools dimensions and 2x mobile/tablet assets; mobile enables touch and small-viewport CSS.
export const BROWSER_VIEWPORT_PRESETS = [
  {
    id: 'mobile-s',
    label: 'Mobile S — 320 × 568',
    width: 320,
    height: 568,
    deviceScaleFactor: 2,
    mobile: true
  },
  {
    id: 'mobile-m',
    label: 'Mobile M — 375 × 667',
    width: 375,
    height: 667,
    deviceScaleFactor: 2,
    mobile: true
  },
  {
    id: 'mobile-l',
    label: 'Mobile L — 425 × 812',
    width: 425,
    height: 812,
    deviceScaleFactor: 2,
    mobile: true
  },
  {
    id: 'tablet',
    label: 'Tablet — 768 × 1024',
    width: 768,
    height: 1024,
    deviceScaleFactor: 2,
    mobile: true
  },
  {
    id: 'laptop',
    label: 'Laptop — 1024 × 768',
    width: 1024,
    height: 768,
    deviceScaleFactor: 1,
    mobile: false
  },
  {
    id: 'laptop-l',
    label: 'Laptop L — 1440 × 900',
    width: 1440,
    height: 900,
    deviceScaleFactor: 1,
    mobile: false
  },
  {
    id: 'desktop',
    label: 'Desktop — 1920 × 1080',
    width: 1920,
    height: 1080,
    deviceScaleFactor: 1,
    mobile: false
  }
] as const satisfies readonly BrowserViewportPreset[]

export function getBrowserViewportPreset(
  id: BrowserViewportPresetId | null | undefined
): BrowserViewportPreset | null {
  if (!id) {
    return null
  }
  return BROWSER_VIEWPORT_PRESETS.find((p) => p.id === id) ?? null
}

export function browserViewportPresetToOverride(
  preset: BrowserViewportPreset
): BrowserViewportOverride {
  return {
    width: preset.width,
    height: preset.height,
    deviceScaleFactor: preset.deviceScaleFactor,
    mobile: preset.mobile
  }
}