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

[styling-base] Move logic for adding global styles from Lumo package #5680

Closed
web-padawan opened this issue Mar 17, 2023 · 1 comment
Closed
Labels
enhancement New feature or request Lit Lit conversion issue needs discussion No decision yet, discussion needed refactor Internal improvement theme

Comments

@web-padawan
Copy link
Member

web-padawan commented Mar 17, 2023

Describe your motivation

There's a new logic added in #5666 to solve problems related to the order in which CSS applies:

export const addLumoGlobalStyles = (id, ...styles) => {
const styleTag = document.createElement('style');
styleTag.id = `${prefix}${id}`;
styleTag.textContent = styles
.map((style) => style.toString())
.join('\n')
.replace(':host', 'html');
document.head.insertAdjacentElement('afterbegin', styleTag);
};

While the current implementation does the job and makes sense, there are some things to improve:

  1. The fact that the logic is currently placed in @vaadin/vaadin-lumo-styles package is a bit unexpected,
  2. The code uses document which might be problematic for <iframe> (embedded components etc).

Describe the solution you'd like

  1. Mover this global.js package to other package, something like @vaadin/styling-base,
  2. After figuring our a proper name, we could also move registerStyles() for consistency,
  3. Replace document usage with window.ownerDocument to ensure proper <iframe> is used.
@web-padawan web-padawan added enhancement New feature or request theme refactor Internal improvement v24.1 labels Mar 17, 2023
@web-padawan web-padawan changed the title [component-base] Move logic for adding global styles from Lumo package [styling-base] Move logic for adding global styles from Lumo package Mar 17, 2023
@yuriy-fix yuriy-fix added the needs discussion No decision yet, discussion needed label Mar 22, 2023
@web-padawan web-padawan added the Lit Lit conversion issue label Mar 27, 2023
@web-padawan
Copy link
Member Author

This was done in #5752 by moving addGlobalThemeStyles helper to @vaadin/vaadin-themable-mixin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Lit Lit conversion issue needs discussion No decision yet, discussion needed refactor Internal improvement theme
Projects
None yet
Development

No branches or pull requests

2 participants