Skip to content

Commit 9ad1a70

Browse files
chore: Improve deprecate and javadoc for StyleSheet (#22493)
* chore: Improve deprecate and javadoc for StyleSheet * add a note about where to put the annotation * Apply suggestion from @mcollovati Co-authored-by: Marco Collovati <[email protected]> * Apply suggestion from @mcollovati Co-authored-by: Marco Collovati <[email protected]> * Update flow-server/src/main/java/com/vaadin/flow/component/dependency/StyleSheet.java Co-authored-by: Marco Collovati <[email protected]> --------- Co-authored-by: Marco Collovati <[email protected]>
1 parent 1084ddd commit 9ad1a70

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

flow-server/src/main/java/com/vaadin/flow/component/dependency/StyleSheet.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828

2929
/**
3030
* Loads style sheets into the browser according to a given loading mode. Style
31-
* sheet URLs can be either a file served by the application itself, or an
32-
* external URL.
31+
* sheet URLs can be either a file served by the application itself, i.e. in
32+
* public static resource locations like
33+
* {@code src/main/resources/META-INF/resources/}, or an external URL.
3334
* <p>
34-
* Can defines style sheet dependencies for a {@link Component} class or
35+
* Can define style sheet dependencies for a {@link Component} class or
3536
* globally.
3637
* <p>
3738
* When this annotation is placed on the
@@ -40,6 +41,30 @@
4041
* during bootstrap. In this case the style sheet is always inlined in the body
4142
* of the html page, thus {@link LoadMode} values are ignored.
4243
* <p>
44+
* This annotation is a recommended way to select a Vaadin theme and to import
45+
* stylesheets. To be put on a class implementing
46+
* {@link com.vaadin.flow.component.page.AppShellConfigurator} in this case.
47+
* Example of usage:
48+
*
49+
* <pre>
50+
* // theme selection
51+
* &#64;StyleSheet(Aura.STYLESHEET) // or Lumo.STYLESHEET
52+
* public class Application implements AppShellConfigurator {
53+
* ...
54+
* }
55+
*
56+
* OR
57+
*
58+
* &#64;StyleSheet("styles.css") // from src/main/resources/META-INF/resources/styles.css
59+
* public class Application implements AppShellConfigurator {
60+
* ...
61+
* }
62+
* // and using @import in the styles.css:
63+
*
64+
* &#64;import '@vaadin/aura/aura.css';
65+
* // your custom styles ...
66+
* </pre>
67+
* <p>
4368
* For adding multiple style sheets, you can use this annotation multiple times.
4469
* It is guaranteed that dependencies will be loaded only once.
4570
* <p>

flow-server/src/main/java/com/vaadin/flow/theme/Theme.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@
7777
* @since 1.0
7878
* @deprecated As of Vaadin 25, this annotation is deprecated. The theming
7979
* system has been reworked to use
80+
* {@link com.vaadin.flow.component.dependency.StyleSheet} to load
81+
* one or more stylesheets from public static resources locations or
8082
* {@link com.vaadin.flow.component.dependency.CssImport} to load
81-
* one or more stylesheets and use mechanisms native to HTML, CSS
82-
* and React (e.g. {@code @import url("morestyles.css")} in CSS).
83+
* one or more stylesheets from a {@code src/main/frontend/} folder
84+
* and use mechanisms native to HTML, CSS and React (e.g.
85+
* {@code @import url("morestyles.css")} in CSS).
8386
*/
8487
@Target(ElementType.TYPE)
8588
@Retention(RetentionPolicy.RUNTIME)

0 commit comments

Comments
 (0)