Skip to content

Commit ad4a61d

Browse files
committed
mobile: Support PF6 style
1 parent 0afaef7 commit ad4a61d

File tree

7 files changed

+80
-58
lines changed

7 files changed

+80
-58
lines changed

pkg/lib/ct-card.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
.ct-card.pf-v6-c-card .pf-v6-c-card__title-text {
3131
font-weight: normal;
32-
font-size: var(--pf-v5-global--FontSize--2xl);
32+
font-size: var(--pf-t--global--font--size--2xl);
3333
}
3434

3535
// Remove excess top padding from top-level empty state in cards,

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

+20-9
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
@@ -350,15 +352,24 @@ to wrap around when there isn't enough space.
350352
margin-inline: 0 var(--pf-v6-c-button__icon--m-start--MarginRight);
351353
}
352354

353-
// Drop side padding in mobile mode,
354-
// intended mainly for PF PageSection elements (pf-v6-c-page__main-section).
355-
// It's similar to adding padding={{ default: 'noPadding', sm: 'padding' }},
356-
// 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-
// }
355+
356+
@media screen and (max-width: $pf-v6-global--breakpoint--md) {
357+
// Drop side padding in mobile mode,
358+
// intended mainly for PF PageSection elements (pf-v6-c-page__main-section).
359+
// It's similar to adding padding={{ default: 'noPadding', sm: 'padding' }},
360+
// except this only affects the sides, not the top and bottom.
361+
.pf-v6-c-page__main>section.pf-v6-c-page__main-section:not(.pf-m-padding) {
362+
padding-inline: 0;
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+
.pf-v6-c-page {
368+
--pf-v6-c-page--inset: 0;
369+
--pf-v6-c-page__main-container--BorderRadius: 0;
370+
--pf-v6-c-page__main-container--MaxHeight: 100%;
371+
}
372+
}
362373

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

pkg/shell/nav.scss

+14-4
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;
@@ -749,8 +749,7 @@ $desktop: $phone + 1px;
749749
grid-template-rows: 28px 1fr;
750750
justify-content: center;
751751
justify-items: center;
752-
color: var(--pf-v5-global--Color--light-100);
753-
padding-block: var(--pf-t--global--spacer--sm);
752+
// padding-block: var(--pf-t--global--spacer--sm);
754753
padding-inline: var(--pf-t--global--spacer--xs);
755754
align-items: center;
756755

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

786796
// 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/shell.scss

+4-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ $desktop: $phone + 1px;
130130
}
131131

132132
.pf-v6-c-toolbar {
133-
--pf-v5-c-toolbar--BackgroundColor: transparent;
133+
--pf-v6-c-toolbar--BackgroundColor: transparent;
134134
}
135135

136136
@media (max-width: $phone) {
@@ -169,6 +169,9 @@ $desktop: $phone + 1px;
169169
// Remove excess padding from masthead in mobile
170170
.pf-v6-c-masthead {
171171
--pf-v6-c-masthead--inset: 0;
172+
--pf-v6-c-masthead--PaddingBlock: 0;
173+
--pf-v6-c-masthead--PaddingInline: 0;
174+
height: 100%;
172175
}
173176
}
174177

pkg/shell/topnav.tsx

+14-11
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

