diff --git a/README.md b/README.md index 54712c0..51bac21 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,24 @@ calendar.setClassNameGenerator(date -> { }); ``` +## Styling dates + +Dates are rendered inside `vaadin-month-calendar`, so the styles for the class names returned by the `ClassNameGenerator` must be imported with `themeFor`: + +``` +@CssImport(value = "./styles/calendar-styles.css", themeFor = "vaadin-month-calendar") +``` + +The background of a date is set through the `--background-color` custom property, and its background on hover through `--hover-background-color`: + +``` +[part~='date'].holiday { + color: white; + --background-color: red; + --hover-background-color: darkred; +} +``` + ## Special configuration when using Spring By default, Vaadin Flow only includes ```com/vaadin/flow/component``` to be always scanned for UI components and views. For this reason, the addon might need to be whitelisted in order to display correctly. diff --git a/pom.xml b/pom.xml index a8e08c1..75e470f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.vaadin.addons.flowingcode year-month-calendar - 4.6.3-SNAPSHOT + 4.7.0-SNAPSHOT Year Month Calendar Add-on Year Month Calendar Add-on for Vaadin Flow https://www.flowingcode.com/en/open-source/ diff --git a/src/main/resources/META-INF/frontend/fc-month-calendar/vaadin-month-calendar.css b/src/main/resources/META-INF/frontend/fc-month-calendar/vaadin-month-calendar.css index 2f69237..150f84e 100644 --- a/src/main/resources/META-INF/frontend/fc-month-calendar/vaadin-month-calendar.css +++ b/src/main/resources/META-INF/frontend/fc-month-calendar/vaadin-month-calendar.css @@ -28,7 +28,7 @@ } [part~='date']:not(:empty):not([part~='disabled']):not([part~='selected']):hover::before { - background-color: var(--lumo-primary-color-10pct, var(--aura-background-color)); + background-color: var(--hover-background-color, var(--lumo-primary-color-10pct, var(--aura-background-color))); } [part~='date']::after { diff --git a/src/test/resources/META-INF/frontend/styles/test_year-month-calendar.css b/src/test/resources/META-INF/frontend/styles/test_year-month-calendar.css index e554ea0..f5ab15d 100644 --- a/src/test/resources/META-INF/frontend/styles/test_year-month-calendar.css +++ b/src/test/resources/META-INF/frontend/styles/test_year-month-calendar.css @@ -20,6 +20,7 @@ [part~='date'].holiday { color: var(--lumo-error-contrast-color, white); --background-color: var(--lumo-error-color, #e00); + --hover-background-color: color-mix(in srgb, var(--lumo-error-color, #e00) 80%, black); } [part~='date'].weekend {