import React from 'react' import { type Meta, type StoryObj } from '@storybook/react-vite' import { useWindowSize } from '..' import { DocsTemplate } from '../../../.storybook' import OutputForDemo from '../../../.storybook/templates/OutputForDemo' const WindowSizeTemplate = (args): React.JSX.Element => { const { width, height } = useWindowSize(args.ignoreHeaderHeight) return (
The width and height dimensions of your browser window. Resize this window to see the updated values. Width: {width}px, Height: {height}px } />
) } export default { title: 'Hooks/useWindowSize', component: WindowSizeTemplate, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> useWindowSize is a hook and will run anytime the window size is changed. , This hook give you access to the width and{' '} height of the browser window. , If you do not want the app's header height to be part of the calculation, pass in true to the hook. , ]} noArgs /> ), }, }, } as Meta type Story = StoryObj const Template: Story = { render: (args) => , } export const Basic: Story = { ...Template, args: {}, } export const IgnoreHeaderHeight: Story = { ...Template, args: { ignoreHeaderHeight: true, }, }