Skip to content

Commit f7e3b47

Browse files
authored
Merge branch 'develop' into filip/handle-interactive-requests
2 parents 18fc06d + 016f892 commit f7e3b47

24 files changed

Lines changed: 198 additions & 198 deletions

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ module.exports = {
44
'plugin:eslint-comments/recommended',
55
],
66
parserOptions: {
7-
ecmaVersion: "latest",
7+
ecmaVersion: 'latest',
88
},
99
rules: {
10-
"no-console": "off",
10+
'no-console': 'off',
1111
},
1212
};

assets/css/admin.css

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ button.prpl-info-icon {
306306
.prpl-wrap button.prpl-button-secondary,
307307
.prpl-wrap a.prpl-button-primary,
308308
.prpl-wrap a.prpl-button-secondary,
309-
#progress_planner_dashboard_widget_score a.prpl-button-primary { /* To be used in WP Dashboard widget */
309+
#progress_planner_dashboard_widget_score a.prpl-button-primary,
310+
#progress_planner_dashboard_widget_score a.prpl-button-secondary { /* To be used in WP Dashboard widget */
310311
display: block;
311312
margin: 1rem 0;
312313
padding: 0.75rem 1.25rem;
@@ -360,13 +361,23 @@ button.prpl-info-icon {
360361
}
361362

362363
.prpl-wrap input.prpl-button-secondary,
363-
.prpl-wrap button.prpl-button-secondary {
364+
.prpl-wrap button.prpl-button-secondary,
365+
.prpl-wrap a.prpl-button-secondary,
366+
#progress_planner_dashboard_widget_score a.prpl-button-secondary {
364367
background: var(--prpl-color-selection-controls-inactive);
365368

369+
&::after {
370+
background: var(--prpl-color-selection-controls-inactive);
371+
}
372+
366373
&:not([disabled]):hover,
367374
&:not([disabled]):focus {
368375
background: var(--prpl-color-ui-icon);
369376
box-shadow: 3px 3px 10px var(--prpl-color-ui-icon);
377+
378+
&::after {
379+
background: var(--prpl-color-ui-icon);
380+
}
370381
}
371382
}
372383

assets/css/page-widgets/latest-badge.css

Lines changed: 0 additions & 31 deletions
This file was deleted.

assets/css/page-widgets/suggested-tasks.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
&.prpl-column-content {
155155
padding: 20px;
156156
border-radius: var(--prpl-border-radius-big);
157-
background-color: var(--background-content);
157+
background-color: var(--prpl-background-content);
158158
}
159159

160160
.prpl-note {

assets/css/variables-color.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
/* Topics */
4646
--prpl-color-monthly: #faa310;
47+
--prpl-color-monthly-2: #faa310;
4748
--prpl-color-streak: var(--prpl-color-monthly);
4849
--prpl-color-content-badge: var(--prpl-color-monthly);
4950
--prpl-background-monthly: #fff9f0;
@@ -93,4 +94,7 @@
9394
--prpl-color-text-placeholder: var(--prpl-color-ui-icon);
9495
--prpl-color-text-dropdown: var(--prpl-color-text);
9596
--prpl-color-field-shadow: var(--prpl-color-shadow-paper);
97+
98+
/* Badge */
99+
--prpl-color-icon-missed-badge: var(--prpl-color-alert-error);
96100
}

assets/css/web-components/prpl-badge.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ prpl-badge {
7676
justify-content: center;
7777
width: 20px;
7878
height: 20px;
79-
background-color: var(--prpl-color-alert-error);
79+
background-color: var(--prpl-color-icon-missed-badge);
8080
border: 2px solid #fff;
8181
border-radius: 50%;
8282
position: absolute;

assets/js/suggested-task-terms.js

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Populate prplSuggestedTasksTerms with the terms for the taxonomies we use.
44
*
5-
* Dependencies: wp-api, progress-planner/document-ready
5+
* Dependencies: wp-api-fetch, progress-planner/document-ready
66
*/
77

88
const prplSuggestedTasksTerms = {};
@@ -40,48 +40,63 @@ const prplTerms = {
4040
`Terms already fetched for taxonomy: ${ taxonomy }`
4141
);
4242
resolve( prplSuggestedTasksTerms[ taxonomy ] );
43+
return;
4344
}
44-
wp.api.loadPromise.done( () => {
45-
console.info( `Fetching terms for taxonomy: ${ taxonomy }...` );
4645

47-
const typeName = taxonomy.replace( 'prpl_', 'Prpl_' );
48-
prplSuggestedTasksTerms[ taxonomy ] =
49-
prplSuggestedTasksTerms[ taxonomy ] || {};
50-
const TermsCollection = new wp.api.collections[ typeName ]();
51-
TermsCollection.fetch( { data: { per_page: 100 } } ).done(
52-
( data ) => {
53-
let userTermFound = false;
54-
// 100 is the maximum number of terms that can be fetched in one request.
55-
data.forEach( ( term ) => {
56-
prplSuggestedTasksTerms[ taxonomy ][ term.slug ] =
57-
term;
58-
if ( 'user' === term.slug ) {
59-
userTermFound = true;
60-
}
61-
} );
46+
console.info( `Fetching terms for taxonomy: ${ taxonomy }...` );
6247

63-
if ( userTermFound ) {
64-
resolve( prplSuggestedTasksTerms[ taxonomy ] );
65-
} else {
66-
// If the `user` term doesn't exist, create it.
67-
const newTermModel = new wp.api.models[ typeName ](
68-
{
69-
slug: 'user',
70-
name: 'user',
71-
}
72-
);
73-
newTermModel
74-
.save()
75-
.then( ( response ) => {
76-
prplSuggestedTasksTerms[ taxonomy ].user =
77-
response;
78-
return prplSuggestedTasksTerms[ taxonomy ];
79-
} )
80-
.then( resolve ); // Resolve the promise after all requests are complete.
48+
prplSuggestedTasksTerms[ taxonomy ] =
49+
prplSuggestedTasksTerms[ taxonomy ] || {};
50+
51+
// Fetch terms using wp.apiFetch.
52+
wp.apiFetch( {
53+
path: `/wp/v2/${ taxonomy }?per_page=100`,
54+
} )
55+
.then( ( data ) => {
56+
let userTermFound = false;
57+
// 100 is the maximum number of terms that can be fetched in one request.
58+
data.forEach( ( term ) => {
59+
prplSuggestedTasksTerms[ taxonomy ][ term.slug ] = term;
60+
if ( 'user' === term.slug ) {
61+
userTermFound = true;
8162
}
63+
} );
64+
65+
if ( userTermFound ) {
66+
resolve( prplSuggestedTasksTerms[ taxonomy ] );
67+
} else {
68+
// If the `user` term doesn't exist, create it.
69+
wp.apiFetch( {
70+
path: `/wp/v2/${ taxonomy }`,
71+
method: 'POST',
72+
data: {
73+
slug: 'user',
74+
name: 'user',
75+
},
76+
} )
77+
.then( ( response ) => {
78+
prplSuggestedTasksTerms[ taxonomy ].user =
79+
response;
80+
resolve( prplSuggestedTasksTerms[ taxonomy ] );
81+
} )
82+
.catch( ( error ) => {
83+
console.error(
84+
`Error creating user term for taxonomy: ${ taxonomy }`,
85+
error
86+
);
87+
// Resolve anyway even if creation fails.
88+
resolve( prplSuggestedTasksTerms[ taxonomy ] );
89+
} );
8290
}
83-
);
84-
} );
91+
} )
92+
.catch( ( error ) => {
93+
console.error(
94+
`Error fetching terms for taxonomy: ${ taxonomy }`,
95+
error
96+
);
97+
// Resolve with empty object on error.
98+
resolve( prplSuggestedTasksTerms[ taxonomy ] || {} );
99+
} );
85100
} );
86101
},
87102

