Add edge-to-edge tweak support to Calendar

This commit is contained in:
mkpaz 2023-05-25 21:33:30 +04:00
parent 0a9564ab14
commit 20305b5b1d
4 changed files with 9 additions and 22 deletions

@ -5,7 +5,7 @@ package atlantafx.sampler.page.components;
import atlantafx.base.controls.Calendar; import atlantafx.base.controls.Calendar;
import atlantafx.base.controls.Popover; import atlantafx.base.controls.Popover;
import atlantafx.base.controls.Popover.ArrowLocation; import atlantafx.base.controls.Popover.ArrowLocation;
import atlantafx.base.theme.Styles; import atlantafx.base.theme.Tweaks;
import atlantafx.base.util.BBCodeParser; import atlantafx.base.util.BBCodeParser;
import atlantafx.sampler.page.ExampleBox; import atlantafx.sampler.page.ExampleBox;
import atlantafx.sampler.page.OutlinePage; import atlantafx.sampler.page.OutlinePage;
@ -51,16 +51,6 @@ public final class PopoverPage extends OutlinePage {
} }
private ExampleBox usageExample() { private ExampleBox usageExample() {
var dataClass = """
.popover .date-picker-popup {
-color-date-border: transparent;
-color-date-bg: transparent;
-color-date-day-bg: transparent;
-color-date-month-year-bg: transparent;
-color-date-day-bg-hover: -color-bg-subtle;
}
""";
//snippet_1:start //snippet_1:start
var textFlow = new TextFlow(new Text( var textFlow = new TextFlow(new Text(
FAKER.lorem().sentence(30) FAKER.lorem().sentence(30)
@ -79,12 +69,7 @@ public final class PopoverPage extends OutlinePage {
// ~ // ~
var cal = new Calendar(); var cal = new Calendar();
cal.setValue(LocalDate.now(ZoneId.systemDefault())); cal.setValue(LocalDate.now(ZoneId.systemDefault()));
// -color-date-border: transparent; cal.getStyleClass().add(Tweaks.EDGE_TO_EDGE);
// -color-date-bg: transparent;
// -color-date-day-bg: transparent;
// -color-date-month-year-bg: transparent;
// -color-date-day-bg-hover: -color-bg-subtle;
cal.getStylesheets().add(Styles.toDataURI(dataClass));
var pop2 = new Popover(cal); var pop2 = new Popover(cal);
pop2.setHeaderAlwaysVisible(false); pop2.setHeaderAlwaysVisible(false);

@ -57,7 +57,7 @@
<Separator orientation="VERTICAL" prefHeight="200.0" styleClass="large" /> <Separator orientation="VERTICAL" prefHeight="200.0" styleClass="large" />
<VBox alignment="TOP_CENTER" spacing="10.0"> <VBox alignment="TOP_CENTER" spacing="10.0">
<children> <children>
<Calendar prefWidth="400.0" showWeekNumbers="true" VBox.vgrow="NEVER" /> <Calendar prefWidth="400.0" showWeekNumbers="true" VBox.vgrow="NEVER" styleClass="edge-to-edge" />
<Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" styleClass="flat"> <Button contentDisplay="GRAPHIC_ONLY" mnemonicParsing="false" styleClass="flat">
<graphic> <graphic>
<Label maxWidth="1.7976931348623157E308" styleClass="danger" text="Remove due date" /> <Label maxWidth="1.7976931348623157E308" styleClass="danger" text="Remove due date" />

@ -54,10 +54,6 @@
-fx-background-radius: 10px; -fx-background-radius: 10px;
} }
.date-picker-popup {
-color-date-border: transparent;
}
.no-border { .no-border {
-fx-background-insets: 0; -fx-background-insets: 0;
} }

@ -252,6 +252,12 @@ $chrono-cell-padding: 0.083333em $cell-padding-x 0.083333em 0.333333em !default;
} }
} }
.edge-to-edge>.calendar.date-picker-popup {
-fx-background-color: -color-date-bg;
-fx-background-insets: 0;
-fx-background-radius: 0;
}
.date-picker-popup>.calendar-grid>.selected, .date-picker-popup>.calendar-grid>.selected,
.date-picker-popup>.calendar-grid>.selected>.secondary-text, .date-picker-popup>.calendar-grid>.selected>.secondary-text,
.date-picker-popup>.calendar-grid>.previous-month.selected, .date-picker-popup>.calendar-grid>.previous-month.selected,