From 18079cc38ef37891c6f7ced612611caaa55c2712 Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Wed, 25 Nov 2026 11:13:12 +0100 Subject: [PATCH 1/3] Give each content activity line its own style The content activity graph drew published, updated and deleted as three solid lines, which were hard to tell apart. Updated is now dotted and deleted dashed; published stays solid. Each legend label shows a sample of its line, which fades when the series is hidden. The line chart reads an optional lineStyle (solid, dotted or dashed) per series. Colours are unchanged. Co-Authored-By: Claude Opus 5.5 --- assets/js/web-components/prpl-chart-line.js | 85 +++++++++++++++++++-- views/page-widgets/content-activity.php | 20 +++-- 2 files changed, 92 insertions(+), 13 deletions(-) diff --git a/assets/js/web-components/prpl-chart-line.js b/assets/js/web-components/prpl-chart-line.js index 5319da0c2..59cd54f9f 100644 --- a/assets/js/web-components/prpl-chart-line.js +++ b/assets/js/web-components/prpl-chart-line.js @@ -72,9 +72,10 @@ customElements.define( */ getCheckboxHTML = ( key ) => ``; + /** + * Get the line style of a data series. + * + * @param {string} key - The key of the data. + * + * @return {string} The line style: solid, dotted or dashed. + */ + getLineStyle = ( key ) => + [ 'dotted', 'dashed' ].includes( + this.options.dataArgs[ key ]?.lineStyle + ) + ? this.options.dataArgs[ key ].lineStyle + : 'solid'; + + /** + * Get the SVG stroke attributes for a line style. + * + * Dots are zero-length dashes with round caps, so each one is a circle + * as wide as the line. Dashes are three line-widths long. + * + * @param {string} key - The key of the data. + * @param {number} strokeWidth - The width of the line. + * + * @return {string} The stroke attributes. + */ + getStrokeStyleAttributes = ( key, strokeWidth ) => { + switch ( this.getLineStyle( key ) ) { + case 'dotted': + return `stroke-dasharray="0 ${ + strokeWidth * 2 + }" stroke-linecap="round" stroke-linejoin="round"`; + case 'dashed': + return `stroke-dasharray="${ strokeWidth * 3 } ${ + strokeWidth * 2 + }" stroke-linejoin="round"`; + default: + return ''; + } + }; + + /** + * Get the line sample shown under a legend label. + * + * @param {string} key - The key of the data. + * + * @return {string} The line sample SVG. + */ + getLegendLineHTML = ( key ) => + ``; + /** * Get the filters label. * @@ -164,7 +231,10 @@ customElements.define( this.options.dataArgs[ key ].color }" stroke-width="${ this.options.strokeWidth - }" points="${ polylinePoints + }" ${ this.getStrokeStyleAttributes( + key, + this.options.strokeWidth + ) } points="${ polylinePoints .map( ( point ) => point.join( ',' ) ) .join( ' ' ) }" />`; }; @@ -390,16 +460,20 @@ customElements.define( ( checkbox ) => { checkbox.addEventListener( 'change', ( e ) => { const el = e.target; - const parentEl = el.parentElement; - const checkboxColorEl = parentEl.querySelector( + const labelEl = el.closest( 'label' ); + const checkboxColorEl = labelEl.querySelector( '.prpl-chart-line-checkbox-color' ); + const legendLineEl = labelEl.querySelector( + '.prpl-chart-line-legend-line' + ); if ( el.checked ) { this.options.showCharts.push( el.getAttribute( 'name' ) ); checkboxColorEl.style.backgroundColor = - parentEl.dataset.color; + labelEl.dataset.color; + legendLineEl.style.opacity = 1; } else { this.options.showCharts = this.options.showCharts.filter( @@ -408,6 +482,7 @@ customElements.define( ); checkboxColorEl.style.backgroundColor = 'transparent'; + legendLineEl.style.opacity = 0.35; } // Update the chart. diff --git a/views/page-widgets/content-activity.php b/views/page-widgets/content-activity.php index 3fd00b378..c5991addb 100644 --- a/views/page-widgets/content-activity.php +++ b/views/page-widgets/content-activity.php @@ -13,16 +13,19 @@ $prpl_activity_types = [ 'publish' => [ - 'label' => \__( 'published', 'progress-planner' ), - 'color' => 'var(--prpl-graph-color-2)', + 'label' => \__( 'published', 'progress-planner' ), + 'color' => 'var(--prpl-graph-color-2)', + 'lineStyle' => 'solid', ], 'update' => [ - 'label' => \__( 'updated', 'progress-planner' ), - 'color' => 'var(--prpl-graph-color-3)', + 'label' => \__( 'updated', 'progress-planner' ), + 'color' => 'var(--prpl-graph-color-3)', + 'lineStyle' => 'dotted', ], 'delete' => [ - 'label' => \__( 'deleted', 'progress-planner' ), - 'color' => 'var(--prpl-graph-color-4)', + 'label' => \__( 'deleted', 'progress-planner' ), + 'color' => 'var(--prpl-graph-color-4)', + 'lineStyle' => 'dashed', ], ]; @@ -50,8 +53,9 @@ ); $prpl_chart_options['dataArgs'][ $prpl_activity_type ] = [ - 'color' => $prpl_activity_data['color'], - 'label' => $prpl_activity_data['label'], + 'color' => $prpl_activity_data['color'], + 'label' => $prpl_activity_data['label'], + 'lineStyle' => $prpl_activity_data['lineStyle'], ]; } From 2327ac6374d6fb6e6ab9d7472cf5956d27ec4d7f Mon Sep 17 00:00:00 2001 From: Filip Ilic Date: Wed, 25 Nov 2026 11:18:27 +0100 Subject: [PATCH 2/3] Make the dotted line bolder and its dots closer Thin 2px dots spaced two line-widths apart read lighter than the solid and dashed lines. Dots are now 1.5 line-widths wide and 1.75 dot-widths apart, matching the design. Co-Authored-By: Claude Opus 5.5 --- assets/js/web-components/prpl-chart-line.js | 35 ++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/assets/js/web-components/prpl-chart-line.js b/assets/js/web-components/prpl-chart-line.js index 59cd54f9f..0d57aaba0 100644 --- a/assets/js/web-components/prpl-chart-line.js +++ b/assets/js/web-components/prpl-chart-line.js @@ -119,26 +119,30 @@ customElements.define( /** * Get the SVG stroke attributes for a line style. * - * Dots are zero-length dashes with round caps, so each one is a circle - * as wide as the line. Dashes are three line-widths long. + * Dots are zero-length dashes with round caps, so each one is a circle. + * A thin dotted line reads lighter than a solid one, so dots are 1.5 + * line-widths wide and sit close together. Dashes are three + * line-widths long. * * @param {string} key - The key of the data. * @param {number} strokeWidth - The width of the line. * - * @return {string} The stroke attributes. + * @return {string} The stroke attributes, including stroke-width. */ getStrokeStyleAttributes = ( key, strokeWidth ) => { switch ( this.getLineStyle( key ) ) { - case 'dotted': - return `stroke-dasharray="0 ${ - strokeWidth * 2 + case 'dotted': { + const dotWidth = strokeWidth * 1.5; + return `stroke-width="${ dotWidth }" stroke-dasharray="0 ${ + dotWidth * 1.75 }" stroke-linecap="round" stroke-linejoin="round"`; + } case 'dashed': - return `stroke-dasharray="${ strokeWidth * 3 } ${ - strokeWidth * 2 - }" stroke-linejoin="round"`; + return `stroke-width="${ strokeWidth }" stroke-dasharray="${ + strokeWidth * 3 + } ${ strokeWidth * 2 }" stroke-linejoin="round"`; default: - return ''; + return `stroke-width="${ strokeWidth }"`; } }; @@ -153,18 +157,15 @@ customElements.define( ``; + }" ${ this.getStrokeStyleAttributes( key, 2 ) } />`; /** * Get the filters label. @@ -229,8 +230,6 @@ customElements.define( return ` Date: Wed, 25 Nov 2026 11:22:26 +0100 Subject: [PATCH 3/3] Fit legend lines to their labels and wrap long translations The line under each legend label was as wide as the widest label, so it ran past shorter words. It is now positioned under its own label and matches its width. Translated labels are longer: in Dutch the legend was 25px wider than the widget and ran past its edge. The legend items are now grouped and wrap as one block, so with long translations the "show:" label moves to its own line and the three items stay together on the next one. Co-Authored-By: Claude Opus 5.5 --- assets/js/web-components/prpl-chart-line.js | 23 ++++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/assets/js/web-components/prpl-chart-line.js b/assets/js/web-components/prpl-chart-line.js index 0d57aaba0..e85a89fae 100644 --- a/assets/js/web-components/prpl-chart-line.js +++ b/assets/js/web-components/prpl-chart-line.js @@ -55,13 +55,22 @@ customElements.define( class="chart-line-checkboxes" style=" display: flex; - gap: 1em; + flex-wrap: wrap; + align-items: flex-start; + gap: 0.5em 1em; margin-bottom: 1em; - justify-content: space-between; font-size: 0.85rem;" - >${ this.getCheckboxesFiltersLabel() }${ Object.keys( this.options.dataArgs ) + >${ this.getCheckboxesFiltersLabel() }
${ Object.keys( this.options.dataArgs ) .map( ( key ) => this.getCheckboxHTML( key ) ) - .join( '' ) }
`; + .join( '' ) }`; /** * Get the HTML for a single checkbox. @@ -72,10 +81,9 @@ customElements.define( */ getCheckboxHTML = ( key ) => ``; @@ -160,7 +167,7 @@ customElements.define( height="3" aria-hidden="true" focusable="false" - style="display: block; overflow: visible; opacity: ${ + style="position: absolute; left: 0; bottom: 0; overflow: visible; opacity: ${ this.options.showCharts.includes( key ) ? 1 : 0.35 };" >