Skip to content

Commit aece7d2

Browse files
authored
Tweak components style (#56)
1 parent 27b7e11 commit aece7d2

File tree

7 files changed

+29
-56
lines changed

7 files changed

+29
-56
lines changed

src/components/controls/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const Controls = ( { settings, piano, onChange }: Props ) => {
106106
return (
107107
<div className="piano-block-controls">
108108
<RangeControl
109-
className="piano-block-controls__control"
109+
__nextHasNoMarginBottom
110110
label={ __( 'Volume', 'piano-block' ) }
111111
value={ volume || 0 }
112112
min={ MIN_VOLUME }
@@ -117,7 +117,7 @@ const Controls = ( { settings, piano, onChange }: Props ) => {
117117
onChange={ onVolumeChange }
118118
/>
119119
<BaseControl
120-
className="piano-block-controls__control"
120+
__nextHasNoMarginBottom
121121
id="piano-block-control-octave"
122122
label={ __( 'Octave Offset', 'piano-block' ) }
123123
>
@@ -135,7 +135,7 @@ const Controls = ( { settings, piano, onChange }: Props ) => {
135135
</ButtonGroup>
136136
</BaseControl>
137137
<SelectControl
138-
className="piano-block-controls__control"
138+
__nextHasNoMarginBottom
139139
label={ __( 'Instrument', 'piano-block' ) }
140140
value={ instrument }
141141
options={ INSTRUMENTS.map( ( { label, value } ) => {
@@ -163,14 +163,14 @@ const Controls = ( { settings, piano, onChange }: Props ) => {
163163
</div>
164164
) }
165165
<ToggleControl
166-
className="piano-block-controls__control"
166+
__nextHasNoMarginBottom
167167
label={ __( 'Sustain Pedal', 'piano-block' ) }
168168
checked={ useSustainPedal }
169169
onChange={ onUseSustainPedalChange }
170170
disabled={ instrument === 'synthesizer' }
171171
/>
172172
<SelectControl
173-
className="piano-block-controls__control"
173+
__nextHasNoMarginBottom
174174
label={ __( 'Key Layout', 'piano-block' ) }
175175
value={ keyLayout }
176176
options={ KEYBOARD_LAYOUTS.map( ( { label, value } ) => {
@@ -180,7 +180,7 @@ const Controls = ( { settings, piano, onChange }: Props ) => {
180180
size="compact"
181181
/>
182182
<SelectControl
183-
className="piano-block-controls__control"
183+
__nextHasNoMarginBottom
184184
label={ __( 'Key Indicator', 'piano-block' ) }
185185
value={ keyIndicator }
186186
options={ KEY_INDICATORS.map( ( { label, value } ) => {
@@ -194,7 +194,7 @@ const Controls = ( { settings, piano, onChange }: Props ) => {
194194
label={ __( 'Help', 'piano-block' ) }
195195
icon={ help }
196196
onClick={ () => setIsHelpOpen( true ) }
197-
size="compact"
197+
size="small"
198198
/>
199199
{ isHelpOpen && <HelpModal onClose={ () => setIsHelpOpen( false ) } /> }
200200
</div>

src/components/controls/style.scss

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../../variables";
2+
13
.piano-block-controls {
24
position: relative;
35
box-sizing: border-box;
@@ -6,7 +8,7 @@
68
gap: $grid-unit-20;
79
align-items: flex-start;
810
width: calc(100% - $grid-unit-40);
9-
max-width: 818px;
11+
max-width: $white-key-width * $white-key-count - $grid-unit-40;
1012
padding: $grid-unit-10 $grid-unit-60 $grid-unit-10 $grid-unit-20;
1113
margin: 0 auto;
1214
background: #fff;
@@ -20,23 +22,7 @@
2022
}
2123
}
2224

23-
.components-base-control__label {
24-
display: block;
25-
font-size: 11px;
26-
font-weight: 500;
27-
line-height: 1.4;
28-
}
29-
30-
.components-base-control__field {
31-
margin-bottom: 0;
32-
}
33-
34-
.components-select-control__input:focus {
35-
outline: none;
36-
}
37-
3825
.components-toggle-control {
39-
margin-bottom: 0;
4026

4127
.components-flex {
4228
flex-flow: column-reverse;
@@ -50,10 +36,6 @@
5036
line-height: 1.4;
5137
text-transform: uppercase;
5238
}
53-
54-
.components-form-toggle {
55-
display: inline-flex;
56-
}
5739
}
5840

5941
.piano-block-controls__synthesizer-toggle {
@@ -66,4 +48,9 @@
6648
top: $grid-unit-10;
6749
right: $grid-unit-10;
6850
}
51+
52+
// Backwards compatible styles for WordPress 6.6 and below
53+
.components-base-control:has(.components-button-group) .components-base-control__label {
54+
display: block;
55+
}
6956
}

src/components/keyboard/style.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
$black-key-width: $grid-unit-40;
2-
$white-key-width: $grid-unit-50;
3-
$white-key-height: $grid-unit-10 * 24;
4-
$white-key-count: 17;
1+
@import "../../variables";
52

63
.piano-block-keyboard {
74
position: relative;

src/components/synthesizer-setting/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Button,
88
RangeControl,
99
SelectControl,
10+
__experimentalGrid as Grid,
1011
__experimentalVStack as VStack,
1112
} from '@wordpress/components';
1213

@@ -122,8 +123,9 @@ const SynthesizerSetting = ( { synthesizerSetting, onChange }: Props ) => {
122123
};
123124

124125
return (
125-
<VStack className="piano-block-synthesizer-setting">
126+
<VStack className="piano-block-synthesizer-setting" spacing={ 4 }>
126127
<SelectControl
128+
__nextHasNoMarginBottom
127129
label={ __( 'Oscillator Type', 'piano-block' ) }
128130
autoComplete="off"
129131
value={ oscillator?.type || DEFAULT_OSCILLATOR_TYPE }
@@ -134,9 +136,10 @@ const SynthesizerSetting = ( { synthesizerSetting, onChange }: Props ) => {
134136
onChange={ onOscillatorTypeChange }
135137
size="compact"
136138
/>
137-
<div className="piano-block-synthesizer-setting__envelope">
139+
<Grid columns={ 2 }>
138140
{ EMVELOPE_CONTROLS.map( ( { label, parameter, max } ) => (
139141
<RangeControl
142+
__nextHasNoMarginBottom
140143
key={ parameter }
141144
label={ label }
142145
value={ envelope[ parameter ] ?? DEFAULT_ENVELOPE[ parameter ] }
@@ -147,12 +150,12 @@ const SynthesizerSetting = ( { synthesizerSetting, onChange }: Props ) => {
147150
onChange={ ( value ) => onEnvelopeChange( parameter, value ) }
148151
/>
149152
) ) }
150-
</div>
153+
</Grid>
151154
<canvas ref={ ref } className="piano-block-synthesizer-setting__graph" />
152155
<Button
153156
className="piano-block-synthesizer-setting__reset"
154157
isDestructive
155-
isSmall
158+
size="small"
156159
onClick={ onEnvelopeReset }
157160
>
158161
{ __( 'Reset envelope', 'piano-block' ) }

src/components/synthesizer-setting/style.scss

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,11 @@
55
padding: $grid-unit-20;
66
overflow: hidden;
77

8-
.components-base-control__field {
9-
margin: 0;
10-
}
11-
12-
.piano-block-synthesizer-setting__envelope {
13-
display: flex;
14-
flex-wrap: wrap;
15-
gap: 0 $grid-unit-20;
16-
17-
.components-range-control {
18-
width: calc(50% - $grid-unit-10);
19-
}
20-
21-
.components-base-control__label {
22-
display: block;
23-
margin-bottom: 0;
24-
}
25-
}
26-
278
.piano-block-synthesizer-setting__graph {
289
display: block;
2910
width: 100%;
3011
height: $grid-unit-10 * 10;
31-
border: $border-width solid var(--wp-admin-theme-color, #007cba);
12+
border: $border-width solid $gray-600;
3213
}
3314

3415
.piano-block-synthesizer-setting__reset {

src/edit.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function Edit( { attributes, setAttributes }: BlockEditProps< Blo
3333
<InspectorControls>
3434
<PanelBody title={ __( 'Settings', 'piano-block' ) }>
3535
<ToggleControl
36+
__nextHasNoMarginBottom
3637
label={ __( 'Display on the front end', 'piano-block' ) }
3738
checked={ settings.showOnFront }
3839
onChange={ ( value ) => onChange( { showOnFront: value } ) }

src/variables.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$black-key-width: $grid-unit-40;
2+
$white-key-width: $grid-unit-50;
3+
$white-key-height: $grid-unit-10 * 24;
4+
$white-key-count: 17;

0 commit comments

Comments
 (0)