NautDrafter's user interface is built using JavaFX and as such, uses CSS to define its look and feel.
The CSS stylesheets can be found in the resources/style/ directory of the main project. Most general-purpose elements, such as buttons, text fields and menus have their styles defined in Base.css. Styles specific to custom UI components are generally placed in separate CSS files, given the same name as the FXML file they relate to (for example, styles specific to Titlebar.fxml are defined in Titlebar.css).
Several colour variables are defined towards the start of Base.css. These can be referenced from any CSS file and should be used when possible (rather than copying and pasting values).
The points below give an overview of how NautDrafter's CSS files should be formatted. In general, just try to follow the style and format of the existing CSS files.
Classes are named following the same convention used by JavaFX's built-in class names. That is, class names should be all lowercase with words separated by hypens, for example, .player-name
When possible, refer to JavaFX controls (such as Button, Label, etc.) using their class name (e.g. .button
rather than Button
to target buttons).
:
in a declaration.Use comments to indicate what is being targeted by a collection of declaration blocks.
/*============================================= * MAJOR SECTION *=============================================*/ /* Sub Section ---------------------*/ /* General comment */ |
Try to keep related declaration blocks near each other in the file. Place more general blocks (e.g. stuff that is being applied to several selectors/elements) towards the top of a section, and progress into more specific selectors further down.
/*============================================= * SCROLLBARS *=============================================*/ .scroll-bar { -fx-background-color: transparent; -fx-opacity: 0.5; } .scroll-bar .track-background, .scroll-bar .track { -fx-background-color: transparent; } .scroll-bar .thumb { -fx-background-radius: 2px; -fx-background-color: -col-primary-trans; } .scroll-bar .increment-button, .scroll-bar .decrement-button { -fx-background-color: transparent; -fx-padding: 0; } .scroll-bar:horizontal .increment-arrow, .scroll-bar:horizontal .decrement-arrow { -fx-background-color: transparent; /* Overall scrollbar height is set by the button's padding */ -fx-padding: 15px 0 0 0; } |