-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/ci_dry_run
- Loading branch information
Showing
84 changed files
with
1,608 additions
and
117 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
118 changes: 118 additions & 0 deletions
118
apps/public-docsite-v9/src/Concepts/Positioning/PositioningOverflowBoundaryRect.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import * as React from 'react'; | ||
import { | ||
Popover, | ||
PopoverTrigger, | ||
PopoverSurface, | ||
Button, | ||
makeStyles, | ||
tokens, | ||
type PositioningRect, | ||
useIsomorphicLayoutEffect, | ||
} from '@fluentui/react-components'; | ||
|
||
const useClasses = makeStyles({ | ||
area: { | ||
border: `2px solid ${tokens.colorStatusDangerBackground3}`, | ||
padding: '60px 20px 20px 20px', | ||
width: '300px', | ||
height: '300px', | ||
|
||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'end', | ||
justifyContent: 'space-between', | ||
position: 'relative', | ||
|
||
'::before': { | ||
content: '"Container"', | ||
position: 'absolute', | ||
padding: `${tokens.spacingHorizontalMNudge} ${tokens.spacingHorizontalS}`, | ||
|
||
top: 0, | ||
left: 0, | ||
|
||
color: tokens.colorStatusDangerBackground1, | ||
backgroundColor: tokens.colorStatusDangerBackground3, | ||
}, | ||
}, | ||
boundary: { | ||
width: '320px', | ||
height: '320px', | ||
outline: `2px solid ${tokens.colorBrandBackground}`, | ||
|
||
position: 'absolute', | ||
top: '50px', | ||
left: '10px', | ||
pointerEvents: 'none', | ||
|
||
'::before': { | ||
content: '"Boundary"', | ||
position: 'absolute', | ||
padding: `${tokens.spacingHorizontalMNudge} ${tokens.spacingHorizontalS}`, | ||
|
||
top: 0, | ||
left: 0, | ||
|
||
color: tokens.colorNeutralForegroundOnBrand, | ||
backgroundColor: tokens.colorBrandBackground, | ||
}, | ||
}, | ||
}); | ||
|
||
export const OverflowBoundaryRect = () => { | ||
const classes = useClasses(); | ||
|
||
const boundaryRef = React.useRef<HTMLDivElement | null>(null); | ||
const [boundaryRect, setBoundaryRect] = React.useState<PositioningRect | null>(null); | ||
|
||
useIsomorphicLayoutEffect(() => { | ||
setBoundaryRect(boundaryRef.current?.getBoundingClientRect() ?? null); | ||
}, []); | ||
|
||
return ( | ||
<div className={classes.area}> | ||
<div className={classes.boundary} ref={boundaryRef} /> | ||
|
||
<Popover | ||
positioning={{ | ||
overflowBoundary: boundaryRect, | ||
position: 'below', | ||
align: 'start', | ||
}} | ||
> | ||
<PopoverTrigger disableButtonEnhancement> | ||
<Button> | ||
<code>align: start</code> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverSurface>Stays within the defined rect</PopoverSurface> | ||
</Popover> | ||
|
||
<Popover | ||
positioning={{ | ||
overflowBoundary: boundaryRect, | ||
position: 'above', | ||
align: 'start', | ||
}} | ||
> | ||
<PopoverTrigger disableButtonEnhancement> | ||
<Button> | ||
<code>align: start</code> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverSurface>Stays within the defined rect</PopoverSurface> | ||
</Popover> | ||
</div> | ||
); | ||
}; | ||
|
||
OverflowBoundaryRect.parameters = { | ||
docs: { | ||
description: { | ||
story: [ | ||
'Boundaries can be also defined as `Rect` objects. ', | ||
'This is useful when a boundary is not an actual element, but some kind of computed values.', | ||
].join('\n'), | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.