convertLength does not work for fromUnit !== 'px'
See original GitHub issueThe file @material-ui/core/styles/cssUtils.js
contains a method convertLength
. It does not work if the provided length is not in px. This test …
it('should convert rem to px', () => {
const convert = convertLength('16px');
expect(convert('2rem', 'px')).to.equal('32px');
});
… will fail.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
import { convertLength } from "@material-ui/core/styles/cssUtils";
convertLength('16px')('2rem', 'px') // ==> '2rem'
Expected Behavior 🤔
import { convertLength } from "@material-ui/core/styles/cssUtils";
convertLength('16px')('2rem', 'px') // ==> '32px'
Looks like the method was badly ported over from https://github.com/KyleAMathews/convert-css-length.
I think this would make a great ‘first issue’, but not sure I’ll take the time to handle it myself. ✌️
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
convertLength does not work for fromUnit !== 'px' · Issue #22693
The file @material-ui/core/styles/cssUtils.js contains a method convertLength . It does not work if the provided length is not in px.
Read more >convert-length: Documentation | Openbase
A simple utility to convert from physical lengths (meters, inches, etc) to pixels and back, based on the CSS spec. Supports converting to...
Read more >How can I convert a string length to a pixel unit? - Stack Overflow
I have font name, size, etc. I have looked at the MeasureString method, but cannot figure out how to create a Graphics object...
Read more >Unit Conversion function—ArcGIS Pro | Documentation
The Unit Conversion function converts pixels from one unit to another unit. It supports conversion of distance, speed, and temperature.
Read more >Length Unit Conversion in JavaScript - Heygrady
Converting between length units is not exactly straight-forward because each unit can have different pixel value based on a variety of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll give the PR a try, if that is ok? 😃
I had a quick look, there is a return that has nothing to do here:
@stefanpl If you want to work on a pull request, feel free too 😃