diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2024-09-02 20:48:40 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2024-09-02 20:48:40 +0000 |
commit | f2639e9038c1d5f9ad2975cc3e246381e9c3ec72 (patch) | |
tree | e4ccbc57cf72d392d4e51b7bd9c8fb473de7a672 | |
parent | bcb9a1cd3347031884474cf8c5de153e43964a9e (diff) | |
download | redmine-f2639e9038c1d5f9ad2975cc3e246381e9c3ec72.tar.gz redmine-f2639e9038c1d5f9ad2975cc3e246381e9c3ec72.zip |
Replace icons for files in repository view with SVG icons (#23980).
git-svn-id: https://svn.redmine.org/redmine/trunk@23011 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/assets/images/icons.svg | 6 | ||||
-rw-r--r-- | app/assets/stylesheets/application.css | 36 | ||||
-rw-r--r-- | app/helpers/icons_helper.rb | 20 |
3 files changed, 39 insertions, 23 deletions
diff --git a/app/assets/images/icons.svg b/app/assets/images/icons.svg index b6a5ed020..c22c19f06 100644 --- a/app/assets/images/icons.svg +++ b/app/assets/images/icons.svg @@ -133,10 +133,10 @@ <path d="M320 464c8.8 0 16-7.2 16-16V160h-80c-17.7 0-32-14.3-32-32V48H64c-8.8 0-16 7.2-16 16v384c0 8.8 7.2 16 16 16zM0 64C0 28.7 28.7 0 64 0h165.5c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64z"/> </symbol> <symbol viewBox="0 0 512 512" id="icon--folder"> - <path d="M0 96c0-35.3 28.7-64 64-64h132.1c19.1 0 37.4 7.6 50.9 21.1L289.9 96H448c35.3 0 64 28.7 64 64v256c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64zm64-16c-8.8 0-16 7.2-16 16v320c0 8.8 7.2 16 16 16h384c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16H286.6c-10.6 0-20.8-4.2-28.3-11.7L213.1 87c-4.5-4.5-10.6-7-17-7z"/> + <path d="M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H288c-10.1 0-19.6-4.7-25.6-12.8L243.2 57.6C231.1 41.5 212.1 32 192 32H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"/> </symbol> <symbol viewBox="0 0 576 512" id="icon--folder-open"> - <path d="M88.7 223.8L0 375.8V96c0-35.3 28.7-64 64-64h117.5c17 0 33.3 6.7 45.3 18.7l26.5 26.5c12 12 28.3 18.7 45.3 18.7L416 96c35.3 0 64 28.7 64 64v32H144c-22.8 0-43.8 12.1-55.3 31.8m27.6 16.1c5.8-9.9 16.3-15.9 27.7-15.9h400c11.5 0 22 6.1 27.7 16.1s5.7 22.2-.1 32.1l-112 192C453.9 474 443.4 480 432 480H32c-11.5 0-22-6.1-27.7-16.1s-5.7-22.2.1-32.1l112-192z"/> + <path d="M384 480l48 0c11.4 0 21.9-6 27.6-15.9l112-192c5.8-9.9 5.8-22.1 .1-32.1S555.5 224 544 224l-400 0c-11.4 0-21.9 6-27.6 15.9L48 357.1 48 96c0-8.8 7.2-16 16-16l117.5 0c4.2 0 8.3 1.7 11.3 4.7l26.5 26.5c21 21 49.5 32.8 79.2 32.8L416 144c8.8 0 16 7.2 16 16l0 32 48 0 0-32c0-35.3-28.7-64-64-64L298.5 96c-17 0-33.3-6.7-45.3-18.7L226.7 50.7c-12-12-28.3-18.7-45.3-18.7L64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l23.7 0L384 480z"/> </symbol> <symbol viewBox="0 0 640 512" id="icon--group"> <path d="M96 128a128 128 0 1 1 256 0a128 128 0 1 1-256 0M0 482.3C0 383.8 79.8 304 178.3 304h91.4c98.5 0 178.3 79.8 178.3 178.3c0 16.4-13.3 29.7-29.7 29.7H29.7C13.3 512 0 498.7 0 482.3M609.3 512H471.5c5.4-9.4 8.6-20.3 8.6-32v-8c0-60.7-27.1-115.2-69.8-151.8c2.4-.1 4.7-.2 7.1-.2h61.4c89 0 161.2 72.2 161.2 161.3c0 17-13.8 30.7-30.7 30.7M432 256c-31 0-59-12.6-79.3-32.9c19.7-26.6 31.3-59.5 31.3-95.1c0-26.8-6.6-52.1-18.3-74.3C384.3 40.1 407.2 32 432 32c61.9 0 112 50.1 112 112s-50.1 112-112 112"/> @@ -288,7 +288,7 @@ <symbol viewBox="0 0 24 24" id="icon--text-x-java"> <path d="M16.5 6.08s-6.84 1.71-3.56 5.48c.97 1.11-.25 2.11-.25 2.11s2.45-1.25 1.31-2.85c-1.06-1.47-1.86-2.2 2.5-4.74m-4.47 1.2C16.08 4.08 14 2 14 2c.84 3.3-2.96 4.3-4.33 6.36c-.94 1.4.46 2.91 2.33 4.64c-.71-1.7-3.22-3.16.03-5.72M9.37 17.47c-3.08.86 1.88 2.63 5.79.96c-.38-.15-.75-.33-1.1-.54c-1.36.31-2.76.37-4.14.18c-1.31-.16-.55-.6-.55-.6m5.32-1.68c-1.75.38-3.56.47-5.34.26c-1.31-.13-.45-.77-.45-.77c-3.4 1.13 1.88 2.4 6.6 1.02c-.29-.11-.57-.3-.81-.51m3.42 3.3s.57.47-.61.83c-2.28.68-9.43.89-11.41.03c-.71-.31.63-.74 1.05-.83c.23-.06.46-.08.69-.08c-.79-.54-5.13 1.1-2.19 1.56c7.97 1.3 14.54-.6 12.47-1.51m-2.74-4.86c.29-.19.6-.35.92-.49c0 0-1.51.26-3.02.4c-1.6.16-3.21.18-4.81.06c-2.35-.31 1.29-1.2 1.29-1.2c-1.1 0-2.18.26-3.16.75c-2.05 1 5.1 1.45 8.78.48m.9 2.42c-.02.04-.04.07-.08.1c5.01-1.31 3.17-4.64.77-3.81c-.13.06-.24.14-.31.25c.14-.05.28-.09.43-.12c1.2-.24 2.92 1.63-.81 3.58m.13 4.61c-3.01.52-6.09.56-9.12.14c0 0 .46.38 2.81.53c3.6.23 9.13-.13 9.26-1.83c.03.01-.23.65-2.95 1.16"/> </symbol> - <symbol viewBox="0 0 24 24" id="icon--text-x-javascript"> + <symbol viewBox="0 0 24 24" id="icon--application-javascript"> <path d="M3 3h18v18H3zm4.73 15.04c.4.85 1.19 1.55 2.54 1.55c1.5 0 2.53-.8 2.53-2.55v-5.78h-1.7V17c0 .86-.35 1.08-.9 1.08c-.58 0-.82-.4-1.09-.87zm5.98-.18c.5.98 1.51 1.73 3.09 1.73c1.6 0 2.8-.83 2.8-2.36c0-1.41-.81-2.04-2.25-2.66l-.42-.18c-.73-.31-1.04-.52-1.04-1.02c0-.41.31-.73.81-.73c.48 0 .8.21 1.09.73l1.31-.87c-.55-.96-1.33-1.33-2.4-1.33c-1.51 0-2.48.96-2.48 2.23c0 1.38.81 2.03 2.03 2.55l.42.18c.78.34 1.24.55 1.24 1.13c0 .48-.45.83-1.15.83c-.83 0-1.31-.43-1.67-1.03z"/> </symbol> <symbol viewBox="0 0 24 24" id="icon--text-x-php"> diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f704df274..c733662dc 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1761,24 +1761,24 @@ span.icon-label { .icon-clear-query:not(:has(svg)) { background-image: url(/close_hl.png); } .icon-import:not(:has(svg)) { background-image: url(/database_go.png); } -.icon-file { background-image: url(/files/default.png); } -.icon-file.text-plain { background-image: url(/files/text.png); } -.icon-file.text-x-c { background-image: url(/files/c.png); } -.icon-file.text-x-csharp { background-image: url(/files/csharp.png); } -.icon-file.text-x-java { background-image: url(/files/java.png); } -.icon-file.application-javascript { background-image: url(/files/js.png); } -.icon-file.text-x-php { background-image: url(/files/php.png); } -.icon-file.text-x-ruby { background-image: url(/files/ruby.png); } -.icon-file.text-xml { background-image: url(/files/xml.png); } -.icon-file.text-css { background-image: url(/files/css.png); } -.icon-file.text-html { background-image: url(/files/html.png); } -.icon-file.image-gif { background-image: url(/files/image.png); } -.icon-file.image-jpeg { background-image: url(/files/image.png); } -.icon-file.image-png { background-image: url(/files/image.png); } -.icon-file.image-tiff { background-image: url(/files/image.png); } -.icon-file.application-pdf { background-image: url(/files/pdf.png); } -.icon-file.application-zip { background-image: url(/files/zip.png); } -.icon-file.application-gzip { background-image: url(/files/zip.png); } +.icon-file:not(:has(svg)) { background-image: url(/files/default.png); } +.icon-file.text-plain:not(:has(svg)) { background-image: url(/files/text.png); } +.icon-file.text-x-c:not(:has(svg)) { background-image: url(/files/c.png); } +.icon-file.text-x-csharp:not(:has(svg)) { background-image: url(/files/csharp.png); } +.icon-file.text-x-java:not(:has(svg)) { background-image: url(/files/java.png); } +.icon-file.application-javascript:not(:has(svg)) { background-image: url(/files/js.png); } +.icon-file.text-x-php:not(:has(svg)) { background-image: url(/files/php.png); } +.icon-file.text-x-ruby:not(:has(svg)) { background-image: url(/files/ruby.png); } +.icon-file.text-xml:not(:has(svg)) { background-image: url(/files/xml.png); } +.icon-file.text-css:not(:has(svg)) { background-image: url(/files/css.png); } +.icon-file.text-html:not(:has(svg)) { background-image: url(/files/html.png); } +.icon-file.image-gif:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.image-jpeg:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.image-png:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.image-tiff:not(:has(svg)) { background-image: url(/files/image.png); } +.icon-file.application-pdf:not(:has(svg)) { background-image: url(/files/pdf.png); } +.icon-file.application-zip:not(:has(svg)) { background-image: url(/files/zip.png); } +.icon-file.application-gzip:not(:has(svg)) { background-image: url(/files/zip.png); } .icon-copy-link:not(:has(svg)) { background-image: url(/copy_link.png); } .sort-handle.ajax-loading { background-image: url(/loading.gif); } diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index b9b25c0ba..26a605fad 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -25,9 +25,12 @@ module IconsHelper sprite_icon(icon_name) + content_tag(:span, label_text, class: "icon-label") end - def icon_for_file(entry, label_text) + def icon_for_file(entry, name) if entry.is_dir? - icon_with_label("folder", label_text) + icon_with_label("folder", name) + else + icon = icon_for_mime_type(Redmine::MimeType.css_class_of(name)) + icon_with_label(icon, name) end end @@ -43,4 +46,17 @@ module IconsHelper } ) end + + private + + def icon_for_mime_type(mime) + if %w(text-plain text-x-c text-x-csharp text-x-java text-x-php + text-x-ruby text-xml text-css text-html text-css text-html + image-gif image-jpeg image-png image-tiff + application-pdf application-zip application-gzip application-javascript).include?(mime) + mime + else + "file" + end + end end |