Skip to content

Commit

Permalink
Rely on theme system to generate the track color
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Aug 10, 2023
1 parent f9a2a9f commit d08732e
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions packages/edit-site/src/components/canvas-spinner/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/**
* External dependencies
*/
import { colord, extend } from 'colord';
import mixPlugin from 'colord/plugins/mix';

extend( [ mixPlugin ] );

/**
* WordPress dependencies
*/
Expand All @@ -23,19 +15,14 @@ const { useGlobalStyle } = unlock( blockEditorPrivateApis );

export default function CanvasSpinner() {
const [ fallbackIndicatorColor ] = useGlobalStyle( 'color.text' );
const [ backgroundColor ] = useGlobalStyle( 'color.background' );
const { highlightedColors } = useStylesPreviewColors();

const indicatorColor =
highlightedColors[ 0 ]?.color ?? fallbackIndicatorColor;
const grayscaleIndicatorColor = colord( indicatorColor ).grayscale();
const trackColorBase = grayscaleIndicatorColor.isDark()
? grayscaleIndicatorColor.tints( 3 )[ 1 ]
: grayscaleIndicatorColor.shades( 3 )[ 1 ];
const trackColor = trackColorBase.alpha( 0.5 ).toHex();

return (
<div className="edit-site-canvas-spinner">
<Theme accent={ indicatorColor } background={ trackColor }>
<Theme accent={ indicatorColor } background={ backgroundColor }>
<ProgressBar />
</Theme>
</div>
Expand Down

0 comments on commit d08732e

Please sign in to comment.