-
Notifications
You must be signed in to change notification settings - Fork 34
Introduce @itwin/quantity-formatting-react #1404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a gif or at least a static image of the components you're adding to the PR description?
apps/test-viewer/src/components/QuantityFormatUiItemsProvider.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new quantity formatting React package (@itwin/quantity-formatting-react
) that provides React components for quantity formatting configuration within iTwin applications. The package includes UI components for various format types including decimal, scientific, fractional, station, bearing, azimuth, and ratio formats.
Key changes:
- New React components for quantity formatting configuration panels and controls
- Comprehensive test coverage for all format types and internal components
- TypeScript configuration and build setup for the new package
Reviewed Changes
Copilot reviewed 74 out of 76 changed files in this pull request and generated 16 comments.
Show a summary per file
File | Description |
---|---|
vite.config.ts | Build configuration for the React package with testing setup |
tsconfig.json | TypeScript configuration for React JSX compilation |
src/quantity-formatting-react.ts | Main entry point exporting public React components |
src/useTranslation.ts | Custom hook for accessing localized strings |
src/components/quantityformat/ | React components for format panels and configuration UI |
src/test/ | Comprehensive test suite covering all components and format types |
Files not reviewed (1)
- apps/test-viewer/pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/itwin/quantity-formatting/src/test/quantityformat/panels/FractionalPanel.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/panels/FractionalPanel.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/panels/FractionalPanel.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/panels/FractionalPanel.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/panels/FractionalPanel.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/internal/DecimalSeparator.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/internal/DecimalSeparator.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/internal/DecimalSeparator.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/internal/DecimalSeparator.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/test/quantityformat/internal/ThousandsSeparator.test.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/FormatSelector.tsx
Outdated
Show resolved
Hide resolved
Sure, but the requirement is not completely clear to me:
Yes, but that's not convenient to access. I think the more appropriate attribute is In any case, I think that should be implemented in a separate PR and warrants a GH issue that describes the requirements. |
Issue opened, we can keep discussing a context menu item in there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed API, package configuration and some top-level code of @itwin/quantity-formatting-react
, also changes to test-viewer. Looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked over React components code. Added some comments that apply to multiple files but didn't want to spam same comment on each file.
packages/itwin/quantity-formatting/src/components/quantityformat/FormatPanel.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/FormatPanel.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/QuantityFormatPanel.tsx
Outdated
Show resolved
Hide resolved
...itwin/quantity-formatting/src/components/quantityformat/internal/StationBaseFactorPreset.tsx
Outdated
Show resolved
Hide resolved
...itwin/quantity-formatting/src/components/quantityformat/internal/StationBaseFactorPreset.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/internal/ScientificType.tsx
Outdated
Show resolved
Hide resolved
...ages/itwin/quantity-formatting/src/components/quantityformat/internal/ThousandsSeparator.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/internal/misc/UnitDescr.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/internal/ScientificType.tsx
Outdated
Show resolved
Hide resolved
...s/itwin/quantity-formatting/src/components/quantityformat/internal/misc/DecimalPrecision.tsx
Outdated
Show resolved
Hide resolved
It's a flex box that expands as the formatted value increases in size, it's meant to draw less attention than panels below it, which serves the largest purpose (configuring formatting) Edit: Removed the flexbox, the preview pane now has the same size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better.
packages/itwin/quantity-formatting/src/components/quantityformat/internal/misc/UnitDescr.tsx
Outdated
Show resolved
Hide resolved
packages/itwin/quantity-formatting/src/components/quantityformat/internal/misc/UnitDescr.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Saulius Skliutas <24278440+saskliutas@users.noreply.github.com>
Co-authored-by: Saulius Skliutas <24278440+saskliutas@users.noreply.github.com>
See README of new package for example workflow, including images
Add @itwin/quantity-formatting-react package, which includes a
QuantityFormatPanel
,FormatSelector
,FormatPanel
(differs from QuantityFormatPanel in that it lets you customize the interactions more granularly if needed).Additionally, adds extensive support to the test viewer in the repo to allow customizing the format settings of the app while being run. Compromises had to be made regarding the display of the formats (many KindOfQuantities share duplicate labels, for those KoQs, wrap the schemaName in parentheses and append to the label)
The test viewer now includes a button on the bottom status bar that will open up a modal to customize the formatting settings (per session)

The modal includes a dropdown selector to select the format you want to customize
Notes: