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

Commit b7cd1f0

Browse files
authored
Use Icon component for icons on AppTile's menu bar (#10955)
* Use icon component for buttons on mx_AppTileMenuBar_widgets * Remove redundant declarations * Add a Percy snapshot test * Set color value to mx_Icon, fill and stroke with currentColor * Iterate
1 parent 2e3cb0a commit b7cd1f0

File tree

8 files changed

+76
-73
lines changed

8 files changed

+76
-73
lines changed

cypress/e2e/widgets/layout.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ describe("Widget Layout", () => {
9595
cy.stopWebServers();
9696
});
9797

98+
it("should be set properly", () => {
99+
cy.get(".mx_AppsDrawer").percySnapshotElement("Widgets drawer on the timeline (AppsDrawer)");
100+
});
101+
98102
it("manually resize the height of the top container layout", () => {
99103
cy.get('iframe[title="widget"]').invoke("height").should("be.lessThan", 250);
100104

res/css/views/rooms/_AppsDrawer.pcss

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -222,60 +222,34 @@ limitations under the License.
222222
}
223223

224224
.mx_AppTileMenuBar_widgets {
225-
float: right;
226225
display: flex;
227-
flex-direction: row;
228226
align-items: center;
229-
}
230-
231-
.mx_AppTileMenuBar_iconButton {
232-
--size: 24px; /* Size of the button. Its height and width values should be same */
233227

234-
margin: 0 4px;
235-
position: relative;
236-
height: var(--size);
237-
width: var(--size);
228+
.mx_AppTileMenuBar_widgets_button {
229+
--size: 24px; /* Size of the button. Its height and width values should be same */
238230

239-
&::before,
240-
&:hover::after {
241-
content: "";
242-
position: absolute;
231+
margin: 0 4px;
232+
position: relative;
243233
height: var(--size);
244234
width: var(--size);
245-
}
246-
247-
&::before {
248-
background-color: $muted-fg-color;
249-
mask-position: center;
250-
mask-repeat: no-repeat;
251-
mask-size: 12px;
252-
}
253-
254-
&:hover::after {
255-
background-color: $panel-actions;
256-
border-radius: 50%;
257-
left: 0;
258-
top: 0;
259-
}
260-
261-
&.mx_AppTileMenuBar_iconButton--collapse::before {
262-
mask-image: url("$(res)/img/element-icons/minimise-collapse.svg");
263-
}
264-
265-
&.mx_AppTileMenuBar_iconButton--maximise::before {
266-
mask-image: url("$(res)/img/element-icons/maximise-expand.svg");
267-
}
268-
269-
&.mx_AppTileMenuBar_iconButton--minimise::before {
270-
mask-image: url("$(res)/img/element-icons/minus-button.svg");
271-
}
272-
273-
&.mx_AppTileMenuBar_iconButton--popout::before {
274-
mask-image: url("$(res)/img/feather-customised/widget/external-link.svg");
275-
}
276-
277-
&.mx_AppTileMenuBar_iconButton--menu::before {
278-
mask-image: url("$(res)/img/element-icons/room/ellipsis.svg");
235+
display: flex;
236+
align-items: center;
237+
justify-content: center;
238+
239+
&:hover::after {
240+
content: "";
241+
position: absolute;
242+
height: var(--size);
243+
width: var(--size);
244+
background-color: $panel-actions;
245+
border-radius: 50%;
246+
left: 0;
247+
top: 0;
248+
}
249+
250+
.mx_Icon {
251+
color: $muted-fg-color;
252+
}
279253
}
280254
}
281255
}
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 3 additions & 3 deletions
Loading
Lines changed: 1 addition & 1 deletion
Loading

src/components/views/elements/AppTile.tsx

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ import { WidgetContextMenu } from "../context_menus/WidgetContextMenu";
4040
import WidgetAvatar from "../avatars/WidgetAvatar";
4141
import LegacyCallHandler from "../../../LegacyCallHandler";
4242
import { IApp, isAppWidget } from "../../../stores/WidgetStore";
43+
import { Icon as CollapseIcon } from "../../../../res/img/element-icons/minimise-collapse.svg";
44+
import { Icon as MaximiseIcon } from "../../../../res/img/element-icons/maximise-expand.svg";
45+
import { Icon as MinimiseIcon } from "../../../../res/img/element-icons/minus-button.svg";
46+
import { Icon as PopoutIcon } from "../../../../res/img/feather-customised/widget/external-link.svg";
47+
import { Icon as MenuIcon } from "../../../../res/img/element-icons/room/ellipsis.svg";
4348
import { Container, WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore";
4449
import { OwnProfileStore } from "../../../stores/OwnProfileStore";
4550
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
@@ -714,27 +719,31 @@ export default class AppTile extends React.Component<IProps, IState> {
714719
const isMaximised =
715720
this.props.room &&
716721
WidgetLayoutStore.instance.isInContainer(this.props.room, this.props.app, Container.Center);
717-
const maximisedClasses = classNames({
718-
"mx_AppTileMenuBar_iconButton": true,
719-
"mx_AppTileMenuBar_iconButton--collapse": isMaximised,
720-
"mx_AppTileMenuBar_iconButton--maximise": !isMaximised,
721-
});
722+
722723
layoutButtons.push(
723724
<AccessibleButton
724725
key="toggleMaximised"
725-
className={maximisedClasses}
726+
className="mx_AppTileMenuBar_widgets_button"
726727
title={isMaximised ? _t("Un-maximise") : _t("Maximise")}
727728
onClick={this.onToggleMaximisedClick}
728-
/>,
729+
>
730+
{isMaximised ? (
731+
<CollapseIcon className="mx_Icon mx_Icon_12" />
732+
) : (
733+
<MaximiseIcon className="mx_Icon mx_Icon_12" />
734+
)}
735+
</AccessibleButton>,
729736
);
730737

731738
layoutButtons.push(
732739
<AccessibleButton
733740
key="minimise"
734-
className="mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton--minimise"
741+
className="mx_AppTileMenuBar_widgets_button"
735742
title={_t("Minimise")}
736743
onClick={this.onMinimiseClicked}
737-
/>,
744+
>
745+
<MinimiseIcon className="mx_Icon mx_Icon_12" />
746+
</AccessibleButton>,
738747
);
739748
}
740749

@@ -753,18 +762,22 @@ export default class AppTile extends React.Component<IProps, IState> {
753762
{layoutButtons}
754763
{this.props.showPopout && !this.state.requiresClient && (
755764
<AccessibleButton
756-
className="mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton--popout"
765+
className="mx_AppTileMenuBar_widgets_button"
757766
title={_t("Popout widget")}
758767
onClick={this.onPopoutWidgetClick}
759-
/>
768+
>
769+
<PopoutIcon className="mx_Icon mx_Icon_12 mx_Icon--stroke" />
770+
</AccessibleButton>
760771
)}
761772
<ContextMenuButton
762-
className="mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton--menu"
773+
className="mx_AppTileMenuBar_widgets_button"
763774
label={_t("Options")}
764775
isExpanded={this.state.menuDisplayed}
765776
inputRef={this.contextMenuButton}
766777
onClick={this.onContextMenuClick}
767-
/>
778+
>
779+
<MenuIcon className="mx_Icon mx_Icon_12" />
780+
</ContextMenuButton>
768781
</span>
769782
</div>
770783
)}

test/components/views/elements/__snapshots__/AppTile-test.tsx.snap

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,38 @@ exports[`AppTile for a pinned widget should render 1`] = `
120120
class="mx_AppTileMenuBar_widgets"
121121
>
122122
<div
123-
class="mx_AccessibleButton mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton--collapse"
123+
class="mx_AccessibleButton mx_AppTileMenuBar_widgets_button"
124124
role="button"
125125
tabindex="0"
126126
title="Un-maximise"
127-
/>
127+
>
128+
<div
129+
class="mx_Icon mx_Icon_12"
130+
/>
131+
</div>
128132
<div
129-
class="mx_AccessibleButton mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton--minimise"
133+
class="mx_AccessibleButton mx_AppTileMenuBar_widgets_button"
130134
role="button"
131135
tabindex="0"
132136
title="Minimise"
133-
/>
137+
>
138+
<div
139+
class="mx_Icon mx_Icon_12"
140+
/>
141+
</div>
134142
<div
135143
aria-expanded="false"
136144
aria-haspopup="true"
137145
aria-label="Options"
138-
class="mx_AccessibleButton mx_AppTileMenuBar_iconButton mx_AppTileMenuBar_iconButton--menu"
146+
class="mx_AccessibleButton mx_AppTileMenuBar_widgets_button"
139147
role="button"
140148
tabindex="0"
141149
title="Options"
142-
/>
150+
>
151+
<div
152+
class="mx_Icon mx_Icon_12"
153+
/>
154+
</div>
143155
</span>
144156
</div>
145157
<div

0 commit comments

Comments
 (0)