/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/separator/deprecated.js
50 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import clsx from 'clsx'; import { getColorClassName, useBlockProps } from '@wordpress/block-editor'; const v1 = { attributes: { color: { type: 'string', }, customColor: { type: 'string', }, }, save( { attributes } ) { const { color, customColor } = attributes; // the hr support changing color using border-color, since border-color // is not yet supported in the color palette, we use background-color const backgroundClass = getColorClassName( 'background-color', color ); // the dots styles uses text for the dots, to change those dots color is // using color, not backgroundColor const colorClass = getColorClassName( 'color', color ); const className = clsx( { 'has-text-color has-background': color || customColor, [ backgroundClass ]: backgroundClass, [ colorClass ]: colorClass, } ); const style = { backgroundColor: backgroundClass ? undefined : customColor, color: colorClass ? undefined : customColor, }; return <hr { ...useBlockProps.save( { className, style } ) } />; }, migrate( attributes ) { const { color, customColor, ...restAttributes } = attributes; return { ...restAttributes, backgroundColor: color ? color : undefined, opacity: 'css', style: customColor ? { color: { background: customColor } } : undefined, tagName: 'hr', }; }, }; export default [ v1 ];