vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
618 stars 167 forks source link

Manual import not working for Lumo Utility #13716

Open gigi opened 2 years ago

gigi commented 2 years ago

Description of the bug

Hi! Tried to import Lumo Utilities as described here: https://vaadin.com/docs/latest/ds/foundation/utility-classes/#usage

@JsModule("@vaadin/vaadin-lumo-styles/utility.js")
@CssImport(value="some-stylesheet.css", include="lumo-utility")

It seems that only theme.json approach works. Maybe we have to enable or whitelist something?

Expected behavior

Manual import should import styles to the DOM

Minimal reproducible example

Used this starter https://github.com/vaadin/skeleton-starter-flow-spring

@Route
@JsModule("@vaadin/vaadin-lumo-styles/utility.js")
@CssImport(value="./styles/shared-styles.css", include="lumo-utility")
public class MainView extends VerticalLayout {

    public MainView() {

        Div block1 = new Div();
        block1.setText("Class");
        block1.setWidth("100px");
        block1.setHeight("100px");
        block1.addClassName("bg-success");

        Div block2 = new Div();
        block2.setText("Inline");
        block2.setWidth("100px");
        block2.setHeight("100px");
        block2.getStyle().set("background","var(--lumo-success-color)");

        add(block1, block2);
    }
}
screen1 screen2

Versions

mcollovati commented 2 years ago

Thanks for reporting. I can reproduce and confirm the issue

lamemind-ud commented 1 year ago

Hello, is there any working workaround for this? Thanks

kristofmaar commented 1 year ago

Hello, is there any working workaround for this? Thanks

Yes, you can create your own theme and add

{
  "lumoImports": ["utility"]
}

to the theme.json file.

mvysny commented 1 year ago

With Material theme, it's not possible to have custom themes, and therefore you're forced to use the @CssImport hack which doesn't work. I mean sure, it can't be expected that LumoUtility works outside of Lumo theme, but still :)