Skip to content
Merged
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
43 changes: 41 additions & 2 deletions apps/examples/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const greenPinkTheme = css.createTheme(themeColors, {

const themedStyles = css.create({
container: {
display: 'flex',
flex: 1,
justifyContent: 'center',
backgroundColor: '#bbb',
Expand Down Expand Up @@ -323,6 +324,15 @@ function Shell(): React.MixedElement {
</html.div>
</ExampleBlock>

{/* logical styles emulation */}
<ExampleBlock title="CSS Logical">
<html.div>
<html.div style={styles.logicalPadding} />
<html.div style={styles.logicalMargin} />
<html.div style={styles.logicalBorder} />
</html.div>
</ExampleBlock>

{/* CSS positioning (static by default) */}
<ExampleBlock title="CSS Position">
<html.div style={[styles.p50, styles.relative]}>
Expand Down Expand Up @@ -571,7 +581,7 @@ function Shell(): React.MixedElement {
>
<html.span style={styles.bgWhite}>{clickData.text}</html.span>
<html.div style={styles.flex}>
<html.div style={styles.flexGrow}>
<html.div style={[styles.flex, styles.flexGrow]}>
<html.div>
<html.span>
{clickEventData.altKey ? '✅' : '🚫'} altKey
Expand All @@ -593,7 +603,7 @@ function Shell(): React.MixedElement {
</html.span>
</html.div>
</html.div>
<html.div style={styles.flexGrow}>
<html.div style={[styles.flex, styles.flexGrow]}>
<html.div>
<html.span>button: {clickEventData.button}</html.span>
</html.div>
Expand Down Expand Up @@ -846,5 +856,34 @@ const styles = css.create({
borderWidth: 1,
borderStyle: 'solid',
borderColor: 'black'
},
logicalMargin: {
backgroundColor: 'pink',
width: 50,
height: 50,
marginBlock: 20,
marginInline: 20,
borderColor: 'black',
borderWidth: 1,
borderStyle: 'solid'
},
logicalPadding: {
backgroundColor: 'pink',
width: 50,
height: 50,
paddingBlock: 20,
paddingInline: 20,
borderColor: 'black',
borderWidth: 1,
borderStyle: 'solid'
},
logicalBorder: {
backgroundColor: 'pink',
width: 50,
height: 50,
borderColor: 'red',
borderBlockWidth: 20,
borderInlineWidth: 20,
borderStyle: 'solid'
}
});
40 changes: 20 additions & 20 deletions apps/website/docs/api/02-css/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The following tables represent the compatibility status of the strict CSS API fo
| color | ✅ | ✅ | |
| columnGap | ✅ | ✅ | |
| cursor | ❌ | ✅ Partial | |
| direction | | | |
| direction | | | |
| display: block | 🟡 Partial | 🟡 Partial | [#2](https://github.com/facebook/react-strict-dom/issues/2) |
| display: contents | ✅ | ✅ | |
| display: flex | ✅ | ✅ | |
Expand All @@ -156,13 +156,13 @@ The following tables represent the compatibility status of the strict CSS API fo
| gap | ✅ | ✅ | |
| height | ✅ | ✅ | |
| inlineSize | 🟡 | 🟡 | |
| inset | | | |
| insetBlock | | | |
| insetBlockEnd | | | |
| insetBlockStart | | | |
| insetInline | | | |
| insetInlineEnd | | | |
| insetInlineStart | | | |
| inset | 🟡 | 🟡 | |
| insetBlock | 🟡 | 🟡 | |
| insetBlockEnd | 🟡 | 🟡 | |
| insetBlockStart | 🟡 | 🟡 | |
| insetInline | 🟡 | 🟡 | |
| insetInlineEnd | 🟡 | 🟡 | |
| insetInlineStart | 🟡 | 🟡 | |
| isolation | ✅ | ✅ | |
| justifyContent | ✅ | ✅ | |
| justifyItems | ❌ | ❌ | |
Expand All @@ -175,13 +175,13 @@ The following tables represent the compatibility status of the strict CSS API fo
| listStylePosition | ❌ | ❌ | |
| listStyleType | ❌ | ❌ | |
| margin | ✅ | ✅ | |
| marginBlock | | | |
| marginBlockEnd | | | |
| marginBlockStart | | | |
| marginBlock | 🟡 | 🟡 | |
| marginBlockEnd | 🟡 | 🟡 | |
| marginBlockStart | 🟡 | 🟡 | |
| marginBottom | ✅ | ✅ | |
| marginInline | | | |
| marginInlineEnd | | | |
| marginInlineStart | | | |
| marginInline | 🟡 | 🟡 | |
| marginInlineEnd | 🟡 | 🟡 | |
| marginInlineStart | 🟡 | 🟡 | |
| marginLeft | ✅ | ✅ | |
| marginRight | ✅ | ✅ | |
| marginTop | ✅ | ✅ | |
Expand All @@ -208,13 +208,13 @@ The following tables represent the compatibility status of the strict CSS API fo
| overflowX | ❌ | ❌ | |
| overflowY | ❌ | ❌ | |
| padding | ✅ | ✅ | |
| paddingBlock | | | |
| paddingBlockEnd | | | |
| paddingBlockStart | | | |
| paddingBlock | 🟡 | 🟡 | |
| paddingBlockEnd | 🟡 | 🟡 | |
| paddingBlockStart | 🟡 | 🟡 | |
| paddingBottom | ✅ | ✅ | |
| paddingInline | | | |
| paddingInlineEnd | | | |
| paddingInlineStart | | | |
| paddingInline | 🟡 | 🟡 | |
| paddingInlineEnd | 🟡 | 🟡 | |
| paddingInlineStart | 🟡 | 🟡 | |
| paddingLeft | ✅ | ✅ | |
| paddingRight | ✅ | ✅ | |
| paddingTop | ✅ | ✅ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ exports[`fixContentBox boxSizing: content-box: height 1`] = `
}
`;

exports[`fixContentBox boxSizing: content-box: logical 1`] = `
{
"borderBlockWidth": 5,
"borderInlineWidth": 5,
"height": 100,
"paddingBlock": 10,
"paddingInline": 20,
"paddingInlineEnd": 30,
"paddingLeft": 40,
"width": 140,
}
`;

exports[`fixContentBox boxSizing: content-box: maxHeight 1`] = `
{
"borderWidth": 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ describe('fixContentBox', () => {
width: 100,
height: 100
},
logical: {
boxSizing: 'content-box',
borderBlockWidth: 5,
borderInlineWidth: 5,
paddingBlock: 10,
paddingInline: 20,
paddingInlineEnd: 30,
paddingLeft: 40,
width: 100,
height: 100
},
auto: {
boxSizing: 'content-box',
borderWidth: 2,
Expand Down Expand Up @@ -100,6 +111,7 @@ describe('fixContentBox', () => {
expect(fixContentBox(styles.minWidth)).toMatchSnapshot('minWidth');
expect(fixContentBox(styles.minHeight)).toMatchSnapshot('minHeight');
expect(fixContentBox(styles.allDifferent)).toMatchSnapshot('allDifferent');
expect(fixContentBox(styles.logical)).toMatchSnapshot('logical');
expect(fixContentBox(styles.auto)).toMatchSnapshot('auto');
expect(fixContentBox(styles.null)).toMatchSnapshot('null');
expect(fixContentBox(styles.string)).toMatchSnapshot('string');
Expand Down
53 changes: 53 additions & 0 deletions packages/react-strict-dom/src/native/stylex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,63 @@ export function props(
nativeProps.cursorColor = styleValue;
}
}
// inset
else if (styleProp === 'inset') {
nextStyle.top ??= styleValue;
nextStyle.start ??= styleValue;
nextStyle.end ??= styleValue;
nextStyle.bottom ??= styleValue;
} else if (styleProp === 'insetBlock') {
nextStyle.top ??= styleValue;
nextStyle.bottom ??= styleValue;
} else if (styleProp === 'insetBlockEnd') {
nextStyle.bottom = flatStyle.bottom ?? styleValue;
} else if (styleProp === 'insetBlockStart') {
nextStyle.top = flatStyle.top ?? styleValue;
} else if (styleProp === 'insetInline') {
nextStyle.end ??= styleValue;
nextStyle.start ??= styleValue;
} else if (styleProp === 'insetInlineEnd') {
nextStyle.end = flatStyle.end ?? styleValue;
} else if (styleProp === 'insetInlineStart') {
nextStyle.start = flatStyle.start ?? styleValue;
}
// lineClamp polyfill
else if (styleProp === 'lineClamp') {
nativeProps.numberOfLines = styleValue;
}
// marginBlock
else if (styleProp === 'marginBlock') {
nextStyle.marginVertical = styleValue;
} else if (styleProp === 'marginBlockStart') {
nextStyle.marginTop ??= styleValue;
} else if (styleProp === 'marginBlockEnd') {
nextStyle.marginBottom ??= styleValue;
}
// marginInline
else if (styleProp === 'marginInline') {
nextStyle.marginHorizontal = styleValue;
} else if (styleProp === 'marginInlineStart') {
nextStyle.marginStart = styleValue;
} else if (styleProp === 'marginInlineEnd') {
nextStyle.marginEnd = styleValue;
}
// paddingBlock
else if (styleProp === 'paddingBlock') {
nextStyle.paddingVertical = styleValue;
} else if (styleProp === 'paddingBlockStart') {
nextStyle.paddingTop ??= styleValue;
} else if (styleProp === 'paddingBlockEnd') {
nextStyle.paddingBottom ??= styleValue;
}
// paddingInline
else if (styleProp === 'paddingInline') {
nextStyle.paddingHorizontal = styleValue;
} else if (styleProp === 'paddingInlineStart') {
nextStyle.paddingStart = styleValue;
} else if (styleProp === 'paddingInlineEnd') {
nextStyle.paddingEnd = styleValue;
}
// '::placeholder' polyfill
else if (styleProp === 'placeholderTextColor') {
nativeProps.placeholderTextColor = styleValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ exports[`<compat.native> "as" equals "view": as=view 1`] = `
style={
{
"boxSizing": "content-box",
"paddingInline": 32,
"paddingHorizontal": 32,
"position": "static",
}
}
Expand All @@ -82,7 +82,7 @@ exports[`<compat.native> default: default 1`] = `
style={
{
"boxSizing": "content-box",
"paddingInline": 32,
"paddingHorizontal": 32,
"position": "static",
}
}
Expand Down
Loading