Skip to content

Commit

Permalink
Use <use /> to render transparent SVG logo instead of inserting it (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent 1b99c90 commit e0f6dc2
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 41 deletions.
12 changes: 8 additions & 4 deletions app/helpers/stream_entries_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ def account_action_button(account)
if user_signed_in?
if account.id == current_user.account_id
link_to settings_profile_url, class: 'button logo-button' do
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('settings.edit_profile')])
safe_join([svg_logo, t('settings.edit_profile')])
end
elsif current_account.following?(account) || current_account.requested?(account)
link_to account_unfollow_path(account), class: 'button logo-button button--destructive', data: { method: :post } do
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('accounts.unfollow')])
safe_join([svg_logo, t('accounts.unfollow')])
end
elsif !(account.memorial? || account.moved?)
link_to account_follow_path(account), class: "button logo-button#{account.blocking?(current_account) ? ' disabled' : ''}", data: { method: :post } do
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('accounts.follow')])
safe_join([svg_logo, t('accounts.follow')])
end
end
elsif !(account.memorial? || account.moved?)
link_to account_remote_follow_path(account), class: 'button logo-button modal-button', target: '_new' do
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('accounts.follow')])
safe_join([svg_logo, t('accounts.follow')])
end
end
end

def svg_logo
content_tag(:svg, tag(:use, 'xlink:href' => '#mastodon-svg-logo'), 'viewBox' => '0 0 216.4144 232.00976')
end

def account_badge(account, all: false)
roles = []

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/images/logo_transparent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/javascript/styles/mastodon-light/diff.scss
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
.button.logo-button {
color: $white;

svg path:first-child {
svg {
fill: $white;
}
}
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/styles/mastodon/containers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,6 @@

.logo-button {
background-color: $secondary-text-color;

svg path:last-child {
fill: $secondary-text-color;
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions app/javascript/styles/mastodon/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@
height: 36px;
width: auto;
margin: 0 auto;

path {
fill: lighten($ui-base-color, 34%);
}
fill: lighten($ui-base-color, 34%);
}

&:hover,
Expand Down
25 changes: 1 addition & 24 deletions app/javascript/styles/mastodon/stream_entries.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,40 +89,21 @@
height: auto;
vertical-align: middle;
margin-right: 5px;

path:first-child {
fill: $primary-text-color;
}

path:last-child {
fill: $ui-highlight-color;
}
fill: $primary-text-color;
}

&:active,
&:focus,
&:hover {
background: lighten($ui-highlight-color, 10%);

svg path:last-child {
fill: lighten($ui-highlight-color, 10%);
}
}

&:disabled,
&.disabled {
svg path:last-child {
fill: $ui-primary-color;
}

&:active,
&:focus,
&:hover {
background: $ui-primary-color;

svg path:last-child {
fill: $ui-primary-color;
}
}
}

Expand All @@ -131,10 +112,6 @@
&:focus,
&:hover {
background: $error-red;

svg path:last-child {
fill: $error-red;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@

%body{ class: body_classes }
= content_for?(:content) ? yield(:content) : yield

%div{ style: 'display: none'}
= render file: Rails.root.join('app', 'javascript', 'images', 'logo_transparent.svg')
4 changes: 1 addition & 3 deletions app/views/layouts/public.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
%li= link_to t('about.api'), 'https://docs.joinmastodon.org/api/guidelines/'
.column-2
%h4= link_to t('about.what_is_mastodon'), 'https://joinmastodon.org/'

= link_to root_url, class: 'brand' do
= render file: Rails.root.join('app', 'javascript', 'images', 'logo_transparent.svg')
= link_to svg_logo, root_url, class: 'brand'
.column-3
%h4= site_hostname
%ul
Expand Down

0 comments on commit e0f6dc2

Please sign in to comment.