Repository navigation
added stretch mode - #1
Deepakktripathy wants to merge 7 commits into
Conversation
sudhz
left a comment
There was a problem hiding this comment.
https://optimize-musicians-jennifer-contracts.trycloudflare.com/
i like this format better
also we gotta remove built by @sudhz
|
lmk if you need that balloon image |
|
i kinda like the stretch is on / crop is on indicator from your design tho, let's keep that but borrow everything else from that design i shared |
|
keep the PR title and commit message like historical commit format? we don't use stuff like |
|
can we update the screenshots in the PR description? |
|
@copilot is this using more code than necessary? a 1,000+ line addition for a simple change like this seems a bit off to me. can you review? |
Co-authored-by: sudhz <61375120+sudhz@users.noreply.github.com>
Reviewed and trimmed it in |
|
@Deepakktripathy here's the balloon image from the design. Please use it in place of
It's square on purpose. Inside the 21:9 frame it gets wide side bars, so crop and stretch look clearly different. With the 16:9 bunny frame, both cards only scale by 1.31×, so they look almost the same. If you switch to it, change One more thing from the design: the faded bits above and below the selected Crop card are the parts that get cut off by the crop. They aren't a mirrored reflection, so the |
607d008 to
c1fb128
Compare
sudhz
left a comment
There was a problem hiding this comment.
@Deepakktripathy thanks for working through this. Here's everything left before we merge. Heads up: I bumped the version to 1.3.0 and force-pushed (c1fb128). If you have the older 607d008 locally, run git pull --rebase before pushing.
Design
- Use the balloon image in place of the bunny
preview.jpg(links in this comment), and change--preview-fillfrom1.3125to2.3333. With a square picture, Crop and Stretch look clearly different. With the 16:9 bunny they look almost the same. - Fix the faded edges on the Crop card. In the design they're the parts the crop cuts off, shown faded above and below the card. They aren't a mirrored reflection, so please remove the
.mirrormarkup (4 extra images) and its CSS.
Less code
- Remove the
cropModemigration:src/storage/mode.ts,parseLegacyMode,tests/mode.test.ts, and thecropModestate tests. That key only existed on this branch and was never released. - Keep the
fillEnabledrename, but make thecropEnabledmigration short and temporary. Mark it for removal in the release after1.3.0, and cover it with a single test that gets deleted along with it. Something like:// Temporary: moves the pre-1.3.0 `cropEnabled` key. Remove in the release after 1.3.0. if (typeof result[ENABLED_KEY] !== 'boolean' && typeof result.cropEnabled === 'boolean') { enabled = result.cropEnabled; await extensionApi.storage.local.set({ [ENABLED_KEY]: enabled }); await extensionApi.storage.local.remove('cropEnabled'); }
- Have the apply function read the state itself, the way
applyCropdid, so callers just callapplyFill(getPlayer())instead of passingisEnabled(), getMode()at 5 call sites. - Use one transform for both modes: one player class plus
--flrm-scale-x/--flrm-scale-y. Crop sets(s, s). Stretch sets(s, 1)or(1, s). That removes the second class,--flrm-scale, and the duplicate CSS block.
Naming
-
Use "fill" everywhere. Right now it's a mix of "fill" (
fillMode,FillMode, "Fill mode") and "fit":fit.ts→fill.tsapplyFit/applyFitNow/applyFitAndSync→applyFill/applyFillNow/applyFillAndSync- player class →
flrm-fill-on
FillMode,getMode,selectMode,toggleEnabled,isEnabled, and the icon classes.flrm-crop/.flrm-stretchcan stay as they are.
Bug
- If the mode changes before the video's size is known,
applyFitreturns early and leaves the previous mode's class on the player. Item 6 fixes this.
PR housekeeping
- Update the PR description. It still describes the looping animation, reduced-motion handling, and "accent outline" cards, which no longer exist. Please also add screenshots of the new popup.
- Commit format:
2c3c32estill starts withfeat:. I'll squash-merge with a plain title, so there's no need to rewrite history.

