Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions packages/documentation-framework/components/example/example.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,48 @@

.ws-full-page-utils {
position: fixed;
inset-inline-start: 0;
inset-block-end: 0;
padding: var(--pf-t--global--spacer--lg);
padding: var(--pf-t--global--spacer--xl);
z-index: var(--pf-t--global--z-index--2xl);
}

.ws-full-page-utils-position-btn {
--ws-full-page-utils-btn--inset: var(--pf-t--global--spacer--xs);
position: absolute;
}

:is(.ws-full-page-utils, .ws-full-page-utils-position-btn).pf-m-top-right {
top: var(--ws-full-page-utils-btn--inset, 0);
right: var(--ws-full-page-utils-btn--inset, 0);
bottom: auto;
left: auto;
}

:is(.ws-full-page-utils, .ws-full-page-utils-position-btn).pf-m-bottom-right {
top: auto;
right: var(--ws-full-page-utils-btn--inset, 0);
bottom: var(--ws-full-page-utils-btn--inset, 0);
left: auto;
}

:is(.ws-full-page-utils, .ws-full-page-utils-position-btn).pf-m-bottom-left {
top: auto;
right: auto;
bottom: var(--ws-full-page-utils-btn--inset, 0);
left: var(--ws-full-page-utils-btn--inset, 0);
}

:is(.ws-full-page-utils, .ws-full-page-utils-position-btn).pf-m-top-left {
top: var(--ws-full-page-utils-btn--inset, 0);
right: auto;
bottom: auto;
left: var(--ws-full-page-utils-btn--inset, 0);
}

.ws-full-page-utils-position-btn.pf-m-clicked {
--pf-v6-c-button__icon--Color: var(--pf-t--global--text--color--regular);
}

.ws-full-page-utils::before {
position: absolute;
inset: 0;
Expand Down
84 changes: 82 additions & 2 deletions packages/documentation-framework/components/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ import missingThumbnail from './missing-thumbnail.jpg';
import { RtlContext } from '../../layouts';
import { ThemeSelector } from '../themeSelector/themeSelector';

import RhUiArrowCircleDownRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-down-right-icon';
import RhUiArrowCircleDownLeftIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-down-left-icon';
import RhUiArrowCircleUpRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-up-right-icon';
import RhUiArrowCircleUpLeftIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-up-left-icon';
import RhUiArrowCircleDownRightFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-down-right-fill-icon';
import RhUiArrowCircleDownLeftFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-down-left-fill-icon';
import RhUiArrowCircleUpRightFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-up-right-fill-icon';
import RhUiArrowCircleUpLeftFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-up-left-fill-icon';

const errorComponent = (err) => <pre>{err.toString()}</pre>;

class ErrorBoundary extends React.Component {
Expand Down Expand Up @@ -137,8 +146,22 @@ export const Example = ({
}

const [editorCode, setEditorCode] = React.useState(code);
const isBrowser = typeof window !== 'undefined' && window.localStorage;
const [fullPageUtilsPosition, setFullPageUtilsPosition] = React.useState(() => {
if (isBrowser) {
return localStorage.getItem('fullPageUtilsPosition') || 'pf-m-bottom-left';
}
return 'pf-m-bottom-left';
});
const loc = useLocation();
const isRTL = useContext(RtlContext);

// Save fullPageUtilsPosition to localStorage when it changes
useEffect(() => {
if (isBrowser) {
localStorage.setItem('fullPageUtilsPosition', fullPageUtilsPosition);
}
}, [fullPageUtilsPosition]);
const scope = {
...liveContext,
// These 2 are in the bundle anyways for the site since we dogfood
Expand Down Expand Up @@ -186,15 +209,51 @@ export const Example = ({
const previewId = getExampleId(source, section[0], id, title);
const className = getExampleClassName(source, section[0], id);

// Four corner position button props
const fullPageUtilsPositionProps = {
topLeft: {
className: 'pf-m-top-left',
label: 'Move to the top left corner',
tooltipPosition: 'bottom-start',
icon: <RhUiArrowCircleUpLeftIcon />,
iconClicked: <RhUiArrowCircleUpLeftFillIcon />
},
topRight: {
className: 'pf-m-top-right',
label: 'Move to the top right corner',
tooltipPosition: 'bottom-end',
icon: <RhUiArrowCircleUpRightIcon />,
iconClicked: <RhUiArrowCircleUpRightFillIcon />
},
bottomLeft: {
className: 'pf-m-bottom-left',
label: 'Move to the bottom left corner',
tooltipPosition: 'top-start',
icon: <RhUiArrowCircleDownLeftIcon />,
iconClicked: <RhUiArrowCircleDownLeftFillIcon />
},
bottomRight: {
className: 'pf-m-bottom-right',
label: 'Move to the bottom right corner',
tooltipPosition: 'top-end',
icon: <RhUiArrowCircleDownRightIcon />,
iconClicked: <RhUiArrowCircleDownRightFillIcon />
}
};

if (isFullscreenPreview) {
const activeFullPageUtilsTooltipPosition = Object.values(fullPageUtilsPositionProps).find(
(props) => props.className === fullPageUtilsPosition
)?.tooltipPosition;

return (
<div id={previewId} className={css(className, 'pf-v6-u-h-100')}>
{livePreview}
{(hasThemeSwitcher || hasRTLSwitcher) && (
<Flex
direction={{ default: 'column' }}
gap={{ default: 'gapMd' }}
className="ws-full-page-utils pf-v6-m-dir-ltr"
gap={{ default: 'gapSm' }}
className={css('ws-full-page-utils', 'pf-v6-m-dir-ltr', fullPageUtilsPosition)}
>
{hasThemeSwitcher && <ThemeSelector id="ws-example-theme-select" />}
{hasRTLSwitcher && (
Expand All @@ -209,6 +268,27 @@ export const Example = ({
}}
/>
)}
{/* Four corner position buttons */}
{Object.entries(fullPageUtilsPositionProps).map(([key, utilsProps]) => (
<Tooltip
key={key}
content={utilsProps.label}
position={activeFullPageUtilsTooltipPosition || utilsProps.tooltipPosition}
enableFlip={false}
aria="none"
aria-live="off"
>
<Button
variant="plain"
size="sm"
className={css('ws-full-page-utils-position-btn', utilsProps.className)}
isClicked={fullPageUtilsPosition === utilsProps.className}
onClick={() => setFullPageUtilsPosition(utilsProps.className)}
aria-label={`${utilsProps.label}${fullPageUtilsPosition === utilsProps.className ? ', selected' : ''}`}
icon={fullPageUtilsPosition === utilsProps.className ? utilsProps.iconClicked : utilsProps.icon}
/>
</Tooltip>
))}
</Flex>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/documentation-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@patternfly/patternfly": "^6.5.0-prerelease.33",
"@patternfly/react-code-editor": "^6.5.0-prerelease.26",
"@patternfly/react-core": "^6.5.0-prerelease.24",
"@patternfly/react-icons": "^6.5.0-prerelease.11",
"@patternfly/react-table": "^6.5.0-prerelease.24",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/documentation-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@patternfly/react-console": "6.1.0",
"@patternfly/react-data-view": "6.4.0-prerelease.8",
"@patternfly/react-docs": "7.5.0-prerelease.26",
"@patternfly/react-icons": "6.5.0-prerelease.11",
"@patternfly/react-log-viewer": "6.3.0",
"@patternfly/react-topology": "6.5.0-prerelease.3",
"@patternfly/react-user-feedback": "6.2.0",
Expand Down
22 changes: 12 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4792,6 +4792,7 @@ __metadata:
"@patternfly/patternfly": ^6.5.0-prerelease.33
"@patternfly/react-code-editor": ^6.5.0-prerelease.26
"@patternfly/react-core": ^6.5.0-prerelease.24
"@patternfly/react-icons": ^6.5.0-prerelease.11
"@patternfly/react-table": ^6.5.0-prerelease.24
react: ^17.0.0 || ^18.0.0
react-dom: ^17.0.0 || ^18.0.0
Expand Down Expand Up @@ -5142,6 +5143,16 @@ __metadata:
languageName: node
linkType: hard

"@patternfly/react-icons@npm:6.5.0-prerelease.11, @patternfly/react-icons@npm:^6.5.0-prerelease.11":
version: 6.5.0-prerelease.11
resolution: "@patternfly/react-icons@npm:6.5.0-prerelease.11"
peerDependencies:
react: ^17 || ^18 || ^19
react-dom: ^17 || ^18 || ^19
checksum: 10c0/d0d91d9e011747dde34a0d3521cd92d58ff29281f6fb1e442c72cf0ea1ca8b3a69e270497e0644ffa499601484394bc9fdf12b070f8568114a7fcfed0428a8c8
languageName: node
linkType: hard

"@patternfly/react-icons@npm:^6.0.0, @patternfly/react-icons@npm:^6.0.0-prerelease.7, @patternfly/react-icons@npm:^6.3.1":
version: 6.3.1
resolution: "@patternfly/react-icons@npm:6.3.1"
Expand All @@ -5162,16 +5173,6 @@ __metadata:
languageName: node
linkType: hard

"@patternfly/react-icons@npm:^6.5.0-prerelease.11":
version: 6.5.0-prerelease.11
resolution: "@patternfly/react-icons@npm:6.5.0-prerelease.11"
peerDependencies:
react: ^17 || ^18 || ^19
react-dom: ^17 || ^18 || ^19
checksum: 10c0/d0d91d9e011747dde34a0d3521cd92d58ff29281f6fb1e442c72cf0ea1ca8b3a69e270497e0644ffa499601484394bc9fdf12b070f8568114a7fcfed0428a8c8
languageName: node
linkType: hard

"@patternfly/react-log-viewer@npm:6.3.0":
version: 6.3.0
resolution: "@patternfly/react-log-viewer@npm:6.3.0"
Expand Down Expand Up @@ -18961,6 +18962,7 @@ __metadata:
"@patternfly/react-console": "npm:6.1.0"
"@patternfly/react-data-view": "npm:6.4.0-prerelease.8"
"@patternfly/react-docs": "npm:7.5.0-prerelease.26"
"@patternfly/react-icons": "npm:6.5.0-prerelease.11"
"@patternfly/react-log-viewer": "npm:6.3.0"
"@patternfly/react-topology": "npm:6.5.0-prerelease.3"
"@patternfly/react-user-feedback": "npm:6.2.0"
Expand Down