-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.qmd
More file actions
262 lines (204 loc) 路 8.29 KB
/
Copy pathREADME.qmd
File metadata and controls
262 lines (204 loc) 路 8.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# brandr <a href = "https://danielvartan.github.io/brandr/"><img src = "man/figures/logo.png" align="right" width="120" /></a>
<!-- quarto render -->
```{r}
#| label: setup
#| include: false
library(badger)
library(brandr)
library(here)
library(rutils) # github.com/danielvartan/rutils
source(here("R", ".setup.R"))
```
<!-- badges: start -->
```{r}
#| echo: false
#| output: asis
cat(
badge_repostatus("active"),
badge_cran_release(),
badge_custom(
x = "doi",
y = "10.32614/CRAN.package.brandr",
color = "1284C5",
url = "https://CRAN.R-project.org/package=brandr"
),
badge_cran_download(type = "grand-total"),
badge_github_actions(action = "R-CMD-check.yaml"),
badge_codecov() |> rutils::shush(),
badge_license(
license = "GPLv3",
color = "bd0000",
url = "https://www.gnu.org/licenses/gpl-3.0"
),
paste0(
"[](",
"https://fairsoftwarechecklist.net/v0.2/?f=31&a=32113&i=32322&r=133",
")"
),
paste0(
"[](",
"https://fair-software.eu",
")"
),
badge_custom(
x = "Contributor%20Covenant",
y = "3.0",
color = "4baaaa",
url = "https://www.contributor-covenant.org/version/3/0/code_of_conduct/",
alt = "Contributor Covenant 3.0 Code of Conduct"
)
)
```
<!-- badges: end -->
## Overview
`brandr` is an R package designed to facilitate brand identity management using the [brand.yml](https://posit-dev.github.io/brand-yml/) standard. It provides functions to consistently access and apply brand colors, typography, and other visual elements across your R projects.
Unlike [Posit](https://posit.co/)'s [`thematic`](https://rstudio.github.io/thematic/) package, `brandr` offers more refined control over brand assets.
> If you find this project useful, please consider giving it a star! [](https://github.com/danielvartan/brandr/)
**`brandr` is not affiliated with [Posit](https://posit.co/) or the developers of [brand.yml](https://posit-dev.github.io/brand-yml/).**
## Installation
You can install the released version of `brandr` from [CRAN](https://CRAN.R-project.org/package=brandr) with:
```r
install.packages("brandr")
```
And the development version from [GitHub](https://github.com/) with:
```r
# install.packages("remotes")
remotes::install_github("danielvartan/brandr")
```
## Usage
`brandr` is equipped with several functions to help you use your `_brand.yml` file, like:
- [`color_brand_sequential()`](https://danielvartan.github.io/brandr/reference/color_brand_sequential.html), `color_brand_diverging()`, `color_brand_qualitative()`: Sequential, diverging, and qualitative brand color palettes
- [`scale_brand()`](https://danielvartan.github.io/brandr/reference/scale_brand.html), `scale_color_brand_d()`, `scale_color_brand_c()`, `scale_color_brand_b()`, `scale_fill_brand_d()`, `scale_fill_brand_c()`, `scale_fill_brand_b()`: Discrete, continuous, and binned brand color scales for [`ggplot2`](https://ggplot2.tidyverse.org/)
- [`get_brand_color()`](https://danielvartan.github.io/brandr/reference/get_brand_color.html): Get a brand color by name (e.g., primary)
- [`get_brand_color_tint()`](https://danielvartan.github.io/brandr/reference/get_brand_color_tint.html): Get a brand color tint
- [`get_brand_color_mix()`](https://danielvartan.github.io/brandr/reference/get_brand_color_mix.html): Get a mix of brand colors
- [`get_brand_font()`](https://danielvartan.github.io/brandr/reference/get_brand_font.html): Get a brand font by name (e.g., headings)
Example:
```{r}
#| label: readme-figure
#| warning: false
library(brandr)
library(ggplot2)
library(palmerpenguins)
penguins |>
ggplot(aes(x = flipper_length_mm, fill = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
scale_fill_brand_d() +
labs(
x = "Flipper Length (mm)",
y = "Frequency",
fill = "Species"
)
```
Click [here](https://danielvartan.github.io/brandr/) to see the full list.
## Configuration
### Path to `_brand.yml`
`brandr` will always look for a `_brand.yml` file in the root directory of your project. If the file is not found, an error message will be displayed. You can also set the path to the file manually using the `options()` function:
```r
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
```
### Brand Color Scales
To control the colors of each brand color scale, assign [hexadecimal](https://en.wikipedia.org/wiki/Web_colors) color codes in a `character` vector to the following options:
- `BRANDR_COLOR_SEQUENTIAL`: For sequential color scales
- `BRANDR_COLOR_DIVERGING`: For diverging color scales
- `BRANDR_COLOR_QUALITATIVE`: For qualitative color scales
You can use `get_brand_color()` to get the hexadecimal color codes from the `_brand.yml` file.
Example:
```r
options(
BRANDR_COLOR_SEQUENTIAL =
get_brand_color(c("primary", "secondary")),
BRANDR_COLOR_DIVERGING =
get_brand_color(c("primary", "white", "secondary")),
BRANDR_COLOR_QUALITATIVE =
get_brand_color(c("primary", "secondary", "tertiary"))
)
```
## Setting Brand Fonts/Typefaces
`brandr` does not support custom fonts directly. We recommend using Yixuan Qiu's [`showtext`](https://doi.org/10.32614/CRAN.package.showtext) R package to apply custom fonts or typefaces to your plots.
Below is an example showing how to use the Google Font [Open Sans](https://fonts.google.com/specimen/Open+Sans) in all of your plots using [`ggplot2`](https://ggplot2.tidyverse.org/). This example assumes that the font files are located in a `ttf` folder within your project directory.
```r
library(brandr)
library(ggplot2)
library(here)
library(sysfonts)
library(showtext)
font_paths(here("ttf"))
font_add(
family = "open-sans",
regular = here("ttf", "opensans-regular.ttf"),
bold = here("ttf", "opensans-bold.ttf"),
italic = here("ttf", "opensans-italic.ttf"),
bolditalic = here("ttf", "opensans-bolditalic.ttf"),
symbol = NULL
)
showtext_auto()
theme_set(
theme(
text = element_text(
color = get_brand_color("black"),
family = "open-sans",
face = "plain"
)
)
)
```
## License
```{r}
#| echo: false
#| output: asis
cat(
badge_license(
license = "GPLv3",
color = "bd0000",
url = "https://www.gnu.org/licenses/gpl-3.0"
)
)
```
```text
Copyright (C) 2025 Daniel Vartanian
brandr is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
```
## Contributing
```{r}
#| echo: false
#| output: asis
cat(
badge_custom(
x = "Contributor%20Covenant",
y = "3.0",
color = "4baaaa",
url = "https://www.contributor-covenant.org/version/3/0/code_of_conduct/",
alt = "Contributor Covenant 3.0 Code of Conduct"
)
)
```
Contributions are welcome! Whether you want to report bugs, suggest features, or improve the code or documentation, your input is highly valued. Please check the [issues tab](https://github.com/danielvartan/brandr/issues) for existing issues or to open a new one.
[](https://github.com/sponsors/danielvartan)
You can also support the development of `brandr` by becoming a sponsor. Click [here](https://github.com/sponsors/danielvartan) to make a donation. Please mention `brandr` in your donation message.
## Acknowledgments
`brandr` is not affiliated with [Posit](https://posit.co/) or the developers of [brand.yml](https://posit-dev.github.io/brand-yml/).
`brandr` brand identity is based on [brand.yml](https://posit-dev.github.io/brand-yml/) brand identity.