Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit fb06ae1

Browse files
authored
Merge pull request #29 from ga4gh/add-theme-config
Add theme config; fixes #25
2 parents f332726 + bd60470 commit fb06ae1

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

src/lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const localConfig = {
1313
docsRoot: userConfig.docsRoot || 'docs',
1414
uiRoot: userConfig.uiRoot || 'swagger-ui',
1515
redocRoot: userConfig.redocRoot || 'redoc-ui',
16+
redocTheme: userConfig.redocTheme || 'default',
1617
defaultBranch: userConfig.defaultBranch || 'master',
1718
branchPathBase: userConfig.branchPath || 'preview',
1819
contactUrl: userConfig.contactUrl || ''

src/lib/redoc-ui.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,29 @@
33
import shell from 'shelljs';
44
import path from 'path';
55
import config from './config';
6+
import themes from './theme';
67
import Log from './log';
78

89
const log = new Log();
910
var OPENAPI_YAML_PATH = path.join(config.branchPath, 'openapi.yaml');
1011

12+
const constructOptsArg = (themes, themeName) => {
13+
if (themeName == 'default') {
14+
return '';
15+
} else {
16+
let argStr = `--options='${JSON.stringify(themes[themeName])}'`;
17+
return argStr
18+
}
19+
}
20+
1121
const setupUI = () => {
22+
var redocOpts = constructOptsArg(themes, config.redocTheme);
1223
var uiPath = path.join(config.branchPath, config.docsRoot);
1324
shell.mkdir('-p', uiPath);
1425
var indexPath = path.join(uiPath, 'index.html');
1526
log.log(`Generating OpenAPI docs index at '${indexPath}'`);
1627
shell.exec(
17-
`redoc-cli bundle --output ${indexPath} ${OPENAPI_YAML_PATH}`
28+
`redoc-cli bundle --output ${indexPath} ${OPENAPI_YAML_PATH} ${redocOpts}`
1829
);
1930
log.preview({
2031
'title': 'OpenAPI docs folder contents',

src/lib/theme.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const ga4gh_theme = {
2+
"pathInMiddlePanel": true,
3+
"theme": {
4+
"spacing": {
5+
"sectionVertical": 10
6+
},
7+
"colors": {
8+
"primary": {
9+
"main": "rgba(27, 117, 187, 1)",
10+
"light": "rgba(99, 162, 211, 1)",
11+
"dark": "rgba(6, 71, 121, 1)",
12+
"contrastText": "#fff"
13+
},
14+
"success": {
15+
"main": "rgba(141, 198, 62, 1)",
16+
"light": "rgba(201, 240, 147, 1)",
17+
"dark": "rgba(83, 136, 10, 1)",
18+
"contrastText": "#000"
19+
},
20+
"warning": {
21+
"main": "rgba(250, 166, 51, 1)",
22+
"light": "rgba(255, 203, 131, 1)",
23+
"dark": "rgba(173, 101, 1, 1)",
24+
"contrastText": "#000"
25+
},
26+
"error": {
27+
"main": "rgba(227, 74, 58, 1)",
28+
"light": "rgba(255, 151, 140, 1)",
29+
"dark": "rgba(155, 20, 6, 1)",
30+
"contrastText": "#000"
31+
},
32+
"http": {
33+
"get": "rgba(107, 189, 91, 1)"
34+
}
35+
},
36+
"typography": {
37+
"links": {
38+
"color": "rgba(144, 98, 165, 1)",
39+
"visited": "rgba(144, 98, 165, 1)",
40+
"hover": "rgba(159, 121, 176, 1)"
41+
},
42+
"code": {
43+
"color": "rgba(227, 74, 58, 1)"
44+
}
45+
},
46+
"rightPanel": {
47+
"backgroundColor": "rgba(66, 66, 66, 1)",
48+
"textColor": "rgba(255, 255, 255, 1)"
49+
},
50+
"codeSample": {
51+
"backgroundColor": "rgba(34, 31, 31, 1)"
52+
},
53+
"menu": {
54+
"backgroundColor": "rgba(246, 246, 248, 1)"
55+
}
56+
}
57+
}
58+
59+
const themes = {
60+
ga4gh: ga4gh_theme
61+
};
62+
63+
export default themes;

0 commit comments

Comments
 (0)