@@ -43,30 +43,37 @@ const secondFrame = {
43
43
44
44
const normalizedWidth = 250 ;
45
45
46
- const StylesPreview = ( { label } ) => {
46
+ const StylesPreview = ( { label, isFocused } ) => {
47
+ const [ fontWeight ] = useStyle ( 'typography.fontWeight' ) ;
47
48
const [ fontFamily = 'serif' ] = useStyle ( 'typography.fontFamily' ) ;
48
49
const [ headingFontFamily = fontFamily ] = useStyle (
49
50
'elements.h1.typography.fontFamily'
50
51
) ;
52
+ const [ headingFontWeight = fontWeight ] = useStyle (
53
+ 'elements.h1.typography.fontWeight'
54
+ ) ;
51
55
const [ textColor = 'black' ] = useStyle ( 'color.text' ) ;
52
56
const [ headingColor = textColor ] = useStyle ( 'elements.h1.color.text' ) ;
53
57
const [ linkColor = 'blue' ] = useStyle ( 'elements.link.color.text' ) ;
54
58
const [ backgroundColor = 'white' ] = useStyle ( 'color.background' ) ;
55
59
const [ gradientValue ] = useStyle ( 'color.gradient' ) ;
56
60
const [ styles ] = useGlobalStylesOutput ( ) ;
57
61
const disableMotion = useReducedMotion ( ) ;
58
- const [ isHovered , setIsHovered ] = useState ( false ) ;
59
62
const [ coreColors ] = useSetting ( 'color.palette.core' ) ;
60
63
const [ themeColors ] = useSetting ( 'color.palette.theme' ) ;
61
64
const [ customColors ] = useSetting ( 'color.palette.custom' ) ;
65
+ const [ isHovered , setIsHovered ] = useState ( false ) ;
62
66
const [ containerResizeListener , { width } ] = useResizeObserver ( ) ;
63
67
const ratio = width ? width / normalizedWidth : 1 ;
64
68
65
69
const paletteColors = ( themeColors ?? [ ] )
66
70
. concat ( customColors ?? [ ] )
67
71
. concat ( coreColors ?? [ ] ) ;
68
72
const highlightedColors = paletteColors
69
- . filter ( ( { color } ) => color !== backgroundColor )
73
+ . filter (
74
+ // we exclude these two colors because they are already visible in the preview.
75
+ ( { color } ) => color !== backgroundColor && color !== headingColor
76
+ )
70
77
. slice ( 0 , 2 ) ;
71
78
72
79
return (
@@ -79,6 +86,7 @@ const StylesPreview = ( { label } ) => {
79
86
} }
80
87
onMouseEnter = { ( ) => setIsHovered ( true ) }
81
88
onMouseLeave = { ( ) => setIsHovered ( false ) }
89
+ tabIndex = { - 1 }
82
90
>
83
91
{ containerResizeListener }
84
92
< motion . div
@@ -89,7 +97,11 @@ const StylesPreview = ( { label } ) => {
89
97
cursor : 'pointer' ,
90
98
} }
91
99
initial = "start"
92
- animate = { isHovered && ! disableMotion ? 'hover' : 'start' }
100
+ animate = {
101
+ ( isHovered || isFocused ) && ! disableMotion
102
+ ? 'hover'
103
+ : 'start'
104
+ }
93
105
>
94
106
< motion . div
95
107
variants = { firstFrame }
@@ -111,14 +123,15 @@ const StylesPreview = ( { label } ) => {
111
123
fontFamily : headingFontFamily ,
112
124
fontSize : 65 * ratio ,
113
125
color : headingColor ,
126
+ fontWeight : headingFontWeight ,
114
127
} }
115
128
>
116
129
Aa
117
130
</ div >
118
131
< VStack spacing = { 2 * ratio } >
119
- { highlightedColors . map ( ( { color } ) => (
132
+ { highlightedColors . map ( ( { slug , color } ) => (
120
133
< div
121
- key = { color }
134
+ key = { slug }
122
135
style = { {
123
136
height : 30 * ratio ,
124
137
width : 30 * ratio ,
@@ -153,6 +166,7 @@ const StylesPreview = ( { label } ) => {
153
166
fontSize : 35 * ratio ,
154
167
fontFamily : headingFontFamily ,
155
168
color : headingColor ,
169
+ fontWeight : headingFontWeight ,
156
170
lineHeight : '1em' ,
157
171
} }
158
172
>
0 commit comments