How to use the @react-md/utils.useAppSize function in @react-md/utils

To help you get started, we’ve selected a few @react-md/utils 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 mlaursen / react-md / packages / examples / src / AppSize.tsx View on Github external
const AppSize: FunctionComponent = () => {
  const appSize = useAppSize();
  // const [appSize, setSize] = useState(getCurrentAppSize());
  // useEventListener("resize", () => setSize(getCurrentAppSize()));

  return (
    
      
      
    
  );
};
github mlaursen / react-md / packages / layout / src / useLayout.ts View on Github external
export default function useLayout({
  phoneLayout,
  tabletLayout,
  landscapeTabletLayout,
  desktopLayout,
  largeDesktopLayout,
}: LayoutConfiguration): LayoutNavigationVisibility {
  const appSize = useAppSize();
  const layout = getLayout({
    appSize,
    phoneLayout,
    tabletLayout,
    landscapeTabletLayout,
    desktopLayout,
    largeDesktopLayout,
  });

  const { isDesktop } = appSize;
  const isFullHeight = layout === "full-height";
  const isPersistent = isPersistentLayout(layout);

  const [visible, setVisible] = useState(isPersistent && isDesktop);

  useEffect(() => {
github mlaursen / react-md / packages / documentation / src / components / Demos / Utils / AppSizeListenerExample.tsx View on Github external
const CurrentSize: FC = () => {
  const context = useAppSize();
  return (
    
      
      {JSON.stringify(context, null, 2)}
    
  );
};
github mlaursen / react-md / packages / documentation / components / Layout / AppSize.tsx View on Github external
export const AppSize: FunctionComponent> = ({
  children,
  ...defaults
}) => {
  const value = useAppSize({ defaultValue: defaults as AppSizeType });
  return (
    {children}
  );
};