UX: Add login button icon to no_ember page (#7982)

This commit is contained in:
David Taylor 2019-08-08 10:44:04 +01:00 committed by GitHub
parent 32b4bdaccd
commit 7bd54eaceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -17,7 +17,7 @@
<%- if can_sign_up? %>
<a href="<%= path "/signup"%>" class='btn btn-primary btn-small signup-button'><%= I18n.t('sign_up') %></a>
<%- end %>
<a href="<%= path "/login"%>" class='btn btn-primary btn-small login-button'><%= I18n.t('log_in') %></a>
<a href="<%= path "/login"%>" class='btn btn-primary btn-small login-button btn-icon-text'><%= SvgSprite.raw_svg('fa-user') %><%= I18n.t('log_in') %></a>
</div>
<%- end %>
</div>

View File

@ -303,6 +303,19 @@ License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL
false
end
# For use in no_ember .html.erb layouts
def self.raw_svg(name)
get_set_cache("raw_svg_#{name}") do
symbol = search(name)
break "" unless symbol
symbol = Nokogiri::XML(symbol).children.first
symbol.name = "svg"
<<~HTML
<svg class="fa d-icon svg-icon svg-node" aria-hidden="true">#{symbol}</svg>
HTML
end.html_safe
end
def self.theme_sprite_variable_name
THEME_SPRITE_VAR_NAME
end

View File

@ -29,6 +29,11 @@ describe SvgSprite do
expect(SvgSprite.search("this-is-not-an-icon")).to eq(false)
end
it 'can get a raw SVG for an icon' do
expect(SvgSprite.raw_svg("fa-heart")).to match(/svg.*svg/) # SVG inside SVG
expect(SvgSprite.raw_svg("this-is-not-an-icon")).to eq("")
end
it 'can get a consistent version string' do
version1 = SvgSprite.version
version2 = SvgSprite.version