]> cat aescling's git repositories - mastodon.git/commitdiff
Use a checkbox for the “Mark media as sensitive” composer button
authorThibaut Girka <thib@sitedethib.com>
Fri, 10 May 2019 11:59:41 +0000 (13:59 +0200)
committerThibG <thib@sitedethib.com>
Sat, 11 May 2019 10:35:38 +0000 (12:35 +0200)
Fixes #1039

app/javascript/flavours/glitch/features/compose/containers/sensitive_button_container.js
app/javascript/flavours/glitch/styles/components/composer.scss

index 8f163979f880ae70ad02dd2bf5513ced96bf0c30..fa1ae8821522c1e1a0ee2387a381cb699bcd75f1 100644 (file)
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
 import classNames from 'classnames';
 import { changeComposeSensitivity } from 'flavours/glitch/actions/compose';
 import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
-import Icon from 'flavours/glitch/components/icon';
 
 const messages = defineMessages({
   marked: { id: 'compose_form.sensitive.marked', defaultMessage: 'Media is marked as sensitive' },
@@ -42,9 +41,19 @@ class SensitiveButton extends React.PureComponent {
 
     return (
       <div className='compose-form__sensitive-button'>
-        <button className={classNames('icon-button', { active })} onClick={onClick} disabled={disabled} title={intl.formatMessage(active ? messages.marked : messages.unmarked)}>
-          <Icon icon='eye-slash' /> <FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />
-        </button>
+        <label className={classNames('icon-button', { active })} title={intl.formatMessage(active ? messages.marked : messages.unmarked)}>
+          <input
+            name='mark-sensitive'
+            type='checkbox'
+            checked={active}
+            onChange={onClick}
+            disabled={disabled}
+          />
+
+          <span className={classNames('checkbox', { active })} />
+
+          <FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />
+        </label>
       </div>
     );
   }
index 86041da200ba077f6ad09211f76e38ab608cb870..bb333d35fbfe0fd2d6040977a117ea1756a86691 100644 (file)
   padding: 10px;
   padding-top: 0;
 
-  .icon-button {
-    font-size: 14px;
-    font-weight: 500;
+  font-size: 14px;
+  font-weight: 500;
+
+  &.active {
+    color: $highlight-text-color;
+  }
+
+  input[type=checkbox] {
+    display: none;
+  }
+
+  .checkbox {
+    display: inline-block;
+    position: relative;
+    border: 1px solid $ui-primary-color;
+    box-sizing: border-box;
+    width: 18px;
+    height: 18px;
+    flex: 0 0 auto;
+    margin-left: 5px;
+    margin-right: 10px;
+    top: -1px;
+    border-radius: 4px;
+    vertical-align: middle;
+
+    &.active {
+      border-color: $highlight-text-color;
+      background: $highlight-text-color;
+    }
   }
 }