/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/components/src/scrollable/hook.ts
35 строк
942 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { useMemo } from '@wordpress/element'; import type { WordPressComponentProps } from '../context'; import { useContextSystem } from '../context'; import * as styles from './styles'; import { useCx } from '../utils/hooks/use-cx'; import type { ScrollableProps } from './types'; export function useScrollable( props: WordPressComponentProps< ScrollableProps, 'div' > ) { const { className, scrollDirection = 'y', smoothScroll = false, ...otherProps } = useContextSystem( props, 'Scrollable' ); const cx = useCx(); 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, cx, scrollDirection, smoothScroll ] ); return { ...otherProps, className: classes }; }