Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const LENGTH_REGEX = /^(-?[0-9]*[.]?[0-9]+)(em|px|rem|vh|vmax|vmin|vw)$/;
type CSSLengthUnitType = 'em' | 'px' | 'rem' | 'vh' | 'vmax' | 'vmin' | 'vw';

type ResolvePixelValueOptions = $ReadOnly<{
fontScale: number | void,
inheritedFontSize: ?number,
viewportHeight: number,
viewportScale: number,
Expand Down Expand Up @@ -54,7 +53,6 @@ export class CSSLengthUnitValue {

resolvePixelValue(options: ResolvePixelValueOptions): number {
const {
fontScale = 1,
inheritedFontSize,
viewportHeight,
viewportScale = 1,
Expand All @@ -66,7 +64,7 @@ export class CSSLengthUnitValue {
switch (unit) {
case 'em': {
if (inheritedFontSize == null) {
return fontScale * 16 * value * viewportScale;
return 16 * value * viewportScale;
} else {
return inheritedFontSize * value;
}
Expand All @@ -75,7 +73,7 @@ export class CSSLengthUnitValue {
return value * viewportScale;
}
case 'rem': {
return fontScale * 16 * value * viewportScale;
return 16 * value * viewportScale;
}
case 'vh': {
return viewportHeight * valuePercent;
Expand Down
4 changes: 0 additions & 4 deletions packages/react-strict-dom/src/native/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ type ResolveStyleOptions = $ReadOnly<{
colorScheme: ?('light' | 'dark'),
customProperties: CustomProperties,
focus?: ?boolean,
fontScale: number | void,
fontSize?: ?number,
hover?: ?boolean,
inheritedFontSize: ?number,
Expand All @@ -142,7 +141,6 @@ function resolveStyle(
const {
active,
focus,
fontScale,
fontSize: _fontSize,
hover,
inheritedFontSize,
Expand Down Expand Up @@ -183,7 +181,6 @@ function resolveStyle(
// we use the inherited fontSize.
if (propName === 'fontSize' || fontSize == null) {
result[propName] = styleValue.resolvePixelValue({
fontScale,
inheritedFontSize: inheritedFontSize,
viewportHeight,
viewportScale,
Expand All @@ -196,7 +193,6 @@ function resolveStyle(
// used as the "inherited" value to resolve other lengths correctly.
if (typeof fontSize === 'number') {
result[propName] = styleValue.resolvePixelValue({
fontScale,
inheritedFontSize: fontSize,
viewportHeight,
viewportScale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function useStyleProps(
writingDirection: dir
} = options;

const { fontScale, height, width } = ReactNative.useWindowDimensions();
const { height, width } = ReactNative.useWindowDimensions();
const colorScheme = ReactNative.useColorScheme();
const { scale: viewportScale } = useViewportScale();

Expand Down Expand Up @@ -130,7 +130,6 @@ export function useStyleProps(
colorScheme: colorScheme === 'unspecified' ? 'light' : colorScheme,
customProperties: customProperties ?? emptyObject,
focus,
fontScale,
hover,
inheritedFontSize:
typeof inheritedFontSize === 'number' ? inheritedFontSize : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,6 @@ exports[`css.create() properties fontSize 1`] = `
}
`;

exports[`css.create() properties fontSize scaling fontScale:2 1`] = `
{
"boxSizing": "content-box",
"fontSize": 80,
"position": "static",
}
`;

exports[`css.create() properties fontVariant 1`] = `
{
Expand Down Expand Up @@ -2077,35 +2070,35 @@ exports[`css.create() values: length units 10 "rem" units are resolved to pixels
exports[`css.create() values: length units 10 "vh" units are resolved to pixels: vh 1`] = `
{
"boxSizing": "content-box",
"height": NaN,
"height": -100,
"position": "static",
"width": NaN,
"width": 100,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that removing the fontScale accidentally fixed this preexisting bug where the resolved value was NAN, I'm assuming it could have been a lack of mocking in the test though?

}
`;

exports[`css.create() values: length units 10 "vmax" units are resolved to pixels: vmax 1`] = `
{
"boxSizing": "content-box",
"height": NaN,
"height": -200,
"position": "static",
"width": NaN,
"width": 200,
}
`;

exports[`css.create() values: length units 10 "vmin" units are resolved to pixels: vmin 1`] = `
{
"boxSizing": "content-box",
"height": NaN,
"height": -100,
"position": "static",
"width": NaN,
"width": 100,
}
`;

exports[`css.create() values: length units 10 "vw" units are resolved to pixels: vw 1`] = `
{
"boxSizing": "content-box",
"height": NaN,
"height": -200,
"position": "static",
"width": NaN,
"width": 200,
}
`;
23 changes: 0 additions & 23 deletions packages/react-strict-dom/tests/css/css-create-test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,29 +497,6 @@ describe('css.create()', () => {
expect(root.toJSON().props.style).toMatchSnapshot();
});

describe('fontSize scaling', () => {
const ReactNative = require('../../src/native/react-native');
beforeEach(() => {
ReactNative.useWindowDimensions.mockReturnValue({ fontScale: 2 });
});
afterEach(() => {
ReactNative.useWindowDimensions.mockReturnValue({ fontScale: 1 });
});

test('fontScale:2', () => {
const styles = css.create({
root: {
fontSize: '2.5rem'
}
});
let root;
act(() => {
root = create(<html.span style={styles.root} />);
});
expect(root.toJSON().props.style).toMatchSnapshot();
});
});

test('fontVariant', () => {
const styles = css.create({
root: {
Expand Down