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
13 changes: 13 additions & 0 deletions .changeset/rude-parks-dig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@lynx-js/web-elements": minor
"@lynx-js/web-style-transformer": patch
"@lynx-js/web-elements-compat": patch
---

feat: support `justify-content`, `align-self` in linear container

Now these two properties could work in a linear container.

We don't transforms the `justify-content` and `align-self` to css vars any more.

The previous version of `@lynx-js/web-core` won't work with current `@lynx-js/web-core` after this change.
1 change: 0 additions & 1 deletion packages/web-platform/web-constants/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"rootDir": "./src",
"outDir": "./dist",
"lib": ["ESNext"],
"verbatimModuleSyntax": true,
},
"include": ["src"],
"references": [
Expand Down
1 change: 0 additions & 1 deletion packages/web-platform/web-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"lib": ["DOM", "ESNext", "WebWorker"],
"noUnusedParameters": false,
"noImplicitReturns": false,
"verbatimModuleSyntax": true,
},
"include": ["src"],
"references": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@

[lynx-computed-display="linear"][lynx-linear-orientation="vertical"] {
flex-direction: column !important;
justify-content: var(--justify-content-column) !important;
justify-content: var(--justify-content-column);
}

[lynx-computed-display="linear"][lynx-linear-orientation="horizontal"] {
flex-direction: row !important;
justify-content: var(--justify-content-row) !important;
justify-content: var(--justify-content-row);
}

[lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"] {
flex-direction: column-reverse !important;
justify-content: var(--justify-content-column-reverse) !important;
justify-content: var(--justify-content-column-reverse);
}

[lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"] {
flex-direction: row-reverse !important;
justify-content: var(--justify-content-row-reverse) !important;
justify-content: var(--justify-content-row-reverse);
}

[lynx-computed-display="linear"][lynx-linear-orientation="vertical"] > *,
Expand All @@ -103,7 +103,7 @@
[lynx-computed-display="linear"][lynx-linear-orientation="vertical-reverse"]
> lynx-wrapper
> * {
align-self: var(--align-self-column) !important;
align-self: var(--align-self-column);
}
[lynx-computed-display="linear"][lynx-linear-orientation="horizontal"] > *,
[lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"],
Expand All @@ -113,5 +113,5 @@
[lynx-computed-display="linear"][lynx-linear-orientation="horizontal-reverse"]
> lynx-wrapper
> * {
align-self: var(--align-self-row) !important;
align-self: var(--align-self-row);
}
12 changes: 1 addition & 11 deletions packages/web-platform/web-elements/src/common-css/linear.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
syntax: "*";
inherits: false;
}
@property --justify-content {
syntax: "*";
inherits: false;
}
@property --align-self {
syntax: "*";
inherits: false;
}
@property --flex-grow {
syntax: "<number>";
inherits: false;
Expand Down Expand Up @@ -207,8 +199,7 @@ x-viewpager-ng {
--lynx-display-flex,
var(--flex-direction)
);
justify-content: var(--lynx-display-linear, var(--linear-justify-content))
var(--lynx-display-flex, var(--justify-content));
justify-content: var(--lynx-display-linear, var(--linear-justify-content));
}

/** For @container
Expand Down Expand Up @@ -318,7 +309,6 @@ x-viewpager-ng {
flex-grow: var(--flex-grow);
flex-shrink: var(--flex-shrink);
flex-basis: var(--flex-basis);
align-self: var(--align-self);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { parseFlexShorthand } from './parseFlexShorthand.js';
/**
* replace values of the property
* if one value is not listed, it will be ignored and kept as is.
*/
const replaceRules: {
[declarationPropertyName: string]: {
[plainValue: string]:
Expand Down Expand Up @@ -210,6 +214,16 @@ const replaceRules: {
['--align-self-column', 'stretch'],
],
},
'justify-content': {
left: [],
right: [],
start: [
['justify-content', 'flex-start'],
],
end: [
['justify-content', 'flex-end'],
],
},
};

