Skip to content

Commit

Permalink
アイコンに猫耳を生やす
Browse files Browse the repository at this point in the history
  • Loading branch information
hinaloe authored and hiyuki2578 committed Oct 2, 2019
1 parent 48da1a0 commit a7f7003
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 13 deletions.
16 changes: 13 additions & 3 deletions app/javascript/mastodon/components/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,32 @@ export default class Avatar extends React.PureComponent {

const src = account.get('avatar');
const staticSrc = account.get('avatar_static');
const isCat = !!account.get('cat');

let className = 'account__avatar';

if (inline) {
className = className + ' account__avatar-inline';
}

if (isCat) {
className = className + ' account__avatar-cat';
}

const style = {
...this.props.style,
width: `${size}px`,
height: `${size}px`,
};

const innerStyle={
backgroundSize: `${size}px ${size}px`,
};

if (hovering || animate) {
style.backgroundImage = `url(${src})`;
innerStyle.backgroundImage = `url(${src})`;
} else {
style.backgroundImage = `url(${staticSrc})`;
innerStyle.backgroundImage = `url(${staticSrc})`;
}

return (
Expand All @@ -65,7 +73,9 @@ export default class Avatar extends React.PureComponent {
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
style={style}
/>
>
<div className={'account__avatar-inner'} style={innerStyle} />
</div>
);
}

Expand Down
3 changes: 3 additions & 0 deletions app/javascript/styles/mastodon-light/diff.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
.column {
> .scrollable {
background: $white;
.account__avatar-inner {
background-color: $white;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/styles/mastodon/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@mixin avatar-radius() {
border-radius: 4px;
border-radius: 50%;
background: transparent no-repeat;
background-position: 50%;
background-clip: padding-box;
Expand Down
36 changes: 35 additions & 1 deletion app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,40 @@
box-sizing: border-box;
}
}

&-cat::before,
&-cat::after {
background: #df548f;
box-sizing: border-box;
content: '';
display: inline-block;
height: 50%;
width: 50%;
position: absolute;
}

&-cat::before {
border-radius: 0 75% 75%;
transform: rotate(37.5deg) skew(30deg);
left: 0;
}

&-cat::after {
border-radius: 75% 0 75% 75%;
transform: rotate(-37.5deg) skew(-30deg);
right: 0;
}

&-inner {
@include avatar-radius();
background-color: $ui-base-color;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}
}

a .account__avatar {
Expand Down Expand Up @@ -1348,7 +1382,7 @@ a.account__display-name {
display: block;
line-height: 24px;
margin-bottom: 15px;
overflow: hidden;
//overflow: hidden;

strong,
span {
Expand Down
12 changes: 8 additions & 4 deletions app/views/stream_entries/_detailed_status.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
:ruby
avatar_classes = 'u-photo account__avatar'
avatar_classes += ' account__avatar-cat' if status.account.cat?
.detailed-status.detailed-status--flex
.p-author.h-card
= link_to TagManager.instance.url_for(status.account), class: 'detailed-status__display-name u-url', target: stream_link_target, rel: 'noopener' do
.detailed-status__display-avatar
- if current_account&.user&.setting_auto_play_gif || autoplay
= image_tag status.account.avatar_original_url, width: 48, height: 48, alt: '', class: 'account__avatar u-photo'
- else
= image_tag status.account.avatar_static_url, width: 48, height: 48, alt: '', class: 'account__avatar u-photo'
%div{ class: avatar_classes, style: 'width: 48px; height: 48px;' }
- if current_account&.user&.setting_auto_play_gif || autoplay
= image_tag status.account.avatar_original_url, width: 48, height: 48, alt: '', class: 'account__avatar-inner'
- else
= image_tag status.account.avatar_static_url, width: 48, height: 48, alt: '', class: 'account__avatar-inner'
%span.display-name
%bdi
%strong.display-name__html.p-name.emojify= display_name(status.account, custom_emojify: true, autoplay: autoplay)
Expand Down
12 changes: 8 additions & 4 deletions app/views/stream_entries/_simple_status.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
:ruby
avatar_classes = 'u-photo account__avatar'
avatar_classes += ' account__avatar-cat' if status.account.cat?
.status
.status__info
= link_to TagManager.instance.url_for(status), class: 'status__relative-time u-url u-uid', target: stream_link_target, rel: 'noopener' do
Expand All @@ -8,10 +11,11 @@
= link_to TagManager.instance.url_for(status.account), class: 'status__display-name u-url', target: stream_link_target, rel: 'noopener' do
.status__avatar
%div
- if current_account&.user&.setting_auto_play_gif || autoplay
= image_tag status.account.avatar_original_url, width: 48, height: 48, alt: '', class: 'u-photo account__avatar'
- else
= image_tag status.account.avatar_static_url, width: 48, height: 48, alt: '', class: 'u-photo account__avatar'
%div{ class: avatar_classes, style: 'width: 48px; height: 48px;' }
- if current_account&.user&.setting_auto_play_gif || autoplay
= image_tag status.account.avatar_original_url, width: 48, height: 48, alt: '', class: 'account__avatar-inner'
- else
= image_tag status.account.avatar_static_url, width: 48, height: 48, alt: '', class: 'account__avatar-inner'
%span.display-name
%bdi
%strong.display-name__html.p-name.emojify= display_name(status.account, custom_emojify: true, autoplay: autoplay)
Expand Down

0 comments on commit a7f7003

Please sign in to comment.