@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
48 lines (47 loc) • 1.54 kB
JavaScript
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import React from 'react';
export const useTablet = (options) => {
const theme = useTheme();
return useMediaQuery(theme.breakpoints.down('md'), options);
};
export const useMobile = (options) => {
const theme = useTheme();
return useMediaQuery(theme.breakpoints.down('sm'), options);
};
export const useBreakpoint = (fnKey, breakpoint, breakpointOrOptions, options) => {
const theme = useTheme();
let args;
if (fnKey === 'between') {
args = [
theme.breakpoints.between(breakpoint, breakpointOrOptions), options
];
}
else {
args = [
theme.breakpoints[fnKey](breakpoint), breakpointOrOptions
];
}
return useMediaQuery(...args);
};
export const HiddenMobile = ({ children }) => {
const isMobile = useMobile();
return isMobile
? null
// eslint-disable-next-line
: React.createElement(React.Fragment, null, children);
};
export const HiddenTablet = ({ children }) => {
const isTablet = useTablet();
return isTablet
? null
// eslint-disable-next-line
: React.createElement(React.Fragment, null, children);
};
export const HiddenDesktop = ({ children }) => {
const isTablet = useTablet();
return isTablet
// eslint-disable-next-line
? React.createElement(React.Fragment, null, children)
: null;
};