const renameRules: {
Expand Down Expand Up @@ -245,12 +259,6 @@ const renameRules: {
'flex-wrap': [
'--flex-wrap',
],
'justify-content': [
'--justify-content',
],
'align-self': [
'--align-self',
],
'flex-grow': [
'--flex-grow',
],
Expand Down
79 changes: 78 additions & 1 deletion packages/web-platform/web-tests/tests/react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3341,6 +3341,24 @@ test.describe('reactlynx3 tests', () => {
await diffScreenShot(page, title, 'index');
},
);
test(
'basic-linear-row-container-main-axis-justify-content-right-left-with-direction-rtl',
async ({
page,
}, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test(
'basic-linear-row-container-main-axis-justify-content-start-end-with-direction-rtl',
async ({
page,
}, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test(
'basic-linear-row-container-main-axis-graverty-top-bottom-with-direction-rtl',
async ({
Expand Down Expand Up @@ -3416,13 +3434,26 @@ test.describe('reactlynx3 tests', () => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
});
test('basic-linear-column-align-items', async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
});
test(
'basic-linear-column-container-items-layout-gravity',
async ({ page }, {
title,
}) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test('basic-linear-column-container-items-align-self', async ({ page }, {
title,
}) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
});
test('basic-linear-row-container-items-align-self', async ({ page }, {
test('basic-linear-row-container-items-layout-gravity', async ({ page }, {
title,
}) => {
await goto(page, title);
Expand All @@ -3440,6 +3471,27 @@ test.describe('reactlynx3 tests', () => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
});
test(
'basic-linear-column-container-main-axis-justify-content-right-left-with-direction-rtl',
async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test(
'basic-linear-column-container-main-axis-justify-content-center',
async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test(
'basic-linear-column-container-main-axis-justify-content-start-end-with-direction-rtl',
async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);

test(
'config-css-default-display-linear-false',
Expand Down Expand Up @@ -3484,6 +3536,31 @@ test.describe('reactlynx3 tests', () => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
});
test(
'basic-flex-column-container-main-axis-justify-content-start-end-with-direction-rtl',
async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test(
'basic-flex-column-container-items-align-self',
async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
test('basic-flex-column-align-items', async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
});
test(
'basic-flex-row-container-main-axis-justify-content-start-end-with-direction-rtl',
async ({ page }, { title }) => {
await goto(page, title);
await diffScreenShot(page, title, 'index');
},
);
});

test.afterEach(async ({ page, browserName, baseURL, browser }, { title }) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
.container {
display: flex;
}
.vertical {
flex-direction: column;
width: 200px;
height: 150px;
background-color: pink;
}
.vertical-reverse {
flex-direction: column-reverse;
width: 200px;
height: 150px;
background-color: #99ddaa;
}
.horizontal {
flex-direction: row;
width: 150px;
height: 100px;
background-color: pink;
}
.horizontal-reverse {
flex-direction: row-reverse;
width: 150px;
height: 100px;
background-color: #99ddaa;
}
.start {
align-items: start;
}
.end {
align-items: end;
}
.flex-start {
align-items: flex-start;
}
.flex-end {
align-items: flex-end;
}
.center {
align-items: center;
}
.stretch {
align-items: stretch;
}
.container-item {
linear-weight: 0;
width: 50px;
height: 50px;
}
.rtl {
direction: lynx-rtl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
import { Component, root } from '@lynx-js/react';
import './index.css';
class Page extends Component {
render() {
return (
<view style='display:flex;flex-direction:column;'>
<view class='container start horizontal'>
<view class='container-item' style='background-color:red;' />
<view class='container-item' style='background-color:green;' />
<view class='container-item' style='background-color:blue;' />
</view>

<view class='container end horizontal'>
<view class='container-item' style='background-color:red;' />
<view class='container-item' style='background-color:green;' />
<view class='container-item' style='background-color:blue;' />
</view>

<view class='container flex-start horizontal'>
<view class='container-item' style='background-color:red;' />
<view class='container-item' style='background-color:green;' />
<view class='container-item' style='background-color:blue;' />
</view>

<view class='container flex-end horizontal'>
<view class='container-item' style='background-color:red;' />
<view class='container-item' style='background-color:green;' />
<view class='container-item' style='background-color:blue;' />
</view>

<view class='container center horizontal'>
<view class='container-item' style='background-color:red;' />
<view class='container-item' style='background-color:green;' />
<view class='container-item' style='background-color:blue;' />
</view>

<view class='container stretch horizontal'>
<view
class='container-item'
style='background-color:red; height:auto'
/>
<view
class='container-item'
style='background-color:green; height:auto'
/>
<view
class='container-item'
style='background-color:blue; height:auto'
/>
</view>
</view>
);
}
}
root.render(<Page></Page>);
Loading