Skip to content

Commit

Permalink
chore: improve install workflow and use filter
Browse files Browse the repository at this point in the history
  • Loading branch information
preda-bogdan committed Jul 12, 2023
1 parent 2b1b58e commit 69bf34f
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 113 deletions.
2 changes: 1 addition & 1 deletion assets/js/build/about/about.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-components', 'wp-element'), 'version' => '8520c84cc054a28168ba');
<?php return array('dependencies' => array('wp-components', 'wp-element'), 'version' => '2355cd85367fea2bdefa');
36 changes: 20 additions & 16 deletions assets/js/build/about/about.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 18 additions & 19 deletions assets/js/build/about/about.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/src/about/components/ProductPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Page( props ) {
return <CurrentPage page={ props.page } />;
}
export default function ProductPage({page= {}}) {
return (<div className="product-page">
return (<div className={'product-page' + ( page && page.product ? ' ' + page.product : '' ) }>
<Page id={ page.id } page={page}/>
</div>);
}
32 changes: 22 additions & 10 deletions assets/js/src/about/components/pages/Otter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ export default function Otter( { page = {} } ) {

const [productStatus, setProductStatus] = useState(plugin.status);
const [loading, setLoading] = useState(false);
const loadingText = 'In Progress';

const runInstall = async () => {
setLoading(true);
await installPluginOrTheme(slug, slug === 'neve').then((res) => {
await installPluginOrTheme(product, false).then((res) => {
if (res.success) {
setProductStatus('installed');
runActivate();
}
});
setLoading(false);
}

const runActivate = async () => {
Expand All @@ -40,10 +41,16 @@ export default function Otter( { page = {} } ) {
<span className="label">Neve + Otter = New Possibilities 🤝</span>
<h1>{ strings.heading }</h1>
<p>{ strings.text }</p>
{productStatus === 'not-installed' &&
<Button variant="primary" className="otter-button" onClick={runInstall}>{strings.buttons.install_otter_free}</Button>}
{productStatus === 'installed' &&
<Button variant="primary" className="otter-button" onClick={runActivate}>{strings.buttons.install_otter_free}</Button>}
{ ( productStatus === 'not-installed' || productStatus === 'installed') &&
<Button
variant="primary"
disabled={loading}
className={'otter-button' + ( loading ? ' is-loading' : '' )}
onClick={ productStatus === 'not-installed' ? runInstall : runActivate}>
{loading ? (<span><span className="dashicons dashicons-update spin"/>{loadingText}</span>) : strings.buttons.install_otter_free }

</Button>
}
</div>
<div className="col-3-highlights">
<div className="col">
Expand Down Expand Up @@ -90,10 +97,15 @@ export default function Otter( { page = {} } ) {
<div className="col">
<h2>{strings.testimonials.heading}</h2>
<div className="button-row">
{productStatus === 'not-installed' &&
<Button variant="primary" className="otter-button" onClick={runInstall}>{strings.buttons.install_now}</Button>}
{productStatus === 'installed' &&
<Button variant="primary" className="otter-button" onClick={runActivate}>{strings.buttons.install_now}</Button>}
{(productStatus === 'not-installed' || productStatus === 'installed' ) &&
<Button
variant="primary"
disabled={loading}
className={'otter-button' + ( loading ? ' is-loading' : '' )}
onClick={ productStatus === 'not-installed' ? runInstall : runActivate}>
{loading ? (<span><span className="dashicons dashicons-update spin"/>{loadingText}</span>) : strings.buttons.install_now }
</Button>
}
<Button variant="secondary" className="otter-button">{strings.buttons.learn_more}</Button>
</div>
</div>
Expand Down
65 changes: 0 additions & 65 deletions assets/js/src/about/scss/pages/_generic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,74 +86,9 @@
}
}

.testimonial-nav {
display: flex;
gap: 8px;
.testimonial-button {
width: 10px;
height: 10px;
background-color: #D9D9D9;
margin: 0;
padding: 0;
border-radius: 50%;
&.active {
background-color: #ED6F57;
}
}
}

.testimonial-container {
width: 100%;
max-width: 450px;
display: flex;
overflow-x: scroll;
scroll-behavior: smooth;
margin: 0;
padding: 0;
&::-webkit-scrollbar {
display: none;
}

.testimonial {
width: 100%;
flex: 1 0 100%;
display: flex;
flex-wrap: wrap;
justify-content: left;
gap: 14px;
align-items: center;
p {
width: 100%;
font-size: 14px;
line-height: 24px;
}
h3 {
font-size: 16px;
line-height: 20px;
font-weight: 700;
color: #1C1C1C;
}
img {
width: 36px;
height: 36px;
border-radius: 50%;
}
}
}

.button-row {
display: flex;
gap: 12px;
margin-top: 48px;
}

.otter-button {
&.is-primary {
background-color: #ED6F57;
}
&.is-secondary {
color: #ED6F57;
box-shadow: inset 0 0 0 1px #ED6F57;
}
}
}
71 changes: 71 additions & 0 deletions assets/js/src/about/scss/pages/_otter.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.otter-blocks {
.testimonial-nav {
display: flex;
gap: 8px;
.testimonial-button {
width: 10px;
height: 10px;
background-color: #D9D9D9;
margin: 0;
padding: 0;
border-radius: 50%;
&.active {
background-color: #ED6F57;
}
}
}

.testimonial-container {
width: 100%;
max-width: 450px;
display: flex;
overflow-x: scroll;
scroll-behavior: smooth;
margin: 0;
padding: 0;
&::-webkit-scrollbar {
display: none;
}

.testimonial {
width: 100%;
flex: 1 0 100%;
display: flex;
flex-wrap: wrap;
justify-content: left;
gap: 14px;
align-items: center;
p {
width: 100%;
font-size: 14px;
line-height: 24px;
}
h3 {
font-size: 16px;
line-height: 20px;
font-weight: 700;
color: #1C1C1C;
}
img {
width: 36px;
height: 36px;
border-radius: 50%;
}
}
}

.otter-button {
&.is-primary {
background-color: #ED6F57;
}
&.is-secondary {
color: #ED6F57;
box-shadow: inset 0 0 0 1px #ED6F57;
}
&.is-loading {
background-color: #6C6C6C;
color: #FFFFFF;
}
}
}

2 changes: 1 addition & 1 deletion src/Modules/About_us.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function enqueue_about_page_script() {
*/
private function get_about_localization_data() {
$links = isset( $this->about_data['page_menu'] ) ? $this->about_data['page_menu'] : [];
$product_pages = isset( $this->about_data['product_pages'] ) ? $this->about_data['product_pages'] : [ 'otter-page' ];
$product_pages = isset( $this->about_data['product_pages'] ) ? $this->about_data['product_pages'] : [];

return [
'links' => $links,
Expand Down

0 comments on commit 69bf34f

Please sign in to comment.