diff --git a/src/components/tools/Popper/Popper.js b/src/components/tools/Popper/Popper.js index 5ae61fb9..2c0291bf 100644 --- a/src/components/tools/Popper/Popper.js +++ b/src/components/tools/Popper/Popper.js @@ -1,7 +1,7 @@ import {useState, useRef} from 'react'; import {customClassSwitcher} from '~/core'; -import {useFloating, useInteractions, useHover, FloatingArrow, arrow, offset, flip, autoUpdate, autoPlacement, useRole, useDismiss} from '@floating-ui/react'; +import {useFloating, useInteractions, useHover, FloatingArrow, arrow, offset, flip, autoPlacement, hide, shift, autoUpdate, useRole, useDismiss} from '@floating-ui/react'; // TODO : Use Floating Portal? // TODO : Collisions dont seem to be working as expected, need to investigate @@ -36,7 +36,7 @@ const Popper = ({ const {refs, floatingStyles, context} = useFloating({ placement: placement, - whileElementsMounted: autoUpdate, + whileElementsMounted: autoUpdate, // this makes sure the popup is attached to the reference on scrolling etc open: isOpen, // strategy: 'fixed', middleware: [ @@ -45,10 +45,18 @@ const Popper = ({ }), offset(ARROW_HEIGHT + GAP), flip({ - mainAxis: false, - fallbackPlacements: ['right', 'bottom'], + mainAxis: true, + fallbackStrategy: 'initialPlacement', }, ), + shift({ + crossAxis: false, + }), + hide({ + strategy: 'referenceHidden', // 'referenceHidden' by default + }), + + ], onOpenChange: setIsOpen, }); @@ -66,9 +74,9 @@ const Popper = ({ dismiss, ]); - return <> + return { console.log('click'); @@ -78,7 +86,7 @@ const Popper = ({ {isOpen &&
{showArrow && } {pop}
} - ; +
; }; export default Popper; diff --git a/src/components/tools/ScrollPlayground/ScrollPlayground.js b/src/components/tools/ScrollPlayground/ScrollPlayground.js new file mode 100644 index 00000000..67d9aebc --- /dev/null +++ b/src/components/tools/ScrollPlayground/ScrollPlayground.js @@ -0,0 +1,34 @@ +import React, {useState} from 'react'; + + +import Button from '~/components/ui/Button/Button'; + +const ScrollPlayground = ({children}) => { + const [scrollable, setScrollable] = useState(false); + + const handleScrollableChange = (e) => { + setScrollable((scrollable) => !scrollable); + + setTimeout(() => { + const elem = document.getElementById('middle'); + if (elem) { + elem.scrollIntoView(); + } + }, 100); + }; + + const SCROLL_BOUNDING_BOX = 200; + + return
+ +
+
+ + {children} + +
+
+
; +}; + +export default ScrollPlayground; diff --git a/src/components/ui/Dropdown/Dropdown.js b/src/components/ui/Dropdown/Dropdown.js index ccc82083..fd10bd4f 100644 --- a/src/components/ui/Dropdown/Dropdown.js +++ b/src/components/ui/Dropdown/Dropdown.js @@ -9,8 +9,8 @@ const Dropdown = ({list=[], selected}) => { })} ; }; - return
- }> + return
+ }> Dropdown
; diff --git a/src/components/ui/Dropdown/Dropdown.stories.js b/src/components/ui/Dropdown/Dropdown.stories.js index d8dffdd7..808ce576 100644 --- a/src/components/ui/Dropdown/Dropdown.stories.js +++ b/src/components/ui/Dropdown/Dropdown.stories.js @@ -15,8 +15,16 @@ export default { {}} label={'Bello'} list={[ - {value: 'hello', label: 'hello'}, - ]}>Hello + {value: `hello Hello this is a dropdown. Hello this is a dropdown. + Hello this is a dropdown. Hello`, label: 'hello'}, + ]}> +
+ Hello this is a dropdown. Hello this is a dropdown. Hello this is a dropdown. Hello this is a + dropdown. Hello this is a dropdown. Hello this is a dropdown. Hello this is a dropdown. Hello + this is a dropdown. Hello this is a dropdown. Hello this is a dropdown. Hello this is a + dropdown. Hello this is a dropdown. Hello this is a dropdown. Hello this is a dropdown. Hello +
+
Dropdown End diff --git a/src/components/ui/Tooltip/Tooltip.stories.js b/src/components/ui/Tooltip/Tooltip.stories.js index 18e2bc6c..09b2446a 100644 --- a/src/components/ui/Tooltip/Tooltip.stories.js +++ b/src/components/ui/Tooltip/Tooltip.stories.js @@ -1,20 +1,18 @@ import {Tooltip, Heading} from '~/'; import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor'; +import ScrollPlayground from '~/components/tools/ScrollPlayground/ScrollPlayground'; // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export export default { title: 'UI/Input/Tooltip', component: Tooltip, render: (args) => -
-
- Tooltip - + + Hello, hover me! - -
-
+ +
, }; diff --git a/styles/themes/default.scss b/styles/themes/default.scss index 1f3830a5..2ce152dc 100644 --- a/styles/themes/default.scss +++ b/styles/themes/default.scss @@ -252,4 +252,8 @@ button:active, button:focus, input:active, input:focus, textarea:active, textare padding: 4px 8px; +} + +.rad-ui-popper{ + // max-width: calc(100vw - 10px); } \ No newline at end of file