Skip to content

Commit 83e783f

Browse files
committed
working session updates
1 parent 3e38390 commit 83e783f

File tree

12 files changed

+268
-245
lines changed

12 files changed

+268
-245
lines changed

packages/react-core/src/components/Compass/Compass.tsx

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Drawer, DrawerContent, DrawerProps } from '../Drawer';
2+
import compassBackgroundImageLight from '@patternfly/react-tokens/dist/esm/c_compass_BackgroundImage_light';
3+
import compassBackgroundImageDark from '@patternfly/react-tokens/dist/esm/c_compass_BackgroundImage_dark';
24
import { css } from '@patternfly/react-styles';
35

46
export interface CompassProps extends React.HTMLProps<HTMLDivElement> {
@@ -9,15 +11,15 @@ export interface CompassProps extends React.HTMLProps<HTMLDivElement> {
911
/** Flag indicating if the header is expanded */
1012
isHeaderExpanded?: boolean;
1113
/** Content placed at the start of the layout */
12-
panelStart?: React.ReactNode;
14+
sidebarStart?: React.ReactNode;
1315
/** Flag indicating if the start panel is expanded */
14-
isPanelStartExpanded?: boolean;
16+
isSidebarStartExpanded?: boolean;
1517
/** Content placed at the center of the layout */
1618
main?: React.ReactNode;
1719
/** Content placed at the end of the layout */
18-
panelEnd?: React.ReactNode;
20+
sidebarEnd?: React.ReactNode;
1921
/** Flag indicating if the end panel is expanded */
20-
isPanelEndExpanded?: boolean;
22+
isSidebarEndExpanded?: boolean;
2123
/** Content placed at the bottom of the layout */
2224
footer?: React.ReactNode;
2325
/** Flag indicating if the footer is expanded */
@@ -26,60 +28,59 @@ export interface CompassProps extends React.HTMLProps<HTMLDivElement> {
2628
drawerContent?: React.ReactNode;
2729
/** Props for the drawer */
2830
drawerProps?: DrawerProps;
29-
/** Light background image path for the compass */
30-
lightBackgroundSrc?: string;
31-
/** Dark background image path for the compass */
32-
darkBackgroundSrc?: string;
31+
/** Light theme background image path for the compass */
32+
backgroundSrcLight?: string;
33+
/** Dark theme background image path for the compass */
34+
backgroundSrcDark?: string;
3335
}
3436

3537
export const Compass: React.FunctionComponent<CompassProps> = ({
3638
className,
3739
header,
3840
isHeaderExpanded = true,
39-
panelStart,
40-
isPanelStartExpanded = true,
41+
sidebarStart,
42+
isSidebarStartExpanded = true,
4143
main,
42-
panelEnd,
43-
isPanelEndExpanded = true,
44+
sidebarEnd,
45+
isSidebarEndExpanded = true,
4446
footer,
4547
isFooterExpanded = true,
4648
drawerContent,
4749
drawerProps,
48-
lightBackgroundSrc,
49-
darkBackgroundSrc,
50+
backgroundSrcLight,
51+
backgroundSrcDark,
5052
...props
5153
}) => {
5254
const hasDrawer = drawerContent !== undefined;
5355

56+
const backgroundImageStyles: { [key: string]: string } = {};
57+
if (backgroundSrcLight) {
58+
backgroundImageStyles[compassBackgroundImageLight.name] = `url(${backgroundSrcLight})`;
59+
}
60+
if (backgroundSrcDark) {
61+
backgroundImageStyles[compassBackgroundImageDark.name] = `url(${backgroundSrcDark})`;
62+
}
63+
5464
const compassContent = (
55-
<div
56-
className={css('pf-v6-c-compass', className)}
57-
style={
58-
{
59-
'[cssLightName.name]': `url(${lightBackgroundSrc})`,
60-
'[cssDarkName.name]': `url(${darkBackgroundSrc})`
61-
} as React.CSSProperties
62-
}
63-
{...props}
64-
>
65+
<div className={css('pf-v6-c-compass', className)} style={{ ...props.style, ...backgroundImageStyles }} {...props}>
6566
<div
6667
className={css('pf-v6-c-compass__header', isHeaderExpanded && 'pf-m-expanded')}
6768
{...(!isHeaderExpanded && { inert: true })}
6869
>
6970
{header}
7071
</div>
7172
<div
72-
className={css('pf-v6-c-compass__panel pf-m-start', isPanelStartExpanded && 'pf-m-expanded')}
73-
{...(!isPanelStartExpanded && { inert: true })}
73+
className={css('pf-v6-c-compass__sidebar pf-m-start', isSidebarStartExpanded && 'pf-m-expanded')}
74+
{...(!isSidebarStartExpanded && { inert: true })}
7475
>
75-
{panelStart}
76+
{sidebarStart}
7677
</div>
7778
<div className={css('pf-v6-c-compass__main')}>{main}</div>
7879
<div
79-
className={css('pf-v6-c-compass__panel pf-m-end', isPanelEndExpanded && 'pf-m-expanded')}
80-
{...(!isPanelEndExpanded && { inert: true })}
80+
className={css('pf-v6-c-compass__sidebar pf-m-end', isSidebarEndExpanded && 'pf-m-expanded')}
81+
{...(!isSidebarEndExpanded && { inert: true })}
8182
>
82-
{panelEnd}
83+
{sidebarEnd}
8384
</div>
8485
<div
8586
className={css('pf-v6-c-compass__footer', isFooterExpanded && 'pf-m-expanded')}

packages/react-core/src/components/Compass/CompassHero.tsx

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,83 @@
1-
import { Flex, FlexItem } from '../../layouts/Flex';
1+
import compassHeroBackgroundImageLight from '@patternfly/react-tokens/dist/esm/c_compass__hero_BackgroundImage_light';
2+
import compassHeroBackgroundImageDark from '@patternfly/react-tokens/dist/esm/c_compass__hero_BackgroundImage_dark';
3+
import compassHeroGradientStop1Light from '@patternfly/react-tokens/dist/esm/c_compass__hero_gradient_stop_1_light';
4+
import compassHeroGradientStop2Light from '@patternfly/react-tokens/dist/esm/c_compass__hero_gradient_stop_2_light';
5+
import compassHeroGradientStop3Light from '@patternfly/react-tokens/dist/esm/c_compass__hero_gradient_stop_3_light';
6+
import compassHeroGradientStop1Dark from '@patternfly/react-tokens/dist/esm/c_compass__hero_gradient_stop_1_dark';
7+
import compassHeroGradientStop2Dark from '@patternfly/react-tokens/dist/esm/c_compass__hero_gradient_stop_2_dark';
8+
import compassHeroGradientStop3Dark from '@patternfly/react-tokens/dist/esm/c_compass__hero_gradient_stop_3_dark';
29
import { css } from '@patternfly/react-styles';
310

411
interface CompassHeroProps extends Omit<React.HTMLProps<HTMLDivElement>, 'content'> {
512
/** Additional classes added to the hero. */
613
className?: string;
7-
/** Styled hero content. If provided, the children prop will be ignored. */
8-
content?: React.ReactNode;
9-
/** Custom hero content. To opt into a default set of styling, use the content prop instead. */
14+
/** Content of the hero. */
1015
children?: React.ReactNode;
11-
/** Light background image path for the hero */
12-
lightBackgroundSrc?: string;
13-
/** Dark background image path for the hero */
14-
darkBackgroundSrc?: string;
16+
/** Light theme background image path for the hero */
17+
backgroundSrcLight?: string;
18+
/** Dark theme background image path for the hero */
19+
backgroundSrcDark?: string;
20+
/** Light theme gradient for the hero */
21+
gradientLight?: {
22+
stop1?: string;
23+
stop2?: string;
24+
stop3?: string;
25+
};
26+
/** Dark theme gradient for the hero */
27+
gradientDark?: {
28+
stop1?: string;
29+
stop2?: string;
30+
stop3?: string;
31+
};
1532
}
1633

1734
export const CompassHero: React.FunctionComponent<CompassHeroProps> = ({
1835
className,
1936
children,
20-
content,
21-
lightBackgroundSrc,
22-
darkBackgroundSrc,
37+
backgroundSrcLight,
38+
backgroundSrcDark,
39+
gradientLight,
40+
gradientDark,
2341
...props
2442
}) => {
25-
const _content =
26-
content !== undefined ? (
27-
<Flex>
28-
<FlexItem grow={{ default: 'grow' }}>{content}</FlexItem>
29-
</Flex>
30-
) : (
31-
children
32-
);
43+
const backgroundImageStyles: { [key: string]: string } = {};
44+
if (backgroundSrcLight) {
45+
backgroundImageStyles[compassHeroBackgroundImageLight.name] = `url(${backgroundSrcLight})`;
46+
}
47+
if (backgroundSrcDark) {
48+
backgroundImageStyles[compassHeroBackgroundImageDark.name] = `url(${backgroundSrcDark})`;
49+
}
50+
51+
if (gradientLight) {
52+
if (gradientLight.stop1) {
53+
backgroundImageStyles[compassHeroGradientStop1Light.name] = gradientLight.stop1;
54+
}
55+
if (gradientLight.stop2) {
56+
backgroundImageStyles[compassHeroGradientStop2Light.name] = gradientLight.stop2;
57+
}
58+
if (gradientLight.stop3) {
59+
backgroundImageStyles[compassHeroGradientStop3Light.name] = gradientLight.stop3;
60+
}
61+
}
62+
if (gradientDark) {
63+
if (gradientDark.stop1) {
64+
backgroundImageStyles[compassHeroGradientStop1Dark.name] = gradientDark.stop1;
65+
}
66+
if (gradientDark.stop2) {
67+
backgroundImageStyles[compassHeroGradientStop2Dark.name] = gradientDark.stop2;
68+
}
69+
if (gradientDark.stop3) {
70+
backgroundImageStyles[compassHeroGradientStop3Dark.name] = gradientDark.stop3;
71+
}
72+
}
3373

3474
return (
3575
<div
36-
className={css('pf-v6-c-compass__hero', className)}
37-
style={
38-
{
39-
'[cssLightName.name]': `url(${lightBackgroundSrc})`,
40-
'[cssDarkName.name]': `url(${darkBackgroundSrc})`
41-
} as React.CSSProperties
42-
}
76+
className={css('pf-v6-c-compass__panel pf-v6-c-compass__hero', className)}
77+
style={{ ...props.style, ...backgroundImageStyles }}
4378
{...props}
4479
>
45-
{_content}
80+
<div className={css('pf-v6-c-compass__hero-body')}>{children}</div>
4681
</div>
4782
);
4883
};

packages/react-core/src/components/Compass/CompassMainHeader.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Flex, FlexItem } from '../../layouts/Flex';
2-
import { CompassSection } from './CompassSection';
2+
import { CompassPanel } from './CompassPanel';
33
import { css } from '@patternfly/react-styles';
44

55
interface CompassMainHeaderProps extends Omit<React.HTMLProps<HTMLDivElement>, 'title'> {
@@ -22,12 +22,12 @@ export const CompassMainHeader: React.FunctionComponent<CompassMainHeaderProps>
2222
}) => {
2323
const _content =
2424
title !== undefined || toolbar !== undefined ? (
25-
<CompassSection>
25+
<CompassPanel>
2626
<Flex alignItems={{ default: 'alignItemsCenter' }}>
2727
<FlexItem grow={{ default: 'grow' }}>{title}</FlexItem>
2828
<FlexItem>{toolbar}</FlexItem>
2929
</Flex>
30-
</CompassSection>
30+
</CompassPanel>
3131
) : (
3232
children
3333
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { css } from '@patternfly/react-styles';
2+
3+
interface CompassMessageBarProps {
4+
/** Content for the message bar */
5+
children?: React.ReactNode;
6+
}
7+
8+
export const CompassMessageBar: React.FunctionComponent<CompassMessageBarProps> = ({ children }) => (
9+
<div className={css('pf-v6-c-compass__message-bar')}>{children}</div>
10+
);
11+
12+
CompassMessageBar.displayName = 'CompassMessageBar';
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { css } from '@patternfly/react-styles';
2+
3+
interface CompassPanelProps extends React.HTMLProps<HTMLDivElement> {
4+
/** Additional classes added to the panel. */
5+
className?: string;
6+
/** Content of the panel. */
7+
children: React.ReactNode;
8+
/** Applies a pill border radius to the panel. */
9+
isPill?: boolean;
10+
/** Applies a gradient border to the panel. */
11+
hasGradientBorder?: boolean;
12+
/** Applies a thinking style to the panel. */
13+
isThinking?: boolean;
14+
/** Indicates the panel should expand to fill the available height. */
15+
isFullHeight?: boolean;
16+
/** Indicates the panel should scroll its overflow. */
17+
isScrollable?: boolean;
18+
/** Removes the border of the panel. */
19+
hasNoBorder?: boolean;
20+
/** Removes the padding of the panel. */
21+
hasNoPadding?: boolean;
22+
}
23+
24+
export const CompassPanel: React.FunctionComponent<CompassPanelProps> = ({
25+
children,
26+
className,
27+
isPill,
28+
hasNoBorder,
29+
hasNoPadding,
30+
hasGradientBorder,
31+
isThinking,
32+
isFullHeight,
33+
isScrollable,
34+
...props
35+
}) => (
36+
<div
37+
className={css(
38+
'pf-v6-c-compass__panel',
39+
isPill && 'pf-m-pill',
40+
hasNoBorder && 'pf-m-no-border',
41+
hasNoPadding && 'pf-m-no-padding',
42+
hasGradientBorder && 'pf-m-gradient-border',
43+
isThinking && 'pf-m-thinking',
44+
isFullHeight && 'pf-m-full-height',
45+
isScrollable && 'pf-m-scrollable',
46+
className
47+
)}
48+
{...props}
49+
>
50+
{children}
51+
</div>
52+
);
53+
54+
CompassPanel.displayName = 'CompassPanel';

packages/react-core/src/components/Compass/CompassSection.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/react-core/src/components/Compass/examples/Compass.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
id: Compass
33
cssPrefix: pf-v6-c-compass
4-
section: layouts
5-
propComponents: ['Compass', 'CompassHeader', 'CompassContent', 'CompassHero', 'CompassMainHeader', 'CompassSection']
4+
section: components
5+
isBeta: true
6+
propComponents: ['Compass', 'CompassHeader', 'CompassContent', 'CompassHero', 'CompassMainHeader', 'CompassPanel']
67
---
78

89
import './compass.css';
10+
import { useRef, useState } from 'react';
911
import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
1012
import OutlinedPlusSquare from '@patternfly/react-icons/dist/esm/icons/outlined-plus-square-icon';
1113
import OutlinedCopy from '@patternfly/react-icons/dist/esm/icons/outlined-copy-icon';

0 commit comments

Comments
 (0)