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.3 KB
Raw Blame
// Pin catalog CSS to English until removed from en.json; MT once translated selectors/keyframes and broke locale-specific UI.

const STYLE_BLOCK =
  /@(keyframes|media|supports|font-face)\b|[.#][a-zA-Z][\w-]*[^{}]*\{[^{}]*[a-z-]+\s*:|\[[a-z-]+=["'][^"']*["']\]|\{[^{}]*[a-z-]+\s*:\s*[^{}]*[;}]/

// A selector with no declaration block has no braces for STYLE_BLOCK to key off.
const SELECTOR_TOKEN = /^(?:[>+~]|[a-zA-Z.#[][\w.#:()[\]"'=^$|*-]*)$/
const LONE_SELECTOR = /^#[a-zA-Z][\w-]*$|^\.[a-zA-Z][\w-]*-[\w-]+$/
// Single dotted/colon/bracket token is code (selector/file/host); translating any of them breaks it.
const LONE_QUALIFIED = /^[a-zA-Z][\w-]*(?:[.#:][\w-]+|\[[^\]]+\])$/

function isStandaloneSelector(enValue) {
  if (/[{}]/.test(enValue)) {
    return false
  }
  const tokens = enValue.trim().split(/\s+/)
  if (!tokens.every((token) => SELECTOR_TOKEN.test(token))) {
    return false
  }
  // A selector join, not a sentence period: two sentences would otherwise clear the threshold.
  const marked = tokens.filter((token) => /^[#.][a-zA-Z]|[\w-][.#:][a-zA-Z]|\[/.test(token))
  if (marked.length >= 2) {
    return true
  }
  return tokens.length === 1 && (LONE_SELECTOR.test(tokens[0]) || LONE_QUALIFIED.test(tokens[0]))
}

export function isStyleValue(enValue) {
  return STYLE_BLOCK.test(enValue) || isStandaloneSelector(enValue)
}