Skip to content

Commit e0f6dc2

Browse files
Gargronhiyuki2578
authored andcommitted
Use <use /> to render transparent SVG logo instead of inserting it (mastodon#10845)
1 parent 1b99c90 commit e0f6dc2

8 files changed

Lines changed: 16 additions & 41 deletions

File tree

app/helpers/stream_entries_helper.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,28 @@ def account_action_button(account)
1616
if user_signed_in?
1717
if account.id == current_user.account_id
1818
link_to settings_profile_url, class: 'button logo-button' do
19-
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('settings.edit_profile')])
19+
safe_join([svg_logo, t('settings.edit_profile')])
2020
end
2121
elsif current_account.following?(account) || current_account.requested?(account)
2222
link_to account_unfollow_path(account), class: 'button logo-button button--destructive', data: { method: :post } do
23-
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('accounts.unfollow')])
23+
safe_join([svg_logo, t('accounts.unfollow')])
2424
end
2525
elsif !(account.memorial? || account.moved?)
2626
link_to account_follow_path(account), class: "button logo-button#{account.blocking?(current_account) ? ' disabled' : ''}", data: { method: :post } do
27-
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('accounts.follow')])
27+
safe_join([svg_logo, t('accounts.follow')])
2828
end
2929
end
3030
elsif !(account.memorial? || account.moved?)
3131
link_to account_remote_follow_path(account), class: 'button logo-button modal-button', target: '_new' do
32-
safe_join([render(file: Rails.root.join('app', 'javascript', 'images', 'logo.svg')), t('accounts.follow')])
32+
safe_join([svg_logo, t('accounts.follow')])
3333
end
3434
end
3535
end
3636

37+
def svg_logo
38+
content_tag(:svg, tag(:use, 'xlink:href' => '#mastodon-svg-logo'), 'viewBox' => '0 0 216.4144 232.00976')
39+
end
40+
3741
def account_badge(account, all: false)
3842
roles = []
3943

Lines changed: 1 addition & 1 deletion
Loading

app/javascript/styles/mastodon-light/diff.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
.button.logo-button {
307307
color: $white;
308308

309-
svg path:first-child {
309+
svg {
310310
fill: $white;
311311
}
312312
}

app/javascript/styles/mastodon/containers.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,6 @@
359359

360360
.logo-button {
361361
background-color: $secondary-text-color;
362-
363-
svg path:last-child {
364-
fill: $secondary-text-color;
365-
}
366362
}
367363
}
368364

app/javascript/styles/mastodon/footer.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@
122122
height: 36px;
123123
width: auto;
124124
margin: 0 auto;
125-
126-
path {
127-
fill: lighten($ui-base-color, 34%);
128-
}
125+
fill: lighten($ui-base-color, 34%);
129126
}
130127

131128
&:hover,

app/javascript/styles/mastodon/stream_entries.scss

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,40 +89,21 @@
8989
height: auto;
9090
vertical-align: middle;
9191
margin-right: 5px;
92-
93-
path:first-child {
94-
fill: $primary-text-color;
95-
}
96-
97-
path:last-child {
98-
fill: $ui-highlight-color;
99-
}
92+
fill: $primary-text-color;
10093
}
10194

10295
&:active,
10396
&:focus,
10497
&:hover {
10598
background: lighten($ui-highlight-color, 10%);
106-
107-
svg path:last-child {
108-
fill: lighten($ui-highlight-color, 10%);
109-
}
11099
}
111100

112101
&:disabled,
113102
&.disabled {
114-
svg path:last-child {
115-
fill: $ui-primary-color;
116-
}
117-
118103
&:active,
119104
&:focus,
120105
&:hover {
121106
background: $ui-primary-color;
122-
123-
svg path:last-child {
124-
fill: $ui-primary-color;
125-
}
126107
}
127108
}
128109

@@ -131,10 +112,6 @@
131112
&:focus,
132113
&:hover {
133114
background: $error-red;
134-
135-
svg path:last-child {
136-
fill: $error-red;
137-
}
138115
}
139116
}
140117

app/views/layouts/application.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@
3333

3434
%body{ class: body_classes }
3535
= content_for?(:content) ? yield(:content) : yield
36+
37+
%div{ style: 'display: none'}
38+
= render file: Rails.root.join('app', 'javascript', 'images', 'logo_transparent.svg')

app/views/layouts/public.html.haml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
%li= link_to t('about.api'), 'https://docs.joinmastodon.org/api/guidelines/'
3939
.column-2
4040
%h4= link_to t('about.what_is_mastodon'), 'https://joinmastodon.org/'
41-
42-
= link_to root_url, class: 'brand' do
43-
= render file: Rails.root.join('app', 'javascript', 'images', 'logo_transparent.svg')
41+
= link_to svg_logo, root_url, class: 'brand'
4442
.column-3
4543
%h4= site_hostname
4644
%ul

0 commit comments

Comments
 (0)