Commit 8fed318a authored by Florie Guibert's avatar Florie Guibert Committed by Heinrich Lee Yu

Use gitlab-ui classes for labels

- Style fixes
- Restructure scoped label
- Remove label render on delete label modal
parent a7edaa33
...@@ -13,15 +13,14 @@ ...@@ -13,15 +13,14 @@
.page-title, .page-title,
.modal-title { .modal-title {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
.modal-title-with-label span { .modal-title-with-label span {
vertical-align: middle; vertical-align: middle;
display: inline-block; display: inline-block;
} }
.gl-label {
vertical-align: top;
line-height: 16px;
}
} }
.modal-title { .modal-title {
......
...@@ -97,6 +97,8 @@ ...@@ -97,6 +97,8 @@
.color-label { .color-label {
padding: 4px $grid-size; padding: 4px $grid-size;
border-radius: $label-border-radius; border-radius: $label-border-radius;
margin-right: 4px;
margin-bottom: 4px;
} }
&:hover .color-label { &:hover .color-label {
...@@ -123,8 +125,7 @@ ...@@ -123,8 +125,7 @@
padding-right: $gl-padding-24; padding-right: $gl-padding-24;
} }
.scoped-label, .scoped-label {
.gl-label-icon {
right: 12px; right: 12px;
} }
} }
...@@ -166,8 +167,11 @@ ...@@ -166,8 +167,11 @@
} }
} }
.gl-label .gl-label-link:hover, a.gl-label-icon {
.gl-label + .gl-label-icon:hover { color: $gray-500;
}
.gl-label .gl-label-link:hover {
text-decoration: none; text-decoration: none;
color: inherit; color: inherit;
...@@ -176,6 +180,11 @@ ...@@ -176,6 +180,11 @@
} }
} }
.gl-label .gl-label-icon:hover {
text-decoration: none;
color: $gray-500;
}
.btn-link { .btn-link {
color: inherit; color: inherit;
outline: none; outline: none;
...@@ -825,6 +834,10 @@ ...@@ -825,6 +834,10 @@
} }
} }
} }
.gl-label-icon {
color: $gray-500;
}
} }
@media(max-width: map-get($grid-breakpoints, lg)-1) { @media(max-width: map-get($grid-breakpoints, lg)-1) {
......
...@@ -310,15 +310,13 @@ ...@@ -310,15 +310,13 @@
width: 150px; width: 150px;
flex-shrink: 0; flex-shrink: 0;
.scoped-label-wrapper,
.gl-label { .gl-label {
max-width: 100%; line-height: $gl-line-height;
}
.gl-label-text { .gl-label-scoped .gl-label-text:last-of-type {
text-overflow: ellipsis; padding-right: 22px;
max-width: 100%;
overflow: hidden;
white-space: nowrap;
}
} }
} }
...@@ -424,14 +422,6 @@ ...@@ -424,14 +422,6 @@
.scoped-label-wrapper { .scoped-label-wrapper {
max-width: 100%; max-width: 100%;
vertical-align: top; vertical-align: top;
line-height: 16px;
.gl-link.gl-label-icon {
color: $gray-500;
display: inline-flex;
align-items: center;
margin-left: 0.25rem;
}
.badge { .badge {
text-overflow: ellipsis; text-overflow: ellipsis;
...@@ -449,17 +439,13 @@ ...@@ -449,17 +439,13 @@
.scoped-label { .scoped-label {
position: absolute; position: absolute;
top: 6px; top: 4px;
right: 8px; right: 8px;
padding: 0; padding: 0;
margin: 0; margin: 0;
line-height: $gl-line-height; line-height: $gl-line-height;
} }
.gl-label-scoped-text {
padding-right: 22px;
}
&.board-label { &.board-label {
.scoped-label { .scoped-label {
top: 1px; top: 1px;
...@@ -467,10 +453,6 @@ ...@@ -467,10 +453,6 @@
} }
} }
.gl-label-sm + .scoped-label {
top: 2px;
}
.gl-label-scoped { .gl-label-scoped {
box-shadow: 0 0 0 2px currentColor inset; box-shadow: 0 0 0 2px currentColor inset;
......
...@@ -59,9 +59,19 @@ $status-box-line-height: 26px; ...@@ -59,9 +59,19 @@ $status-box-line-height: 26px;
} }
.issuable-row { .issuable-row {
span a { span {
color: $gl-text-color; a {
word-wrap: break-word; color: $gl-text-color;
word-wrap: break-word;
}
.gl-label-link {
color: inherit;
}
.gl-label-icon {
color: $gray-500;
}
} }
} }
......
...@@ -46,7 +46,7 @@ module LabelsHelper ...@@ -46,7 +46,7 @@ module LabelsHelper
end end
end end
def render_label(label, tooltip: true, link: nil, dataset: nil, small: false, wrapper_class: nil, wrapper_style: nil) def render_label(label, tooltip: true, link: nil, dataset: nil, small: false, wrapper_class: nil, wrapper_style: nil, extra: nil)
# if scoped label is used then EE wraps label tag with scoped label # if scoped label is used then EE wraps label tag with scoped label
# doc link # doc link
html = render_colored_label(label) html = render_colored_label(label)
...@@ -60,6 +60,8 @@ module LabelsHelper ...@@ -60,6 +60,8 @@ module LabelsHelper
) )
end end
html += extra.html_safe if extra
wrapper_classes = Array.wrap(wrapper_class) wrapper_classes = Array.wrap(wrapper_class)
wrapper_classes << 'gl-label' wrapper_classes << 'gl-label'
wrapper_classes << 'gl-label-sm' if small wrapper_classes << 'gl-label-sm' if small
...@@ -136,7 +138,7 @@ module LabelsHelper ...@@ -136,7 +138,7 @@ module LabelsHelper
end end
if (r + g + b) > 500 if (r + g + b) > 500
'gl-label-text-black' 'gl-label-text-dark'
else else
'gl-label-text-light' 'gl-label-text-light'
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.modal-dialog .modal-dialog
.modal-content .modal-content
.modal-header .modal-header
%h3.page-title Delete #{render_label(label, tooltip: false)} ? %h3.page-title Delete label: #{label.name} ?
%button.close{ type: "button", "data-dismiss": "modal", "aria-label" => _('Close') } %button.close{ type: "button", "data-dismiss": "modal", "aria-label" => _('Close') }
%span{ "aria-hidden": true } &times; %span{ "aria-hidden": true } &times;
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
@{{ list.assignee.username }} @{{ list.assignee.username }}
%gl-label{ "v-if" => " list.type === \"label\"", %gl-label{ "v-if" => " list.type === \"label\"",
":id" => "list.label.id",
":background-color" => "list.label.color", ":background-color" => "list.label.color",
":title" => "list.label.title", ":title" => "list.label.title",
":description" => "list.label.description", ":description" => "list.label.description",
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
%span.no-value{ "v-if" => "issue.labels && issue.labels.length === 0" } %span.no-value{ "v-if" => "issue.labels && issue.labels.length === 0" }
= _("None") = _("None")
%span{ "v-for" => "label in issue.labels" } %span{ "v-for" => "label in issue.labels" }
%gl-label{ ":id" => "label.id", %gl-label{ ":key" => "label.id",
":key" => "label.id",
":background-color" => "label.color", ":background-color" => "label.color",
":title" => "label.title", ":title" => "label.title",
":description" => "label.description", ":description" => "label.description",
......
...@@ -11,7 +11,7 @@ module EE ...@@ -11,7 +11,7 @@ module EE
def render_label(label, tooltip: true, link: nil, dataset: nil, small: false) def render_label(label, tooltip: true, link: nil, dataset: nil, small: false)
return super unless label.scoped_label? return super unless label.scoped_label?
scoped_label_doc_wrapper( scoped_label_wrapper(
super( super(
label, label,
tooltip: tooltip, tooltip: tooltip,
...@@ -19,7 +19,8 @@ module EE ...@@ -19,7 +19,8 @@ module EE
dataset: dataset, dataset: dataset,
small: small, small: small,
wrapper_class: 'gl-label-scoped', wrapper_class: 'gl-label-scoped',
wrapper_style: "color: #{label.color}" wrapper_style: "color: #{label.color}",
extra: scoped_labels_doc_link(label)
), ),
label label
) )
...@@ -39,13 +40,12 @@ module EE ...@@ -39,13 +40,12 @@ module EE
bg_color: label.color bg_color: label.color
) + render_partial_label( ) + render_partial_label(
label, label_suffix: label_suffix, label, label_suffix: label_suffix,
label_name: label_name, label_name: label_name
css_class: 'gl-label-scoped-text'
) )
end end
def scoped_label_doc_wrapper(link, label) def scoped_label_wrapper(link, label)
%(<span class="d-inline-block position-relative scoped-label-wrapper">#{link}#{scoped_labels_doc_link(label)}</span>).html_safe %(<span class="d-inline-block position-relative scoped-label-wrapper">#{link}</span>).html_safe
end end
def label_tooltip_title(label) def label_tooltip_title(label)
...@@ -84,13 +84,11 @@ module EE ...@@ -84,13 +84,11 @@ module EE
super + ['epics'] super + ['epics']
end end
private
def scoped_labels_doc_link(label) def scoped_labels_doc_link(label)
content = %(<i class="fa fa-question-circle"></i>) content = %(<i class="fa fa-question-circle"></i>)
help_url = ::Gitlab::Routing.url_helpers.help_page_url('user/project/labels.md', anchor: 'scoped-labels') help_url = ::Gitlab::Routing.url_helpers.help_page_url('user/project/labels.md', anchor: 'scoped-labels')
%(<a href="#{help_url}" class="label scoped-label gl-link gl-label-icon" target="_blank" rel="noopener">#{content}</a>) %(<a href="#{help_url}" class="gl-link gl-label-icon" target="_blank" rel="noopener">#{content}</a>)
end end
end end
end end
...@@ -13,6 +13,8 @@ module EE ...@@ -13,6 +13,8 @@ module EE
if label.scoped_label? && parent && parent.feature_available?(:scoped_labels) if label.scoped_label? && parent && parent.feature_available?(:scoped_labels)
presenter = label.present(issuable_parent: parent) presenter = label.present(issuable_parent: parent)
doc_link = ::LabelsHelper.scoped_labels_doc_link(label)
content = %(<span class="gl-label gl-label-scoped gl-label-sm" style="color: #{label.color}">#{link}#{doc_link}</span>)
content = ::LabelsHelper.scoped_label_wrapper(content, presenter) content = ::LabelsHelper.scoped_label_wrapper(content, presenter)
end end
......
...@@ -15,7 +15,7 @@ describe LabelsHelper do ...@@ -15,7 +15,7 @@ describe LabelsHelper do
it 'includes link to scoped labels documentation' do it 'includes link to scoped labels documentation' do
scoped = scoped_label.title.split('::') scoped = scoped_label.title.split('::')
expect(render_label(scoped_label)).to match(%r(<span.+><span.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span></span><a.+>.*question-circle.*</a></span>$)) expect(render_label(scoped_label)).to match(%r(<span.+><span.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span><a.+>.*question-circle.*</a></span></span>$))
end end
it 'does not include link to scoped label documentation for common labels' do it 'does not include link to scoped label documentation for common labels' do
......
...@@ -18,7 +18,7 @@ describe Banzai::Filter::LabelReferenceFilter do ...@@ -18,7 +18,7 @@ describe Banzai::Filter::LabelReferenceFilter do
doc = reference_filter("See #{scoped_label.to_reference}") doc = reference_filter("See #{scoped_label.to_reference}")
scoped = scoped_label.name.split('::') scoped = scoped_label.name.split('::')
expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span></a></span><a.+>.*question-circle.*</a>)) expect(doc.to_html).to match(%r(<span.+><a.+><span.+>#{scoped.first}</span><span.+>#{scoped.last}</span></a><a.+>.*question-circle.*</a></span>))
end end
it 'does not include link to scoped documentation for common labels' do it 'does not include link to scoped documentation for common labels' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment