-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge branch 'temp/settings-ui'
# Conflicts: # modules/ppcp-settings/resources/js/Components/Screens/Settings.js
- Loading branch information
Showing
48 changed files
with
1,632 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Global app-level styles | ||
*/ | ||
|
||
.ppcp-r-app.loading { | ||
height: 400px; | ||
width: 400px; | ||
position: absolute; | ||
left: 50%; | ||
transform: translate(-50%, 0); | ||
text-align: center; | ||
|
||
.ppcp-r-spinner-overlay { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
} | ||
|
||
.ppcp-r-spinner-overlay__message { | ||
transform: translate(0, 32px) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
modules/ppcp-settings/resources/css/components/reusable-components/_busy-state.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.ppcp-r-busy-wrapper { | ||
position: relative; | ||
|
||
&.ppcp--is-loading { | ||
pointer-events: none; | ||
user-select: none; | ||
|
||
--spinner-overlay-color: #fff4; | ||
} | ||
} |
108 changes: 81 additions & 27 deletions
108
modules/ppcp-settings/resources/css/components/reusable-components/_button.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,102 @@ | ||
%button-style-default { | ||
background-color: var(--button-background); | ||
color: var(--button-color); | ||
box-shadow: inset 0 0 0 1px var(--button-border-color); | ||
} | ||
|
||
%button-style-hover { | ||
background-color: var(--button-hover-background); | ||
color: var(--button-hover-color); | ||
box-shadow: inset 0 0 0 1px var(--button-hover-border-color); | ||
} | ||
|
||
%button-style-disabled { | ||
background-color: var(--button-disabled-background); | ||
color: var(--button-disabled-color); | ||
box-shadow: inset 0 0 0 1px var(--button-disabled-border-color); | ||
} | ||
|
||
%button-shape-pill { | ||
border-radius: 50px; | ||
padding: 15px 32px; | ||
height: auto; | ||
} | ||
|
||
button.components-button, a.components-button { | ||
&.is-primary, &.is-secondary { | ||
&:not(:disabled) { | ||
background-color: $color-black; | ||
} | ||
/* default theme */ | ||
--button-color: var(--color-gray-900); | ||
--button-background: transparent; | ||
--button-border-color: transparent; | ||
|
||
&:disabled { | ||
color: $color-gray-700; | ||
} | ||
--button-hover-color: var(--button-color); | ||
--button-hover-background: var(--button-background); | ||
--button-hover-border-color: var(--button-border-color); | ||
|
||
--button-disabled-color: var(--color-gray-500); | ||
--button-disabled-background: transparent; | ||
--button-disabled-border-color: transparent; | ||
|
||
/* style the button template */ | ||
|
||
border-radius: 50px; | ||
padding: 15px 32px; | ||
height: auto; | ||
&:not(:disabled) { | ||
@extend %button-style-default; | ||
} | ||
|
||
&:hover { | ||
@extend %button-style-hover; | ||
} | ||
|
||
&:disabled { | ||
@extend %button-style-disabled; | ||
} | ||
|
||
/* | ||
---------------------------------------------- | ||
Customize variants using the theming variables | ||
*/ | ||
|
||
&.is-primary, | ||
&.is-secondary { | ||
@extend %button-shape-pill; | ||
} | ||
|
||
&.is-primary { | ||
@include font(14, 18, 900); | ||
|
||
&:not(:disabled) { | ||
background-color: $color-blueberry; | ||
color: $color-white; | ||
} | ||
--button-color: #{$color-white}; | ||
--button-background: #{$color-blueberry}; | ||
|
||
--button-disabled-color: #{$color-gray-100}; | ||
--button-disabled-background: #{$color-gray-500}; | ||
} | ||
|
||
&.is-secondary:not(:disabled) { | ||
border-color: $color-blueberry; | ||
background-color: $color-white; | ||
color: $color-blueberry; | ||
&.is-secondary { | ||
--button-color: #{$color-blueberry}; | ||
--button-background: #{$color-white}; | ||
--button-border-color: #{$color-blueberry}; | ||
|
||
&:hover { | ||
background-color: $color-white; | ||
background: none; | ||
} | ||
--button-disabled-color: #{$color-gray-600}; | ||
--button-disabled-background: #{$color-gray-100}; | ||
--button-disabled-border-color: #{$color-gray-400}; | ||
} | ||
|
||
&.is-tertiary { | ||
color: $color-blueberry; | ||
|
||
&:hover { | ||
color: $color-gradient-dark; | ||
} | ||
--button-color: #{$color-blueberry}; | ||
--button-hover-color: #{$color-gradient-dark}; | ||
|
||
&:focus:not(:disabled) { | ||
border: none; | ||
box-shadow: none; | ||
} | ||
} | ||
|
||
&.small-button { | ||
@include small-button; | ||
} | ||
} | ||
|
||
.ppcp--is-loading { | ||
button.components-button, a.components-button { | ||
@extend %button-style-disabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
margin: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
modules/ppcp-settings/resources/js/Components/ReusableComponents/BusyStateWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { | ||
Children, | ||
isValidElement, | ||
cloneElement, | ||
useMemo, | ||
createContext, | ||
useContext, | ||
} from '@wordpress/element'; | ||
import classNames from 'classnames'; | ||
|
||
import { CommonHooks } from '../../data'; | ||
import SpinnerOverlay from './SpinnerOverlay'; | ||
|
||
// Create context to track the busy state across nested wrappers | ||
const BusyContext = createContext( false ); | ||
|
||
/** | ||
* Wraps interactive child elements and modifies their behavior based on the global `isBusy` state. | ||
* Allows custom processing of child props via the `onBusy` callback. | ||
* | ||
* @param {Object} props - Component properties. | ||
* @param {Children} props.children - Child components to wrap. | ||
* @param {boolean} props.enabled - Enables or disables the busy-state logic. | ||
* @param {boolean} props.busySpinner - Allows disabling the spinner in busy-state. | ||
* @param {string} props.className - Additional class names for the wrapper. | ||
* @param {Function} props.onBusy - Callback to process child props when busy. | ||
*/ | ||
const BusyStateWrapper = ( { | ||
children, | ||
enabled = true, | ||
busySpinner = true, | ||
className = '', | ||
onBusy = () => ( { disabled: true } ), | ||
} ) => { | ||
const { isBusy } = CommonHooks.useBusyState(); | ||
const hasBusyParent = useContext( BusyContext ); | ||
|
||
const isBusyComponent = isBusy && enabled; | ||
const showSpinner = busySpinner && isBusyComponent && ! hasBusyParent; | ||
|
||
const wrapperClassName = classNames( 'ppcp-r-busy-wrapper', className, { | ||
'ppcp--is-loading': isBusyComponent, | ||
} ); | ||
|
||
const memoizedChildren = useMemo( | ||
() => | ||
Children.map( children, ( child ) => | ||
isValidElement( child ) | ||
? cloneElement( | ||
child, | ||
isBusyComponent ? onBusy( child.props ) : {} | ||
) | ||
: child | ||
), | ||
[ children, isBusyComponent, onBusy ] | ||
); | ||
|
||
return ( | ||
<BusyContext.Provider value={ isBusyComponent }> | ||
<div className={ wrapperClassName }> | ||
{ showSpinner && <SpinnerOverlay /> } | ||
{ memoizedChildren } | ||
</div> | ||
</BusyContext.Provider> | ||
); | ||
}; | ||
|
||
export default BusyStateWrapper; |
1 change: 1 addition & 0 deletions
1
modules/ppcp-settings/resources/js/Components/ReusableComponents/Icons.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as openSignup } from './Icons/open-signup'; |
12 changes: 12 additions & 0 deletions
12
modules/ppcp-settings/resources/js/Components/ReusableComponents/Icons/open-signup.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.