@@ -176,15 +177,15 @@ export class TopNav extends React.Component {
176177

177178
// HACK: This should be a DropdownItem so the normal onSelect closing behaviour works, but we can't embed a button in a button
178179
const main_menu = [
179-
<div // eslint-disable-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events
180-
id="super-user-indicator-mobile"
181-
className="mobile_v"
182-
key="superusermobile"
183-
onClick={() => {
184-
this.setState((prevState: TopNavState) => { return { menuOpened: !prevState.menuOpened } });
185-
}}>
186-
<SuperuserIndicator proxy={this.superuser} host={current_machine.connection_string} />
187-
</div>,
180+
<li // eslint-disable-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events
181+
id="super-user-indicator-mobile"
182+
className="pf-v6-c-menu__list-item pf-v6-c-menu__item mobile_v"
183+
key="superusermobile"
184+
onClick={() => {
185+
this.setState((prevState: TopNavState) => { return { menuOpened: !prevState.menuOpened } });
186+
}}>
187+
<SuperuserIndicator proxy={this.superuser} host={current_machine.connection_string} />
188+
</li>,
188189
<Divider key="separator2" className="mobile_v" />,
189190
<DropdownGroup label={_("Style")} key="dark-switcher">
190191
<DropdownList>
@@ -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) => {

pkg/systemd/overview.scss

+23-31
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,15 @@
2020
//
2121
// When we have the upcoming version of PF4 in Cockpit, we should drop this code
2222
// (and adjust things for the button to show up on the side of desktop mode instead)
23-
@media (max-width: $pf-v6-global--breakpoint--lg) {
24-
grid-template-areas: "icon title" ". content" ". action";
25-
grid-gap: var(--pf-v5-global--spacer--sm) 0;
23+
@media (max-width: $pf-v6-global--breakpoint--md) {
24+
--pf-v6-c-alert--GridTemplateAreas: "icon title" ". description" ". action";
25+
--pf-v6-c-alert__action--MarginBlockStart: 0;
2626
}
2727

2828
@media (max-width: 320px) {
2929
// Allow the action button to have a bit more space on iPhone SE sized phones
30-
grid-template-areas: "icon title" ". content" "action action";
31-
}
32-
33-
> .pf-v6-c-alert__action {
34-
margin-inline: var(--pf-v5-global--spacer--md) 0;
35-
}
36-
37-
// Align left content with the rest of the page
38-
@media (min-width: $pf-v6-global--breakpoint--xl) {
39-
padding-inline-start: var(--pf-v5-global--spacer--lg);
30+
--pf-v6-c-alert--GridTemplateAreas: "icon title" "description description" "action action";
31+
--pf-v6-c-alert__action--MarginBlockStart: 0;
4032
}
4133
}
4234

@@ -83,16 +75,16 @@
8375

8476
.pf-v6-l-gallery.ct-system-overview {
8577
--cards: 2;
86-
--pf-v5-l-gallery--GridTemplateColumns: repeat(var(--cards), 1fr);
78+
--pf-v6-l-gallery--GridTemplateColumns: repeat(var(--cards), 1fr);
8779

8880
// Small mobile: Reduce spacing
8981
@media (max-width: 320px) {
90-
// --pf-v5-l-gallery--m-gutter--GridGap: 0.25rem;
82+
--pf-v6-l-gallery--m-gutter--GridGap: 0.25rem;
9183
}
9284

9385
// Mobile: reduce to 1 card wide and minimize spacing
9486
@media (max-width: 680px) {
95-
--pf-v5-l-gallery--m-gutter--GridGap: var(--pf-v5-global--spacer--sm);
87+
--pf-v6-l-gallery--m-gutter--GridGap: var(--pf-t--global--spacer--sm);
9688
--cards: 1;
9789
}
9890

@@ -102,18 +94,18 @@
10294
}
10395

10496
// Extra large desktop: Let cards align to the left at an optimal size
105-
@media (min-width: 110rem) {
106-
--pf-v5-l-gallery--GridTemplateColumns: repeat(auto-fill, minmax(min-content, 26rem));
97+
@media (min-width: 113rem) {
98+
--pf-v6-l-gallery--GridTemplateColumns: repeat(auto-fill, minmax(min-content, 26rem));
10799
}
108100

109101
// VMs @ 1024x768; add a little leeway For titlebars, start bar, etc.
110102
@media (orientation: landscape) and (min-width: 684px) and (max-width: 832px) and (max-height: 703px) {
111-
--pf-v5-l-gallery--m-gutter--GridGap: var(--pf-v5-global--spacer--sm);
103+
--pf-v6-l-gallery--m-gutter--GridGap: var(--pf-t--global--spacer--sm);
112104

113105
// Also skim off some vertical space for the cards
114106
.pf-v6-c-card {
115-
--pf-v5-c-card--first-child--PaddingTop: var(--pf-v5-global--spacer--md);
116-
--pf-v5-c-card--child--PaddingRight: var(--pf-v5-global--spacer--md);
107+
--pf-v6-c-card--first-child--PaddingTop: var(--pf-t--global--spacer--md);
108+
--pf-v6-c-card--child--PaddingRight: var(--pf-t--global--spacer--md);
117109
}
118110
}
119111

@@ -123,8 +115,8 @@
123115

124116
.pf-v6-c-card {
125117
&__title-text {
126-
font-size: var(--pf-v5-global--FontSize--xl);
127-
font-weight: var(--pf-v5-global--FontWeight--normal);
118+
font-size: var(--pf-t--global--font--size--xl);
119+
font-weight: var(--pf-t--global--font--weight--body);
128120
}
129121

130122
&__body {
@@ -136,7 +128,7 @@
136128
p {
137129
+ p,
138130
+ button {
139-
margin-block-start: calc(var(--pf-v5-global--LineHeight--md) * 1rem);
131+
margin-block-start: calc(var(--pf-t--global--font--line-height--body) * 1rem);
140132
}
141133
}
142134

@@ -145,7 +137,7 @@
145137
}
146138

147139
th {
148-
font-size: var(--pf-v5-global--FontSize--sm);
140+
font-size: var(--pf-t--global--font--size--sm);
149141
}
150142
}
151143
}
@@ -191,15 +183,15 @@
191183
/* Reduce gutter & padding on smaller widths, for desktop & mobile */
192184

193185
.pf-v6-l-gallery.ct-system-overview {
194-
--pf-v5-l-gallery--m-gutter--GridGap: calc(var(--pf-v5-global--gutter--md)/2);
186+
--pf-v6-l-gallery--m-gutter--GridGap: calc(var(--pf-t--global--spacer--md)/2);
195187
}
196188

197189
.pf-v6-c-card {
198-
--pf-v5-c-card--first-child--PaddingTop: var(--pf-v5-global--spacer--md);
199-
--pf-v5-c-card--child--PaddingRight: var(--pf-v5-global--spacer--md);
200-
--pf-v5-c-card--child--PaddingBottom: var(--pf-v5-global--spacer--md);
201-
--pf-v5-c-card--child--PaddingLeft: var(--pf-v5-global--spacer--md);
202-
--pf-v5-c-card__title--not-last-child--PaddingBottom: var(--pf-v5-global--spacer--sm);
190+
--pf-v6-c-card--first-child--PaddingTop: var(--pf-t--global--spacer--md);
191+
--pf-v6-c-card--child--PaddingRight: var(--pf-t--global--spacer--md);
192+
--pf-v6-c-card--child--PaddingBottom: var(--pf-t--global--spacer--md);
193+
--pf-v6-c-card--child--PaddingLeft: var(--pf-t--global--spacer--md);
194+
--pf-v6-c-card__title--not-last-child--PaddingBottom: var(--pf-t--global--spacer--sm);
203195
}
204196
}
205197

0 commit comments

Comments
 (0)