Skip to content

Commit

Permalink
Fix visual design issues with combobox examples 1-3
Browse files Browse the repository at this point in the history
Part of #1255.
  • Loading branch information
zcorpan committed Nov 14, 2019
1 parent e51ad04 commit 73ca367
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 108 deletions.
5 changes: 5 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"media-feature-name-whitelist": ["forced-colors", "-ms-high-contrast"]
}
}
8 changes: 3 additions & 5 deletions examples/combobox/combobox-autocomplete-both.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<!-- js and css for this example. -->
<link rel="stylesheet" href="css/combobox.css">
<link rel="stylesheet" href="css/listbox.css">
<script type="text/javascript" src="js/combobox-list.js"></script>
<script type="text/javascript" src="js/listbox.js"></script>
<script type="text/javascript" src="js/listboxOption.js"></script>
Expand Down Expand Up @@ -50,12 +49,11 @@ <h1>Editable Combobox With Both List and Inline Autocomplete Example</h1>
<h2 id="ex_label">Example</h2>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<div class="combobox-list">
<label for="cb1-input">State</label>
<label for="cb1-input">State</label>
<div class="combobox combobox-list">
<div class="group">
<input id="cb1-input" class="cb_edit" type="text" role="combobox" aria-autocomplete="both"
aria-expanded="false" aria-controls="lb1"
/>
aria-expanded="false" aria-controls="lb1">
<button type="button" id="cb1-button" aria-label="Open" tabindex="-1">&#9661;</button>
</div>
<ul id="lb1" role="listbox" aria-label="States">
Expand Down
8 changes: 3 additions & 5 deletions examples/combobox/combobox-autocomplete-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<!-- js and css for this example. -->
<link href="css/combobox.css" rel="stylesheet">
<link href="css/listbox.css" rel="stylesheet">
<script src="js/combobox-list.js" type="text/javascript"></script>
<script src="js/listbox.js" type="text/javascript"></script>
<script src="js/listboxOption.js" type="text/javascript"></script>
Expand Down Expand Up @@ -45,17 +44,16 @@ <h1>Editable Combobox With List Autocomplete Example</h1>
<li><a href="combobox-autocomplete-none.html">Editable Combobox Without Autocomplete</a>: An editable combobox that demonstrates the behavior associated with <code>aria-autocomplete=none</code>.</li>
<li><a href="grid-combo.html">Editable Combobox with Grid Popup</a>: An editable combobox that presents suggestions in a grid, enabling users to navigate descriptive information about each suggestion.</li>
</ul>

<section>
<h2 id="ex_label">Example</h2>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<div class="combobox-list">
<div class="combobox combobox-list">
<label for="cb1-input">State</label>
<div class="group">
<input id="cb1-input" class="cb_edit" type="text" role="combobox" aria-autocomplete="list"
aria-expanded="false" aria-controls="cb1-listbox"
/>
aria-expanded="false" aria-controls="cb1-listbox">
<button id="cb1-button" tabindex="-1" aria-label="Open">&#9661;</button>
</div>
<ul id="cb1-listbox" role="listbox" aria-label="States">
Expand Down
12 changes: 4 additions & 8 deletions examples/combobox/combobox-autocomplete-none.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<!-- js and css for this example. -->
<link href="css/combobox.css" rel="stylesheet">
<link href="css/listbox.css" rel="stylesheet">
<script src="js/combobox-list.js" type="text/javascript"></script>
<script src="js/listbox.js" type="text/javascript"></script>
<script src="js/listboxOption.js" type="text/javascript"></script>
Expand Down Expand Up @@ -43,23 +42,20 @@ <h1>Editable Combobox without Autocomplete Example</h1>
<li><a href="combobox-autocomplete-list.html">Editable Combobox with List Autocomplete</a>: An editable combobox that demonstrates the autocomplete behavior known as <q>list with manual selection</q>.</li>
<li><a href="grid-combo.html">Editable Combobox with Grid Popup</a>: An editable combobox that presents suggestions in a grid, enabling users to navigate descriptive information about each suggestion.</li>
</ul>

<section>
<h2 id="ex_label">Example</h2>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
<div id="ex1">
<div class="combobox-list">
<div class="combobox combobox-list">
<label for="cb1-input">Search</label>
<div class="group">
<input id="cb1-input" class="cb_edit" type="text"
role="combobox"
aria-autocomplete="none"
aria-expanded="false"
aria-controls="cb1-listbox"
/>
<button type="button" id="cb1-button" tabindex="-1" aria-label="Open">
&#9661;
</button>
aria-controls="cb1-listbox">
<button type="button" id="cb1-button" tabindex="-1" aria-label="Open">&#9661;</button>
</div>
<ul id="cb1-listbox" role="listbox" aria-label="Previous Searches">
<li id="lb1-01" role="option">weather</li>
Expand Down
113 changes: 92 additions & 21 deletions examples/combobox/css/combobox.css
Original file line number Diff line number Diff line change
@@ -1,36 +1,107 @@
.annotate {
font-style: italic;
color: #366ed4;
}

