Skip to content
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

Replace resize observer with CSS container queries #56

Closed
blackfalcon opened this issue Jul 28, 2023 · 0 comments · Fixed by #52
Closed

Replace resize observer with CSS container queries #56

blackfalcon opened this issue Jul 28, 2023 · 0 comments · Fixed by #52
Assignees

Comments

@blackfalcon
Copy link
Member

blackfalcon commented Jul 28, 2023

Is your feature request related to a problem? Please describe.

The following code is part of a bootstrap solution to support container queries before CSS container queries were broadly available.

constructor() {
super();
this.canceled = false;
this.cq = defaultContainerWidth;
/** @private */
this.showAllStops = false;
/** @private */
this.hasCanceledSegment = false;
/** @private */
this.firstSegmentCanceled = false;
/** @private */
this.lastSegmentCanceled = false;
}

The current issue is that the following tests are failing for unknown reasons.

it('shows all stops depending on width', async () => {
const el = await fixture(html`
<auro-flightline id="condensed">
<auro-flight-segment iata="SEA" duration="0h 40m"></auro-flight-segment>
<auro-flight-segment iata="BOS" duration="1h 40m"></auro-flight-segment>
<auro-flight-segment iata="DUB" duration="13h 40m"></auro-flight-segment>
</auro-flightline>
`);
const slottedSegment = el.querySelector('auro-flight-segment');
const summarySegment = el.shadowRoot.querySelector('auro-flight-segment');
// when too narrow to show all segments, the condensed segment is shwon
el.style.width = "100px";
await waitUntil(() => !el.showAllStops);
expect(window.getComputedStyle(slottedSegment).display).to.eql('none');
expect(window.getComputedStyle(summarySegment).display).to.eql('block');
// when the element is resized, the expanded view is shown
el.style.width = "700px";
await waitUntil(() => el.showAllStops);
expect(window.getComputedStyle(slottedSegment).display).to.eql('block');
expect(window.getComputedStyle(summarySegment).display).to.eql('none');
});

Describe the solution you'd like

Instead of updating code/tests it is preferred that we remove the bootstrap code and update the component to use CSS container queries that are easily supported by the browser. This solution will remove the maintenance and testing dependency related to supporting the bootstrap solution.

https://caniuse.com/css-container-queries

https://mxb.dev/blog/container-queries-web-components/

This will be a BREAKING CHANGE in regards to the cq attribute will no longer be supported. This work should be addressed with the current efforts to re-release the component under the @aurodesignsystem npm namespace.

Describe alternatives you've considered

Trying to fix the code/tests.

Exit criteria

This issue will be considered complete once the resize observer code has been removed from the project and the currently supported feature (see attached screenshot) is still supported without any changes needed by the consumers.

Screen Shot 2023-07-28 at 2 45 56 PM
@blackfalcon blackfalcon added this to the Node 18+ update milestone Jul 28, 2023
@blackfalcon blackfalcon linked a pull request Jul 28, 2023 that will close this issue
3 tasks
@blackfalcon blackfalcon self-assigned this Jul 31, 2023
blackfalcon added a commit that referenced this issue Aug 2, 2023
BREAKING CHANGE: This commit removes the custom built
container query support and replaces it with standard
CSS container query support.

This commit also REMOVES the custom `cq` attribute as this
is no longer supported. The default `414px` width was replaced
with the standard `auro-grid-breakpoint-xs` token.

Changes to be committed:
modified:   docs/api.md
modified:   src/auro-flightline.js
deleted:    src/observer.js
modified:   src/style-flightline.scss
modified:   test/auro-flightline.test.js
blackfalcon added a commit that referenced this issue Aug 2, 2023
BREAKING CHANGE: This commit removes the custom built
container query support and replaces it with standard
CSS container query support.

This commit also REMOVES the custom `cq` attribute as this
is no longer supported. The default `414px` width was replaced
with the standard `auro-grid-breakpoint-xs` token.

Changes to be committed:
modified:   docs/api.md
modified:   src/auro-flightline.js
deleted:    src/observer.js
modified:   src/style-flightline.scss
modified:   test/auro-flightline.test.js
blackfalcon pushed a commit that referenced this issue Aug 2, 2023
# [2.0.0](v1.4.0...v2.0.0) (2023-08-02)

### Bug Fixes

* **demo:** update demo.md custom component html ([9e40bd4](9e40bd4))
* **postinstall:** renamed postinstall.js ([3a3cfac](3a3cfac))
* **tsc:** update typo filename ([dc1e4d7](dc1e4d7))

### Documentation

* **npm:** Update npm namespace ([464c480](464c480))

### Features

* **cq:** remove custom container query support [#56](#56) ([4ea9bd5](4ea9bd5))
* **customize:** update component registration [#45](#45) ([c1ae11e](c1ae11e))
* **typescript:** add typescript support [#45](#45) ([32d54a0](32d54a0))

### Performance Improvements

* add build:watch command npm script ([439d434](439d434))
* **es5:** Remove legacy es5 bundling resource [#44](#44) ([781a79b](781a79b))
* **husky:** pre-commit and husky update [#45](#45) ([70f1edd](70f1edd))
* **husky:** update config to support linters ([6397945](6397945))
* **lit:** update to Lit2.0 [#45](#45) ([0bb2505](0bb2505))
* **node18:** update to support Node 18++ [#46](#46) ([107791d](107791d))
* **sass:** Update to use dart-sass dependency ([6012dc1](6012dc1))
* **server:** update to use single shell [#53](#53) ([1418d25](1418d25))

### BREAKING CHANGES

* **cq:** This commit removes the custom built
container query support and replaces it with standard
CSS container query support.

This commit also REMOVES the custom `cq` attribute as this
is no longer supported. The default `414px` width was replaced
with the standard `auro-grid-breakpoint-xs` token.

Changes to be committed:
modified:   docs/api.md
modified:   src/auro-flightline.js
deleted:    src/observer.js
modified:   src/style-flightline.scss
modified:   test/auro-flightline.test.js
* **npm:** This update will redefine the npm namespace
for the auro-flightline element.

Changes to be committed:
	modified:   package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant