🚚 Move Separator component

This commit is contained in:
Philipp Stracker 2025-01-22 15:09:04 +01:00
parent 54504b7591
commit 1ca6641d77
No known key found for this signature in database
7 changed files with 6 additions and 5 deletions

View file

@ -0,0 +1,34 @@
const Separator = ( { className = '', text = '', withLine = true } ) => {
const separatorClass = [ 'ppcp-r-separator' ];
const innerClass = withLine
? 'ppcp-r-separator__line'
: 'ppcp-r-separator__space';
if ( className ) {
separatorClass.push( className );
}
const getClass = ( type ) => `${ innerClass } ${ innerClass }--${ type }`;
const renderSeparator = () => {
if ( text ) {
return (
<>
<span className={ getClass( 'before' ) }></span>
<span className="ppcp-r-separator__text">{ text }</span>
<span className={ getClass( 'after' ) }></span>
</>
);
}
return <span className={ getClass( 'full' ) }></span>;
};
return (
<div className={ separatorClass.join( ' ' ) }>
{ renderSeparator() }
</div>
);
};
export default Separator;