Garrick Aden-Buie 7 лет назад
Родитель
Сommit
6c95b33df8
6 измененных файлов: 69 добавлений и 8 удалений
  1. +7
    -8
      R/show_colors.R
  2. +47
    -0
      README.Rmd
  3. +15
    -0
      README.md
  4. Двоичные данные
      docs/palettes-1.png
  5. Двоичные данные
      docs/palettes-2.png
  6. Двоичные данные
      docs/palettes-3.png

+ 7
- 8
R/show_colors.R Просмотреть файл

@@ -1,22 +1,21 @@
library(tidyverse)

read_colors <- function(file) {
library(dplyr)
text <- readLines(file, warn = FALSE) %>%
str_subset("#[0-9a-fA-F]{6}") # must be len-6 hex
stringr::str_subset("#[0-9a-fA-F]{6}") # must be len-6 hex
str_match_all(text, "\\$(.+)\\s*:\\s*(#[0-9a-fA-F]{6});") %>%
discard(~ length(.) < 1) %>%
map_dfr(~ tibble(name = .[, 2], color = .[, 3])) %>%
stringr::str_match_all(text, "\\$(.+)\\s*:\\s*(#[0-9a-fA-F]{6});") %>%
purrr::discard(~ length(.) < 1) %>%
purrr::map_dfr(~ tibble(name = .[, 2], color = .[, 3])) %>%
distinct(name, color) %>%
mutate(name = factor(name, unique(name)))
}


show_colors <- function(colors) {
show_colors <- function(colors, ...) {
ggplot(colors) +
aes(1, 1, fill = color) +
geom_tile() +
facet_wrap(~ name + color) +
facet_wrap(~ name + color, ...) +
scale_fill_identity() +
theme_void()
}

+ 47
- 0
README.Rmd Просмотреть файл

@@ -0,0 +1,47 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
echo = FALSE,
warning = FALSE, message = FALSE,
fig.path = "docs/"
)
```
# RStudio Themes

<!-- badges: start -->
<!-- badges: end -->

`rstudio-scss` provides SCSS/SASS templates for full RStudio themes for RStudio version 1.2 (and possibly RStudio 1.2+).

## Palettes

```{r palettes, echo=FALSE, results="asis", fig.width=10, fig.height=4}
library(ggplot2)
source("R/make_functions.R")
source("R/show_colors.R")

themes <- list(
"Solarized" = "_solarized.scss",
"Nord" = "_nord.scss",
"Oceanic Plus" = "_oceanic-plus.scss"
)

for (theme in names(themes)) {
theme_file <- fs::path("src", "palettes", themes[[theme]])
colors <- read_colors(theme_file)
g <- show_colors(colors, ncol = 8) +
ggtitle(theme) +
coord_equal() +
theme(
plot.title = element_text(size = rel(2), hjust = 0.5, margin = margin(t = 20, b = 10))
)
print(g)
}
```

+ 15
- 0
README.md Просмотреть файл

@@ -0,0 +1,15 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# RStudio Themes

<!-- badges: start -->

<!-- badges: end -->

`rstudio-scss` provides SCSS/SASS templates for full RStudio themes for
RStudio version 1.2 (and possibly RStudio 1.2+).

## Palettes

![](docs/palettes-1.png)<!-- -->![](docs/palettes-2.png)<!-- -->![](docs/palettes-3.png)<!-- -->

Двоичные данные
docs/palettes-1.png Просмотреть файл

Before After
Width: 960  |  Height: 384  |  Size: 28KB

Двоичные данные
docs/palettes-2.png Просмотреть файл

Before After
Width: 960  |  Height: 384  |  Size: 25KB

Двоичные данные
docs/palettes-3.png Просмотреть файл

Before After
Width: 960  |  Height: 384  |  Size: 29KB

Загрузка…
Отмена
Сохранить