agentleFS
reescalderreescalder/claude-skills/iframe-preview/SKILL.md

iframe-preview

Skill0 starsChanged 4 months agoMITView on GitHub

Auto-scaling iframe website preview with before/after toggle. Measures container width and scales a full-width (1440px) iframe to fit. Before state shows static image, click triggers animated transition to live iframe. For website redesign demos, portfolio previews.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use sandbox="allow-scripts allow-same-origin" for security

    line 34
  2. Very specific:

    Use loading="lazy" for iframes in carousels (performance)

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

iframe Website Preview

An auto-scaling iframe that fits any container width by measuring the container and applying CSS transform scale. Features a before/after toggle with loading animation.

When to Use

  • Website redesign before/after demos
  • Portfolio project previews in cards
  • Live site embeds in dashboards
  • Any context where a full website needs to fit a small container

Architecture

  • Container ref measures offsetWidth on mount
  • Scale factor = containerWidth / 1440 (assumes 1440px design width)
  • iframe rendered at native 1440px width, scaled down via transform: scale()
  • transformOrigin: 'top left' ensures proper positioning
  • iframe height = containerHeight / scale to fill the visible area

Before/After Pattern

  1. Initial state: static screenshot image with "Update" button overlay
  2. Click triggers loading spinner (2.2s fake delay)
  3. Transition: old image fades out, iframe fades in
  4. iframe scrolls internally (no parent scroll interference)

Key Lessons

  • Use sandbox="allow-scripts allow-same-origin" for security
  • Set pointerEvents: 'none' on card-embedded iframes to prevent interaction stealing
  • Use loading="lazy" for iframes in carousels (performance)
  • Measure container on mount AND on resize (ResizeObserver)
  • For scroll-controlled video inside iframes, don't use hash anchors

Reference Implementation

See reference/IframePreview.tsx

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.