code-yeongyu/oh-my-openagent / packages/shared-skills/skills/frontend
frontend
FlaggedBuilds, styles, and polishes anything drawn with HTML, CSS, or SVG: web UI, pages, components, HTML reports rendered to PDF or print, figures, PNG/SVG diagrams, slides, and images for Notion or Slack. Use for any styling, layout, animation, or visual-quality task, or when asked to make something look or feel a certain way.
scripts/detect/core/page.ts
View on GitHubimport type { ElementSnapshot, PageSnapshot } from "../types"
import { blend, parseColor, type Rgba, WHITE } from "./color"
export const IGNORE_ATTRIBUTES = ["data-detect-ignore", "data-impeccable-ignore"] as const
/** Numeric value of a computed length in px ("12px" -> 12, "normal"/"auto" -> null). */
export function px(value: string | undefined): number | null {
if (value === undefined) return null
const m = /^(-?\d*\.?\d+)px$/.exec(value.trim())
return m?.[1] === undefined ? null : Number.parseFloat(m[1])
}
export const styleOf = (el: ElementSnapshot, prop: string): string => el.style[prop] ?? ""
export function parentOf(snap: PageSnapshot, el: ElementSnapshot): ElementSnapshot | null {
return el.parent === null ? null : (snap.elements[el.parent] ?? null)
}
export function* ancestors(snap: PageSnapshot, el: ElementSnapshot): Generator<ElementSnapshot> {
let cur = parentOf(snap, el)
while (cur) {
yield cur
cur = parentOf(snap, cur)
}
}
export function* descendants(snap: PageSnapshot, el: ElementSnapshot): Generator<ElementSnapshot> {
for (const i of el.children) {
const child = snap.elements[i]
if (!child) continue
yield child
yield* descendants(snap, child)
}
}
export const childrenOf = (snap: PageSnapshot, el: ElementSnapshot): readonly ElementSnapshot[] =>
el.children.map((i) => snap.elements[i]).filter((c): c is ElementSnapshot => c !== undefined)
/** Rendered and not visually suppressed: has a box, is not display:none/visibility:hidden, and no ancestor has opacity 0. */
export function isRendered(snap: PageSnapshot, el: ElementSnapshot): boolean {
if (el.rect.width <= 0 || el.rect.height <= 0) return false
if (styleOf(el, "display") === "none" || styleOf(el, "visibility") === "hidden") return false
if (Number.parseFloat(styleOf(el, "opacity")) === 0) return false
for (const a of ancestors(snap, el)) if (Number.parseFloat(styleOf(a, "opacity")) === 0) return false
return true
}
/** True when the element or an ancestor waives `ruleId` with data-detect-ignore (or upstream's data-impeccable-ignore). */
export function isIgnored(snap: PageSnapshot, el: ElementSnapshot, ruleId: string): boolean {
const waives = (e: ElementSnapshot): boolean =>
IGNORE_ATTRIBUTES.some((name) => {
const v = e.attributes[name]
if (v === undefined) return false
const ids = v.split(/[\s,]+/).filter(Boolean)
return ids.length === 0 || ids.includes(ruleId) || ids.includes("all")
})
if (waives(el)) return true
for (const a of ancestors(snap, el)) if (waives(a)) return true
return false
}
/** The opaque color painted behind `el`: its own and its ancestors' background-colors composited bottom-up over white. */
export function effectiveBackground(snap: PageSnapshot, el: ElementSnapshot): Rgba {
const layers: Rgba[] = []
for (const e of [el, ...ancestors(snap, el)]) {
const c = parseColor(styleOf(e, "background-color"))
if (c && c.a > 0) {
layers.push(c)
if (c.a >= 1) break
}
}
return layers.reduceRight<Rgba>((under, top) => blend(top, under), WHITE)
}
const HEADING_TAGS = ["h1", "h2", "h3", "h4", "h5", "h6"] as const
export const isHeading = (el: ElementSnapshot): boolean => HEADING_TAGS.some((tag) => tag === el.tag)
export const headingLevel = (el: ElementSnapshot): number | null => (isHeading(el) ? Number(el.tag.slice(1)) : null)
export const textElements = (snap: PageSnapshot): readonly ElementSnapshot[] =>
snap.elements.filter((el) => el.ownText !== "" && isRendered(snap, el))
export const fontSizePx = (el: ElementSnapshot): number => px(styleOf(el, "font-size")) ?? 16
export const shortSnippet = (el: ElementSnapshot): string =>
el.text === "" ? `<${el.tag}>` : `<${el.tag}> ${el.text.slice(0, 80)}`
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |