diff --git a/packages/documentation-framework/components/example/example.css b/packages/documentation-framework/components/example/example.css index 0e646106f2..a9750d46c4 100644 --- a/packages/documentation-framework/components/example/example.css +++ b/packages/documentation-framework/components/example/example.css @@ -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; diff --git a/packages/documentation-framework/components/example/example.js b/packages/documentation-framework/components/example/example.js index ab00910be7..8ee8de60fb 100644 --- a/packages/documentation-framework/components/example/example.js +++ b/packages/documentation-framework/components/example/example.js @@ -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) =>
{err.toString()}
; class ErrorBoundary extends React.Component { @@ -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 @@ -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: , + iconClicked: + }, + topRight: { + className: 'pf-m-top-right', + label: 'Move to the top right corner', + tooltipPosition: 'bottom-end', + icon: , + iconClicked: + }, + bottomLeft: { + className: 'pf-m-bottom-left', + label: 'Move to the bottom left corner', + tooltipPosition: 'top-start', + icon: , + iconClicked: + }, + bottomRight: { + className: 'pf-m-bottom-right', + label: 'Move to the bottom right corner', + tooltipPosition: 'top-end', + icon: , + iconClicked: + } + }; + if (isFullscreenPreview) { + const activeFullPageUtilsTooltipPosition = Object.values(fullPageUtilsPositionProps).find( + (props) => props.className === fullPageUtilsPosition + )?.tooltipPosition; + return (
{livePreview} {(hasThemeSwitcher || hasRTLSwitcher) && ( {hasThemeSwitcher && } {hasRTLSwitcher && ( @@ -209,6 +268,27 @@ export const Example = ({ }} /> )} + {/* Four corner position buttons */} + {Object.entries(fullPageUtilsPositionProps).map(([key, utilsProps]) => ( + +
diff --git a/packages/documentation-framework/package.json b/packages/documentation-framework/package.json index 161c6f4878..b549ae7b52 100644 --- a/packages/documentation-framework/package.json +++ b/packages/documentation-framework/package.json @@ -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" diff --git a/packages/documentation-site/package.json b/packages/documentation-site/package.json index 3bc2bab43c..ac00f38f7b 100644 --- a/packages/documentation-site/package.json +++ b/packages/documentation-site/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index a096fc119f..ff6d7245fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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" @@ -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" @@ -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"