mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
♻️ Make Separator component more generic
This commit is contained in:
parent
65814f51e9
commit
3fa823ee02
4 changed files with 35 additions and 26 deletions
|
@ -2,13 +2,22 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&__space,
|
||||
&__line {
|
||||
height: 1px;
|
||||
background-color: $color-gray-600;
|
||||
margin: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&__line {
|
||||
background-color: $color-gray-600;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
&__space {
|
||||
margin-bottom: 48px;
|
||||
}
|
||||
|
||||
&__text {
|
||||
color: $color-gray;
|
||||
@include font(12, 24, 500, 0.8px);
|
||||
|
|
|
@ -20,14 +20,6 @@
|
|||
margin: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.ppcp-r-page-welcome-mode-separator {
|
||||
margin: 0 0 48px 0;
|
||||
|
||||
.ppcp-r-separator__line {
|
||||
background-color: $color-gray-300;
|
||||
}
|
||||
}
|
||||
|
||||
.components-base-control__field {
|
||||
margin: 0 0 24px 0;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,32 @@
|
|||
const Separator = ( props ) => {
|
||||
let separatorClass = 'ppcp-r-separator';
|
||||
const Separator = ( { className = '', text = '', withLine = true } ) => {
|
||||
const separatorClass = [ 'ppcp-r-separator' ];
|
||||
const innerClass = withLine
|
||||
? 'ppcp-r-separator__line'
|
||||
: 'ppcp-r-separator__space';
|
||||
|
||||
if ( props?.className ) {
|
||||
separatorClass += ' ' + props.className;
|
||||
if ( className ) {
|
||||
separatorClass.push( className );
|
||||
}
|
||||
|
||||
if ( props.text ) {
|
||||
return (
|
||||
<div className={ separatorClass }>
|
||||
<span className="ppcp-r-separator__line ppcp-r-separator__line--before"></span>
|
||||
const getClass = ( type ) => `${ innerClass } ${ innerClass }--${ type }`;
|
||||
|
||||
<span className="ppcp-r-separator__text">{ props.text }</span>
|
||||
<span className="ppcp-r-separator__line ppcp-r-separator__line--after"></span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
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 }>
|
||||
<span className="ppcp-r-separator__line ppcp-r-separator__line--before"></span>
|
||||
<div className={ separatorClass.join( ' ' ) }>
|
||||
{ renderSeparator() }
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -122,7 +122,7 @@ const AdvancedOptionsForm = ( { setCompleted } ) => {
|
|||
{ __( 'Connect Account', 'woocommerce-paypal-payments' ) }
|
||||
</Button>
|
||||
</SettingsToggleBlock>
|
||||
<Separator className="ppcp-r-page-welcome-mode-separator" />
|
||||
<Separator withLine={ false } />
|
||||
<SettingsToggleBlock
|
||||
label={
|
||||
__( 'Manually Connect', 'woocommerce-paypal-payments' ) +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue