Skip to content

Commit 2fd78c1

Browse files
silverwindlafrikstechknowlogick
authored
Move jquery-minicolors to npm/webpack (#12305)
* Move jquery-minicolors to npm/webpack - Unvendor and add as npm dependency - Removed unneeded backend variable - Fixed existing bug where picker would previously initizalize to the same green color when editing a label. There was probably a version bump because the previous version was over 3 years old but it seems to be compatible. * use file-loader * trailing comma and comment update * misc tweaks Co-authored-by: Lauris BH <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 2f6aadf commit 2fd78c1

File tree

15 files changed

+36
-366
lines changed

15 files changed

+36
-366
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ coverage.all
7979
/public/serviceworker.js
8080
/public/css
8181
/public/fonts
82+
/public/img/webpack
8283
/web_src/fomantic/build
8384
/VERSION
8485
/.air

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ FOMANTIC_DEST_DIR := web_src/fomantic/build
9696
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f) $(FOMANTIC_DEST)
9797
WEBPACK_CONFIGS := webpack.config.js
9898
WEBPACK_DEST := public/js/index.js public/css/index.css
99-
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/serviceworker.js
99+
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
100100

101101
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
102102
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))

package-lock.json

Lines changed: 5 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@babel/plugin-transform-runtime": "7.10.5",
1111
"@babel/preset-env": "7.10.4",
1212
"@babel/runtime": "7.10.5",
13+
"@claviska/jquery-minicolors": "2.3.5",
1314
"@primer/octicons": "10.0.0",
1415
"babel-loader": "8.1.0",
1516
"clipboard": "2.0.6",

public/vendor/plugins/jquery.minicolors/LICENSE

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

public/vendor/plugins/jquery.minicolors/jquery.minicolors.css

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

public/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js

Lines changed: 0 additions & 11 deletions
This file was deleted.
Binary file not shown.

routers/org/setting.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ func DeleteWebhook(ctx *context.Context) {
202202
func Labels(ctx *context.Context) {
203203
ctx.Data["Title"] = ctx.Tr("repo.labels")
204204
ctx.Data["PageIsOrgSettingsLabels"] = true
205-
ctx.Data["RequireMinicolors"] = true
206205
ctx.Data["RequireTribute"] = true
207206
ctx.Data["LabelTemplates"] = models.LabelTemplates
208207
ctx.HTML(200, tplSettingsLabels)

routers/repo/issue_label.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func Labels(ctx *context.Context) {
2323
ctx.Data["Title"] = ctx.Tr("repo.labels")
2424
ctx.Data["PageIsIssueList"] = true
2525
ctx.Data["PageIsLabels"] = true
26-
ctx.Data["RequireMinicolors"] = true
2726
ctx.Data["RequireTribute"] = true
2827
ctx.Data["LabelTemplates"] = models.LabelTemplates
2928
ctx.HTML(200, tplLabels)

templates/base/footer.tmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
{{end}}
3131
{{end}}
3232
<script src="{{StaticUrlPrefix}}/js/index.js?v={{MD5 AppVer}}"></script>
33-
{{if .RequireMinicolors}}
34-
<script src="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.min.js"></script>
35-
{{end}}
3633
{{template "custom/footer" .}}
3734
</body>
3835
</html>

templates/base/head.tmpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
UseServiceWorker: {{UseServiceWorker}},
6767
csrf: '{{.CsrfToken}}',
6868
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
69-
Minicolors: {{if .RequireMinicolors}}true{{else}}false{{end}},
7069
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
7170
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
7271
U2F: {{if .RequireU2F}}true{{else}}false{{end}},
@@ -101,9 +100,6 @@
101100
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
102101
</style>
103102
</noscript>
104-
{{if .RequireMinicolors}}
105-
<link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css">
106-
{{end}}
107103
<style class="list-search-style"></style>
108104
{{if .PageIsUserProfile}}
109105
<meta property="og:title" content="{{.Owner.Name}}" />

web_src/js/features/colorpicker.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default async function createColorPicker($els) {
2+
if (!$els || !$els.length) return;
3+
4+
await Promise.all([
5+
import(/* webpackChunkName: "minicolors" */'@claviska/jquery-minicolors'),
6+
import(/* webpackChunkName: "minicolors" */'@claviska/jquery-minicolors/jquery.minicolors.css'),
7+
]);
8+
9+
$els.minicolors();
10+
}

web_src/js/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import initServiceWorker from './features/serviceworker.js';
1515
import initMarkdownAnchors from './markdown/anchors.js';
1616
import renderMarkdownContent from './markdown/content.js';
1717
import attachTribute from './features/tribute.js';
18+
import createColorPicker from './features/colorpicker.js';
1819
import createDropzone from './features/dropzone.js';
1920
import initTableSort from './features/tablesort.js';
2021
import ActivityTopAuthors from './components/ActivityTopAuthors.vue';
@@ -134,15 +135,15 @@ function initLabelEdit() {
134135
$newLabelPanel.hide();
135136
});
136137

137-
$('.color-picker').each(function () {
138-
$(this).minicolors();
139-
});
138+
createColorPicker($('.color-picker'));
139+
140140
$('.precolors .color').on('click', function () {
141141
const color_hex = $(this).data('color-hex');
142142
$('.color-picker').val(color_hex);
143143
$('.minicolors-swatch-color').css('background-color', color_hex);
144144
});
145145
$('.edit-label-button').on('click', function () {
146+
$('.color-picker').minicolors('value', $(this).data('color'));
146147
$('#label-modal-id').val($(this).data('id'));
147148
$('.edit-label .new-label-input').val($(this).data('title'));
148149
$('.edit-label .new-label-desc-input').val($(this).data('description'));

0 commit comments

Comments
 (0)