Skip to content

Commit 90aca5f

Browse files
authored
Merge pull request #435 from facultyai/r-themes
Export R themes without running function on package load
2 parents aa2f45f + 355cbd4 commit 90aca5f

File tree

6 files changed

+186
-37
lines changed

6 files changed

+186
-37
lines changed

.Rbuildignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ demo/.*\.js
2020
demo/.*\.html
2121
demo/.*\.css
2222

23-
# ignore python files/folders
23+
# ignore Python files/folders
2424
setup.py
2525
usage.py
2626
setup.py

R/themes.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.prependBootswatch <- function(suffix) {
2+
BOOTSWATCH_BASE <- "https://stackpath.bootstrapcdn.com/bootswatch/4.5.0/"
3+
return(paste(BOOTSWATCH_BASE, suffix, sep=""))
4+
}
5+
6+
#' @export'
7+
dbcThemes <- list(
8+
BOOTSTRAP = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css",
9+
GRID = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap-grid.min.css",
10+
CERULEAN = .prependBootswatch("cerulean/bootstrap.min.css"),
11+
COSMO = .prependBootswatch("cosmo/bootstrap.min.css"),
12+
CYBORG = .prependBootswatch("cyborg/bootstrap.min.css"),
13+
DARKLY = .prependBootswatch("darkly/bootstrap.min.css"),
14+
FLATLY = .prependBootswatch("flatly/bootstrap.min.css"),
15+
JOURNAL = .prependBootswatch("journal/bootstrap.min.css"),
16+
LITERA = .prependBootswatch("litera/bootstrap.min.css"),
17+
LUMEN = .prependBootswatch("lumen/bootstrap.min.css"),
18+
LUX = .prependBootswatch("lux/bootstrap.min.css"),
19+
MATERIA = .prependBootswatch("materia/bootstrap.min.css"),
20+
MINTY = .prependBootswatch("minty/bootstrap.min.css"),
21+
PULSE = .prependBootswatch("pulse/bootstrap.min.css"),
22+
SANDSTONE = .prependBootswatch("sandstone/bootstrap.min.css"),
23+
SIMPLEX = .prependBootswatch("simplex/bootstrap.min.css"),
24+
SKETCHY = .prependBootswatch("sketchy/bootstrap.min.css"),
25+
SLATE = .prependBootswatch("slate/bootstrap.min.css"),
26+
SOLAR = .prependBootswatch("solar/bootstrap.min.css"),
27+
SPACELAB = .prependBootswatch("spacelab/bootstrap.min.css"),
28+
SUPERHERO = .prependBootswatch("superhero/bootstrap.min.css"),
29+
UNITED = .prependBootswatch("united/bootstrap.min.css"),
30+
YETI = .prependBootswatch("yeti/bootstrap.min.css")
31+
)

R/zzz.R

Lines changed: 0 additions & 33 deletions
This file was deleted.

gulpfile.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const {dest, parallel, series, src} = require('gulp');
22
const del = require('del');
33
const mkdirp = require('mkdirp');
44
const rename = require('gulp-rename');
5+
const footer = require('gulp-footer');
56

67
function cleanLib() {
78
mkdirp.sync('lib');
@@ -42,5 +43,16 @@ function copyGeneratedFiles() {
4243
.pipe(dest('dash_bootstrap_components/_components'));
4344
}
4445

45-
exports.default = series(copyGeneratedFiles, cleanGeneratedFiles);
46+
function addThemesToRNamespace() {
47+
return src('NAMESPACE')
48+
.pipe(footer('export(dbcThemes)'))
49+
.pipe(dest('.', {overwrite: true}));
50+
}
51+
52+
exports.postPyBuild = series(copyGeneratedFiles, cleanGeneratedFiles);
4653
exports.clean = parallel(cleanGeneratedFiles, cleanComponents, cleanLib);
54+
exports.postRBuild = series(
55+
copyGeneratedFiles,
56+
cleanGeneratedFiles,
57+
addThemesToRNamespace
58+
);

package-lock.json

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"build": "run-s clean build:js build:py build:r",
99
"build:lib": "webpack --config=webpack/config.lib.js",
1010
"build:js": "NODE_ENV=production webpack --config=webpack/config.dist.js",
11-
"build:py": "dash-generate-components ./src/components dash_bootstrap_components && gulp",
12-
"build:r": "dash-generate-components ./src/components dash_bootstrap_components --r-prefix 'dbc' && gulp",
11+
"build:py": "dash-generate-components ./src/components dash_bootstrap_components && gulp postPyBuild",
12+
"build:r": "dash-generate-components ./src/components dash_bootstrap_components --r-prefix 'dbc' && gulp postRBuild",
1313
"clean": "gulp clean",
1414
"demo": "webpack-dev-server --hot --inline --port=8888 --config=webpack/config.demo.js",
1515
"format": "prettier src/**/*.js --write",
@@ -46,6 +46,7 @@
4646
"css-loader": "^1.0.1",
4747
"del": "^5.1.0",
4848
"gulp": "^4.0.2",
49+
"gulp-footer": "^2.0.2",
4950
"gulp-rename": "^2.0.0",
5051
"jest": "^24.9.0",
5152
"mkdirp": "^0.5.4",

0 commit comments

Comments
 (0)