Skip to content

Commit 39db2d3

Browse files
committed
feat: allow full-page example utils to change position
1 parent e26f52f commit 39db2d3

File tree

2 files changed

+81
-2
lines changed

2 files changed

+81
-2
lines changed

packages/documentation-framework/components/example/example.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,39 @@
7272

7373
.ws-full-page-utils {
7474
position: fixed;
75-
inset-inline-start: 0;
7675
inset-block-end: 0;
7776
padding: var(--pf-t--global--spacer--lg);
7877
z-index: var(--pf-t--global--z-index--2xl);
7978
}
8079

80+
.ws-full-page-utils.pf-m-top-right {
81+
top: 0;
82+
right: 0;
83+
bottom: auto;
84+
left: auto;
85+
}
86+
87+
.ws-full-page-utils.pf-m-bottom-right {
88+
top: auto;
89+
right: 0;
90+
bottom: 0;
91+
left: auto;
92+
}
93+
94+
.ws-full-page-utils.pf-m-bottom-left {
95+
top: auto;
96+
right: auto;
97+
bottom: 0;
98+
left: 0;
99+
}
100+
101+
.ws-full-page-utils.pf-m-top-left {
102+
top: 0;
103+
right: auto;
104+
bottom: auto;
105+
left: 0;
106+
}
107+
81108
.ws-full-page-utils::before {
82109
position: absolute;
83110
inset: 0;
@@ -86,3 +113,7 @@
86113
opacity: 0.8;
87114
box-shadow: var(--pf-t--global--box-shadow--sm);
88115
}
116+
117+
.ws-full-page-utils .pf-v6-c-button.pf-m-no-padding.pf-m-clicked {
118+
--pf-v6-c-button__icon--Color: var(--pf-t--global--text--color--regular);
119+
}

packages/documentation-framework/components/example/example.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ import { convertToReactComponent } from '@patternfly/ast-helpers';
3333
import missingThumbnail from './missing-thumbnail.jpg';
3434
import { RtlContext } from '../../layouts';
3535
import { ThemeSelector } from '../themeSelector/themeSelector';
36+
// import RhUiArrowCircleDownRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-down-right-icon';
37+
// import RhUiArrowCircleDownLeftIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-down-left-icon';
38+
// import RhUiArrowCircleTopRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-top-right-icon';
39+
// import RhUiArrowCircleTopLeftIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-circle-top-left-icon';
40+
41+
const RhUiArrowCircleUpRightIcon = <svg class="pf-v6-svg" viewBox="0 0 32 32" fill="currentColor" aria-labelledby="icon-title-1847" role="img" width="1em" height="1em"><title id="icon-title-1847">RhUiArrowCircleUpRightIcon</title><path d="M22 11.5V20a1 1 0 1 1-2 0v-6.586l-8.243 8.243a.997.997 0 0 1-1.414 0 .999.999 0 0 1 0-1.414L18.586 12H12a1 1 0 1 1 0-2h8.5c.827 0 1.5.673 1.5 1.5Zm9 4.5c0 8.271-6.729 15-15 15S1 24.271 1 16 7.729 1 16 1s15 6.729 15 15Zm-2 0c0-7.168-5.832-13-13-13S3 8.832 3 16s5.832 13 13 13 13-5.832 13-13Z"></path></svg>;
42+
const RhUiArrowCircleDownRightIcon = <svg class="pf-v6-svg" viewBox="0 0 32 32" fill="currentColor" aria-labelledby="icon-title-1837" role="img" width="1em" height="1em"><title id="icon-title-1837">RhUiArrowCircleDownRightIcon</title><path d="M22 12v8.5c0 .827-.673 1.5-1.5 1.5H12a1 1 0 1 1 0-2h6.586l-8.243-8.243a.999.999 0 1 1 1.414-1.414L20 18.586V12a1 1 0 1 1 2 0Zm9 4c0 8.271-6.729 15-15 15S1 24.271 1 16 7.729 1 16 1s15 6.729 15 15Zm-2 0c0-7.168-5.832-13-13-13S3 8.832 3 16s5.832 13 13 13 13-5.832 13-13Z"></path></svg>;
43+
const RhUiArrowCircleDownLeftIcon = <svg class="pf-v6-svg" viewBox="0 0 32 32" fill="currentColor" aria-labelledby="icon-title-1835" role="img" width="1em" height="1em"><title id="icon-title-1835">RhUiArrowCircleDownLeftIcon</title><path d="M21.657 10.343a.999.999 0 0 1 0 1.414L13.414 20H20a1 1 0 1 1 0 2h-8.5c-.827 0-1.5-.673-1.5-1.5V12a1 1 0 1 1 2 0v6.586l8.243-8.243a.999.999 0 0 1 1.414 0ZM31 16c0 8.271-6.729 15-15 15S1 24.271 1 16 7.729 1 16 1s15 6.729 15 15Zm-2 0c0-7.168-5.832-13-13-13S3 8.832 3 16s5.832 13 13 13 13-5.832 13-13Z"></path></svg>;
44+
const RhUiArrowCircleUpLeftIcon = <svg class="pf-v6-svg" viewBox="0 0 32 32" fill="currentColor" aria-labelledby="icon-title-1845" role="img" width="1em" height="1em"><title id="icon-title-1845">RhUiArrowCircleUpLeftIcon</title><path d="M21.657 20.243a.999.999 0 1 1-1.414 1.414L12 13.414V20a1 1 0 1 1-2 0v-8.5c0-.827.673-1.5 1.5-1.5H20a1 1 0 1 1 0 2h-6.586l8.243 8.243ZM31 16c0 8.271-6.729 15-15 15S1 24.271 1 16 7.729 1 16 1s15 6.729 15 15Zm-2 0c0-7.168-5.832-13-13-13S3 8.832 3 16s5.832 13 13 13 13-5.832 13-13Z"></path></svg>;
3645

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

