Skip to content

Commit 65e709d

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Change icon and label depending on whether media is marked as sensitive (mastodon#10748)
* Change icon and label depending on whether media is marked as sensitive * WiP use a checkbox
1 parent 69851c4 commit 65e709d

2 files changed

Lines changed: 41 additions & 7 deletions

File tree

app/javascript/mastodon/features/compose/containers/sensitive_button_container.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
44
import classNames from 'classnames';
55
import { changeComposeSensitivity } from 'mastodon/actions/compose';
66
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
7-
import Icon from 'mastodon/components/icon';
87

98
const messages = defineMessages({
109
marked: { id: 'compose_form.sensitive.marked', defaultMessage: 'Media is marked as sensitive' },
@@ -38,9 +37,19 @@ class SensitiveButton extends React.PureComponent {
3837

3938
return (
4039
<div className='compose-form__sensitive-button'>
41-
<button className={classNames('icon-button', { active })} onClick={onClick} disabled={disabled} title={intl.formatMessage(active ? messages.marked : messages.unmarked)}>
42-
<Icon id='eye-slash' /> <FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />
43-
</button>
40+
<label className={classNames('icon-button', { active })} title={intl.formatMessage(active ? messages.marked : messages.unmarked)}>
41+
<input
42+
name='mark-sensitive'
43+
type='checkbox'
44+
checked={active}
45+
onChange={onClick}
46+
disabled={disabled}
47+
/>
48+
49+
<span className={classNames('checkbox', { active })} />
50+
51+
<FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />
52+
</label>
4453
</div>
4554
);
4655
}

app/javascript/styles/mastodon/components.scss

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,34 @@
268268
padding: 10px;
269269
padding-top: 0;
270270

271-
.icon-button {
272-
font-size: 14px;
273-
font-weight: 500;
271+
font-size: 14px;
272+
font-weight: 500;
273+
274+
&.active {
275+
color: $highlight-text-color;
276+
}
277+
278+
input[type=checkbox] {
279+
display: none;
280+
}
281+
282+
.checkbox {
283+
display: inline-block;
284+
position: relative;
285+
border: 1px solid $ui-primary-color;
286+
box-sizing: border-box;
287+
width: 18px;
288+
height: 18px;
289+
flex: 0 0 auto;
290+
margin-right: 10px;
291+
top: -1px;
292+
border-radius: 4px;
293+
vertical-align: middle;
294+
295+
&.active {
296+
border-color: $highlight-text-color;
297+
background: $highlight-text-color;
298+
}
274299
}
275300
}
276301

0 commit comments

Comments
 (0)