You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(unit-converter): add optional per-time denominator for rate conversion - #149
Adds a "Per time" checkbox to the Unit Converter. When checked, a per <time unit> select appears under both From and To, so rates convert: MB/s to GB/day, km/h to m/s, L/min to gal/h, kg/h to lb/min.
The denominator reuses the existing TIME_UNITS list.
Off by default, so plain conversions are unchanged. The checkbox only shows for Length, Mass, Volume and Data (Time per time and Temperature rates don't make sense).
Swap also swaps the two time units.
New pure helpers in unitConversions.ts: convertRate and supportsRate, with unit tests for the three examples above.
State uses useWidgetState (perTime, fromPer, toPer); turning on per time counts as dirty.
Definition description and search keywords mention rates.
Result display
The result now shows two copyable rows: the raw value (2160) and the value with its unit (2160 GB/d, 212 °F). Each unit got a short symbol field for this.
The result sits right under the inputs instead of being pushed to the bottom, so tall widgets no longer leave a gap between inputs and result.
Default size for newly added widgets is now 3x4 so per time mode fits without scrolling. The 3x3 minimum is unchanged; at 3x3 plain conversions fit, and per time mode scrolls a little.
Testing
npx tsc -b --noEmit, npm run lint (no new warnings), prettier --check
npm test: 182 files, 2189 tests passed
Checked in the dev server in light and dark themes
No actionable comments were generated in the recent review.
Walkthrough
The unit converter now supports per-time conversions for length, mass, volume, and data. It adds unit symbols, time-unit selectors, rate results, and separate copy actions for numeric results and results with units.
Changes: Rate conversion
Layer / File(s)
Summary
Rate unit data and calculations src/widgets/unit-converter/unitConversions.ts, src/widgets/unit-converter/unitConversions.test.ts
Unit definitions now include display symbols. Rate conversion uses amount and time base factors. Tests cover rate calculations and supported categories.
The widget adds per-time controls and time-unit selections for supported categories. It displays the destination unit or rate unit and provides separate copy actions. The definition adds rate-related terms and increases the default height.
sequenceDiagram
participant User
participant UnitConverterWidget
participant unitConversions
User->>UnitConverterWidget: Enable per-time mode and select units
UnitConverterWidget->>unitConversions: Check rate support and convert rate
unitConversions-->>UnitConverterWidget: Return converted value
UnitConverterWidget-->>User: Display value and destination rate unit
Loading
Merge Risk: Minimal · up to b74c2
This adds an optional per-time mode to the unit converter. The mode is off by default and leaves existing conversions unchanged. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "feat(unit-converter): add optional per-time denominator for rate conversion" names the main change. The PR adds an optional Per time mode to the Unit Converter, with a time denominator for …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(unit-converter): add optional per-time denominator for rate conversion" names the main change. The PR adds an optional Per time mode to the Unit Converter, with a time denominator for source and target units, and adds the convertRate and supportsRate helpers. The title is specific, short, and matches the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Dropsnorz · project thread
Summary
Adds a "Per time" checkbox to the Unit Converter. When checked, a
per <time unit>select appears under both From and To, so rates convert: MB/s to GB/day, km/h to m/s, L/min to gal/h, kg/h to lb/min.TIME_UNITSlist.unitConversions.ts:convertRateandsupportsRate, with unit tests for the three examples above.useWidgetState(perTime,fromPer,toPer); turning on per time counts as dirty.Result display
2160) and the value with its unit (2160 GB/d,212 °F). Each unit got a shortsymbolfield for this.Testing
npx tsc -b --noEmit,npm run lint(no new warnings),prettier --checknpm test: 182 files, 2189 tests passed🤖 Generated with Claude Code
https://claude.ai/code/session_01Eru75CPpoxvC9CfpdFNKTh
Summary by CodeRabbit