Skip to content

Commit daf3a01

Browse files
Gargronhiyuki2578
authored andcommitted
Add responsive panels to the single-column layout (mastodon#10820)
* Add responsive panels to the single-column layout * Fixes * Fix not being able to save the preference * Fix code style issues * Set max-height on the compose textarea and add a link to relationship manager
1 parent ae8f450 commit daf3a01

26 files changed

Lines changed: 389 additions & 96 deletions

File tree

app/controllers/settings/preferences_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def user_settings_params
4949
:setting_hide_network,
5050
:setting_aggregate_reblogs,
5151
:setting_show_application,
52+
:setting_advanced_layout,
5253
notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account),
5354
interactions: %i(must_be_follower must_be_following)
5455
)

app/javascript/mastodon/actions/compose.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ const messages = defineMessages({
6363
uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
6464
});
6565

66+
const COMPOSE_PANEL_BREAKPOINT = 600 + (285 * 1) + (10 * 3);
67+
68+
export const ensureComposeIsVisible = (getState, routerHistory) => {
69+
if (!getState().getIn(['compose', 'mounted']) && window.innerWidth < COMPOSE_PANEL_BREAKPOINT) {
70+
routerHistory.push('/statuses/new');
71+
}
72+
};
73+
6674
export function changeCompose(text) {
6775
return {
6876
type: COMPOSE_CHANGE,
@@ -77,9 +85,7 @@ export function replyCompose(status, routerHistory) {
7785
status: status,
7886
});
7987

80-
if (!getState().getIn(['compose', 'mounted'])) {
81-
routerHistory.push('/statuses/new');
82-
}
88+
ensureComposeIsVisible(getState, routerHistory);
8389
};
8490
};
8591

@@ -102,9 +108,7 @@ export function mentionCompose(account, routerHistory) {
102108
account: account,
103109
});
104110

105-
if (!getState().getIn(['compose', 'mounted'])) {
106-
routerHistory.push('/statuses/new');
107-
}
111+
ensureComposeIsVisible(getState, routerHistory);
108112
};
109113
};
110114

@@ -115,9 +119,7 @@ export function directCompose(account, routerHistory) {
115119
account: account,
116120
});
117121

118-
if (!getState().getIn(['compose', 'mounted'])) {
119-
routerHistory.push('/statuses/new');
120-
}
122+
ensureComposeIsVisible(getState, routerHistory);
121123
};
122124
};
123125

app/javascript/mastodon/actions/statuses.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { evictStatus } from '../storage/modifier';
44

55
import { deleteFromTimelines } from './timelines';
66
import { importFetchedStatus, importFetchedStatuses, importAccount, importStatus } from './importer';
7+
import { ensureComposeIsVisible } from './compose';
78

89
export const STATUS_FETCH_REQUEST = 'STATUS_FETCH_REQUEST';
910
export const STATUS_FETCH_SUCCESS = 'STATUS_FETCH_SUCCESS';
@@ -139,7 +140,7 @@ export function redraft(status, raw_text) {
139140
};
140141
};
141142

