-
Notifications
You must be signed in to change notification settings - Fork 79
Theming system renewal #7453
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
Comments
Is there a split between free/pro/prime components? Or is everything included in lumo.css? |
Good question, @knoobie. We’ve assumed all components would be included, as we expect most of the styling to reside in the component JS modules themselves, and themes are mostly a layer on top that sets custom properties and minimal component-specific selectors (this will probably vary between components). Are you mainly worried about the unnecessary CSS that gets imported for the components you’re not using? Or do you have some other concerns? |
Possible things that come into mind that might be a problem:
e.g. lumo.styles looks like this: @import("@vaadin/pro-component/lumo.css");
@import("@vaadin/free-component1/lumo.css");
@import("@vaadin/free-component2/lumo.css");
@import("@vaadin/free-component3/lumo.css");
|
All Lumo-related stylesheets are going to be in the same package (e.g. I suppose the license wouldn't be an issue because of that, since the Lumo theme package is non-commercial. If you worry about unused CSS, you can import only the parts of Lumo you actually need, instead of the catch-all |
We could have a separate sub-catch-all stylesheet that only includes free component stylesheets, if it looks like it might be an issue. |
This is what
After deprecating Here are the options I have in mind to address that:
// global.css will be added to the regular DOM and the shadow DOM of all exporters
@CssImport("global.css")
public class MyComponent extends Div {} // my-component.css will be added only to the Shadow DOM of the specified exporters,
// @font-face definitions will be extracted to the regular DOM
@CssImport(value = "my-component.css", exporters = { ChatExporter.class, LoginFormExporter.class })
public class MyComponent extends Div {} Update: It turns out |
Description
A simplification of the theme/styling system in Vaadin, to bring it closer to normal/native web development, and minimize Vaadin-specific peculiarities, while keeping migration from earlier versions as painless as possible.
Tier
Free
License
Apache 2.0
Motivation
Background
Mainly due to shadow DOM styling in Vaadin components, Vaadin themes have traditionally needed to be more than just stylesheets. This has required various Vaadin-specific concepts and APIs that new users have had to learn, regardless of their prior knowledge of web development and CSS.
Problem
With the introduction of 100% light-DOM styling in V24, and developments in web standards, those Vaadin-specific features are no longer necessary, but are still retained, and in some cases required, in V24, keeping the learning threshold for new users higher then necessary, and imposing certain limitations on and complications on styling Vaadin applications.
Solution
The entire "theme" concept, with its various APIs, folder structures, and special files, is retired in favor of "just normal stylesheets":
The special
frontend/themes
folder, and thecomponents
sub-folder for css shadow-DOM injection, is deprecated (but still supported).frontend
folder.@import
rules.The
@Theme
annotation is deprecated (but still supported);@CssImport("styles.css")
) and mechanisms native to HTML, CSS and React (e.g.@import url("morestyles.css")
in CSS).@import("@vaadin/lumo-styles/lumo.css")
)color-scheme: dark
), either statically, or based on the user's system settings.The
theme.json
configuration file is deprecated (but still supported, with the exception of thelumoImports
property).lumoImports
property intheme.json
, all Lumo styles can be loaded by importing a single stylesheet (e.g.@import url("@vaadin/lumo-styles/lumo.css")
).@import url("@vaadin/lumo-styles/colors.css")
or@import url("@vaadin/lumo-styles/components/vaadin-button.css")
).cssImport
andassets
properties intheme.json
, stylesheets and other frontend assets can be used in stylesheets using the same syntax as seen above.parent
property intheme.json
, parent themes can simply be loaded as normal stylesheets.The
themeFor
parameter of the@CssImport
annotation (for shadow-DOM injection) is deprecated (but still supported);The special
document.css
file (for loading styles into the document root in embedded components) is removed as no longer necessary;WebComponentExporter
automatically copies any@font-face
declarations in embedded stylesheets into the document root. (No other use cases fordocument.css
are needed in modern browsers.)Example of applying your own CSS on top of Lumo in V25 Flow:
Your Flow application class:
The
my-styles.css
stylesheet:Notes
components
folder can still be used by toggling a feature flag and using the legacy@Theme
annotation andthemes
folder structure to load a theme the legacy way.Requirements
@media vaadin-button {...}
to load styles into the shadow DOM ofvaadin-button
).@CssImport
.@media
to inject component shadow DOM styles.color-scheme
CSS property.@NpmPackage
annotation).components
theme sub-folder.WebComponentExporter
automatically copies@font-face
declarations into document root.@Theme
,themeFor
andinclude
parameter deprecated.Nice-to-haves
url()
syntax, for stylesheets and other assets used via CSS. (Otherwise stylesheets from NPM packages, including Lumo and Aura, will need to be done with@CssImport
etc.Risks, limitations and breaking changes
Risks
Nothing specific expected at this point.
Limitations
Material theme will no longer be supported.
Breaking changes
These changes are not expected to be breaking for most Vaadin applications. Below are some cases where small adjustments will be needed:
@Theme
annotation must explicitly load Lumo styles (e.g. by adding a single@CssImport("@vaadin/lumo/lumo.css")
annotation).Materials
RFC
See PRDs for
Metrics
TBD
Pre-implementation checklist
Pre-release checklist
Security review
None
The text was updated successfully, but these errors were encountered: