How to use the reakit/Menu.useMenuState function in reakit

To help you get started, we’ve selected a few reakit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / packages / common / src / components / MultiAction / MultiAction.tsx View on Github external
({
    Icon,
    primaryActionLabel,
    onPrimaryClick,
    disablePrimary = false,
    small = false,
    block = false,
    disabled = false,
    secondary = false,
    red = false,
    danger = false,
    children,
    className,
  }) => {
    const menu = useMenuState();
    const buttonProps = { small, block, disabled, secondary, red, danger };

    return (
      
        {/*
        // @ts-ignore */}
         onPrimaryClick(e, menu)}
          className={className}
          {...buttonProps}
          disabled={disablePrimary || disabled}
        >
          {Icon && }
          {primaryActionLabel}
github codesandbox / codesandbox-client / packages / common / src / components / Menu / Menu.tsx View on Github external
export const Menu: React.FC = ({
  label,
  as = MenuButton,
  disabled = false,
  onOpen = () => {},
  onClose = () => {},
  onToggle = () => {},
  children,
  ...props
}) => {
  const menu = useMenuState();
  useEffect(() => {
    if (menu.visible) {
      onOpen();
    } else {
      onClose();
    }
  }, [onOpen, onClose, menu.visible]);

  return (
    
      
        {label}
      
      
        {children && (children as React.ReactElement[]).length
          ? /* eslint-disable react/no-array-index-key */
github codesandbox / codesandbox-client / packages / app / src / app / pages / common / UserMenu / index.tsx View on Github external
export const UserMenu: FunctionComponent = () => {
  const {
    actions: {
      modalOpened,
      signOutClicked,
      files: { gotUploadedFiles },
    },
    state: { user },
  } = useOvermind();
  const menu = useMenuState({
    placement: 'bottom-end',
  });

  return (
github codesandbox / codesandbox-client / packages / app / src / app / pages / Dashboard / Content / Sandboxes / Filters / SortOptions / index.tsx View on Github external
export const SortOptions: React.FC<{ hideOrder: boolean }> = ({
  hideOrder,
}) => {
  const {
    state: {
      dashboard: {
        orderBy: { field, order },
      },
    },
    actions: {
      dashboard: { orderByChanged },
    },
  } = useOvermind();
  const menu = useMenuState();

  const toggleSort = e => {
    e.preventDefault();

    orderByChanged({
      orderBy: {
        order: order === 'asc' ? 'desc' : 'asc',
        field,
      },
    });
  };

  const setField = (fieldToSet: string) => {
    orderByChanged({
      orderBy: {
        order,
github btzr-io / Villain / src / components / menu.js View on Github external
({ disclosure, tooltip, items, placement, ariaLabel, ...props }, ref) => {
    const menu = useMenuState({ placement })
    const tooltipState = useTooltipState({ placement })

    const subRef = React.useRef(null)
    const mainRef = React.useRef(null)

    const [height, setHeight] = React.useState(0)
    const [submenuState, setSubmenuState] = React.useState({
      show: false,
      list: null,
      index: null,
      items: null,
      title: null,
    })
    const getHeight = element => {
      const bounds = element.getBoundingClientRect()
      return bounds.height
github pubpub / pubpub / client / components / Menu / Menu.js View on Github external
export const Menu = (props) => {
	const {
		'aria-label': ariaLabel,
		children,
		disclosure,
		placement,
		onDismiss,
		gutter,
		menuStyle,
	} = props;

	const menu = RK.useMenuState({
		placement: placement,
		gutter: gutter,
		unstable_preventOverflow: false,
	});

	const handleDismiss = () => {
		menu.hide();
		onDismiss();
	};

	return (
github codesandbox / codesandbox-client / packages / app / src / app / pages / Dashboard / Content / Sandboxes / Filters / FilterOptions / index.tsx View on Github external
const FilterOptionsComponent: React.FC = ({
  possibleTemplates,
  hideFilters,
}: IFilterOptionsProps) => {
  const menu = useMenuState({
    placement: 'bottom-end',
  });

  const {
    state: {
      dashboard: { isTemplateSelected, filters },
    },
    actions: {
      dashboard: {
        blacklistedTemplateAdded,
        blacklistedTemplateRemoved,
        blacklistedTemplatesCleared,
        blacklistedTemplatesChanged,
      },
    },
  } = useOvermind();