-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.qmd
173 lines (122 loc) Β· 6.77 KB
/
README.qmd
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
# 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(brandr)
source(here::here("R", ".setup.R"))
```
<!-- badges: start -->
[](https://www.repostatus.org/#active)
[](https://CRAN.R-project.org/package=brandr)
[](https://doi.org/10.32614/CRAN.package.brandr)
[](https://danielvartan.shinyapps.io/cran-logs/?package=brandr)
[](https://lifecycle.r-lib.org/articles/stages.html#maturing)
[](https://github.com/danielvartan/brandr/actions/workflows/check-standard.yaml)
[](https://app.codecov.io/gh/danielvartan/brandr?branch=main)
[](https://opensource.org/license/mit)
[](https://www.contributor-covenant.org/version/2/1/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.
**Please note that `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"
)
```
## 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
Currently, `brandr` does not support the use of custom fonts directly. This feature is planned for future releases.
In the meantime, you can use Yixuan Qiu's [`showtext`](https://doi.org/10.32614/CRAN.package.showtext) R package to apply custom fonts/typefaces to your plots.
Below is an example of how to use the Google Font [Open Sans](https://fonts.google.com/specimen/Open+Sans) in all of your plots. 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
[](https://opensource.org/license/mit)
`brandr` code is released under the [MIT license](https://opensource.org/license/mit).
## Contributing
Contributions are welcome, including bug reports. Take a moment to review the [Guidelines for Contributing](https://danielvartan.github.io/brandr/CONTRIBUTING.html).
## Acknowledgments
`brandr` brand identity is based on [brand.yml](https://posit-dev.github.io/brand-yml/) brand identity.
<br>
Become a `brandr` supporter!
Click [here](https://github.com/sponsors/danielvartan) to make a donation. Please indicate the `brandr` package in your donation message.