Skip to content

Commit 5e9aa1e

Browse files
committed
use svg, fine tune styles
1 parent 77ee1f1 commit 5e9aa1e

File tree

4 files changed

+15
-33
lines changed

4 files changed

+15
-33
lines changed

templates/repo/home.tmpl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
</div>
2929
{{end}}
3030
</div>
31-
<div class="gt-mt-3" id="repo-topics">
31+
<div class="gt-df gt-ac gt-fw gt-mt-3" id="repo-topics">
3232
{{range .Topics}}<a class="ui repo-topic large label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
33-
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<button id="manage_topic" class="ui button tiny tertiary">{{.locale.Tr "repo.topic.manage_topics"}}</button>{{end}}
33+
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<button id="manage_topic" class="ui button tiny tertiary gt-ml-2">{{.locale.Tr "repo.topic.manage_topics"}}</button>{{end}}
3434
</div>
3535
{{end}}
3636
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
@@ -43,9 +43,8 @@
4343
>
4444
<input type="hidden" name="topics" value="{{range $i, $v := .Topics}}{{.Name}}{{if lt (Add $i 1) (len $.Topics)}},{{end}}{{end}}">
4545
{{range .Topics}}
46-
{{/* lalels generated by Fomantic still use `<i class="delete icon">`, to avoid mixing different style together and to remind future developers, use it instead of svg
47-
and keep the same as template (repo-topic-label), the style is also added by Fomantic Dropdown automatically when generating new labels */}}
48-
<div class="ui small label topic transition visible" data-value="{{.Name}}" style="display: inline-block !important;">{{.Name}}<i class="delete icon"></i></div>
46+
{{/* keep the same as template (repo-topic-label), the style "display" is also added by Fomantic Dropdown automatically when generating new labels */}}
47+
<div class="ui small label topic transition visible gt-cursor-default" data-value="{{.Name}}" style="display: inline-block !important;">{{.Name}}{{svg "octicon-x" 16 "delete icon gt-ml-3 gt-mt-1"}}</div>
4948
{{end}}
5049
<div class="text"></div>
5150
</div>

web_src/js/features/repo-home.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import $ from 'jquery';
22
import {stripTags} from '../utils.js';
33
import {hideElem, showElem} from '../utils/dom.js';
44
import {htmlEscape} from 'escape-goat';
5+
import {svg} from '../svg.js';
56

67
const {appSubUrl, csrfToken} = window.config;
78

@@ -21,16 +22,16 @@ export function initRepoTopicBar() {
2122
};
2223

2324
function addLabelDeleteIconAria($el) {
24-
$el.attr({
25+
$el.removeAttr('aria-hidden').attr({
2526
'aria-label': topicPrompts.remove,
2627
'role': 'button',
27-
}).addClass('gt-px-2'); // make it slightly larger to be easier to click on mobile
28+
});
2829
}
2930

3031
mgrBtn.on('click', () => {
3132
hideElem(topicListDiv);
3233
showElem(topicForm);
33-
addLabelDeleteIconAria(topicDropdown.find('i.delete.icon'));
34+
addLabelDeleteIconAria(topicDropdown.find('.delete.icon'));
3435
topicDropdownSearch.focus();
3536
});
3637

@@ -151,9 +152,9 @@ export function initRepoTopicBar() {
151152
onLabelCreate(value) {
152153
value = value.toLowerCase().trim();
153154
// `this` is the default label jQuery element, it's "<a class="ui small label">"
154-
// we create a new div element to replace it, to keep the same as template (repo-topic-label), because we do not want the `<a>` tag to affect aria focus.
155-
const $el = $(`<div class="ui small label topic" data-value="${htmlEscape(value)}">${htmlEscape(value)}<i class="delete icon"></i></div>`);
156-
addLabelDeleteIconAria($el.find('i.delete.icon'));
155+
// we create a new div element to replace it, to keep the same as template (repo-topic-label), because we do not want the `<a>` tag which affects aria focus.
156+
const $el = $(`<div class="ui small label topic gt-cursor-default" data-value="${htmlEscape(value)}">${htmlEscape(value)}${svg('octicon-x', 16, 'delete icon gt-ml-3 gt-mt-1')}</div>`);
157+
addLabelDeleteIconAria($el.find('.delete.icon'));
157158
return $el;
158159
},
159160
onAdd(addedValue, _addedText, $addedChoice) {

web_src/less/_repository.less

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,21 +3010,10 @@ tbody.commit-list {
30103010
top: -2px;
30113011
}
30123012

3013-
#topic_edit {
3014-
margin-top: 5px;
3015-
}
3016-
3017-
#repo-topics {
3018-
margin-top: 5px;
3019-
display: flex;
3020-
align-items: center;
3021-
flex-wrap: wrap;
3022-
}
3023-
3024-
.repo-topic {
3025-
font-weight: normal !important;
3013+
#repo-topics .repo-topic {
3014+
font-weight: normal;
30263015
cursor: pointer;
3027-
margin: 2px !important;
3016+
margin: 2px;
30283017
}
30293018

30303019
#new-dependency-drop-list {
@@ -3042,14 +3031,6 @@ tbody.commit-list {
30423031
}
30433032
}
30443033

3045-
.label + #manage_topic {
3046-
margin-left: 5px;
3047-
}
3048-
3049-
.ui.small.label.topic {
3050-
margin-bottom: 4px;
3051-
}
3052-
30533034
.repo-header {
30543035
display: flex;
30553036
align-items: center;

web_src/less/helpers.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/* below class names match Tailwind CSS */
2222
.gt-pointer-events-none { pointer-events: none !important; }
2323
.gt-relative { position: relative !important; }
24+
.gt-cursor-default { cursor: default !important; }
2425

2526
.gt-mono {
2627
font-family: var(--fonts-monospace) !important;

0 commit comments

Comments
 (0)