-
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/HBC_multi_legend
- Loading branch information
Showing
426 changed files
with
10,209 additions
and
1,887 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
apps/perf-test-react-components/src/scenarios/ColorPicker.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,18 @@ | ||
import * as React from 'react'; | ||
import { ColorPicker, ColorArea, ColorSlider, AlphaSlider } from '@fluentui/react-color-picker-preview'; | ||
import { FluentProvider } from '@fluentui/react-provider'; | ||
import { webLightTheme } from '@fluentui/react-theme'; | ||
|
||
const Scenario = () => ( | ||
<ColorPicker color={{ h: 109, s: 1, v: 0.91 }}> | ||
<ColorArea /> | ||
<ColorSlider /> | ||
<AlphaSlider /> | ||
</ColorPicker> | ||
); | ||
|
||
Scenario.decorator = (props: { children: React.ReactNode }) => ( | ||
<FluentProvider theme={webLightTheme}>{props.children}</FluentProvider> | ||
); | ||
|
||
export default Scenario; |
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
30 changes: 30 additions & 0 deletions
30
apps/vr-tests-react-components/src/stories/ColorPicker/ColorPicker.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,30 @@ | ||
import * as React from 'react'; | ||
import type { Meta } from '@storybook/react'; | ||
import { ColorPicker } from '@fluentui/react-color-picker-preview'; | ||
import { SampleColorPicker } from './utils'; | ||
import { Steps } from 'storywright'; | ||
|
||
import { DARK_MODE, getStoryVariant, HIGH_CONTRAST, RTL, withStoryWrightSteps } from '../../utilities'; | ||
|
||
export default { | ||
title: 'ColorPicker Converged', | ||
decorators: [ | ||
story => withStoryWrightSteps({ story, steps: new Steps().snapshot('default', { cropTo: '.testWrapper' }).end() }), | ||
], | ||
} satisfies Meta<typeof ColorPicker>; | ||
|
||
export const Default = () => <SampleColorPicker color={{ h: 109, s: 1, v: 0.91 }} />; | ||
|
||
export const DefaultDarkMode = getStoryVariant(Default, DARK_MODE); | ||
|
||
export const DefaultHighContrast = getStoryVariant(Default, HIGH_CONTRAST); | ||
|
||
export const DefaultRTL = getStoryVariant(Default, RTL); | ||
|
||
export const Shape = () => ( | ||
<> | ||
<SampleColorPicker color={{ h: 195, s: 0.85, v: 0.93 }} shape="square" /> | ||
<SampleColorPicker color={{ h: 195, s: 0.85, v: 0.913 }} shape="rounded" /> | ||
</> | ||
); | ||
Shape.storyName = 'shape'; |
16 changes: 16 additions & 0 deletions
16
apps/vr-tests-react-components/src/stories/ColorPicker/utils.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,16 @@ | ||
import * as React from 'react'; | ||
import { | ||
ColorPicker, | ||
ColorArea, | ||
AlphaSlider, | ||
ColorSlider, | ||
type ColorPickerProps, | ||
} from '@fluentui/react-color-picker-preview'; | ||
|
||
export const SampleColorPicker = (props: ColorPickerProps) => ( | ||
<ColorPicker {...props}> | ||
<ColorArea /> | ||
<ColorSlider /> | ||
<AlphaSlider /> | ||
</ColorPicker> | ||
); |
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.