Skip to content

feat: support min() css function#588

Merged
Brentlok merged 1 commit into
mainfrom
feat/min-css-function
Jun 26, 2026
Merged

feat: support min() css function#588
Brentlok merged 1 commit into
mainfrom
feat/min-css-function

Conversation

@Brentlok

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/min-css-function

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds support for the CSS min() function, mirroring the existing max() handler. It also expands the CSS functions test suite with new tests for min(), max(), calc(), and nested combinations, and fixes the pre-existing fontScale/pixelRatio tests to properly mock PixelRatio values instead of relying on environment defaults.

  • New min() handler added to processFunction using Math.min(...), placed immediately before the identical max() pattern.
  • Test suite expanded with min, max, calc, and combinations test cases; fontScale and pixelRatio tests now mock PixelRatio and clean up with mockRestore().

Confidence Score: 5/5

Safe to merge — the change is a minimal, well-tested addition that follows an established pattern already used for max().

The min() handler is four lines that exactly mirror the max() implementation, a pattern that has been in production and is now covered by the expanded test suite. The test file improvements (proper mocking with mockRestore cleanup, nested combination tests) increase confidence in the whole functions pipeline rather than just the new case. No existing behaviour is changed.

No files require special attention.

Important Files Changed

Filename Overview
packages/uniwind/src/bundler/css-processor/functions.ts Adds a min() handler in processFunction — 4 lines, mirrors the existing max() block exactly. No concerns.
packages/uniwind/tests/native/styles-parsing/css-functions.test.tsx Adds min, max, calc, and combinations tests; improves fontScale/pixelRatio tests with proper mocking and cleanup. Test math expectations are all correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["processFunction(fn)"] --> B{fn.name?}
    B --> C["'calc' → tryEval(processValue(args))"]
    B --> D["'cubic-bezier' → rt.cubicBezier(...)"]
    B --> E["'min' → Math.min(processValue(args))"]
    B --> F["'max' → Math.max(processValue(args))"]
    B --> G["'linear-gradient' → processValue(args)"]
    B --> H["color / filter functions → ..."]
    B --> I["'hairlineWidth' / 'pixelRatio' / 'fontScale' → rt.*"]
    style E fill:#b6f5c1,stroke:#28a745
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["processFunction(fn)"] --> B{fn.name?}
    B --> C["'calc' → tryEval(processValue(args))"]
    B --> D["'cubic-bezier' → rt.cubicBezier(...)"]
    B --> E["'min' → Math.min(processValue(args))"]
    B --> F["'max' → Math.max(processValue(args))"]
    B --> G["'linear-gradient' → processValue(args)"]
    B --> H["color / filter functions → ..."]
    B --> I["'hairlineWidth' / 'pixelRatio' / 'fontScale' → rt.*"]
    style E fill:#b6f5c1,stroke:#28a745
Loading

Reviews (1): Last reviewed commit: "feat: support min() css function" | Re-trigger Greptile

@Brentlok Brentlok merged commit a394051 into main Jun 26, 2026
2 checks passed
@Brentlok Brentlok deleted the feat/min-css-function branch June 26, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant