Skip to content

Commit 2fcea34

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Change icon button styles to make hover/focus states more obvious (mastodon#11474)
* Change icon buttons styles to make hover/focused states more obvious * Fix CW button size inconsistency * Fix icon button background color consistency
1 parent 6a52ce7 commit 2fcea34

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

app/javascript/mastodon/features/compose/components/text_icon_button.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4+
const iconStyle = {
5+
height: null,
6+
lineHeight: '27px',
7+
width: `${18 * 1.28571429}px`,
8+
};
9+
410
export default class TextIconButton extends React.PureComponent {
511

612
static propTypes = {
@@ -20,7 +26,14 @@ export default class TextIconButton extends React.PureComponent {
2026
const { label, title, active, ariaControls } = this.props;
2127

2228
return (
23-
<button title={title} aria-label={title} className={`text-icon-button ${active ? 'active' : ''}`} aria-expanded={active} onClick={this.handleClick} aria-controls={ariaControls}>
29+
<button
30+
title={title}
31+
aria-label={title}
32+
className={`text-icon-button ${active ? 'active' : ''}`}
33+
aria-expanded={active}
34+
onClick={this.handleClick}
35+
aria-controls={ariaControls} style={iconStyle}
36+
>
2437
{label}
2538
</button>
2639
);

app/javascript/styles/mastodon/components.scss

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,28 @@
129129
padding: 0;
130130
color: $action-button-color;
131131
border: 0;
132+
border-radius: 4px;
132133
background: transparent;
133134
cursor: pointer;
134-
transition: color 100ms ease-in;
135+
transition: all 100ms ease-in;
136+
transition-property: background-color, color;
135137

136138
&:hover,
137139
&:active,
138140
&:focus {
139141
color: lighten($action-button-color, 7%);
140-
transition: color 200ms ease-out;
142+
background-color: rgba($action-button-color, 0.15);
143+
transition: all 200ms ease-out;
144+
transition-property: background-color, color;
145+
}
146+
147+
&:focus {
148+
background-color: rgba($action-button-color, 0.3);
141149
}
142150

143151
&.disabled {
144152
color: darken($action-button-color, 13%);
153+
background-color: transparent;
145154
cursor: default;
146155
}
147156

@@ -166,10 +175,16 @@
166175
&:active,
167176
&:focus {
168177
color: darken($lighter-text-color, 7%);
178+
background-color: rgba($lighter-text-color, 0.15);
179+
}
180+
181+
&:focus {
182+
background-color: rgba($lighter-text-color, 0.3);
169183
}
170184

171185
&.disabled {
172186
color: lighten($lighter-text-color, 7%);
187+
background-color: transparent;
173188
}
174189

175190
&.active {
@@ -197,24 +212,33 @@
197212
.text-icon-button {
198213
color: $lighter-text-color;
199214
border: 0;
215+
border-radius: 4px;
200216
background: transparent;
201217
cursor: pointer;
202218
font-weight: 600;
203219
font-size: 11px;
204220
padding: 0 3px;
205221
line-height: 27px;
206222
outline: 0;
207-
transition: color 100ms ease-in;
223+
transition: all 100ms ease-in;
224+
transition-property: background-color, color;
208225

209226
&:hover,
210227
&:active,
211228
&:focus {
212229
color: darken($lighter-text-color, 7%);
213-
transition: color 200ms ease-out;
230+
background-color: rgba($lighter-text-color, 0.15);
231+
transition: all 200ms ease-out;
232+
transition-property: background-color, color;
233+
}
234+
235+
&:focus {
236+
background-color: rgba($lighter-text-color, 0.3);
214237
}
215238

216239
&.disabled {
217240
color: lighten($lighter-text-color, 20%);
241+
background-color: transparent;
218242
cursor: default;
219243
}
220244

@@ -604,7 +628,8 @@
604628
}
605629
}
606630

607-
.icon-button {
631+
.icon-button,
632+
.text-icon-button {
608633
box-sizing: content-box;
609634
padding: 0 3px;
610635
}

0 commit comments

Comments
 (0)