Skip to content

Commit 3a60f49

Browse files
committed
Fix hashtags select styling in default and high contrast themes
1 parent 3d374ed commit 3a60f49

3 files changed

Lines changed: 128 additions & 53 deletions

File tree

app/javascript/mastodon/features/hashtag_timeline/components/column_settings.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import ImmutablePropTypes from 'react-immutable-proptypes';
4-
import { injectIntl, FormattedMessage } from 'react-intl';
4+
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
55
import Toggle from 'react-toggle';
66
import AsyncSelect from 'react-select/lib/Async';
77

8+
const messages = defineMessages({
9+
placeholder: { id: 'hashtag.column_settings.select.placeholder', defaultMessage: 'Enter hashtags…' },
10+
noOptions: { id: 'hashtag.column_settings.select.no_options_message', defaultMessage: 'No suggestions found' },
11+
});
12+
813
export default @injectIntl
914
class ColumnSettings extends React.PureComponent {
1015

@@ -25,76 +30,82 @@ class ColumnSettings extends React.PureComponent {
2530

2631
tags (mode) {
2732
let tags = this.props.settings.getIn(['tags', mode]) || [];
33+
2834
if (tags.toJSON) {
2935
return tags.toJSON();
3036
} else {
3137
return tags;
3238
}
3339
};
3440

35-
onSelect = (mode) => {
36-
return (value) => {
37-
this.props.onChange(['tags', mode], value);
38-
};
39-
};
41+
onSelect = mode => value => this.props.onChange(['tags', mode], value);
4042

4143
onToggle = () => {
4244
if (this.state.open && this.hasTags()) {
4345
this.props.onChange('tags', {});
4446
}
47+
4548
this.setState({ open: !this.state.open });
4649
};
4750

51+
noOptionsMessage = () => this.props.intl.formatMessage(messages.noOptions);
52+
4853
modeSelect (mode) {
4954
return (
50-
<div className='column-settings__section'>
51-
{this.modeLabel(mode)}
55+
<div className='column-settings__row'>
56+
<span className='column-settings__section'>
57+
{this.modeLabel(mode)}
58+
</span>
59+
5260
<AsyncSelect
5361
isMulti
5462
autoFocus
5563
value={this.tags(mode)}
56-
settings={this.props.settings}
57-
settingPath={['tags', mode]}
5864
onChange={this.onSelect(mode)}
5965
loadOptions={this.props.onLoad}
60-
classNamePrefix='column-settings__hashtag-select'
66+
className='column-select__container'
67+
classNamePrefix='column-select'
6168
name='tags'
69+
placeholder={this.props.intl.formatMessage(messages.placeholder)}
70+
noOptionsMessage={this.noOptionsMessage}
6271
/>
6372
</div>
6473
);
6574
}
6675

6776
modeLabel (mode) {
6877
switch(mode) {
69-
case 'any': return <FormattedMessage id='hashtag.column_settings.tag_mode.any' defaultMessage='Any of these' />;
70-
case 'all': return <FormattedMessage id='hashtag.column_settings.tag_mode.all' defaultMessage='All of these' />;
71-
case 'none': return <FormattedMessage id='hashtag.column_settings.tag_mode.none' defaultMessage='None of these' />;
78+
case 'any':
79+
return <FormattedMessage id='hashtag.column_settings.tag_mode.any' defaultMessage='Any of these' />;
80+
case 'all':
81+
return <FormattedMessage id='hashtag.column_settings.tag_mode.all' defaultMessage='All of these' />;
82+
case 'none':
83+
return <FormattedMessage id='hashtag.column_settings.tag_mode.none' defaultMessage='None of these' />;
84+
default:
85+
return '';
7286
}
73-
return '';
7487
};
7588

7689
render () {
7790
return (
7891
<div>
7992
<div className='column-settings__row'>
8093
<div className='setting-toggle'>
81-
<Toggle
82-
id='hashtag.column_settings.tag_toggle'
83-
onChange={this.onToggle}
84-
checked={this.state.open}
85-
/>
94+
<Toggle id='hashtag.column_settings.tag_toggle' onChange={this.onToggle} checked={this.state.open} />
95+
8696
<span className='setting-toggle__label'>
8797
<FormattedMessage id='hashtag.column_settings.tag_toggle' defaultMessage='Include additional tags in this column' />
8898
</span>
8999
</div>
90100
</div>
91-
{this.state.open &&
101+
102+
{this.state.open && (
92103
<div className='column-settings__hashtags'>
93104
{this.modeSelect('any')}
94105
{this.modeSelect('all')}
95106
{this.modeSelect('none')}
96107
</div>
97-
}
108+
)}
98109
</div>
99110
);
100111
}

app/javascript/styles/mastodon/_mixins.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,34 @@
4141
font-size: 16px;
4242
}
4343
}
44+
45+
@mixin search-popout() {
46+
background: $simple-background-color;
47+
border-radius: 4px;
48+
padding: 10px 14px;
49+
padding-bottom: 14px;
50+
margin-top: 10px;
51+
color: $light-text-color;
52+
box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4);
53+
54+
h4 {
55+
text-transform: uppercase;
56+
color: $light-text-color;
57+
font-size: 13px;
58+
font-weight: 500;
59+
margin-bottom: 10px;
60+
}
61+
62+
li {
63+
padding: 4px 0;
64+
}
65+
66+
ul {
67+
margin-bottom: 10px;
68+
}
69+
70+
em {
71+
font-weight: 500;
72+
color: $inverted-text-color;
73+
}
74+
}