Summary
This PR adds stretch mode and splits the controls: the toolbar popup chooses the mode (Crop or Stretch) and the player button turns that mode on or off.
The player button used to be a single crop toggle. It is now a simple on/off switch for whichever mode is picked in the popup, so the two trade-offs — trimming edges vs. distorting the picture — are an explicit choice instead of a hidden third click.
Crop is off,Crop is on,Stretch is off, orStretch is on.cropEnabledvalues migrate automatically.cropModewas never released, so there is nocropModemigration.Behavior
Clicking the already-selected card turns it on, so the card does not double as an off switch. The player button is the only off switch.
Screenshots
Popup
The previews loop, so each capture is taken at the held “applied” point of the animation. The player button icon remains the same.
Implementation
Two values instead of one
State is now:
fillMode:"crop" | "stretch"fillEnabled:booleanThe player can be off while still remembering which mode its button should turn back on.
Player button
src/player/button.tsnow callstoggleEnabled()instead of advancing a cycle. It writes:data-flrm-mode— the selected mode, alwaysaria-pressed— whether fill is ontitle/aria-label—Fullorama: crop on,Fullorama: stretch off, etc.The icon still contains both overlay shapes.
content.cssreveals the square or wide bar only whenaria-pressed="true"and the mode matches, so the inner mark disappears when off.Popup
src/popup/popup.tsis now interactive:loadState()once on openrender()sets the status text, the green status dot, and the selected cardselectMode(mode), which sets the mode and enables fillCard states:
The green dot and the
Crop is on/offstatus line carry on/off. The footer is reduced to Share feedback and the version.Animated previews
src/popup/preview.jpgis a 768×768 still of a hot-air balloon over a mountain valley at sunset. It appears in the Original frame above the cards and inside both card previews. Every frame is a 21:9 box, so the square still starts with side bars.21 ÷ 9 = 2.3333, filling the width and clipping top/bottom. No distortion. On the selected card, the clipped parts reappear as a faded overflow above and below the frame.2.3333, filling the width and visibly widening the picture. Nothing is clipped.Both cards run the same 5-second loop: hold normal, transition, hold applied, transition back.
prefers-reduced-motion: reduceremoves the animation and holds each card in its applied state, so the preview still explains the mode. The previews arearia-hidden; the label and status line carry the meaning.The card grid uses
minmax(0, 1fr)plusmin-width: 0; without that, the image's intrinsic width forces the cards wide. At the 360 px popup width the cards are 153 px wide with 66 px previews, and the Original frame is 46% of the content width. The faded crop overflow is a single pseudo-element behind the preview with a vertical opacity mask, not a second image or a mirrored reflection.Renderer
src/player/fill.tsexportsapplyFill(player)and reads the stored state itself:flrm-fill-onand both scale variablesmax(player / video, video / player)1and the longer axis to the fill ratioOne class,
flrm-fill-on, and one transform block incontent.csshandle both modes; crop sets(s, s), stretch sets(s, 1)or(1, s). Transforms are still used rather thanwidth/heightplusobject-fit: YouTube sizes.html5-main-videoto the video's own aspect ratio and centres it inside the player, and the video container can have zero height.Migration
Only the pre-1.3.0
cropEnabledkey is migrated.cropModewas never in a release, so it is not read.fillEnabledplus a validfillModecropEnabled: trueonlycropEnabled: falseonlyThe old key is removed after it is moved. The migration is marked in
src/storage/state.tsfor removal in the release after 1.3.0. A fresh install starts in crop, off.onStorageChangewatches bothfillEnabledandfillMode, so changing a mode in the popup updates open YouTube tabs immediately.Update: popup redesign
The toolbar popup now mirrors the player: an Original frame branches into two result cards, Crop and Stretch. The header shows the current state (
Crop is off/on,Stretch is off/on) with a green dot when on. The selected card gets a white outline and a filled radio, without the accent tint from the first draft. The selected Crop card shows the cut-off parts as a faded overflow above and below the frame instead of a mirrored reflection. The footer is only Share feedback and the version, and the popup is 360 px wide.Both previews keep looping; the Original frame supplies the before state, and reduced motion holds each card in its applied state.
Validation
bun run typecheck— cleanbun test— 32 pass, 0 failweb-ext lint— 0 errors, 1 pre-existing Firefox Android min-version warning