|
| 1 | +#' UI Style Constants for cOmicsArt |
| 2 | +#' |
| 3 | +#' Centralized styling definitions for consistent UI appearance. |
| 4 | +#' This file contains all color palettes and style strings used throughout the app. |
| 5 | +#' |
| 6 | +#' @author cOmicsArt Development Team |
| 7 | +#' @date 2026-06-14 |
| 8 | + |
| 9 | +# Color Palette ---------------------------------------------------------------- |
| 10 | + |
| 11 | +#' Primary background color (light green with transparency) |
| 12 | +COMICSART_PRIMARY_BG <- "#70BF4F47" |
| 13 | + |
| 14 | +#' Primary text color (white) |
| 15 | +COMICSART_PRIMARY_TEXT <- "#ffffff" |
| 16 | + |
| 17 | +#' Secondary background color (white) |
| 18 | +COMICSART_SECONDARY_BG <- "white" |
| 19 | + |
| 20 | +#' Secondary text color (black) |
| 21 | +COMICSART_SECONDARY_TEXT <- "black" |
| 22 | + |
| 23 | +#' Border color (black) |
| 24 | +COMICSART_BORDER_COLOR <- "#000000" |
| 25 | + |
| 26 | +#' Link color (black) |
| 27 | +COMICSART_LINK_COLOR <- "black" |
| 28 | + |
| 29 | +#' Transparent background |
| 30 | +COMICSART_TRANSPARENT_BG <- "transparent" |
| 31 | + |
| 32 | +#' Loading/waiter overlay color (blue with transparency) |
| 33 | +COMICSART_WAITER_COLOR <- "#3897F147" |
| 34 | + |
| 35 | +# Button Styles ---------------------------------------------------------------- |
| 36 | + |
| 37 | +#' Primary button style (green background, white text) |
| 38 | +#' |
| 39 | +#' Use for main action buttons like "Start the Journey", "Go to Preprocessing" |
| 40 | +#' |
| 41 | +#' @export |
| 42 | +STYLE_PRIMARY_BUTTON <- sprintf( |
| 43 | + "color: %s; background-color: %s; border-color: %s", |
| 44 | + COMICSART_PRIMARY_TEXT, |
| 45 | + COMICSART_PRIMARY_BG, |
| 46 | + COMICSART_BORDER_COLOR |
| 47 | +) |
| 48 | + |
| 49 | +#' Secondary button style (white background, black text) |
| 50 | +#' |
| 51 | +#' Use for secondary actions like "Upload new data", "GO!" |
| 52 | +#' |
| 53 | +#' @export |
| 54 | +STYLE_SECONDARY_BUTTON <- sprintf( |
| 55 | + "color: %s; background-color: %s; border-color: %s", |
| 56 | + COMICSART_SECONDARY_TEXT, |
| 57 | + COMICSART_SECONDARY_BG, |
| 58 | + COMICSART_BORDER_COLOR |
| 59 | +) |
| 60 | + |
| 61 | +#' Transparent button style (no background, black text) |
| 62 | +#' |
| 63 | +#' Use for toggle buttons or less prominent actions |
| 64 | +#' |
| 65 | +#' @export |
| 66 | +STYLE_TRANSPARENT_BUTTON <- sprintf( |
| 67 | + "color: %s; background-color: %s; border-color: %s", |
| 68 | + COMICSART_SECONDARY_TEXT, |
| 69 | + COMICSART_TRANSPARENT_BG, |
| 70 | + COMICSART_TRANSPARENT_BG |
| 71 | +) |
| 72 | + |
| 73 | +# Link Styles ------------------------------------------------------------------ |
| 74 | + |
| 75 | +#' Underlined link style (18px font, black, underlined) |
| 76 | +#' |
| 77 | +#' Use for prominent links like "Go To Documentation" |
| 78 | +#' |
| 79 | +#' @export |
| 80 | +STYLE_UNDERLINED_LINK <- "font-size: 18px; color: black; text-decoration: underline;" |
| 81 | + |
| 82 | +# Layout Styles ---------------------------------------------------------------- |
| 83 | + |
| 84 | +#' Horizontal line style (gray border) |
| 85 | +#' |
| 86 | +#' Use with hr() for section dividers |
| 87 | +#' |
| 88 | +#' @export |
| 89 | +STYLE_HORIZONTAL_LINE <- "border-top: 1px solid #858585;" |
| 90 | + |
| 91 | +# Helper Functions ------------------------------------------------------------- |
| 92 | + |
| 93 | +#' Get button style by type |
| 94 | +#' |
| 95 | +#' Convenience function to retrieve button styles by name. |
| 96 | +#' |
| 97 | +#' @param type Character. One of: "primary", "secondary", "transparent" |
| 98 | +#' @return Character. CSS style string |
| 99 | +#' |
| 100 | +#' @examples |
| 101 | +#' \dontrun{ |
| 102 | +#' actionButton("my_btn", "Click Me", style = get_button_style("primary")) |
| 103 | +#' } |
| 104 | +#' |
| 105 | +#' @export |
| 106 | +get_button_style <- function(type = "primary") { |
| 107 | + switch(type, |
| 108 | + primary = STYLE_PRIMARY_BUTTON, |
| 109 | + secondary = STYLE_SECONDARY_BUTTON, |
| 110 | + transparent = STYLE_TRANSPARENT_BUTTON, |
| 111 | + stop("Unknown button type: ", type, ". Use 'primary', 'secondary', or 'transparent'.") |
| 112 | + ) |
| 113 | +} |
| 114 | + |
| 115 | +#' Get standardized horizontal line |
| 116 | +#' |
| 117 | +#' Creates an hr() element with consistent styling. |
| 118 | +#' |
| 119 | +#' @return Shiny hr element with standard styling |
| 120 | +#' |
| 121 | +#' @examples |
| 122 | +#' \dontrun{ |
| 123 | +#' # In UI: |
| 124 | +#' get_styled_hr() |
| 125 | +#' } |
| 126 | +#' |
| 127 | +#' @export |
| 128 | +get_styled_hr <- function() { |
| 129 | + hr(style = STYLE_HORIZONTAL_LINE) |
| 130 | +} |
0 commit comments