This package contains a avatar component.
Change Log
You can install this package using npm, yarn, or pnpm.
npm install @pikas-utils/screen
yarn add @pikas-utils/screen
pnpm add @pikas-utils/screen
Use this hook to get the window size.
This hook comes from usehooks-ts library.
{}
import { useWindowSize } from '@pikas-utils/screen';
const Example: React.FC = () => {
const { width, height } = useWindowSize();
return (
<div>
The current window dimensions are:{' '}
<code>{JSON.stringify({ width, height })}</code>
</div>
);
};
Use this hook to know the screen media in relation to the window size.
import { useWindowSize } from '@pikas-utils/screen';
const Example: React.FC = () => {
const media = useMediaScreen();
return (
<div>
The current media screen is: <b>{media}</b>
</div>
);
};
Use this hook to find out if the screen media is valid for the current screen.
import { useMediaScreenValid } from '@pikas-utils/screen';
const Example: React.FC = () => {
const mediaValid = useMediaScreenValid({ media: 'md', operator: '>' });
return (
<div>
<span>
Media screen: <b>md</b>
</span>
<span>
Operator: <b>></b>
</span>
<span>
Media valid: <b>{mediaValid ? 'true' : 'false'}</b>
</span>
</div>
);
};
import { getMediaByScreenSize } from '@pikas-utils/screen';
const size: number = 1200;
getMediaByScreenSize(size);
// 'xl'
import { getScreenSizeByMedia } from '@pikas-utils/screen';
const media: Medias = 'md';
getScreenSizeByMedia(media);
// 768
This documentation can be edited on GitHub here