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

Get the application theme and replace the html imports for the bundler with theme ones #3288

Closed
caalador opened this issue Jan 10, 2018 · 3 comments
Assignees
Milestone

Comments

@caalador
Copy link
Contributor

caalador commented Jan 10, 2018

Make it possible to get the used theme from the class specified with the @Theme(MyTheme.class) annotation for the bundler in flow-maven-plugin and to get the theme html import to path used in url translation.

The theme import path only applies to files from (@HtmlImport) that have on the import path a march for the baseUrl specified in MyTheme::getBaseUrl.

If there are multiple different @Theme specified, things should explode with clear message on: multiple themes are not supported, found this thing X from Y and Z from W.

@pleku pleku changed the title Get the application theme for the bundler Get the application theme and replace the html imports for the bundler with theme ones Jan 10, 2018
@denis-anisimov denis-anisimov self-assigned this Jan 22, 2018
@denis-anisimov
Copy link
Contributor

@caalador : I'm not familiar with the way the themes work at all.

So please clarify the ticket for me: as I see from the https://github.com/vaadin/vaadin-button e.g. the theme is imported inside the HTML file.
What should I do if I want to use theme other than lumo ?
From here https://github.com/vaadin/flow/blob/master/flow-documentation/theme/tutorial-built-in-themes.asciidoc I understood that the Theme class file should give a URL translation way which will be used to replace the original one with the URL that refers to the file whose content uses another theme.
Is this correct ?

The first sentence is clear :

Make it possible to get the used theme from the class specified with the @theme(MyTheme.class) annotation for the bundler in flow-maven-plugin and to get the theme html import to path used in url translation.

Means extracting somehow the theme from the application as a class.

The second sentence is not clear for me:

The theme import path only applies to every (@HtmlImport) files that have the import matching the specified theme in a webjar.
Does it mean that:

  • the theme should be imported by the component HTML file? So in the case of vaadin-button it's vaadin-button.html ? Does it mean I should scan the content of the HTML file?
  • or it means that the translated URL for the HTML file IMPORT should match (exists in the webjar)?
  • any theme that we may to apply to the component should be a part of webjar?

The second question makes me confusing: how may I specify my own theme at all without webjar modification?

@caalador
Copy link
Contributor Author

The base is that our components have the @HtmlImport annotation with the import that matches on the pattern ".*/src/vaadin-([\\w\\-]*).html" Lumo for instance has the BaseUrl as src/ which should be changed to theme/lumo/ as per Lumo::getThemeUrl

On the fly we check that the target item exists in the servlet resources so that we don't change a possibly working import that matches to a faulty theme import.

webJars are strictly not needed as it works also from a local file that for vaadin-button would be src/main/webapp/frontend/bower_components/vaadin-button/theme/myTheme/vaadin-button.html in the application.

@denis-anisimov
Copy link
Contributor

The base is that our components have the @HtmlImport annotation with the import that matches on the pattern "./src/vaadin-([\w\-]).html" Lumo for instance has the BaseUrl as src/ which should be changed to theme/lumo/ as per Lumo::getThemeUrl

OK, got it. The question was related to the fact that there is also https://github.com/vaadin/vaadin-button/blob/master/vaadin-button.html which imports the lumo theme directly.

webJars are strictly not needed as it works also from a local file that for vaadin-button would be src/main/webapp/frontend/bower_components/vaadin-button/theme/myTheme/vaadin-button.html in the application.

Alright, the description is confusing then. So technically it doesn't matter whether the file is in the webjar or not but it should be in the end available as a file resource in the frontend directory.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants