Skip to content

Commit 4825540

Browse files
committed
Fixed mobile navigation
1 parent 599a1e3 commit 4825540

File tree

5 files changed

+66
-29
lines changed

5 files changed

+66
-29
lines changed

pkg/lib/patternfly/patternfly-5-overrides.scss

+17-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Pull in variables (for breakpoints)
33
@use "global-variables" as *;
44

5+
$phone: 767px;
6+
57
// PF Select is deprecated - no issue reported upstream - this needs to be removed from our codebase
68
// Make select have the expected width
79
// REVIEW @Venefilyn: Check if still relevant
@@ -354,11 +356,21 @@ to wrap around when there isn't enough space.
354356
// intended mainly for PF PageSection elements (pf-v6-c-page__main-section).
355357
// It's similar to adding padding={{ default: 'noPadding', sm: 'padding' }},
356358
// except this only affects the sides, not the top and bottom.
357-
// @media screen and (max-width: $pf-v6-global--breakpoint--sm) {
358-
// .pf-v6-c-page__main>section.pf-v6-c-page__main-section:not(.pf-m-padding) {
359-
// padding-inline: 0;
360-
// }
361-
// }
359+
@media screen and (max-width: $pf-v6-global--breakpoint--sm) {
360+
.pf-v6-c-page__main>section.pf-v6-c-page__main-section:not(.pf-m-padding) {
361+
padding-inline: 0;
362+
}
363+
}
364+
365+
// Drop page padding and radius for page container in mobile mode. Make sure
366+
// the page container is also covering as much as possible
367+
@media screen and (max-width: $phone) {
368+
.pf-v6-c-page {
369+
--pf-v6-c-page--inset: 0;
370+
--pf-v6-c-page__main-container--BorderRadius: 0;
371+
--pf-v6-c-page__main-container--MaxHeight: 100%;
372+
}
373+
}
362374

363375
// Patch tabular number 0s to not have the slash inside
364376
// https://github.com/RedHatOfficial/RedHatFont/issues/53

pkg/shell/hosts.tsx

+21-15
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { split_connection_string } from "./machines/machines";
4040
import { add_host, edit_host, connect_host } from "./hosts_dialog.jsx";
4141

4242
import { ShellState } from "./state";
43+
import { Icon } from "@patternfly/react-core";
4344

4445
const _ = cockpit.gettext;
4546

@@ -244,23 +245,28 @@ export class CockpitHosts extends React.Component {
244245
<div className="ct-switcher">
245246
<div className="pf-v6-c-select pf-m-dark">
246247
<button onClick={this.toggleMenu} id="host-toggle" aria-labelledby="host-toggle" aria-expanded={(this.state.opened ? "true" : "false")} aria-haspopup="listbox" type="button" className="ct-nav-toggle pf-v6-c-select__toggle pf-v6-c-menu-toggle pf-m-plain">
247-
<span className="pf-v6-c-select__toggle-wrapper desktop_v">
248-
<span className="pf-v6-c-select__toggle-text">
249-
<HostLine user={user} host={label} />
248+
<span className="pf-v6-c-button__text">
249+
<span className="pf-v6-c-select__toggle-wrapper desktop_v">
250+
<span className="pf-v6-c-select__toggle-text">
251+
<HostLine user={user} host={label} />
252+
</span>
250253
</span>
254+
<Icon size="xl">
255+
<CaretUpIcon
256+
className={`pf-v6-c-select__toggle-arrow mobile_v ${this.state.opened ? 'clicked' : ''}`}
257+
aria-hidden="true"
258+
/>
259+
</Icon>
260+
<span className="pf-v6-c-select__toggle-wrapper mobile_v">
261+
{_("Host")}
262+
</span>
263+
<Icon size="xl">
264+
<CaretDownIcon
265+
className={`pf-v6-c-select__toggle-arrow desktop_v ${this.state.opened ? 'clicked' : ''}`}
266+
aria-hidden="true"
267+
/>
268+
</Icon>
251269
</span>
252-
<CaretUpIcon
253-
className={`pf-v6-c-select__toggle-arrow mobile_v pf-v6-c-icon pf-m-lg ${this.state.opened ? 'clicked' : ''}`}
254-
aria-hidden="true"
255-
/>
256-
<span className="pf-v6-c-select__toggle-wrapper mobile_v">
257-
{_("Host")}
258-
</span>
259-
<CaretDownIcon
260-
className={`pf-v6-c-select__toggle-arrow desktop_v pf-v6-c-icon ${this.state.opened ? 'clicked' : ''}`}
261-
aria-hidden="true"
262-
/>
263-
264270
</button>
265271
</div>
266272

pkg/shell/nav.scss

+19-6
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ $desktop: $phone + 1px;
641641
.ct-nav-toggle:not(.pf-v6-c-menu) {
642642
&:hover, &:active, &.active, &.interact, &[aria-expanded="true"] {
643643
text-decoration: none;
644-
// approximate --pf-v5-global--BackgroundColor--dark-400, but with opacity
645-
background: var(--pf-t--global--background--color--secondary--hover) !important;
644+
// add in opacity so the navigation colored line doesn't hide on hover
645+
background: color-mix(in srgb, var(--pf-t--global--background--color--secondary--hover) 32%, transparent) !important;
646646

647647
.hostname {
648648
text-decoration: underline;
@@ -734,9 +734,12 @@ $desktop: $phone + 1px;
734734

735735
// Mobile sizes
736736
@media (max-width: $phone) {
737-
#host-toggle ,
738-
#nav-system-item ,
737+
#host-toggle,
738+
#nav-system-item,
739+
button.ct-nav-toggle,
739740
button.ct-nav-toggle > .pf-v6-c-button__text {
741+
// Remove gap between text and icon
742+
--pf-v6-c-menu-toggle--Gap: 0;
740743
// Stretch to navbar
741744
block-size: 100%;
742745
// Don't stretch to fill content; make optimal width same as height
@@ -747,8 +750,7 @@ $desktop: $phone + 1px;
747750
grid-template-rows: 28px 1fr;
748751
justify-content: center;
749752
justify-items: center;
750-
color: var(--pf-v5-global--Color--light-100);
751-
padding-block: var(--pf-t--global--spacer--sm);
753+
// padding-block: var(--pf-t--global--spacer--sm);
752754
padding-inline: var(--pf-t--global--spacer--xs);
753755
align-items: center;
754756

@@ -779,6 +781,17 @@ $desktop: $phone + 1px;
779781
max-inline-size: 100%;
780782
}
781783
}
784+
785+
// FIXME @Venefilyn: Some bug is causing the listener in SidebarToggle to trigger pointer clicks on internal elements causing the menu to not work.
786+
// Setting it to initial means that the after content that covers up the whole button will still allow us to trigger it correctly.
787+
#nav-system-item::after {
788+
pointer-events: initial
789+
}
790+
791+
// PF6 introduced toolbar column gap which is great in general. But not what we want for mobile view
792+
.ct-topnav-content {
793+
--pf-v6-c-toolbar__content-section--ColumnGap: 0;
794+
}
782795
}
783796

784797
// HACK: Don't span the navigation as wide or tall as possible

pkg/shell/nav.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { Status } from "notifications";
3131
import { Location, encode_location, ManifestItem } from "./util.jsx";
3232
import { ShellState } from "./state";
3333
import { ManifestKeyword } from "./manifests";
34+
import { Icon } from "@patternfly/react-core";
3435

3536
const _ = cockpit.gettext;
3637

@@ -65,7 +66,9 @@ export const SidebarToggle = () => {
6566
<Button className={"pf-v6-c-select__toggle ct-nav-toggle " + (active ? "active" : "")}
6667
id="nav-system-item" variant="plain"
6768
onClick={() => setActive(!active)}>
68-
<ContainerNodeIcon className="pf-v6-c-icon pf-m-lg" />
69+
<Icon size="xl">
70+
<ContainerNodeIcon />
71+
</Icon>
6972
{_("System")}
7073
</Button>
7174
);

pkg/shell/topnav.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { AboutCockpitModal, LangModal, OopsModal } from "./shell-modals.jsx";
3737
import { SuperuserIndicator } from "./superuser.jsx";
3838
import { read_os_release } from "os-release.js";
3939
import { DialogsContext } from "dialogs.jsx";
40+
import { Icon } from "@patternfly/react-core";
4041

4142
const _ = cockpit.gettext;
4243

@@ -264,8 +265,9 @@ export class TopNav extends React.Component {
264265
<MenuToggle
265266
ref={toggleRef}
266267
id="toggle-docs"
268+
variant="plain"
267269
className="ct-nav-toggle"
268-
icon={<HelpIcon className="toggle-docs-icon pf-v6-c-icon pf-m-lg" />}
270+
icon={<Icon size="lg"><HelpIcon className="toggle-docs-icon" /></Icon>}
269271
isExpanded={this.state.docsOpened}
270272
isFullHeight
271273
onClick={() => {
@@ -298,8 +300,9 @@ export class TopNav extends React.Component {
298300
<MenuToggle
299301
ref={toggleRef}
300302
id="toggle-menu"
303+
variant="plain"
301304
className="ct-nav-toggle"
302-
icon={<CogIcon className="pf-v6-c-icon pf-m-lg" />}
305+
icon={<Icon size="lg"><CogIcon /></Icon>}
303306
isExpanded={this.state.menuOpened}
304307
isFullHeight
305308
onClick={(event) => {

0 commit comments

Comments
 (0)