Skip to content

Commit 60f7663

Browse files
committed
Customize: Add visible text on responsive view switches.
Add a visible text label on the Customizer's responsive view switches. While the text is very small, it serves to supplement the icons to help more readily comprehend the purpose of these controls. Consolidate the labels so the visible label matches the accessible name of the control for voice command users, and add a `group` role with `aria-label` to provide improved context for screen reader users. Developed in WordPress#12519 Props ahortin, iamjolly, cheffheid, oglekler, afercia, abcd95, westonruter, celloexpressions, rianrietveld, joshuawold, estelaris, mukesh27, joedolson, wildworks. Fixes #36447. git-svn-id: https://develop.svn.wordpress.org/trunk@62745 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b036e40 commit 60f7663

5 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/wp-admin/css/themes.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ body.full-overlay-active {
17481748
background: transparent;
17491749
border: none;
17501750
height: 45px;
1751+
min-width: 50px;
17511752
padding: 0 3px;
17521753
margin: 0 0 0 -4px;
17531754
box-shadow: none;
@@ -1767,9 +1768,9 @@ body.full-overlay-active {
17671768
.wp-full-overlay-footer .devices button:before {
17681769
display: inline-block;
17691770
-webkit-font-smoothing: antialiased;
1770-
font: normal 20px/30px "dashicons";
1771+
font: normal 20px/20px "dashicons";
17711772
vertical-align: top;
1772-
margin: 3px 0;
1773+
margin: 0 0 -2px;
17731774
padding: 4px 8px;
17741775
color: #646970;
17751776
}
@@ -1812,6 +1813,12 @@ body.full-overlay-active {
18121813
content: "\f470" / '';
18131814
}
18141815

1816+
.wp-full-overlay-footer .devices .devices__preview-label {
1817+
display: block;
1818+
font-size: 10px;
1819+
line-height: 1;
1820+
}
1821+
18151822
@media screen and (max-width: 1024px) {
18161823
.wp-full-overlay-footer .devices {
18171824
display: none;

src/wp-admin/customize.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
</button>
276276
<?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
277277
<?php if ( ! empty( $previewable_devices ) ) : ?>
278-
<div class="devices-wrapper">
278+
<div class="devices-wrapper" role="group" aria-label="<?php echo esc_attr_x( 'Responsive Views', 'label for responsive previews group' ); ?>">
279279
<div class="devices">
280280
<?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
281281
<?php
@@ -289,7 +289,7 @@
289289
}
290290
?>
291291
<button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ); ?>" data-device="<?php echo esc_attr( $device ); ?>">
292-
<span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
292+
<span class="devices__preview-label"><?php echo esc_html( $settings['label'] ); ?></span>
293293
</button>
294294
<?php endforeach; ?>
295295
</div>

src/wp-includes/class-wp-customize-manager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5044,14 +5044,14 @@ public function customize_pane_settings() {
50445044
public function get_previewable_devices() {
50455045
$devices = array(
50465046
'desktop' => array(
5047-
'label' => __( 'Enter desktop preview mode' ),
5047+
'label' => __( 'Desktop' ),
50485048
'default' => true,
50495049
),
50505050
'tablet' => array(
5051-
'label' => __( 'Enter tablet preview mode' ),
5051+
'label' => __( 'Tablet' ),
50525052
),
50535053
'mobile' => array(
5054-
'label' => __( 'Enter mobile preview mode' ),
5054+
'label' => __( 'Mobile' ),
50555055
),
50565056
);
50575057

tests/phpunit/tests/customize/manager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,14 +3519,14 @@ public function test_get_previewable_devices() {
35193519
// The default devices list.
35203520
$default_devices = array(
35213521
'desktop' => array(
3522-
'label' => __( 'Enter desktop preview mode' ),
3522+
'label' => __( 'Desktop' ),
35233523
'default' => true,
35243524
),
35253525
'tablet' => array(
3526-
'label' => __( 'Enter tablet preview mode' ),
3526+
'label' => __( 'Tablet' ),
35273527
),
35283528
'mobile' => array(
3529-
'label' => __( 'Enter mobile preview mode' ),
3529+
'label' => __( 'Mobile' ),
35303530
),
35313531
);
35323532

@@ -3551,7 +3551,7 @@ public function test_get_previewable_devices() {
35513551
private function filtered_device_list() {
35523552
return array(
35533553
'custom-device' => array(
3554-
'label' => __( 'Enter custom-device preview mode' ),
3554+
'label' => __( 'Custom device' ),
35553555
'default' => true,
35563556
),
35573557
);

tests/qunit/fixtures/customize-settings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ window._wpCustomizeSettings = {
146146
},
147147
'previewableDevices': {
148148
'desktop': {
149-
'label': 'Enter desktop preview mode',
149+
'label': 'Desktop',
150150
'default': true
151151
},
152152
'tablet': {
153-
'label': 'Enter tablet preview mode'
153+
'label': 'Tablet'
154154
},
155155
'mobile': {
156-
'label': 'Enter mobile preview mode'
156+
'label': 'Mobile'
157157
}
158158
},
159159
initialClientTimestamp: 1506510531595,

0 commit comments

Comments
 (0)