Commit b92449c7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Predefine colors for project identicons

parent 70c44a0d
......@@ -29,10 +29,10 @@
vertical-align: top;
&.s16 { font-size: 12px; line-height: 1.33; }
&.s24 { font-size: 18px; line-height: 1.33; }
&.s24 { font-size: 14px; line-height: 1.8; }
&.s26 { font-size: 20px; line-height: 1.33; }
&.s32 { font-size: 24px; line-height: 1.33; }
&.s60 { font-size: 45px; line-height: 1.33; }
&.s90 { font-size: 68px; line-height: 1.33; }
&.s160 { font-size: 120px; line-height: 1.33; }
}
\ No newline at end of file
}
......@@ -100,7 +100,7 @@
}
.dash-project-access-icon {
float: left;
margin-right: 3px;
margin-right: 5px;
width: 16px;
}
......
......@@ -64,13 +64,22 @@ module ApplicationHelper
end
def project_identicon(project, options = {})
allowed_colors = {
red: 'FFEBEE',
purple: 'F3E5F5',
indigo: 'E8EAF6',
blue: 'E3F2FD',
teal: 'E0F2F1',
orange: 'FBE9E7',
gray: 'EEEEEE'
}
options[:class] ||= ''
options[:class] << ' identicon'
bg_color = Digest::MD5.hexdigest(project.name)[0, 6]
brightness = bg_color[0, 2].hex + bg_color[2, 2].hex + bg_color[4, 2].hex
text_color = (brightness > 375) ? '#000' : '#fff'
bg_key = project.id % 7
content_tag(:div, class: options[:class],
style: "background-color: ##{ bg_color }; color: #{ text_color }") do
style: "background-color: ##{ allowed_colors.values[bg_key] }; color: #555") do
project.name[0, 1].upcase
end
end
......
= link_to project_path(project), class: dom_class(project) do
.dash-project-avatar
= project_icon(project.to_param, alt: '', class: 'avatar s24')
.dash-project-access-icon
= visibility_level_icon(project.visibility_level)
.dash-project-avatar
= project_icon(project.to_param, alt: '', class: 'avatar s24')
%span.str-truncated
%span.namespace-name
- if project.namespace
......
......@@ -12,10 +12,10 @@
- projects.each do |project|
%li.project-row
= link_to project_path(project), class: dom_class(project) do
.dash-project-avatar
= project_icon(project.to_param, alt: '', class: 'avatar s24')
.dash-project-access-icon
= visibility_level_icon(project.visibility_level)
.dash-project-avatar
= project_icon(project.to_param, alt: '', class: 'avatar s24')
%span.str-truncated
%span.project-name
= project.name
......
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