From cca41ea544fe7de3e7afdc250992a1c6e48d2a31 Mon Sep 17 00:00:00 2001 From: Stephen Burgess Date: Sat, 22 Apr 2017 21:26:55 -0500 Subject: Replace inline styles with CSS classes (BEM) (#2338) * fix(classnames): Status icon style classnames Take out inline css and put into classnames for the following components: account, avatar, icon button, status action bar, notification. * fix(status): Move styles from inline to classes for statuses Move styles to classnames in components.scss for the following components: display name media gallery status status content video player * fix(classnames): Add classnames to rest of components Take out inline styles and apply them to classnames in the sass for the following components: button column back button slim column back button collapsable column dropdown menu loading indicator status list * fix(classnames): Remove all non-dynamic inline styles Components affected: autosuggested permalink action bar header character counter compose form emoji dropdown privacy dropdown reply indicator upload form account auth followers getting started column settings mutes settings reblogs status checkbox report action bar status card boost modal media modal video modal * fix(permalink): Do not lose classname * fix(tests): Add space back in display name * fix(status__wrapper): Remove duplicate css name Remove incorrect style attribute. Remove style attribute all together. Cursor defaults to "auto" when not specified as 'default'. * fix(nl): do not lose translations --- .../features/account/components/action_bar.jsx | 15 ++------ .../features/account/components/header.jsx | 6 ++-- .../account_timeline/components/header.jsx | 2 +- .../compose/components/autosuggest_account.jsx | 4 +-- .../compose/components/autosuggest_status.jsx | 2 +- .../compose/components/character_counter.jsx | 4 +-- .../features/compose/components/compose_form.jsx | 14 ++++---- .../compose/components/emoji_picker_dropdown.jsx | 14 ++++++-- .../features/compose/components/navigation_bar.jsx | 8 ++--- .../compose/components/privacy_dropdown.jsx | 7 +--- .../compose/components/reply_indicator.jsx | 8 ++--- .../features/compose/components/upload_button.jsx | 9 ++--- .../features/compose/components/upload_form.jsx | 8 ++--- .../compose/components/upload_progress.jsx | 4 +-- .../components/account_authorize.jsx | 31 +++++----------- .../components/features/followers/index.jsx | 2 +- .../components/features/following/index.jsx | 2 +- .../components/features/getting_started/index.jsx | 2 +- .../home_timeline/components/column_settings.jsx | 27 ++++---------- .../home_timeline/components/setting_text.jsx | 10 ------ .../components/features/mutes/index.jsx | 3 +- .../notifications/components/column_settings.jsx | 33 +++++------------ .../notifications/components/notification.jsx | 14 +++----- .../notifications/components/setting_toggle.jsx | 17 ++------- .../components/features/reblogs/index.jsx | 2 +- .../report/components/status_check_box.jsx | 5 ++- .../components/features/report/index.jsx | 17 ++++----- .../features/status/components/action_bar.jsx | 8 ++--- .../components/features/status/components/card.jsx | 19 ++-------- .../features/status/components/detailed_status.jsx | 22 +++++++++--- .../components/features/status/index.jsx | 2 +- .../features/ui/components/boost_modal.jsx | 8 ++--- .../features/ui/components/column_header.jsx | 2 +- .../features/ui/components/column_link.jsx | 17 ++------- .../features/ui/components/columns_area.jsx | 8 +---- .../features/ui/components/media_modal.jsx | 42 +++------------------- .../features/ui/components/modal_root.jsx | 2 +- .../features/ui/components/video_modal.jsx | 9 +---- 38 files changed, 129 insertions(+), 280 deletions(-) (limited to 'app/assets/javascripts/components/features') diff --git a/app/assets/javascripts/components/features/account/components/action_bar.jsx b/app/assets/javascripts/components/features/account/components/action_bar.jsx index 3aefee027..772ea3a38 100644 --- a/app/assets/javascripts/components/features/account/components/action_bar.jsx +++ b/app/assets/javascripts/components/features/account/components/action_bar.jsx @@ -17,17 +17,6 @@ const messages = defineMessages({ disclaimer: { id: 'account.disclaimer', defaultMessage: 'This user is from another instance. This number may be larger.' } }); -const outerDropdownStyle = { - padding: '10px', - flex: '1 1 auto' -}; - -const outerLinksStyle = { - flex: '1 1 auto', - display: 'flex', - lineHeight: '18px' -}; - class ActionBar extends React.PureComponent { render () { @@ -63,11 +52,11 @@ class ActionBar extends React.PureComponent { return (
-
+
-
+
{extraInfo} diff --git a/app/assets/javascripts/components/features/account/components/header.jsx b/app/assets/javascripts/components/features/account/components/header.jsx index 3ebfb7df3..958a5206b 100644 --- a/app/assets/javascripts/components/features/account/components/header.jsx +++ b/app/assets/javascripts/components/features/account/components/header.jsx @@ -25,11 +25,11 @@ class Avatar extends React.PureComponent { constructor (props, context) { super(props, context); - + this.state = { isHovered: false }; - + this.handleMouseOver = this.handleMouseOver.bind(this); this.handleMouseOut = this.handleMouseOut.bind(this); } @@ -56,7 +56,7 @@ class Avatar extends React.PureComponent { className='account__header__avatar' target='_blank' rel='noopener' - style={{ display: 'block', width: '90px', height: '90px', margin: '0 auto', marginBottom: '10px', borderRadius: `${radius}px`, overflow: 'hidden', backgroundSize: '90px 90px', backgroundImage: `url(${autoPlayGif || isHovered ? account.get('avatar') : account.get('avatar_static')})` }} + style={{ borderRadius: `${radius}px`, backgroundImage: `url(${autoPlayGif || isHovered ? account.get('avatar') : account.get('avatar_static')})` }} onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut} onFocus={this.handleMouseOver} diff --git a/app/assets/javascripts/components/features/account_timeline/components/header.jsx b/app/assets/javascripts/components/features/account_timeline/components/header.jsx index fb8b8b287..fd66c13e0 100644 --- a/app/assets/javascripts/components/features/account_timeline/components/header.jsx +++ b/app/assets/javascripts/components/features/account_timeline/components/header.jsx @@ -44,7 +44,7 @@ class Header extends React.PureComponent { } return ( -
+
( -
-
+
+
); diff --git a/app/assets/javascripts/components/features/compose/components/autosuggest_status.jsx b/app/assets/javascripts/components/features/compose/components/autosuggest_status.jsx index 086488649..275b3d5a6 100644 --- a/app/assets/javascripts/components/features/compose/components/autosuggest_status.jsx +++ b/app/assets/javascripts/components/features/compose/components/autosuggest_status.jsx @@ -3,7 +3,7 @@ import DisplayName from '../../../components/display_name'; import ImmutablePropTypes from 'react-immutable-proptypes'; const AutosuggestStatus = ({ status }) => ( -
+
@{status.getIn(['account', 'acct'])} }} />
); diff --git a/app/assets/javascripts/components/features/compose/components/character_counter.jsx b/app/assets/javascripts/components/features/compose/components/character_counter.jsx index b1e74b4de..31d82d4d2 100644 --- a/app/assets/javascripts/components/features/compose/components/character_counter.jsx +++ b/app/assets/javascripts/components/features/compose/components/character_counter.jsx @@ -4,9 +4,9 @@ class CharacterCounter extends React.PureComponent { checkRemainingText (diff) { if (diff <= 0) { - return {diff}; + return {diff}; } - return {diff}; + return {diff}; } render () { diff --git a/app/assets/javascripts/components/features/compose/components/compose_form.jsx b/app/assets/javascripts/components/features/compose/components/compose_form.jsx index b8e8ed5ef..c5ff8a5bd 100644 --- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx @@ -137,13 +137,13 @@ class ComposeForm extends React.PureComponent { } if (this.props.privacy === 'private' || this.props.privacy === 'direct') { - publishText = {intl.formatMessage(messages.publish)}; + publishText = {intl.formatMessage(messages.publish)}; } else { publishText = intl.formatMessage(messages.publish) + (this.props.privacy !== 'unlisted' ? '!' : ''); } return ( -
+
@@ -154,7 +154,7 @@ class ComposeForm extends React.PureComponent { -
+
-
+
@@ -184,9 +184,9 @@ class ComposeForm extends React.PureComponent {
-
-
-
+
+
+
diff --git a/app/assets/javascripts/components/features/compose/components/emoji_picker_dropdown.jsx b/app/assets/javascripts/components/features/compose/components/emoji_picker_dropdown.jsx index b8acf7ada..69042d3f7 100644 --- a/app/assets/javascripts/components/features/compose/components/emoji_picker_dropdown.jsx +++ b/app/assets/javascripts/components/features/compose/components/emoji_picker_dropdown.jsx @@ -22,12 +22,20 @@ const settings = { imagePathPNG: '/emoji/' }; -const style = { +const dropdownStyle = { position: 'absolute', right: '5px', top: '5px' }; +const dropdownTriggerStyle = { + display: 'block', + fontSize: '24px', + lineHeight: '24px', + marginLeft: '2px', + width: '24px' +} + class EmojiPickerDropdown extends React.PureComponent { constructor (props, context) { @@ -84,8 +92,8 @@ class EmojiPickerDropdown extends React.PureComponent { } return ( - - + + 馃檪 diff --git a/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx b/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx index f4c45278c..f3329133d 100644 --- a/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx +++ b/app/assets/javascripts/components/features/compose/components/navigation_bar.jsx @@ -11,11 +11,11 @@ class NavigationBar extends React.PureComponent { render () { return (
- + -
- {this.props.account.get('acct')} - +
+ {this.props.account.get('acct')} +
); diff --git a/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx b/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx index 6a80cf7a2..537871bb5 100644 --- a/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx +++ b/app/assets/javascripts/components/features/compose/components/privacy_dropdown.jsx @@ -14,11 +14,6 @@ const messages = defineMessages({ change_privacy: { id: 'privacy.change', defaultMessage: 'Adjust status privacy' } }); -const iconStyle = { - lineHeight: '27px', - height: null -}; - class PrivacyDropdown extends React.PureComponent { constructor (props, context) { @@ -77,7 +72,7 @@ class PrivacyDropdown extends React.PureComponent { return (
-
+
{options.map(item =>
diff --git a/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx b/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx index 784f08284..442ed5a35 100644 --- a/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx +++ b/app/assets/javascripts/components/features/compose/components/reply_indicator.jsx @@ -40,11 +40,11 @@ class ReplyIndicator extends React.PureComponent { return (
-
-
+ diff --git a/app/assets/javascripts/components/features/compose/components/upload_button.jsx b/app/assets/javascripts/components/features/compose/components/upload_button.jsx index 64b36a4df..80e5a0545 100644 --- a/app/assets/javascripts/components/features/compose/components/upload_button.jsx +++ b/app/assets/javascripts/components/features/compose/components/upload_button.jsx @@ -6,11 +6,6 @@ const messages = defineMessages({ upload: { id: 'upload_button.label', defaultMessage: 'Add media' } }); -const iconStyle = { - lineHeight: '27px', - height: null -}; - class UploadButton extends React.PureComponent { constructor (props, context) { @@ -38,8 +33,8 @@ class UploadButton extends React.PureComponent { const { intl, resetFileKey, disabled } = this.props; return ( -
- +
+
); diff --git a/app/assets/javascripts/components/features/compose/components/upload_form.jsx b/app/assets/javascripts/components/features/compose/components/upload_form.jsx index f28944ad5..a937cafb7 100644 --- a/app/assets/javascripts/components/features/compose/components/upload_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/upload_form.jsx @@ -15,10 +15,10 @@ class UploadForm extends React.PureComponent { const { intl, media } = this.props; const uploads = media.map(attachment => -
+
{({ scale }) => -
+
} @@ -27,9 +27,9 @@ class UploadForm extends React.PureComponent { ); return ( -
+
-
{uploads}
+
{uploads}
); } diff --git a/app/assets/javascripts/components/features/compose/components/upload_progress.jsx b/app/assets/javascripts/components/features/compose/components/upload_progress.jsx index a04edb97d..8f03bb76a 100644 --- a/app/assets/javascripts/components/features/compose/components/upload_progress.jsx +++ b/app/assets/javascripts/components/features/compose/components/upload_progress.jsx @@ -13,11 +13,11 @@ class UploadProgress extends React.PureComponent { return (
-
+
-
+
diff --git a/app/assets/javascripts/components/features/follow_requests/components/account_authorize.jsx b/app/assets/javascripts/components/features/follow_requests/components/account_authorize.jsx index a194d2b27..d35a54c12 100644 --- a/app/assets/javascripts/components/features/follow_requests/components/account_authorize.jsx +++ b/app/assets/javascripts/components/features/follow_requests/components/account_authorize.jsx @@ -12,38 +12,23 @@ const messages = defineMessages({ reject: { id: 'follow_request.reject', defaultMessage: 'Reject' } }); -const outerStyle = { - padding: '14px 10px' -}; - -const panelStyle = { - display: 'flex', - flexDirection: 'row', - padding: '10px 0' -}; - -const btnStyle = { - flex: '1 1 auto', - textAlign: 'center' -}; - const AccountAuthorize = ({ intl, account, onAuthorize, onReject }) => { const content = { __html: emojify(account.get('note')) }; return ( -
-
- -
+
+
+ +
-
+
-
-
-
+
+
+
) diff --git a/app/assets/javascripts/components/features/followers/index.jsx b/app/assets/javascripts/components/features/followers/index.jsx index 3ba4c2885..2b1e3719e 100644 --- a/app/assets/javascripts/components/features/followers/index.jsx +++ b/app/assets/javascripts/components/features/followers/index.jsx @@ -68,7 +68,7 @@ class Followers extends React.PureComponent {
-
+
{accountIds.map(id => )} diff --git a/app/assets/javascripts/components/features/following/index.jsx b/app/assets/javascripts/components/features/following/index.jsx index 0e3c440a5..30b320917 100644 --- a/app/assets/javascripts/components/features/following/index.jsx +++ b/app/assets/javascripts/components/features/following/index.jsx @@ -68,7 +68,7 @@ class Following extends React.PureComponent {
-
+
{accountIds.map(id => )} diff --git a/app/assets/javascripts/components/features/getting_started/index.jsx b/app/assets/javascripts/components/features/getting_started/index.jsx index 3fc4a683c..f9561b937 100644 --- a/app/assets/javascripts/components/features/getting_started/index.jsx +++ b/app/assets/javascripts/components/features/getting_started/index.jsx @@ -32,7 +32,7 @@ const GettingStarted = ({ intl, me }) => { return ( -
+
diff --git a/app/assets/javascripts/components/features/home_timeline/components/column_settings.jsx b/app/assets/javascripts/components/features/home_timeline/components/column_settings.jsx index b209a9f90..81a1a0e5b 100644 --- a/app/assets/javascripts/components/features/home_timeline/components/column_settings.jsx +++ b/app/assets/javascripts/components/features/home_timeline/components/column_settings.jsx @@ -10,21 +10,6 @@ const messages = defineMessages({ settings: { id: 'home.settings', defaultMessage: 'Column settings' } }); -const outerStyle = { - padding: '15px' -}; - -const sectionStyle = { - cursor: 'default', - display: 'block', - fontWeight: '500', - marginBottom: '10px' -}; - -const rowStyle = { - -}; - class ColumnSettings extends React.PureComponent { render () { @@ -32,20 +17,20 @@ class ColumnSettings extends React.PureComponent { return ( -
- +
+ -
+
} />
-
+
} />
- + -
+
diff --git a/app/assets/javascripts/components/features/home_timeline/components/setting_text.jsx b/app/assets/javascripts/components/features/home_timeline/components/setting_text.jsx index 44f8658e1..90b4aeb94 100644 --- a/app/assets/javascripts/components/features/home_timeline/components/setting_text.jsx +++ b/app/assets/javascripts/components/features/home_timeline/components/setting_text.jsx @@ -1,15 +1,6 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; -const style = { - display: 'block', - fontFamily: 'inherit', - marginBottom: '10px', - padding: '7px 0', - boxSizing: 'border-box', - width: '100%' -}; - class SettingText extends React.PureComponent { constructor (props, context) { @@ -26,7 +17,6 @@ class SettingText extends React.PureComponent { return ( -
+
{accountIds.map(id => )} @@ -60,6 +60,7 @@ class Mutes extends React.PureComponent { ); } + } Mutes.propTypes = { diff --git a/app/assets/javascripts/components/features/notifications/components/column_settings.jsx b/app/assets/javascripts/components/features/notifications/components/column_settings.jsx index 41c2e7d36..30063010c 100644 --- a/app/assets/javascripts/components/features/notifications/components/column_settings.jsx +++ b/app/assets/javascripts/components/features/notifications/components/column_settings.jsx @@ -8,21 +8,6 @@ const messages = defineMessages({ settings: { id: 'notifications.settings', defaultMessage: 'Column settings' } }); -const outerStyle = { - padding: '15px' -}; - -const sectionStyle = { - cursor: 'default', - display: 'block', - fontWeight: '500', - marginBottom: '10px' -}; - -const rowStyle = { - -}; - class ColumnSettings extends React.PureComponent { render () { @@ -34,34 +19,34 @@ class ColumnSettings extends React.PureComponent { return ( -
- +
+ -
+
- + -
+
- + -
+
- + -
+
diff --git a/app/assets/javascripts/components/features/notifications/components/notification.jsx b/app/assets/javascripts/components/features/notifications/components/notification.jsx index dadc6696a..34dd76bb7 100644 --- a/app/assets/javascripts/components/features/notifications/components/notification.jsx +++ b/app/assets/javascripts/components/features/notifications/components/notification.jsx @@ -6,17 +6,13 @@ import Permalink from '../../../components/permalink'; import emojify from '../../../emoji'; import escapeTextContentForBrowser from 'escape-html'; -const linkStyle = { - fontWeight: '500' -}; - class Notification extends React.PureComponent { renderFollow (account, link) { return (
-
+
@@ -36,8 +32,8 @@ class Notification extends React.PureComponent { return (
-
- +
+
@@ -52,7 +48,7 @@ class Notification extends React.PureComponent { return (
-
+
@@ -69,7 +65,7 @@ class Notification extends React.PureComponent { const account = notification.get('account'); const displayName = account.get('display_name').length > 0 ? account.get('display_name') : account.get('username'); const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) }; - const link = ; + const link = ; switch(notification.get('type')) { case 'follow': diff --git a/app/assets/javascripts/components/features/notifications/components/setting_toggle.jsx b/app/assets/javascripts/components/features/notifications/components/setting_toggle.jsx index 1c3957651..e9bca5928 100644 --- a/app/assets/javascripts/components/features/notifications/components/setting_toggle.jsx +++ b/app/assets/javascripts/components/features/notifications/components/setting_toggle.jsx @@ -2,23 +2,10 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import Toggle from 'react-toggle'; -const labelStyle = { - display: 'block', - lineHeight: '24px', - verticalAlign: 'middle' -}; - -const labelSpanStyle = { - display: 'inline-block', - verticalAlign: 'middle', - marginBottom: '14px', - marginLeft: '8px' -}; - const SettingToggle = ({ settings, settingKey, label, onChange, htmlFor = '' }) => ( -