142-
export function deleteStatus(id, router, withRedraft = false) {
143+
export function deleteStatus(id, routerHistory, withRedraft = false) {
143144
return (dispatch, getState) => {
144145
let status = getState().getIn(['statuses', id]);
145146

@@ -156,10 +157,7 @@ export function deleteStatus(id, router, withRedraft = false) {
156157

157158
if (withRedraft) {
158159
dispatch(redraft(status, response.data.text));
159-
160-
if (!getState().getIn(['compose', 'mounted'])) {
161-
router.push('/statuses/new');
162-
}
160+
ensureComposeIsVisible(getState, routerHistory);
163161
}
164162
}).catch(error => {
165163
dispatch(deleteStatusFail(id, error));

app/javascript/mastodon/components/autosuggest_input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class AutosuggestInput extends ImmutablePureComponent {
4949
autoFocus: PropTypes.bool,
5050
className: PropTypes.string,
5151
id: PropTypes.string,
52-
searchTokens: ImmutablePropTypes.list,
52+
searchTokens: PropTypes.arrayOf(PropTypes.string),
5353
maxLength: PropTypes.number,
5454
};
5555

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ActionBar extends React.PureComponent {
4646
return (
4747
<div className='compose__action-bar'>
4848
<div className='compose__action-bar-dropdown'>
49-
<DropdownMenuContainer items={menu} icon='ellipsis-v' size={24} direction='right' />
49+
<DropdownMenuContainer items={menu} icon='chevron-down' size={16} direction='right' />
5050
</div>
5151
</div>
5252
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class NavigationBar extends ImmutablePureComponent {
2020
<div className='navigation-bar'>
2121
<Permalink href={this.props.account.get('url')} to={`/accounts/${this.props.account.get('id')}`}>
2222
<span style={{ display: 'none' }}>{this.props.account.get('acct')}</span>
23-
<Avatar account={this.props.account} size={40} />
23+
<Avatar account={this.props.account} size={48} />
2424
</Permalink>
2525

2626
<div className='navigation-bar__profile'>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ class SearchPopout extends React.PureComponent {
4747
export default @injectIntl
4848
class Search extends React.PureComponent {
4949

50+
static contextTypes = {
51+
router: PropTypes.object.isRequired,
52+
};
53+
5054
static propTypes = {
5155
value: PropTypes.string.isRequired,
5256
submitted: PropTypes.bool,
5357
onChange: PropTypes.func.isRequired,
5458
onSubmit: PropTypes.func.isRequired,
5559
onClear: PropTypes.func.isRequired,
5660
onShow: PropTypes.func.isRequired,
61+
openInRoute: PropTypes.bool,
5762
intl: PropTypes.object.isRequired,
5863
};
5964

@@ -76,7 +81,12 @@ class Search extends React.PureComponent {
7681
handleKeyUp = (e) => {
7782
if (e.key === 'Enter') {
7883
e.preventDefault();
84+
7985
this.props.onSubmit();
86+
87+
if (this.props.openInRoute) {
88+
this.context.router.history.push('/search');
89+
}
8090
} else if (e.key === 'Escape') {
8191
document.querySelector('.ui').parentElement.focus();
8292
}

app/javascript/mastodon/features/getting_started/index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
99
import ImmutablePureComponent from 'react-immutable-pure-component';
1010
import { me, invitesEnabled, version, profile_directory, repository, source_url } from '../../initial_state';
1111
import { fetchFollowRequests } from 'mastodon/actions/accounts';
12-
import { changeSetting } from 'mastodon/actions/settings';
1312
import { List as ImmutableList } from 'immutable';
1413
import { Link } from 'react-router-dom';
1514
import NavigationBar from '../compose/components/navigation_bar';
1615
import Icon from 'mastodon/components/icon';
17-
import Toggle from 'react-toggle';
1816

1917
const messages = defineMessages({
2018
home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
@@ -41,12 +39,10 @@ const messages = defineMessages({
4139
const mapStateToProps = state => ({
4240
myAccount: state.getIn(['accounts', me]),
4341
unreadFollowRequests: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size,
44-
forceSingleColumn: state.getIn(['settings', 'forceSingleColumn'], false),
4542
});
4643

4744
const mapDispatchToProps = dispatch => ({
4845
fetchFollowRequests: () => dispatch(fetchFollowRequests()),
49-
changeForceSingleColumn: checked => dispatch(changeSetting(['forceSingleColumn'], checked)),
5046
});
5147

5248
const badgeDisplay = (number, limit) => {
@@ -71,8 +67,6 @@ class GettingStarted extends ImmutablePureComponent {
7167
fetchFollowRequests: PropTypes.func.isRequired,
7268
unreadFollowRequests: PropTypes.number,
7369
unreadNotifications: PropTypes.number,
74-
forceSingleColumn: PropTypes.bool,
75-
changeForceSingleColumn: PropTypes.func.isRequired,
7670
};
7771

7872
componentDidMount () {
@@ -83,12 +77,8 @@ class GettingStarted extends ImmutablePureComponent {
8377
}
8478
}
8579

86-
handleForceSingleColumnChange = ({ target }) => {
87-
this.props.changeForceSingleColumn(target.checked);
88-
}
89-
9080
render () {
91-
const { intl, myAccount, multiColumn, unreadFollowRequests, forceSingleColumn } = this.props;
81+
const { intl, myAccount, multiColumn, unreadFollowRequests } = this.props;
9282

9383
const navItems = [];
9484
let i = 1;
@@ -187,11 +177,6 @@ class GettingStarted extends ImmutablePureComponent {
187177
</p>
188178
</div>
189179
</div>
190-
191-
<label className='navigational-toggle'>
192-
<FormattedMessage id='getting_started.use_simple_layout' defaultMessage='Use simple layout' />
193-
<Toggle checked={forceSingleColumn} onChange={this.handleForceSingleColumnChange} />
194-
</label>
195180
</Column>
196181
);
197182
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import SearchContainer from 'mastodon/features/compose/containers/search_container';
3+
import SearchResultsContainer from 'mastodon/features/compose/containers/search_results_container';
4+
5+
const Search = () => (
6+
<div className='column search-page'>
7+
<SearchContainer />
8+
9+
<div className='drawer__pager'>
10+
<div className='drawer__inner darker'>
11+
<SearchResultsContainer />
12+
</div>
13+
</div>
14+
</div>
15+
);
16+
17+
export default Search;

app/javascript/mastodon/features/ui/components/columns_area.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import DrawerLoading from './drawer_loading';
1414
import BundleColumnError from './bundle_column_error';
1515
import { Compose, Notifications, HomeTimeline, CommunityTimeline, PublicTimeline, HashtagTimeline, DirectTimeline, FavouritedStatuses, ListTimeline } from '../../ui/util/async-components';
1616
import Icon from 'mastodon/components/icon';
17+
import ComposePanel from './compose_panel';
18+
import NavigationPanel from './navigation_panel';
1719

1820
import detectPassiveEvents from 'detect-passive-events';
1921
import { scrollRight } from '../../../scroll';
@@ -173,14 +175,22 @@ class ColumnsArea extends ImmutablePureComponent {
173175

174176
return (
175177
<div className='columns-area__panels'>
176-
<div className='columns-area__panels__pane' />
178+
<div className='columns-area__panels__pane columns-area__panels__pane--compositional'>
179+
<div className='columns-area__panels__pane__inner'>
180+
<ComposePanel />
181+
</div>
182+
</div>
177183

178184
<div className='columns-area__panels__main'>
179185
<TabsBar key='tabs' />
180186
{content}
181187
</div>
182188

183-
<div className='columns-area__panels__pane' />
189+
<div className='columns-area__panels__pane columns-area__panels__pane--start columns-area__panels__pane--navigational'>
190+
<div className='columns-area__panels__pane__inner'>
191+
<NavigationPanel />
192+
</div>
193+
</div>
184194

185195
{floatingActionButton}
186196
</div>

0 commit comments

Comments
 (0)