-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the global styles preview to the sidebar (#34991)
- Loading branch information
1 parent
0c05cfe
commit 1b0a380
Showing
4 changed files
with
62 additions
and
0 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
39 changes: 39 additions & 0 deletions
39
packages/edit-site/src/components/sidebar/global-styles/preview.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,39 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalHStack as HStack, | ||
__experimentalVStack as VStack, | ||
Card, | ||
ColorIndicator, | ||
} from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ import { useGlobalStylesContext } from '../../editor/global-styles-provider'; | ||
|
||
export const StylePreview = () => { | ||
const { getStyle } = useGlobalStylesContext(); | ||
const fontFamily = getStyle( 'root', 'fontFamily' ) ?? 'serif'; | ||
const textColor = getStyle( 'root', 'color' ) ?? 'black'; | ||
const linkColor = getStyle( 'root', 'linkColor' ) ?? 'blue'; | ||
const backgroundColor = getStyle( 'root', 'backgroundColor' ) ?? 'white'; | ||
|
||
return ( | ||
<Card | ||
className="edit-site-global-styles-preview" | ||
style={ { background: backgroundColor } } | ||
> | ||
<HStack spacing={ 5 }> | ||
<div> | ||
<span style={ { fontFamily, fontSize: '80px' } }>A</span> | ||
<span style={ { fontFamily, fontSize: '80px' } }>a</span> | ||
</div> | ||
<VStack spacing={ 2 }> | ||
<ColorIndicator colorValue={ textColor } /> | ||
<ColorIndicator colorValue={ linkColor } /> | ||
</VStack> | ||
</HStack> | ||
</Card> | ||
); | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/edit-site/src/components/sidebar/global-styles/style.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,16 @@ | ||
.edit-site-global-styles-preview { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 152px; | ||
|
||
.component-color-indicator { | ||
border-radius: 50%; | ||
border: 0; | ||
height: 36px; | ||
width: 36px; | ||
margin-left: 0; | ||
padding: 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