| @@ -5,6 +5,7 @@ export(bulma_column) | |||
| export(bulma_column_narrow) | |||
| export(bulma_column_options) | |||
| export(bulma_columns) | |||
| export(bulma_constants) | |||
| export(bulma_document) | |||
| export(bulma_helper) | |||
| export(bulma_level) | |||
| @@ -95,7 +95,7 @@ bulma_column_options <- function(size = NULL, width = NULL, offset = NULL, narro | |||
| list( | |||
| size = validate_col_size(size), | |||
| width = validate_value(paste(width), paste(1:12), FALSE, "width"), | |||
| offset = validate_value(offset, c(.bulma_col_sizes, paste(1:12)), FALSE, "offset"), | |||
| offset = validate_value(offset, c(bulma_constants("column sizes"), paste(1:12)), FALSE, "offset"), | |||
| narrow = use_bulma_column_narrow(narrow, "narrow"), | |||
| class = class, | |||
| style = style | |||
| @@ -107,20 +107,14 @@ bulma_column_options <- function(size = NULL, width = NULL, offset = NULL, narro | |||
| bulma_column_options_format <- function(size = NULL, width = NULL, offset = NULL, narrow = NULL) { | |||
| size <- c_is(validate_col_size(size)) | |||
| width <- c_is(validate_value(paste(width), paste(1:12), FALSE, "width")) | |||
| offset <- validate_value(offset, c(.bulma_col_sizes, paste(1:12)), FALSE, "offset") | |||
| offset <- validate_value(offset, c(bulma_constants("column sizes"), paste(1:12)), FALSE, "offset") | |||
| offset <- c_is(c_prefix(offset, "offset-")) | |||
| narrow <- use_bulma_column_narrow(narrow, "narrow") | |||
| str_trim(paste(size, width, offset, narrow)) | |||
| } | |||
| .bulma_col_sizes <- c( | |||
| "full", "four-fifths", "three-quarters", "two-thirds", | |||
| "three-fifths", "half", "two-fifths", "one-third", "one-quarter", | |||
| "one-fifth" | |||
| ) | |||
| validate_col_size <- function(size, var_name = "size") { | |||
| validate_value(size, .bulma_col_sizes, FALSE, var_name) | |||
| validate_value(size, bulma_constants("column sizes"), FALSE, var_name) | |||
| } | |||
| #' Bulma Narrow Column Helper | |||
| @@ -0,0 +1,31 @@ | |||
| #' Bulma Constants | |||
| #' | |||
| #' Returns possible values or strings for a number of Bulma variables. | |||
| #' | |||
| #' @param variable One of "colors", "column sizes", "viewports" | |||
| #' @examples | |||
| #' bulma_constants("colors") | |||
| #' bulma_constants("column sizes") | |||
| #' bulma_constants("viewports") | |||
| #' | |||
| #' @export | |||
| bulma_constants <- function( | |||
| variable = c("colors", "column sizes", "viewports", "alignment") | |||
| ) { | |||
| variable <- tolower(variable) | |||
| switch( | |||
| match.arg(variable), | |||
| "colors" = c( | |||
| "white", "black", "light", "dark", "primary", "info", "link", | |||
| "success", "warning", "danger", "black-bis", "black-ter", | |||
| "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| "white-ter", "white-bis"), | |||
| "column sizes" = c( | |||
| "full", "four-fifths", "three-quarters", "two-thirds", | |||
| "three-fifths", "half", "two-fifths", "one-third", "one-quarter", | |||
| "one-fifth"), | |||
| "viewports" = c( | |||
| "mobile", "tablet", "touch", "desktop", "widescreen", "fullhd"), | |||
| "alignment" = c("centered", "justified", "left", "right") | |||
| ) | |||
| } | |||
| @@ -85,12 +85,8 @@ bulma_responsive <- function(display = NULL, viewport = NULL, only = FALSE) { | |||
| c_is(paste(display, viewport, if (only) "only", sep = "-")) | |||
| } | |||
| .bulma_viewports <- c( | |||
| "mobile", "tablet", "touch", "desktop", "widescreen", "fullhd" | |||
| ) | |||
| validate_viewport <- function(viewport, var_name = "viewport") { | |||
| validate_value(viewport, .bulma_viewports , FALSE, var_name) | |||
| validate_value(viewport, bulma_constants("viewports") , FALSE, var_name) | |||
| } | |||
| # Modifiers :: Color ------------------------------------------------------ | |||
| @@ -99,11 +95,11 @@ validate_viewport <- function(viewport, var_name = "viewport") { | |||
| #' | |||
| #' @param text One of "white", "black", "light", "dark", "primary", "info", | |||
| #' "link", "success", "warning", "danger", "black-bis", "black-ter", | |||
| #' "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| #' "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| #' "white-ter", "white-bis" | |||
| #' @param background One of "white", "black", "light", "dark", "primary", | |||
| #' "info", "link", "success", "warning", "danger", "black-bis", "black-ter", | |||
| #' "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| #' "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| #' "white-ter", "white-bis" | |||
| #' | |||
| #' @examples | |||
| @@ -114,18 +110,15 @@ validate_viewport <- function(viewport, var_name = "viewport") { | |||
| #' @return String of modifer classes | |||
| #' @export | |||
| bulma_color <- function(text = NULL, background = NULL) { | |||
| text <- validate_value(text, .bulma_colors, FALSE, "text") | |||
| text <- c_prefix(text, "text-") | |||
| background <- validate_value(background, .bulma_colors, FALSE, "background") | |||
| background <- c_prefix(background, prefix = "background-") | |||
| text <- validate_color(text, "text") | |||
| background <- validate_color(background, "background") | |||
| c_has(c(text, background)) | |||
| } | |||
| .bulma_colors <- c("white", "black", "light", "dark", "primary", "info", "link", | |||
| "success", "warning", "danger", "black-bis", "black-ter", | |||
| "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| "white-ter", "white-bis") | |||
| validate_color <- function(color, var_name = "text", prefix = paste0(var_name, "-"), several.ok = FALSE) { | |||
| color <- validate_value(color, bulma_constants("colors"), several.ok, var_name) | |||
| c_prefix(color, prefix) | |||
| } | |||
| # Modifiers :: Typography ------------------------------------------------- | |||
| @@ -134,7 +127,7 @@ bulma_color <- function(text = NULL, background = NULL) { | |||
| #' @param size One of 1 through 7 (large to small) | |||
| #' @param text One of "white", "black", "light", "dark", "primary", "info", | |||
| #' "link", "success", "warning", "danger", "black-bis", "black-ter", | |||
| #' "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| #' "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| #' "white-ter", "white-bis" | |||
| #' @param responsive_size See [bulma_responsive_size()]. | |||
| #' @param alignment One of "centered", "justified", "left", "right" | |||
| @@ -164,13 +157,9 @@ bulma_typography <- function( | |||
| size <- c_prefix(size, prefix = "size-") | |||
| responsive_size <- use_bulma_responsive(responsive_size, "size", "responsive_size") | |||
| color <- validate_value(color, .bulma_colors, FALSE, "text") | |||
| color <- c_prefix(color, prefix = "text-") | |||
| color <- validate_color(color, "color", "text-") | |||
| alignment <- validate_value(alignment, c("centered", "justified", "left", "right"), | |||
| FALSE, "alignment") | |||
| alignment <- c_prefix(alignment, "text-") | |||
| alignment <- validate_alignment(alignment) | |||
| responsive_alignment <- use_bulma_responsive(responsive_alignment, "alignment", "responsive_alignment") | |||
| transformation <- validate_value(transformation, | |||
| @@ -193,6 +182,11 @@ bulma_typography <- function( | |||
| str_trim(x) | |||
| } | |||
| validate_alignment <- function(alignment, var_name = "alignment", prefix = "text-") { | |||
| alignment <- validate_value(alignment, bulma_constants("alignment"), FALSE, var_name) | |||
| c_prefix(alignment, prefix) | |||
| } | |||
| #' Bulma Responsive Size Helper Classes | |||
| #' | |||
| #' @inheritParams bulma_typography | |||
| @@ -235,9 +229,7 @@ use_bulma_responsive <- function(x, var, varname) { | |||
| #' @export | |||
| bulma_responsive_alignment <- function(alignment = "left", viewport = "desktop") { | |||
| # TODO: Needs to be vectorized, matching alignment/viewport arguments | |||
| alignment <- validate_value(alignment, c("centered", "justified", "left", "right"), | |||
| FALSE, "alignment") | |||
| alignment <- c_prefix(alignment, "text-") | |||
| alignment <- validate_alignment(alignment) | |||
| viewport <- validate_viewport(viewport) | |||
| x <- c_has(paste0(alignment, "-", viewport)) | |||
| class(x) <- c("responsive_alignment", "bulma", "character") | |||
| @@ -0,0 +1,156 @@ | |||
| <!-- Generated by pkgdown: do not edit by hand --> | |||
| <!DOCTYPE html> | |||
| <html> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |||
| <title>Bulma Constants — bulma_constants • bulma</title> | |||
| <!-- jquery --> | |||
| <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> | |||
| <!-- Bootstrap --> | |||
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |||
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> | |||
| <!-- Font Awesome icons --> | |||
| <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> | |||
| <!-- clipboard.js --> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js" integrity="sha384-cV+rhyOuRHc9Ub/91rihWcGmMmCXDeksTtCihMupQHSsi8GIIRDG0ThDc3HGQFJ3" crossorigin="anonymous"></script> | |||
| <!-- sticky kit --> | |||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script> | |||
| <!-- pkgdown --> | |||
| <link href="../pkgdown.css" rel="stylesheet"> | |||
| <script src="../pkgdown.js"></script> | |||
| <meta property="og:title" content="Bulma Constants — bulma_constants" /> | |||
| <meta property="og:description" content="Returns possible values or strings for a number of Bulma variables." /> | |||
| <meta name="twitter:card" content="summary" /> | |||
| <!-- mathjax --> | |||
| <script src='https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> | |||
| <!--[if lt IE 9]> | |||
| <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> | |||
| <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | |||
| <![endif]--> | |||
| </head> | |||
| <body> | |||
| <div class="container template-reference-topic"> | |||
| <header> | |||
| <div class="navbar navbar-default navbar-fixed-top" role="navigation"> | |||
| <div class="container"> | |||
| <div class="navbar-header"> | |||
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> | |||
| <span class="icon-bar"></span> | |||
| <span class="icon-bar"></span> | |||
| <span class="icon-bar"></span> | |||
| </button> | |||
| <span class="navbar-brand"> | |||
| <a class="navbar-link" href="../index.html">bulma</a> | |||
| <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.0.0.9000</span> | |||
| </span> | |||
| </div> | |||
| <div id="navbar" class="navbar-collapse collapse"> | |||
| <ul class="nav navbar-nav"> | |||
| <li> | |||
| <a href="../index.html"> | |||
| <span class="fa fa-home fa-lg"></span> | |||
| </a> | |||
| </li> | |||
| <li> | |||
| <a href="../reference/index.html">Reference</a> | |||
| </li> | |||
| </ul> | |||
| <ul class="nav navbar-nav navbar-right"> | |||
| </ul> | |||
| </div><!--/.nav-collapse --> | |||
| </div><!--/.container --> | |||
| </div><!--/.navbar --> | |||
| </header> | |||
| <div class="row"> | |||
| <div class="col-md-9 contents"> | |||
| <div class="page-header"> | |||
| <h1>Bulma Constants</h1> | |||
| <div class="hidden name"><code>bulma_constants.Rd</code></div> | |||
| </div> | |||
| <div class="ref-description"> | |||
| <p>Returns possible values or strings for a number of Bulma variables.</p> | |||
| </div> | |||
| <pre class="usage"><span class='fu'>bulma_constants</span>(<span class='kw'>variable</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"colors"</span>, <span class='st'>"column sizes"</span>, <span class='st'>"viewports"</span>, | |||
| <span class='st'>"alignment"</span>))</pre> | |||
| <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2> | |||
| <table class="ref-arguments"> | |||
| <colgroup><col class="name" /><col class="desc" /></colgroup> | |||
| <tr> | |||
| <th>variable</th> | |||
| <td><p>One of "colors", "column sizes", "viewports"</p></td> | |||
| </tr> | |||
| </table> | |||
| <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> | |||
| <pre class="examples"><div class='input'><span class='fu'>bulma_constants</span>(<span class='st'>"colors"</span>)</div><div class='output co'>#> [1] "white" "black" "light" "dark" "primary" | |||
| #> [6] "info" "link" "success" "warning" "danger" | |||
| #> [11] "black-bis" "black-ter" "grey-darker" "grey-dark" "grey" | |||
| #> [16] "gre-light" "grey-lighter" "white-ter" "white-bis" </div><div class='input'><span class='fu'>bulma_constants</span>(<span class='st'>"column sizes"</span>)</div><div class='output co'>#> [1] "full" "four-fifths" "three-quarters" "two-thirds" | |||
| #> [5] "three-fifths" "half" "two-fifths" "one-third" | |||
| #> [9] "one-quarter" "one-fifth" </div><div class='input'><span class='fu'>bulma_constants</span>(<span class='st'>"viewports"</span>)</div><div class='output co'>#> [1] "mobile" "tablet" "touch" "desktop" "widescreen" | |||
| #> [6] "fullhd" </div><div class='input'> | |||
| </div></pre> | |||
| </div> | |||
| <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> | |||
| <h2>Contents</h2> | |||
| <ul class="nav nav-pills nav-stacked"> | |||
| <li><a href="#arguments">Arguments</a></li> | |||
| <li><a href="#examples">Examples</a></li> | |||
| </ul> | |||
| </div> | |||
| </div> | |||
| <footer> | |||
| <div class="copyright"> | |||
| <p>Developed by Garrick Aden-Buie.</p> | |||
| </div> | |||
| <div class="pkgdown"> | |||
| <p>Site built with <a href="http://pkgdown.r-lib.org/">pkgdown</a>.</p> | |||
| </div> | |||
| </footer> | |||
| </div> | |||
| </body> | |||
| </html> | |||
| @@ -139,6 +139,12 @@ | |||
| <td><p>Bulma Columns</p></td> | |||
| </tr><tr> | |||
| <td> | |||
| <p><code><a href="bulma_constants.html">bulma_constants()</a></code> </p> | |||
| </td> | |||
| <td><p>Bulma Constants</p></td> | |||
| </tr><tr> | |||
| <td> | |||
| <p><code><a href="bulma_document.html">bulma_document()</a></code> </p> | |||
| </td> | |||
| @@ -9,12 +9,12 @@ bulma_color(text = NULL, background = NULL) | |||
| \arguments{ | |||
| \item{text}{One of "white", "black", "light", "dark", "primary", "info", | |||
| "link", "success", "warning", "danger", "black-bis", "black-ter", | |||
| "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| "white-ter", "white-bis"} | |||
| \item{background}{One of "white", "black", "light", "dark", "primary", | |||
| "info", "link", "success", "warning", "danger", "black-bis", "black-ter", | |||
| "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| "white-ter", "white-bis"} | |||
| } | |||
| \value{ | |||
| @@ -0,0 +1,21 @@ | |||
| % Generated by roxygen2: do not edit by hand | |||
| % Please edit documentation in R/constants.R | |||
| \name{bulma_constants} | |||
| \alias{bulma_constants} | |||
| \title{Bulma Constants} | |||
| \usage{ | |||
| bulma_constants(variable = c("colors", "column sizes", "viewports", | |||
| "alignment")) | |||
| } | |||
| \arguments{ | |||
| \item{variable}{One of "colors", "column sizes", "viewports"} | |||
| } | |||
| \description{ | |||
| Returns possible values or strings for a number of Bulma variables. | |||
| } | |||
| \examples{ | |||
| bulma_constants("colors") | |||
| bulma_constants("column sizes") | |||
| bulma_constants("viewports") | |||
| } | |||
| @@ -24,7 +24,7 @@ bulma_typography(size = NULL, color = NULL, responsive_size = NULL, | |||
| \item{text}{One of "white", "black", "light", "dark", "primary", "info", | |||
| "link", "success", "warning", "danger", "black-bis", "black-ter", | |||
| "grey-darker", "grey-dark", "grey", "gre-light", "grey-lighter", | |||
| "grey-darker", "grey-dark", "grey", "grey-light", "grey-lighter", | |||
| "white-ter", "white-bis"} | |||
| } | |||
| \value{ | |||