app/javascript/styles/mastodon/components.scss

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,24 +3056,84 @@ a.status-card.compact:hover {
30563056
display: block;
30573057
font-weight: 500;
30583058
margin-bottom: 10px;
3059+
}
3060+
3061+
.column-settings__hashtags {
3062+
.column-settings__row {
3063+
margin-bottom: 15px;
3064+
}
30593065

3060-
.column-settings__hashtag-select {
3066+
.column-select {
30613067
&__control {
30623068
@include search-input();
30633069
}
30643070

3071+
&__placeholder {
3072+
color: $dark-text-color;
3073+
padding-left: 2px;
3074+
font-size: 12px;
3075+
}
3076+
3077+
&__value-container {
3078+
padding-left: 6px;
3079+
}
3080+
30653081
&__multi-value {
30663082
background: lighten($ui-base-color, 8%);
3083+
3084+
&__remove {
3085+
cursor: pointer;
3086+
3087+
&:hover,
3088+
&:active,
3089+
&:focus {
3090+
background: lighten($ui-base-color, 12%);
3091+
color: lighten($darker-text-color, 4%);
3092+
}
3093+
}
30673094
}
30683095

30693096
&__multi-value__label,
30703097
&__input {
30713098
color: $darker-text-color;
30723099
}
30733100

3074-
&__indicator-separator,
3101+
&__clear-indicator,
30753102
&__dropdown-indicator {
3076-
display: none;
3103+
cursor: pointer;
3104+
transition: none;
3105+
color: $dark-text-color;
3106+
3107+
&:hover,
3108+
&:active,
3109+
&:focus {
3110+
color: lighten($dark-text-color, 4%);
3111+
}
3112+
}
3113+
3114+
&__indicator-separator {
3115+
background-color: lighten($ui-base-color, 8%);
3116+
}
3117+
3118+
&__menu {
3119+
@include search-popout();
3120+
padding: 0;
3121+
background: $ui-secondary-color;
3122+
}
3123+
3124+
&__menu-list {
3125+
padding: 6px;
3126+
}
3127+
3128+
&__option {
3129+
color: $inverted-text-color;
3130+
border-radius: 4px;
3131+
font-size: 14px;
3132+
3133+
&--is-focused,
3134+
&--is-selected {
3135+
background: darken($ui-secondary-color, 10%);
3136+
}
30773137
}
30783138
}
30793139
}
@@ -4867,34 +4927,7 @@ a.status-card.compact:hover {
48674927
}
48684928

48694929
.search-popout {
4870-
background: $simple-background-color;
4871-
border-radius: 4px;
4872-
padding: 10px 14px;
4873-
padding-bottom: 14px;
4874-
margin-top: 10px;
4875-
color: $light-text-color;
4876-
box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4);
4877-
4878-
h4 {
4879-
text-transform: uppercase;
4880-
color: $light-text-color;
4881-
font-size: 13px;
4882-
font-weight: 500;
4883-
margin-bottom: 10px;
4884-
}
4885-
4886-
li {
4887-
padding: 4px 0;
4888-
}
4889-
4890-
ul {
4891-
margin-bottom: 10px;
4892-
}
4893-
4894-
em {
4895-
font-weight: 500;
4896-
color: $inverted-text-color;
4897-
}
4930+
@include search-popout();
48984931
}
48994932

49004933
noscript {

0 commit comments

Comments
 (0)