assets/js/web-components/prpl-big-counter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ customElements.define(
1313
content = content || this.getAttribute( 'content' );
1414
backgroundColor =
1515
backgroundColor || this.getAttribute( 'background-color' );
16-
backgroundColor = backgroundColor || 'var(--background-content)';
16+
backgroundColor =
17+
backgroundColor || 'var(--prpl-background-content)';
1718

1819
const el = this;
1920

assets/js/web-components/prpl-gauge.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ customElements.define(
2020
maxDeg: '180deg',
2121
background: 'var(--prpl-background-monthly)',
2222
color: 'var(--prpl-color-monthly)',
23+
color2: 'var(--prpl-color-monthly-2)',
2324
start: '270deg',
2425
cutout: '57%',
2526
contentFontSize: 'var(--prpl-font-size-6xl)',
@@ -64,10 +65,25 @@ customElements.define(
6465
props.brandingId =
6566
this.getAttribute( 'branding-id' ) || props.brandingId;
6667

68+
let colorTransitions;
69+
70+
// If the progress is less than 50%, we have only one color, no gradient.
71+
if ( props.value <= 0.5 ) {
72+
colorTransitions = `${ props.color } calc(${ props.maxDeg } * ${ props.value })`;
73+
} else {
74+
// Otherwise we show first color for 0.5 and then the second color.
75+
colorTransitions = `${ props.color } calc(${
76+
props.maxDeg
77+
} * ${ 0.5 })`;
78+
colorTransitions += `, ${ props.color2 } calc(${ props.maxDeg } * ${ props.value })`;
79+
}
80+
// Add the remaining color.
81+
colorTransitions += `, var(--prpl-color-gauge-remain) calc(${ props.maxDeg } * ${ props.value }) ${ props.maxDeg }`;
82+
6783
this.innerHTML = `
6884
<div style="padding: ${ props.contentPadding };
6985
background: ${ props.background }; border-radius:var(--prpl-border-radius-big); aspect-ratio: 2 / 1; overflow: hidden; position: relative; margin-bottom: ${ props.marginBottom };">
70-
<div style="width: 100%; aspect-ratio: 1 / 1; border-radius: 100%; position: relative; background: radial-gradient(${ props.background } 0 ${ props.cutout }, transparent ${ props.cutout } 100%), conic-gradient(from ${ props.start }, ${ props.color } calc(${ props.maxDeg } * ${ props.value }), var(--prpl-color-gauge-remain) calc(${ props.maxDeg } * ${ props.value }) ${ props.maxDeg }, transparent ${ props.maxDeg }); text-align: center;">
86+
<div style="width: 100%; aspect-ratio: 1 / 1; border-radius: 100%; position: relative; background: radial-gradient(${ props.background } 0 ${ props.cutout }, transparent ${ props.cutout } 100%), conic-gradient(from ${ props.start }, ${ colorTransitions }, transparent ${ props.maxDeg }); text-align: center;">
7187
<span style="font-size: var(--prpl-font-size-small); position: absolute; top: 50%; color: var(--prpl-color-text); width: 10%; text-align: center; left:0;">0</span>
7288
<span style="font-size: ${ props.contentFontSize }; ${ contentSpecificStyles } display: block; font-weight: 600; text-align: center; position: absolute; color: var(--prpl-color-text); width: 100%; line-height: 1.2;">
7389
<span style="display:inline-block;width: 50%;">

classes/admin/class-enqueue.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private function get_badge_urls() {
312312
$monthly_badge = \progress_planner()->get_badges()->get_badge( Monthly::get_badge_id_from_date( new \DateTime() ) );
313313

314314
if ( $monthly_badge ) {
315-
$badge_urls['month'] = \progress_planner()->get_remote_server_root_url() . '/wp-json/progress-planner-saas/v1/badge-svg/?badge_id=' . $monthly_badge->get_id();
315+
$badge_urls['month'] = \progress_planner()->get_remote_server_root_url() . '/wp-json/progress-planner-saas/v1/badge-svg/?badge_id=' . $monthly_badge->get_id() . '&branding_id=' . (int) \progress_planner()->get_ui__branding()->get_branding_id();
316316
}
317317

318318
// Get the content and maintenance badge URLs.
@@ -321,12 +321,12 @@ private function get_badge_urls() {
321321
foreach ( $set_badges as $badge ) {
322322
$progress = $badge->get_progress();
323323
if ( $progress['progress'] > 100 ) {
324-
$badge_urls[ $context ] = \progress_planner()->get_remote_server_root_url() . '/wp-json/progress-planner-saas/v1/badge-svg/?badge_id=' . $badge->get_id();
324+
$badge_urls[ $context ] = \progress_planner()->get_remote_server_root_url() . '/wp-json/progress-planner-saas/v1/badge-svg/?badge_id=' . $badge->get_id() . '&branding_id=' . (int) \progress_planner()->get_ui__branding()->get_branding_id();
325325
}
326326
}
327327
if ( ! isset( $badge_urls[ $context ] ) ) {
328328
// Fallback to the first badge in the set if no badge is completed.
329-
$badge_urls[ $context ] = \progress_planner()->get_remote_server_root_url() . '/wp-json/progress-planner-saas/v1/badge-svg/?badge_id=' . $set_badges[0]->get_id();
329+
$badge_urls[ $context ] = \progress_planner()->get_remote_server_root_url() . '/wp-json/progress-planner-saas/v1/badge-svg/?badge_id=' . $set_badges[0]->get_id() . '&branding_id=' . (int) \progress_planner()->get_ui__branding()->get_branding_id();
330330
}
331331
}
332332

0 commit comments

Comments
 (0)