.combobox-list {
position: relative;
}

.combobox-inline label,
.combobox-list label {
.combobox .group {
display: inline-flex;
}

.combobox .group input,
.combobox .group button {
background-color: white;
color: black;
box-sizing: border-box;
height: 1.5rem;
padding: 0 0.25em;
margin: 0;
padding: 0;
display: block;
vertical-align: bottom;
border: 1px solid gray;
}

.combobox-list .group input,
.combobox-list .group button {
display: inline;
background-color: #eee;
.combobox .group input {
width: 10rem;
border-right: none;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
outline: none;
}

.combobox .group button {
width: 1.5rem;
border-left: none;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
outline: none;
font-size: 85%;
}

.combobox-list .group input.focus {
.combobox .group.focus input,
.combobox .group.focus button {
background-color: #d6e8f5;
outline-color: #348ccb;
border-color: #348ccb;
}

.combobox .group.focus {
outline: 2px solid black;
outline-offset: 1px;
}

.combobox-list .group button {
ul[role="listbox"] {
margin: 0;
padding: 0 0.125em 0 0.125em;
position: relative;
top: 1px;
left: -2px;
font-size: 85%;
padding: 0;
position: absolute;
left: 0;
top: 1.5rem;
list-style: none;
background-color: #eee;
display: none;
box-sizing: border-box;
border: 1px gray solid;
border-radius: 3px;
max-height: 12em;
width: 11.5rem;
overflow: scroll;
overflow-x: hidden;
}

ul[role="listbox"] li[role="option"] {
margin: 0;
padding: 0;
padding-left: 0.125em;
border-top: 1px solid transparent;
border-bottom: 1px solid transparent;
}

[role="listbox"].focus {
border-color: #348ccb;
}

[role="listbox"] [role="option"] {
display: block;
margin: 0.25em;
padding: 0;
background-color: #eee;
font-size: 100%;
}

/* focus and hover styling */

[role="listbox"] [role="option"][aria-selected="true"] {
background-color: #ccc;
}

[role="listbox"].focus [role="option"][aria-selected="true"] {
background-color: #aed2ea;
border-color: #348ccb;
}

@media (forced-colors: active), (-ms-high-contrast: active) {
[role="listbox"].focus [role="option"][aria-selected="true"] {
background-color: highlight;
color: highlighttext;
}
}

[role="listbox"] li[role="option"]:hover {
background-color: #c2ddef;
}
5 changes: 0 additions & 5 deletions examples/combobox/css/grid-combo.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.annotate {
font-style: italic;
color: #366ed4;
}

.hidden {
display: none;
}
Expand Down
60 changes: 0 additions & 60 deletions examples/combobox/css/listbox.css

This file was deleted.

2 changes: 1 addition & 1 deletion examples/combobox/grid-combo.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1>Editable Combobox with Grid Popup Example</h1>
<li><a href="combobox-autocomplete-list.html">Editable Combobox with List Autocomplete</a>: An editable combobox that demonstrates the autocomplete behavior known as <q>list with manual selection</q>.</li>
<li><a href="combobox-autocomplete-none.html">Editable Combobox Without Autocomplete</a>: An editable combobox that demonstrates the behavior associated with <code>aria-autocomplete=none</code>.</li>
</ul>

<section>
<h2 id="ex_label">Example</h2>
<div role="separator" id="ex_start_sep" aria-labelledby="ex_start_sep ex_label" aria-label="Start of"></div>
Expand Down
6 changes: 3 additions & 3 deletions examples/combobox/js/combobox-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@ ComboboxList.prototype.setOption = function (option, flag) {
ComboboxList.prototype.setVisualFocusTextbox = function () {
this.listbox.domNode.classList.remove('focus');
this.listbox.hasFocus = false;
this.domNode.classList.add('focus');
this.domNode.parentNode.classList.add('focus'); // set the focus class to the parent for easier styling
this.hasFocus = true;
this.setActiveDescendant(false);
};

ComboboxList.prototype.setVisualFocusListbox = function () {
this.domNode.classList.remove('focus');
this.domNode.parentNode.classList.remove('focus');
this.hasFocus = false;
this.listbox.domNode.classList.add('focus');
this.listbox.hasFocus = true;
this.setActiveDescendant(this.option);
};

ComboboxList.prototype.removeVisualFocusAll = function () {
this.domNode.classList.remove('focus');
this.domNode.parentNode.classList.remove('focus');
this.hasFocus = false;
this.listbox.domNode.classList.remove('focus');
this.listbox.hasFocus = true;
Expand Down

0 comments on commit 73ca367

Please sign in to comment.