Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5ca9acc

Browse files
authored
Improve design of the rich text editor (#9533)
New design for rich text composer
1 parent 9101b42 commit 5ca9acc

31 files changed

+669
-271
lines changed

res/css/_components.pcss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
@import "./views/rooms/_AuxPanel.pcss";
261261
@import "./views/rooms/_BasicMessageComposer.pcss";
262262
@import "./views/rooms/_E2EIcon.pcss";
263+
@import "./views/rooms/_EmojiButton.pcss";
263264
@import "./views/rooms/_EditMessageComposer.pcss";
264265
@import "./views/rooms/_EntityTile.pcss";
265266
@import "./views/rooms/_EventBubbleTile.pcss";

res/css/views/rooms/_EmojiButton.pcss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
@import "./_MessageComposerButton.pcss";
18+
19+
.mx_EmojiButton {
20+
@mixin composerButton 50%,$accent;
21+
}
22+
23+
.mx_EmojiButton_highlight {
24+
@mixin composerButtonHighLight;
25+
}
26+
27+
.mx_EmojiButton_icon::before {
28+
mask-image: url('$(res)/img/element-icons/room/composer/emoji.svg');
29+
}
30+
31+
.mx_MessageComposer_wysiwyg {
32+
.mx_EmojiButton {
33+
@mixin composerButton 5px,$tertiary-content;
34+
}
35+
}

res/css/views/rooms/_MessageComposer.pcss

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18+
@import "./_MessageComposerButton.pcss";
19+
1820
.mx_MessageComposer_wrapper {
1921
vertical-align: middle;
2022
margin: auto;
@@ -59,6 +61,12 @@ limitations under the License.
5961
width: 100%;
6062
}
6163

64+
.mx_MessageComposer_actions {
65+
display: flex;
66+
align-items: center;
67+
gap: 6px;
68+
}
69+
6270
.mx_MessageComposer .mx_MessageComposer_avatar {
6371
position: absolute;
6472
left: 26px;
@@ -171,53 +179,16 @@ limitations under the License.
171179
}
172180

173181
.mx_MessageComposer_button_highlight {
174-
background: rgba($accent, 0.25);
175-
/* make the icon the accent color too */
176-
&::before {
177-
background-color: $accent !important;
178-
}
182+
@mixin composerButtonHighLight;
179183
}
180184

181185
.mx_MessageComposer_button {
182-
--size: 26px;
183-
position: relative;
184-
cursor: pointer;
185-
height: var(--size);
186-
line-height: var(--size);
187-
width: auto;
188-
padding-left: var(--size);
189-
border-radius: 50%;
190-
margin-right: 6px;
186+
@mixin composerButton 50%,$accent;
191187

192188
&:last-child {
193189
margin-right: auto;
194190
}
195191

196-
&::before {
197-
content: '';
198-
position: absolute;
199-
top: 3px;
200-
left: 3px;
201-
height: 20px;
202-
width: 20px;
203-
background-color: $icon-button-color;
204-
mask-repeat: no-repeat;
205-
mask-size: contain;
206-
mask-position: center;
207-
}
208-
209-
&::after {
210-
content: '';
211-
position: absolute;
212-
left: 0;
213-
top: 0;
214-
z-index: 0;
215-
width: var(--size);
216-
height: var(--size);
217-
border-radius: 50%;
218-
}
219-
220-
&:hover,
221192
&.mx_MessageComposer_closeButtonMenu {
222193
&::after {
223194
background: rgba($accent, 0.1);
@@ -232,15 +203,43 @@ limitations under the License.
232203
background-color: $alert;
233204
}
234205
}
235-
236-
/*
237-
The wysisyg composer increase the size of the MessageComposer. We temporary move the buttons
238-
Soon the dom structure of the MessageComposer will change with the next evolution of the wysiwyg composer
239-
and this workaround will disappear
240-
*/
241206
.mx_MessageComposer_wysiwyg {
242-
.mx_MessageComposer_e2eIcon.mx_E2EIcon,.mx_MessageComposer_button, .mx_MessageComposer_sendMessage {
243-
margin-top: 28px;
207+
.mx_MessageComposer_wrapper {
208+
padding-left: 16px;
209+
margin-top: 6px;
210+
margin-bottom: 12px;
211+
}
212+
213+
.mx_MessageComposer_row {
214+
align-items: flex-end;
215+
}
216+
217+
.mx_MessageComposer_actions {
218+
/* Height of the composer editor */
219+
height: 40px;
220+
}
221+
222+
.mx_MediaBody {
223+
padding-top: 4px;
224+
padding-bottom: 4px;
225+
}
226+
227+
.mx_MessageComposer_button {
228+
@mixin composerButton 5px,$tertiary-content;
229+
230+
&.mx_MessageComposer_closeButtonMenu {
231+
&::after {
232+
background: rgba($accent, 0.1);
233+
}
234+
235+
&::before {
236+
background-color: $accent;
237+
}
238+
}
239+
240+
&.mx_MessageComposer_hangup:not(.mx_AccessibleButton_disabled)::before {
241+
background-color: $alert;
242+
}
244243
}
245244
}
246245

@@ -260,10 +259,6 @@ limitations under the License.
260259
mask-image: url('$(res)/img/element-icons/live.svg');
261260
}
262261

263-
.mx_MessageComposer_emoji::before {
264-
mask-image: url('$(res)/img/element-icons/room/composer/emoji.svg');
265-
}
266-
267262
.mx_MessageComposer_plain_text::before {
268263
mask-image: url('$(res)/img/element-icons/room/composer/plain_text.svg');
269264
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
@define-mixin composerButtonHighLight {
18+
background: rgba($accent, 0.25);
19+
/* make the icon the accent color too */
20+
&::before {
21+
background-color: $accent !important;
22+
}
23+
}
24+
25+
@define-mixin composerButton $border-radius,$hover-color {
26+
--size: 26px;
27+
position: relative;
28+
cursor: pointer;
29+
height: var(--size);
30+
line-height: var(--size);
31+
width: auto;
32+
padding-left: var(--size);
33+
border-radius: $border-radius;
34+
35+
&::before {
36+
content: '';
37+
position: absolute;
38+
top: 3px;
39+
left: 3px;
40+
height: 20px;
41+
width: 20px;
42+
background-color: $icon-button-color;
43+
mask-repeat: no-repeat;
44+
mask-size: contain;
45+
mask-position: center;
46+
}
47+
48+
&::after {
49+
content: '';
50+
position: absolute;
51+
left: 0;
52+
top: 0;
53+
z-index: 0;
54+
width: var(--size);
55+
height: var(--size);
56+
border-radius: $border-radius;
57+
}
58+
59+
&:hover {
60+
&::after {
61+
background: rgba($hover-color, 0.1);
62+
}
63+
64+
&::before {
65+
background-color: $hover-color;
66+
}
67+
}
68+
}

res/css/views/rooms/_VoiceRecordComposerTile.pcss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
height: 28px;
2121
border: 2px solid $voice-record-stop-border-color;
2222
border-radius: 32px;
23-
margin-right: 8px; /* between us and the waveform component */
23+
margin-right: 2px; /* between us and the waveform component */
2424
position: relative;
2525

2626
&::after {
@@ -39,7 +39,7 @@ limitations under the License.
3939
width: 24px;
4040
height: 24px;
4141
vertical-align: middle;
42-
margin-right: 8px; /* distance from left edge of waveform container (container has some margin too) */
42+
margin-right: 2px; /* distance from left edge of waveform container (container has some margin too) */
4343
background-color: $voice-record-icon-color;
4444
mask-repeat: no-repeat;
4545
mask-size: contain;
@@ -69,7 +69,7 @@ limitations under the License.
6969
height: 32px;
7070

7171
margin: 6px; /* force the composer area to put a gutter around us */
72-
margin-right: 12px; /* isolate from stop/send button */
72+
margin-right: 6px; /* isolate from stop/send button */
7373

7474
position: relative; /* important for the live circle */
7575

@@ -93,6 +93,14 @@ limitations under the License.
9393
}
9494
}
9595

96+
.mx_MessageComposer_wysiwyg .mx_VoiceMessagePrimaryContainer {
97+
&.mx_VoiceRecordComposerTile_recording {
98+
&::before {
99+
top: 15px; /* vertically center (middle align with clock) */
100+
}
101+
}
102+
}
103+
96104
/* The keyframes are slightly weird here to help make a ramping/punch effect */
97105
/* for the recording dot. We start and end at 100% opacity to help make the */
98106
/* dot feel a bit like a real lamp that is blinking: the animation ends up */

res/css/views/rooms/wysiwyg_composer/_EditWysiwygComposer.pcss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424
gap: 8px;
2525
padding: 8px var(--EditWysiwygComposer-padding-inline);
2626

27-
.mx_WysiwygComposer_content {
27+
.mx_WysiwygComposer_Editor_content {
2828
border-radius: 4px;
2929
border: solid 1px $primary-hairline-color;
3030
background-color: $background;

res/css/views/rooms/wysiwyg_composer/_SendWysiwygComposer.pcss

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,65 @@ limitations under the License.
2222
/* fixed line height to prevent emoji from being taller than text */
2323
line-height: $font-18px;
2424
justify-content: center;
25-
margin-right: 6px;
26-
/* don't grow wider than available space */
27-
min-width: 0;
25+
margin-right: 13px;
26+
gap: 8px;
2827

29-
.mx_WysiwygComposer_container {
30-
flex: 1;
28+
.mx_FormattingButtons {
29+
margin-left: 12px;
30+
}
31+
32+
.mx_WysiwygComposer_Editor {
33+
border: 1px solid;
34+
border-color: $quinary-content;
35+
padding: 6px 11px 6px 12px;
3136
display: flex;
32-
flex-direction: column;
33-
/* min-height at this level so the mx_BasicMessageComposer_input */
34-
/* still stays vertically centered when less than 55px. */
35-
/* We also set this to ensure the voice message recording widget */
36-
/* doesn't cause a jump. */
37-
min-height: 55px;
38-
39-
.mx_WysiwygComposer_content {
40-
border: 1px solid;
41-
border-radius: 20px;
42-
padding: 8px 10px;
43-
/* this will center the contenteditable */
44-
/* in it's parent vertically */
45-
/* while keeping the autocomplete at the top */
46-
/* of the composer. The parent needs to be a flex container for this to work. */
47-
margin: auto 0;
48-
/* max-height at this level so autocomplete doesn't get scrolled too */
49-
max-height: 140px;
50-
overflow-y: auto;
37+
align-items: flex-end;
38+
gap: 10px;
39+
40+
.mx_E2EIcon {
41+
margin: 0 0 7px 0;
42+
width: 12px;
43+
height: 12px;
44+
}
45+
46+
&[data-is-expanded="true"] {
47+
border-radius: 14px;
48+
49+
.mx_WysiwygComposer_Editor_container {
50+
margin-top: 3px;
51+
margin-bottom: 3px;
52+
}
53+
}
54+
55+
&[data-is-expanded="false"] {
56+
border-radius: 40px;
57+
}
58+
59+
.mx_WysiwygComposer_Editor_container {
60+
flex: 1;
61+
display: flex;
62+
flex-direction: column;
63+
min-height: 22px;
64+
margin-bottom: 2px;
65+
/* don't grow wider than available space */
66+
width: 0;
67+
68+
.mx_WysiwygComposer_Editor_content {
69+
/* this will center the contenteditable */
70+
/* in it's parent vertically */
71+
/* while keeping the autocomplete at the top */
72+
/* of the composer. The parent needs to be a flex container for this to work. */
73+
margin: auto 0;
74+
/* max-height at this level so autocomplete doesn't get scrolled too */
75+
max-height: 140px;
76+
overflow-y: auto;
77+
}
5178
}
5279
}
5380
}
81+
82+
.mx_SendWysiwygComposer-focused {
83+
.mx_WysiwygComposer_Editor {
84+
border-color: $quaternary-content;
85+
}
86+
}

0 commit comments

Comments
 (0)