-
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' of https://github.com/microsoft/fluentui into u…
…sers/srmukher/legendsMultiSelectVBC
- Loading branch information
Showing
453 changed files
with
8,124 additions
and
1,186 deletions.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
apps/public-docsite-v9/src/Concepts/Positioning/PositioningShiftToCoverTarget.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,132 @@ | ||
import * as React from 'react'; | ||
import { | ||
Button, | ||
makeStyles, | ||
SpinButton, | ||
Menu, | ||
MenuTrigger, | ||
MenuPopover, | ||
MenuList, | ||
MenuItem, | ||
PositioningImperativeRef, | ||
useMergedRefs, | ||
Checkbox, | ||
RadioGroup, | ||
Field, | ||
Radio, | ||
PositioningProps, | ||
} from '@fluentui/react-components'; | ||
|
||
const useStyles = makeStyles({ | ||
boundary: { | ||
border: '2px dashed red', | ||
width: '300px', | ||
height: '300px', | ||
overflow: 'auto', | ||
resize: 'both', | ||
}, | ||
trigger: { | ||
display: 'block', | ||
width: '150px', | ||
margin: '200px auto', | ||
}, | ||
}); | ||
|
||
const ResizableBoundary = React.forwardRef< | ||
HTMLDivElement, | ||
{ | ||
onResize: ResizeObserverCallback; | ||
children: React.ReactNode; | ||
} | ||
>(({ onResize, children }, ref) => { | ||
const containerRef = React.useRef<HTMLDivElement | null>(null); | ||
|
||
React.useEffect(() => { | ||
if (containerRef.current) { | ||
const resizeObserver = new ResizeObserver(onResize); | ||
resizeObserver.observe(containerRef.current); | ||
|
||
return () => { | ||
resizeObserver.disconnect(); | ||
}; | ||
} | ||
}, [onResize]); | ||
|
||
const styles = useStyles(); | ||
|
||
return ( | ||
<div ref={useMergedRefs(ref, containerRef)} className={styles.boundary}> | ||
{children} | ||
</div> | ||
); | ||
}); | ||
|
||
export const CoverTargetForSmallViewport = () => { | ||
const styles = useStyles(); | ||
const [boundaryRef, setBoundaryRef] = React.useState<HTMLDivElement | null>(null); | ||
|
||
const [menuItemCount, setMenuItemCount] = React.useState(6); | ||
|
||
const positioningRef = React.useRef<PositioningImperativeRef>(null); | ||
|
||
const [open, setOpen] = React.useState(false); | ||
const [menuPosition, setMenuPosition] = React.useState<PositioningProps['position']>('above'); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<Checkbox label="Open" checked={open} onChange={(e, data) => setOpen(data.checked as boolean)} />{' '} | ||
<Field label="Menu position"> | ||
<RadioGroup | ||
value={menuPosition} | ||
onChange={(_, data) => setMenuPosition(data.value as PositioningProps['position'])} | ||
> | ||
<Radio value="above" label="above" /> | ||
<Radio value="after" label="after" /> | ||
</RadioGroup> | ||
</Field> | ||
<Field label="Menu Item Count"> | ||
<SpinButton value={menuItemCount} onChange={(_e, { value }) => value && setMenuItemCount(value)} /> | ||
</Field> | ||
</div> | ||
<ResizableBoundary | ||
ref={setBoundaryRef} | ||
onResize={() => { | ||
positioningRef.current?.updatePosition(); | ||
}} | ||
> | ||
<Menu | ||
open={open} | ||
positioning={{ | ||
positioningRef, | ||
overflowBoundary: boundaryRef, | ||
flipBoundary: boundaryRef, | ||
autoSize: true, | ||
shiftToCoverTarget: true, | ||
position: menuPosition, | ||
}} | ||
> | ||
<MenuTrigger disableButtonEnhancement> | ||
<Button className={styles.trigger}>Open Menu</Button> | ||
</MenuTrigger> | ||
<MenuPopover> | ||
<MenuList> | ||
{Array.from({ length: menuItemCount }, (_, i) => ( | ||
<MenuItem>Item {i}</MenuItem> | ||
))} | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu> | ||
</ResizableBoundary> | ||
</> | ||
); | ||
}; | ||
|
||
CoverTargetForSmallViewport.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
"`shiftToCoverTarget` is a positioning option that allows the positioned element to shift and cover the target element when there isn't enough space available to fit it.", | ||
}, | ||
}, | ||
}; |
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
7 changes: 0 additions & 7 deletions
7
change/@fluentui-react-carousel-6c54eead-adb1-472f-9bdd-51f424e2c9db.json
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
change/@fluentui-react-carousel-b0491798-cc10-487f-a3c0-98bcd6016f7f.json
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
change/@fluentui-react-carousel-d45f8c82-f098-4820-9e34-31862a08f3d3.json
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-charting-f56dc096-9891-4d5c-ae30-4d8a6ac5b481.json
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,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Ensure type safety of dependent fields", | ||
"packageName": "@fluentui/react-charting", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 0 additions & 7 deletions
7
change/@fluentui-react-charting-fd790dc8-78f9-4645-926b-0f0c017d3bfd.json
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
change/@fluentui-react-color-picker-preview-efdd71e7-571d-48bf-9e41-37f6d220a529.json
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
change/@fluentui-react-tabs-7a95002f-25eb-47c0-9f9b-a77ffdef753a.json
This file was deleted.
Oops, something went wrong.
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.