Skip to content

Commit 844e981

Browse files
noellaboGargron
authored andcommitted
Improvement variable height in single column layout (mastodon#10917)
* Improvement variable height of compose and navigation panel in single column layout * Fix wrong quotes and missing commas
1 parent 39810ef commit 844e981

4 files changed

Lines changed: 95 additions & 58 deletions

File tree

app/javascript/mastodon/components/autosuggest_textarea.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,42 +189,46 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
189189
}
190190

191191
render () {
192-
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props;
192+
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, children } = this.props;
193193
const { suggestionsHidden } = this.state;
194194
const style = { direction: 'ltr' };
195195

196196
if (isRtl(value)) {
197197
style.direction = 'rtl';
198198
}
199199

200-
return (
201-
<div className='autosuggest-textarea'>
202-
<label>
203-
<span style={{ display: 'none' }}>{placeholder}</span>
204-
205-
<Textarea
206-
inputRef={this.setTextarea}
207-
className='autosuggest-textarea__textarea'
208-
disabled={disabled}
209-
placeholder={placeholder}
210-
autoFocus={autoFocus}
211-
value={value}
212-
onChange={this.onChange}
213-
onKeyDown={this.onKeyDown}
214-
onKeyUp={onKeyUp}
215-
onFocus={this.onFocus}
216-
onBlur={this.onBlur}
217-
onPaste={this.onPaste}
218-
style={style}
219-
aria-autocomplete='list'
220-
/>
221-
</label>
222-
200+
return [
201+
<div className='compose-form__autosuggest-wrapper'>
202+
<div className='autosuggest-textarea'>
203+
<label>
204+
<span style={{ display: 'none' }}>{placeholder}</span>
205+
206+
<Textarea
207+
inputRef={this.setTextarea}
208+
className='autosuggest-textarea__textarea'
209+
disabled={disabled}
210+
placeholder={placeholder}
211+
autoFocus={autoFocus}
212+
value={value}
213+
onChange={this.onChange}
214+
onKeyDown={this.onKeyDown}
215+
onKeyUp={onKeyUp}
216+
onFocus={this.onFocus}
217+
onBlur={this.onBlur}
218+
onPaste={this.onPaste}
219+
style={style}
220+
aria-autocomplete='list'
221+
/>
222+
</label>
223+
</div>
224+
{children}
225+
</div>,
226+
<div className='autosuggest-textarea__suggestions-wrapper'>
223227
<div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}>
224228
{suggestions.map(this.renderSuggestion)}
225229
</div>
226-
</div>
227-
);
230+
</div>,
231+
];
228232
}
229233

230234
}

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,29 @@ class ComposeForm extends ImmutablePureComponent {
200200
/>
201201
</div>
202202

203-
<div className='compose-form__autosuggest-wrapper'>
204-
<AutosuggestTextarea
205-
ref={this.setAutosuggestTextarea}
206-
placeholder={intl.formatMessage(messages.placeholder)}
207-
disabled={disabled}
208-
value={this.props.text}
209-
onChange={this.handleChange}
210-
suggestions={this.props.suggestions}
211-
onKeyDown={this.handleKeyDown}
212-
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
213-
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
214-
onSuggestionSelected={this.onSuggestionSelected}
215-
onPaste={onPaste}
216-
autoFocus={!showSearch && !isMobile(window.innerWidth)}
217-
/>
218-
203+
<div className='emoji-picker-wrapper'>
219204
<EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} />
220205
</div>
221206

222-
<div className='compose-form__modifiers'>
223-
<UploadFormContainer />
224-
<PollFormContainer />
225-
</div>
207+
<AutosuggestTextarea
208+
ref={this.setAutosuggestTextarea}
209+
placeholder={intl.formatMessage(messages.placeholder)}
210+
disabled={disabled}
211+
value={this.props.text}
212+
onChange={this.handleChange}
213+
suggestions={this.props.suggestions}
214+
onKeyDown={this.handleKeyDown}
215+
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
216+
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
217+
onSuggestionSelected={this.onSuggestionSelected}
218+
onPaste={onPaste}
219+
autoFocus={!showSearch && !isMobile(window.innerWidth)}
220+
>
221+
<div className='compose-form__modifiers'>
222+
<UploadFormContainer />
223+
<PollFormContainer />
224+
</div>
225+
</AutosuggestTextarea>
226226

