Improve sample block title style

This commit is contained in:
mkpaz 2022-09-28 16:27:12 +04:00
parent a9dd26d798
commit a238eb62e4
2 changed files with 24 additions and 7 deletions

@ -1,10 +1,12 @@
/* SPDX-License-Identifier: MIT */ /* SPDX-License-Identifier: MIT */
package atlantafx.sampler.page; package atlantafx.sampler.page;
import javafx.geometry.Insets;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.scene.text.TextFlow; import javafx.scene.text.TextFlow;
import net.datafaker.Faker; import net.datafaker.Faker;
@ -31,12 +33,19 @@ public class SampleBlock extends VBox {
public SampleBlock(String title, Node content, String description) { public SampleBlock(String title, Node content, String description) {
titleLabel = new Label(Objects.requireNonNull(title)); titleLabel = new Label(Objects.requireNonNull(title));
titleLabel.getStyleClass().add("title");
Polygon polygon = new Polygon();
polygon.getPoints().addAll(0.0, 0.0, 20.0, 10.0, 20.0, 0.0);
polygon.getStyleClass().add("polygon");
var titleBox = new VBox(titleLabel, polygon);
titleBox.getStyleClass().add("title");
VBox.setMargin(titleBox, new Insets(-5, 0, 0, -40));
this.content = Objects.requireNonNull(content); this.content = Objects.requireNonNull(content);
content.getStyleClass().add("content"); content.getStyleClass().add("content");
getChildren().setAll(titleLabel, content); getChildren().setAll(titleBox, content);
if (description != null && !description.isBlank()) { if (description != null && !description.isBlank()) {
descriptionText = new TextFlow(new Text(description)); descriptionText = new TextFlow(new Text(description));
getChildren().add(descriptionText); getChildren().add(descriptionText);

@ -35,12 +35,20 @@
-fx-effect: dropshadow(gaussian, -color-shadow-default, 10, 0.4, 0, 0); -fx-effect: dropshadow(gaussian, -color-shadow-default, 10, 0.4, 0, 0);
-fx-border-color: -color-border-muted; -fx-border-color: -color-border-muted;
-fx-border-width: 1px; -fx-border-width: 1px;
-fx-padding: 1em 1.5em 1.5em 1.5em; -fx-padding: 15px 20px 15px 20px;
-fx-spacing: 1em; -fx-spacing: 20px;
-fx-min-width: 220px; -fx-min-width: 220px;
>.title { >.title {
-fx-font-weight: bold; >.label {
-fx-padding: 0 0 10px 0; -fx-padding: 5px 15px 5px 10px;
-fx-background-color: -color-accent-subtle;
-fx-text-fill: -color-fg-default;
-fx-font-size: 1.1em;
}
>.polygon {
-fx-fill: -color-accent-muted;
}
} }
} }