Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow labels to contain emoji #6063

Merged
merged 7 commits into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ issues.label_templates.info = No labels exist yet. Create a label with 'New Labe
issues.label_templates.helper = Select a label set
issues.label_templates.use = Use Label Set
issues.label_templates.fail_to_load_file = Failed to load label template file '%s': %v
issues.add_label_at = added the <div class="ui label" style="color: %s\; background-color: %s">%s</div> label %s
issues.remove_label_at = removed the <div class="ui label" style="color: %s\; background-color: %s">%s</div> label %s
issues.add_label_at = added the <div class="ui label has-emoji" style="color: %s\; background-color: %s">%s</div> label %s
issues.remove_label_at = removed the <div class="ui label has-emoji" style="color: %s\; background-color: %s">%s</div> label %s
issues.add_milestone_at = `added this to the <b>%s</b> milestone %s`
issues.change_milestone_at = `modified the milestone from <b>%s</b> to <b>%s</b> %s`
issues.remove_milestone_at = `removed this from the <b>%s</b> milestone %s`
Expand Down
2 changes: 1 addition & 1 deletion public/css/index.css

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions public/less/_emojify.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.emoji {
width: 1.5em;
height: 1.5em;
display: inline-block;
background-size: contain;
}
.emoji {
width: 1.5em;
height: 1.5em;
display: inline-block;
background-size: contain;
}

.ui.label .emoji {
height: 1.2em !important;
}
1 change: 1 addition & 0 deletions routers/repo/issue_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func Labels(ctx *context.Context) {
ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsLabels"] = true
ctx.Data["RequireMinicolors"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["LabelTemplates"] = models.LabelTemplates
ctx.HTML(200, tplLabels)
}
Expand Down
18 changes: 14 additions & 4 deletions templates/base/footer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@
}
return itemStr;
}
})
issuesTribute.attach(document.getElementById('content'))
});
var content = document.getElementById('content');
if (content != null) {
issuesTribute.attach(content);
}
</script>
<script>
var emojiTribute = new Tribute({
Expand All @@ -93,15 +96,22 @@
return item;
},
selectTemplate: function (item) {
if (typeof item === 'undefinied') return null;
if (typeof item === 'undefined') return null;
return ':' + item.original + ':';
},
menuItemTemplate: function (item) {
return '<img class="emoji" src="{{AppSubUrl}}/vendor/plugins/emojify/images/' + item.original + '.png"/>' + item.original;
}
}]
});
emojiTribute.attach(document.getElementById('content'))
var emojiInputs = document.querySelectorAll('.emoji-input');
if (emojiInputs.length > 0) {
emojiTribute.attach(emojiInputs);
}
var content = document.getElementById('content');
if (content != null) {
emojiTribute.attach(document.getElementById('content'));
}
</script>
{{end}}
<script src="{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions templates/repo/issue/labels.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="ui grid">
<div class="three wide column">
<div class="ui small input">
<input class="new-label-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
<input class="new-label-input emoji-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
</div>
</div>
<div class="five wide column">
Expand Down Expand Up @@ -98,7 +98,7 @@
<li class="item">
<div class="ui grid">
<div class="three wide column">
<div class="ui label" style="color: {{.ForegroundColor}}; background-color: {{.Color}}"><i class="octicon octicon-tag"></i> {{.Name}}</div>
<div class="ui label has-emoji" style="color: {{.ForegroundColor}}; background-color: {{.Color}}"><i class="octicon octicon-tag"></i> {{.Name}}</div>
</div>
<div class="seven wide column">
{{.Description}}
Expand Down Expand Up @@ -151,7 +151,7 @@
<div class="ui grid">
<div class="three wide column">
<div class="ui small input">
<input class="new-label-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
<input class="new-label-input emoji-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
</div>
</div>
<div class="five wide column">
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<a class="ui label" href="{{$.RepoLink}}/src/branch/{{.Ref}}">{{.Ref}}</a>
{{end}}
{{range .Labels}}
<a class="ui label" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
<a class="ui label has-emoji" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
{{end}}

{{if .NumComments}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
<div class="filter menu" data-id="#label_ids">
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_labels"}}</div>
{{range .Labels}}
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
<a class="{{if .IsChecked}}checked{{end}} item has-emoji" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
{{end}}
</div>
</div>
<div class="ui labels list">
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
{{range .Labels}}
<a class="{{if not .IsChecked}}hide{{end}} item" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}"><span class="label color" style="background-color: {{.Color}}"></span> <span class="text">{{.Name}}</span></a>
<a class="{{if not .IsChecked}}hide{{end}} item" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}"><span class="label color" style="background-color: {{.Color}}"></span> <span class="text has-emoji">{{.Name}}</span></a>
{{end}}
</div>

Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="filter menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/labels">
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_labels"}}</div>
{{range .Labels}}
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
<a class="{{if .IsChecked}}checked{{end}} item has-emoji" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
{{if .Description }}<br><small class="desc">{{.Description}}</small>{{end}}</a>
{{end}}
</div>
Expand All @@ -19,7 +19,7 @@
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
{{range .Labels}}
<div class="item">
<a class="ui label {{if not .IsChecked}}hide{{end}}" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
<a class="ui label has-emoji {{if not .IsChecked}}hide{{end}}" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
</div>

{{end}}
Expand Down