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

refactor: dev overlay to make it easier to work with VT #8966

Merged
merged 3 commits into from
Oct 31, 2023

Conversation

Princesseuh
Copy link
Member

@Princesseuh Princesseuh commented Oct 31, 2023

Changes

The diff looks really messy, but to summarize the changes here:

  • The dev overlay web component has been moved to its own file, so the entrypoint that's being imported in the browser is just "create overlay, give it the plugins, add overlay to DOM". Additionally, this allow importing the type of the dev overlay element.
  • This refactor allowed much easier support for view transitions, so I did it

Testing

Tests should pass!

Docs

N/A, just a bug fix. We could have a section on making your plugin work with VT, though...

Copy link

changeset-bot bot commented Oct 31, 2023

🦋 Changeset detected

Latest commit: 89c96f8

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Oct 31, 2023
Comment on lines +2330 to +2338
declare global {
interface HTMLElementTagNameMap {
'astro-dev-overlay': AstroDevOverlay;
'astro-dev-overlay-window': DevOverlayWindow;
'astro-dev-overlay-plugin-canvas': DevOverlayCanvas;
'astro-dev-overlay-tooltip': DevOverlayTooltip;
'astro-dev-overlay-highlight': DevOverlayHighlight;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I had forgotten about this thing, it's quite neat.

Copy link
Contributor

github-actions bot commented Oct 31, 2023

⚖️ Bundle Size Check

Latest commit: 89c96f8

File Old Size New Size Change
dev-overlay/entrypoint 0 B 28.04 KB + 28.04 KB
dev-overlay/overlay 25.47 KB 12.4 KB - NaN undefined
dev-overlay/plugins/astro 1.36 KB 1.36 KB 0 B
dev-overlay/plugins/audit 1.97 KB 2.21 KB + 247 B
dev-overlay/plugins/utils/highlight 691 B 764 B + 73 B
dev-overlay/plugins/xray 2.49 KB 2.72 KB + 230 B
dev-overlay/ui-library/tooltip 6.81 KB 6.8 KB - NaN undefined

Comment on lines +7 to +28
const [
{ loadDevOverlayPlugins },
{ default: astroDevToolPlugin },
{ default: astroAuditPlugin },
{ default: astroXrayPlugin },
{ AstroDevOverlay, DevOverlayCanvas },
{ DevOverlayCard },
{ DevOverlayHighlight },
{ DevOverlayTooltip },
{ DevOverlayWindow },
] = await Promise.all([
// @ts-expect-error
import('astro:dev-overlay'),
import('./plugins/astro.js'),
import('./plugins/audit.js'),
import('./plugins/xray.js'),
import('./overlay.js'),
import('./ui-library/card.js'),
import('./ui-library/highlight.js'),
import('./ui-library/tooltip.js'),
import('./ui-library/window.js'),
]);
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the imports into the DOMContentLoaded, that way we really do the big things outside of the page load

Comment on lines +36 to +43
view-transition-name: astro-dev-overlay;
display: contents;
}

::view-transition-old(astro-dev-overlay),
::view-transition-new(astro-dev-overlay) {
animation: none;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

All of this is required to ensure animations don't affect the dev overlay, otherwise it might move, get faded away etc

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Nice refactors!

@Princesseuh Princesseuh removed the pr: docs A PR that includes documentation for review label Oct 31, 2023
@Princesseuh Princesseuh merged commit 262cef2 into main Oct 31, 2023
15 checks passed
@Princesseuh Princesseuh deleted the feat/refactor-overlay-vt branch October 31, 2023 22:35
@astrobot-houston astrobot-houston mentioned this pull request Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants