Skip to content

Commit aa6c6a1

Browse files
authored
Merge pull request #12 from st3phhays/choco-theme/release/0.1.0
(#10)(#11) choco-theme JavaScript and Bootstrap
2 parents 076babc + 6b63855 commit aa6c6a1

File tree

7 files changed

+3162
-1011
lines changed

7 files changed

+3162
-1011
lines changed

bundleconfig.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
{
99
"outputFileName": "assets/js/chocolatey-head.bundle.js",
1010
"inputFiles": [
11-
"node_modules/choco-theme/js/chocolatey-theme-toggle-head.js"
11+
"assets/js/temp/chocolatey-theme-toggle-head.js"
1212
]
1313
},
1414
{
1515
"outputFileName": "assets/js/chocolatey.bundle.js",
1616
"inputFiles": [
17-
"node_modules/choco-theme/js/chocolatey-theme-toggle.js",
18-
"node_modules/choco-theme/js/chocolatey-tables.js",
19-
"node_modules/choco-theme/js/chocolatey-inputs.js"
17+
"assets/js/temp/init/chocolatey-zendesk.js"
2018
]
2119
}
2220
]

global-partials/themetoggle.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ partial: themetoggle
55
<input id="themeToggle" class="toggle-checkbox theme-toggle" type="checkbox" aria-label="Toggle theme settings" />
66
<div class="toggle-slot">
77
<div class="sun-icon-wrapper">
8-
<div class="sun-icon fas fa-sun"></div>
8+
<div class="sun-icon fa-solid fa-sun"></div>
99
</div>
1010
<div class="toggle-button"></div>
1111
<div class="moon-icon-wrapper">
12-
<div class="moon-icon fas fa-moon"></div>
12+
<div class="moon-icon fa-solid fa-moon"></div>
1313
</div>
1414
</div>

gulpfile.js

Lines changed: 94 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
'use strict';
22

3-
const gulp = require('gulp'),
4-
babel = require('gulp-babel'),
5-
concat = require('gulp-concat'),
6-
cleancss = require('gulp-clean-css'),
7-
uglify = require('gulp-uglify-es').default,
8-
sass = require('gulp-sass')(require('sass')),
9-
clean = require('gulp-clean'),
10-
purgecss = require('gulp-purgecss'),
11-
rename = require('gulp-rename'),
12-
merge = require('merge-stream'),
13-
injectstring = require('gulp-inject-string'),
14-
inlinesource = require('gulp-inline-source'),
15-
bundleconfig = require('./bundleconfig.json'),
16-
zendeskconfig = require('./zendeskconfig.json'),
17-
fs = require('fs');
3+
const concat = require('gulp-concat');
4+
const cleancss = require('gulp-clean-css');
5+
const uglify = require('gulp-uglify-es').default;
6+
const sass = require('gulp-sass')(require('sass'));
7+
const clean = require('gulp-clean');
8+
const purgecss = require('gulp-purgecss');
9+
const rename = require('gulp-rename');
10+
const merge = require('merge-stream');
11+
const injectstring = require('gulp-inject-string');
12+
const browserify = require('browserify');
13+
const babelify = require('babelify');
14+
const source = require('vinyl-source-stream');
15+
const buffer = require('vinyl-buffer');
16+
const util = require('gulp-util');
17+
const inlinesource = require('gulp-inline-source');
18+
const bundleconfig = require('./bundleconfig.json');
19+
const zendeskconfig = require('./zendeskconfig.json');
20+
// const fs = require('fs');
1821

1922
const editFilePartial = 'Edit this file at https://github.com/chocolatey/choco-theme/partials';
20-
const { series, parallel, src, dest, watch } = require('gulp');
23+
const { series, parallel, src, dest } = require('gulp');
2124

2225
const regex = {
2326
css: /\.css$/,
@@ -33,105 +36,109 @@ const paths = {
3336
theme: 'node_modules/choco-theme/'
3437
};
3538

36-
const getBundles = (regexPattern) => {
39+
const getBundles = regexPattern => {
3740
return bundleconfig.filter(bundle => {
3841
return regexPattern.test(bundle.outputFileName);
3942
});
4043
};
4144

42-
const getZendeskBundles = (regexPattern) => {
45+
const getZendeskBundles = regexPattern => {
4346
return zendeskconfig.filter(bundle => {
4447
return regexPattern.test(bundle.outputFileName);
4548
});
4649
};
4750

48-
function del() {
51+
const del = () => {
4952
return src([
50-
paths.assets + 'css',
51-
paths.assets + 'js',
53+
`${paths.assets}css`,
54+
`${paths.assets}js`,
5255
paths.partials
5356
], { allowEmpty: true })
5457
.pipe(clean({ force: true }));
55-
}
58+
};
5659

57-
function copyTheme() {
58-
var copyThemeToggleHbs = src(paths.theme + 'partials/ThemeToggle.txt')
59-
.pipe(injectstring.prepend('---\npartial: themetoggle\n---\n{{!-- ' + editFilePartial + ' --}}\n'))
60+
const copyTheme = () => {
61+
const copyThemeToggleHbs = src(`${paths.theme}partials/ThemeToggle.txt`)
62+
.pipe(injectstring.prepend(`---\npartial: themetoggle\n---\n{{!-- ${editFilePartial} --}}\n`))
6063
.pipe(rename({ basename: 'themetoggle', extname: '.hbs' }))
6164
.pipe(dest(paths.partials));
6265

63-
return merge(copyThemeToggleHbs);
64-
}
66+
const copyChocoThemeJs = src(`${paths.theme}js/**/*.js`)
67+
.pipe(dest(`${paths.assets}js/temp`));
6568

66-
function compileSass() {
67-
return src(paths.theme + 'scss/zendesk.scss')
68-
.pipe(sass().on('error', sass.logError))
69-
.pipe(dest(paths.assets + 'css'));
70-
}
69+
return merge(copyThemeToggleHbs, copyChocoThemeJs);
70+
};
7171

72-
function compileJs() {
73-
var tasks = getBundles(regex.js).map(function (bundle) {
72+
const compileSass = () => {
73+
return src(`${paths.theme}scss/zendesk.scss`)
74+
.pipe(sass().on('error', sass.logError))
75+
.pipe(dest(`${paths.assets}css`));
76+
};
7477

75-
return src(bundle.inputFiles, { base: '.' })
76-
.pipe(babel({
77-
"sourceType": "unambiguous",
78-
"presets": [
79-
["@babel/preset-env", {
80-
"targets": {
81-
"ie": "10"
82-
}
83-
}
84-
]]
85-
}))
86-
.pipe(concat(bundle.outputFileName))
78+
const compileJs = () => {
79+
const tasks = getBundles(regex.js).map(bundle => {
80+
const b = browserify({
81+
entries: bundle.inputFiles,
82+
debug: true,
83+
transform: [babelify.configure({
84+
presets: [
85+
'@babel/preset-env',
86+
['@babel/preset-react', { runtime: 'automatic' }]
87+
],
88+
compact: false
89+
})]
90+
});
91+
92+
return b.bundle()
93+
.pipe(source(bundle.outputFileName))
94+
.pipe(buffer())
95+
.on('error', util.log)
8796
.pipe(dest('.'));
8897
});
8998

9099
return merge(tasks);
91-
}
92-
93-
function compileCss() {
94-
var tasks = getBundles(regex.css).map(function (bundle) {
100+
};
95101

102+
const compileCss = () => {
103+
const tasks = getBundles(regex.css).map(bundle => {
96104
return src(bundle.inputFiles, { base: '.' })
97105
.pipe(concat(bundle.outputFileName))
98106
.pipe(dest('.'));
99107
});
100108

101109
return merge(tasks);
102-
}
110+
};
103111

104-
function purgeCss() {
105-
return src(paths.assets + 'css/chocolatey.bundle.css')
112+
const purgeCss = () => {
113+
return src(`${paths.assets}css/chocolatey.bundle.css`)
106114
.pipe(purgecss({
107115
content: [
108-
paths.templates + '*.hbs',
109-
paths.globalpartials + '*.hbs',
110-
paths.assets + 'js/*.*',
111-
paths.assets + 'js/*.*.*',
112-
paths.assets + 'js/*.*.*.*'
116+
`${paths.templates}*.hbs`,
117+
`${paths.globalpartials}*.hbs`,
118+
`${paths.assets}js/*.*`,
119+
`${paths.assets}js/*.*.*`,
120+
`${paths.assets}js/*.*.*.*`
113121
],
114122
safelist: [
115-
'::-webkit-scrollbar',
116-
'::-webkit-scrollbar-thumb',
117-
'link-light',
118-
'main',
119-
'table-bordered',
120-
'table-striped',
121-
'table-responsive-sm',
122-
'table-responsive',
123+
'::-webkit-scrollbar',
124+
'::-webkit-scrollbar-thumb',
125+
'link-light',
126+
'main',
127+
'table-bordered',
128+
'table-striped',
129+
'table-responsive-sm',
130+
'table-responsive',
123131
'clear-button',
124132
'recent-activity-item-meta'
125133
],
126134
keyframes: true,
127135
variables: true
128136
}))
129-
.pipe(dest(paths.assets + 'css/'));
130-
}
131-
132-
function minCss() {
133-
var tasks = getBundles(regex.css).map(function (bundle) {
137+
.pipe(dest(`${paths.assets}css/`));
138+
};
134139

140+
const minCss = () => {
141+
const tasks = getBundles(regex.css).map(bundle => {
135142
return src(bundle.outputFileName, { base: '.' })
136143
.pipe(cleancss({
137144
level: 2,
@@ -142,49 +149,48 @@ function minCss() {
142149
});
143150

144151
return merge(tasks);
145-
}
146-
147-
function minJs() {
148-
var tasks = getBundles(regex.js).map(function (bundle) {
152+
};
149153

154+
const minJs = () => {
155+
const tasks = getBundles(regex.js).map(bundle => {
150156
return src(bundle.outputFileName, { base: '.' })
151157
.pipe(uglify())
152158
.pipe(rename({ suffix: '.min' }))
153159
.pipe(dest('.'));
154160
});
155161

156162
return merge(tasks);
157-
}
158-
159-
function zendeskCss() {
160-
var tasks = getZendeskBundles(regex.css).map(function (bundle) {
163+
};
161164

165+
const zendeskCss = () => {
166+
const tasks = getZendeskBundles(regex.css).map(bundle => {
162167
return src(bundle.inputFiles, { base: '.' })
163168
.pipe(concat(bundle.outputFileName))
164169
.pipe(dest('.'));
165170
});
166171

167172
return merge(tasks);
168-
}
173+
};
169174

170-
// If the JS/CSS included in the inline assets below need to be updated,
175+
// If the JS/CSS included in the inline assets below need to be updated,
171176
// replace the inline code with the tags specified above the function, and run `gulp`.
172177

173178
// document_head.hbs - <script type="text/javascript" src="../assets/js/chocolatey-head.bundle.min.js" inline></script>
174179
// footer.hbs - <script type="text/javascript" src="../assets/js/chocolatey.bundle.min.js" inline></script>
175-
function inlineAssets() {
176-
return src([paths.templates + 'footer.hbs', paths.templates + 'document_head.hbs'])
180+
const inlineAssets = () => {
181+
return src([`${paths.templates}footer.hbs`, `${paths.templates}document_head.hbs`])
177182
.pipe(inlinesource())
178183
.pipe(dest(paths.templates));
179-
}
184+
};
180185

181-
function delEnd() {
186+
const delEnd = () => {
182187
return src([
183-
paths.assets + 'css',
184-
paths.assets + 'js'
188+
`${paths.assets}css`,
189+
`${paths.assets}js`,
190+
`${paths.assets}js/temp`
185191
], { allowEmpty: true })
186192
.pipe(clean({ force: true }));
187-
}
193+
};
188194

189195
// Independednt tasks
190196
exports.del = del;
@@ -196,8 +202,3 @@ exports.compileZendesk = parallel(zendeskCss, inlineAssets);
196202

197203
// Gulp default
198204
exports.default = series(copyTheme, exports.compileSassJs, compileCss, purgeCss, exports.minCssJs, exports.compileZendesk, delEnd);
199-
200-
// Watch files
201-
exports.watchFiles = function () {
202-
watch([paths.theme], exports.default);
203-
};

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "choco-theme",
33
"author": "Chocolatey Software",
4-
"version": "101.1.0",
4+
"version": "101.2.0",
55
"api_version": 2,
66
"default_locale": "en-us",
77
"settings": [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@semantic-release/changelog": "^5.0.0",
1313
"@semantic-release/exec": "^5.0.0",
1414
"@semantic-release/git": "^9.0.0",
15-
"choco-theme": "git+https://github.com/chocolatey/choco-theme.git",
15+
"choco-theme": "0.1.6",
1616
"husky": "^4.2.3",
1717
"js-yaml": "^3.13.1",
1818
"semantic-release": "^17.0.4"

0 commit comments

Comments
 (0)