UNPKG

@wordpress/components

Version:
33 lines (28 loc) 987 B
import { cx as _cx } from "emotion"; /** * WordPress dependencies */ import { useMemo } from '@wordpress/element'; /** * Internal dependencies */ import { useContextSystem } from '../context'; import * as styles from './styles'; /* eslint-disable jsdoc/valid-types */ /** * @param {import('../context').ViewOwnProps<import('./types').Props, 'div'>} props */ /* eslint-enable jsdoc/valid-types */ export function useScrollable(props) { const { className, scrollDirection = 'y', smoothScroll = false, ...otherProps } = useContextSystem(props, 'Scrollable'); const classes = useMemo(() => _cx(styles.Scrollable, styles.scrollableScrollbar, smoothScroll && styles.smoothScroll, scrollDirection === 'x' && styles.scrollX, scrollDirection === 'y' && styles.scrollY, scrollDirection === 'auto' && styles.scrollAuto, className), [className, scrollDirection, smoothScroll]); return { ...otherProps, className: classes }; } //# sourceMappingURL=hook.js.map