227227
<div className='compose-form__buttons-wrapper'>
228228
<div className='compose-form__buttons'>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ const ComposePanel = () => (
99
<SearchContainer openInRoute />
1010
<NavigationContainer />
1111
<ComposeFormContainer />
12-
13-
<div className='flex-spacer' />
14-
1512
<LinkFooter withHotkeys />
1613
</div>
1714
);

app/javascript/styles/mastodon/components.scss

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,15 @@
333333
}
334334
}
335335

336+
.emoji-picker-dropdown {
337+
position: absolute;
338+
top: 5px;
339+
right: 5px;
340+
z-index: 1;
341+
}
342+
336343
.compose-form__autosuggest-wrapper {
337344
position: relative;
338-
339-
.emoji-picker-dropdown {
340-
position: absolute;
341-
right: 5px;
342-
top: 5px;
343-
}
344345
}
345346

346347
.autosuggest-textarea,
@@ -355,7 +356,8 @@
355356
opacity: 0.0;
356357

357358
&.spoiler-input--visible {
358-
height: 47px;
359+
height: 36px;
360+
margin-bottom: 11px;
359361
opacity: 1.0;
360362
}
361363
}
@@ -406,6 +408,12 @@
406408
}
407409
}
408410

411+
.emoji-picker-wrapper,
412+
.autosuggest-textarea__suggestions-wrapper {
413+
position: relative;
414+
height: 0;
415+
}
416+
409417
.autosuggest-textarea__suggestions {
410418
box-sizing: border-box;
411419
display: none;
@@ -566,6 +574,7 @@
566574
border-radius: 0 0 4px 4px;
567575
display: flex;
568576
justify-content: space-between;
577+
flex: 0 0 auto;
569578

570579
.compose-form__buttons {
571580
display: flex;
@@ -614,6 +623,7 @@
614623
display: flex;
615624
justify-content: flex-end;
616625
min-width: 0;
626+
flex: 0 0 auto;
617627

618628
.compose-form__publish-button-wrapper {
619629
overflow: hidden;
@@ -644,6 +654,9 @@
644654
margin-bottom: 10px;
645655
background: $ui-primary-color;
646656
padding: 10px;
657+
min-height: 23px;
658+
overflow-y: auto;
659+
flex: 0 2 auto;
647660
}
648661

649662
.reply-indicator__header {
@@ -2184,7 +2197,8 @@ a.account__display-name {
21842197
margin-top: 10px;
21852198
display: flex;
21862199
flex-direction: column;
2187-
height: 100%;
2200+
height: calc(100% - 10px);
2201+
overflow-y: hidden;
21882202

21892203
.search__input {
21902204
line-height: 18px;
@@ -2200,14 +2214,33 @@ a.account__display-name {
22002214
.navigation-bar {
22012215
padding-top: 20px;
22022216
padding-bottom: 20px;
2217+
flex: 0 1 48px;
2218+
min-height: 20px;
22032219
}
22042220

22052221
.flex-spacer {
22062222
background: transparent;
22072223
}
22082224

2225+
.compose-form {
2226+
flex: 1;
2227+
overflow-y: hidden;
2228+
display: flex;
2229+
flex-direction: column;
2230+
min-height: 310px;
2231+
padding-bottom: 71px;
2232+
margin-bottom: -71px;
2233+
}
2234+
2235+
.compose-form__autosuggest-wrapper {
2236+
overflow-y: auto;
2237+
background-color: $white;
2238+
border-radius: 4px 4px 0 0;
2239+
flex: 0 1 auto;
2240+
}
2241+
22092242
.autosuggest-textarea__textarea {
2210-
max-height: 200px;
2243+
overflow-y: hidden;
22112244
}
22122245

22132246
.compose-form__upload-thumbnail {
@@ -2217,6 +2250,9 @@ a.account__display-name {
22172250

22182251
.navigation-panel {
22192252
margin-top: 10px;
2253+
margin-bottom: 10px;
2254+
height: calc(100% - 20px);
2255+
overflow-y: auto;
22202256

22212257
hr {
22222258
border: 0;

0 commit comments

Comments
 (0)