@@ -137,6 +146,7 @@ export const Example = ({
137146
}
138147

139148
const [editorCode, setEditorCode] = React.useState(code);
149+
const [fullPageUtilsPosition, setFullPageUtilsPosition] = React.useState('pf-m-bottom-right');
140150
const loc = useLocation();
141151
const isRTL = useContext(RtlContext);
142152
const scope = {
@@ -194,8 +204,46 @@ export const Example = ({
194204
<Flex
195205
direction={{ default: 'column' }}
196206
gap={{ default: 'gapMd' }}
197-
className="ws-full-page-utils pf-v6-m-dir-ltr"
207+
className={css('ws-full-page-utils', 'pf-v6-m-dir-ltr', fullPageUtilsPosition)}
198208
>
209+
<Flex justifyContent={{ default: 'justifyContentCenter' }} gap={{ default: 'gapXs' }}>
210+
<Button
211+
variant="plain"
212+
size="sm"
213+
hasNoPadding
214+
isClicked={fullPageUtilsPosition === 'pf-m-top-left'}
215+
onClick={() => setFullPageUtilsPosition('pf-m-top-left')}
216+
aria-label="Position utilities top left"
217+
icon={RhUiArrowCircleUpLeftIcon}
218+
/>
219+
<Button
220+
variant="plain"
221+
size="sm"
222+
hasNoPadding
223+
isClicked={fullPageUtilsPosition === 'pf-m-bottom-left'}
224+
onClick={() => setFullPageUtilsPosition('pf-m-bottom-left')}
225+
aria-label="Position utilities bottom left"
226+
icon={RhUiArrowCircleDownLeftIcon}
227+
/>
228+
<Button
229+
variant="plain"
230+
size="sm"
231+
hasNoPadding
232+
isClicked={fullPageUtilsPosition === 'pf-m-bottom-right'}
233+
onClick={() => setFullPageUtilsPosition('pf-m-bottom-right')}
234+
aria-label="Position utilities bottom right"
235+
icon={RhUiArrowCircleDownRightIcon}
236+
/>
237+
<Button
238+
variant="plain"
239+
size="sm"
240+
hasNoPadding
241+
isClicked={fullPageUtilsPosition === 'pf-m-top-right'}
242+
onClick={() => setFullPageUtilsPosition('pf-m-top-right')}
243+
aria-label="Position utilities top right"
244+
icon={RhUiArrowCircleUpRightIcon}
245+
/>
246+
</Flex>
199247
{hasThemeSwitcher && <ThemeSelector id="ws-example-theme-select" />}
200248
{hasRTLSwitcher && (
201249
<Switch

0 commit comments

Comments
 (0)