Skip to content

Commit 319b75a

Browse files
committed
Copenhagen Theme v2
Update manifest to v2 Bump theme version to major alpha Update Recent Activities styles for v2 Remove red `*` for required fields [COMM-628] Remove arrows from vote buttons Rather than adding * Unicode Character 'UPWARDS BLACK ARROW' (U+2B06) * Unicode Character 'DOWNWARDS BLACK ARROW' (U+2B07) to the vote buttons using `::before` and a font to go with those symbols we want to use SVG to display those arrows. To style those icons I'm also removing the `::before` selectors for the remaining rules that deal with styling (hover highlight etc) for these elements. The modification of the `font-size`, `display` and `flex-direction` was to fix a centering/alignment issue with this new approach. I've copied over this file: https://github.com/zendeskgarden/svg-icons/blob/master/src/16/chevron-down-fill.svg From zendeskgarden. For the upwards pointing caret I've added an SVG transformation to the root `<svg>` element to mirror it along the horizontal axis. Otherwise the two elements are the same. I've also removed the `outline: none;` rule. [COMM-629] Add SVG cog wheel to moderation actions button The SVG is taken from `gear-stroke.svg`[1] from the Zendesk Garden SVG Icons repository. Another possibility is `gear-fill.svg`[2] from the same repo. I've changed the markup from a span to a button. It has multiple effects, one of which is making it possible to focus it with the keyboard. I've also made the button 44px by 44px. I've also removed the rules that removed the outline (when it's focused). TODO: === Include `aria-pressed`: > The aria-pressed attribute values of true or false identify a button as a toggle button. A menu button is a button that controls a menu and has an aria-haspopup property attribute set to either menu or true. -- https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role [1]: https://github.com/zendeskgarden/svg-icons/blob/master/src/16/gear-stroke.svg [2]: https://github.com/zendeskgarden/svg-icons/blob/master/src/16/gear-fill.svg Add normalize.css Bump manifest version User current_filter.identifier instead of the deprecated filter_by Port notifications styles Use SVG for notification-error icon Remove notification-lock Bump manifest version [COMM-722] Center actions icon Revert "[COMM-628] Remove arrows from vote buttons" This reverts commit 53c7460. Add css to fix table rendering We had this table styling in v1, so the row border didn't render properly in v2, so this adds those rules to v2 css. Deprecate icon-lock Deprecate icon-agent Deprecate icon-comments Inline search icon svg Use SVG for collapsible-nav-toggle Inline attachment icon Use SVG for collapsible-sidebar-toggle Use SVG in user profile page Replace "Return to top" icon Use SVG for promoted article icon Missing search icons Add SVG chevrons to dropdowns Remove old icon styles Change share icon styling Bump manifest version Remove [role="button"] global styling Bump manifest version Reimplement `user_info` in theme Bump manifest version Style v2 cursor-esque paginiation Bump manifest version Adding support for accessible dropdowns Styling actions dropdowns Styling subscribe dropdowns Regenarate style.css Removing bits of es6 Don't disable focus outline for checkboxes Since `border` won't really affect checkboxes, we'll keep focus outlines around for these. Bump manifest version Use classes to style comment submit buttons Bump manifest version Add `button` class name to `button-large` elements These button relied on `[role="button"]` styling before, which are no longer in v2. Remove obsolete `role="button"` from links Bump manifest version Fix misaligned focus ring for share icons Bump manifest version Use proper ARIA attribute for top links Bump manifest version Use `sign_in` string for header link `{{link 'sign_in'}}` will output a long string for unauthenticated users, and that's not what we want. Bump manifest version Use proper ARIA attributes in search results page Bump manifest version Fix vote buttons Revert "Aligning vote buttons with api v2" Readd styling for [input="submit] Bump manifest version Fix follow button styling to display the follower count Move Edit Profile button styling to a parent Bump manifest version Add `cursor: pointer;` where it's missing Bump manifest version Fix overlap in official comments The actions button overlaps with the "Official comment" label, so this re-adds the margin from v1. Remove redundant `actions` class names Add transparent background-color to .button Addresses visual bugs in Firefox and Safari Bump version Revert "Fix overlap in official comments" Bump version Fix overlap in official comments The actions button overlaps with the "Official comment" label, so this re-adds the margin from v1. We can't add class names to {{actions}}, so the styling is moved to an element selector. Bump manifest version Helpers cannot be used with an #if Bump manifest version Fix ARIA for subfilters on search page Bump manifest version Add transparent background to actions button Bump manifest version Styling follow buttons without using class and selected_class Fix styling for Edit Profile button For some reason, `sassc` transforms `.edit-profile-button > *` into `.edit-profile-button > button` which breaks the styling. This change also aligns the styling of other buttons. Bump manifest version Update vote helpers based off from the new behaviour with aria-pressed Addressing PR feedback Fix typo in aria-labelledby Readding lost vote background fix
1 parent 12d2e5b commit 319b75a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1936
-978
lines changed

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "Copenhagen",
33
"author": "Zendesk",
4-
"version": "1.14.4",
5-
"api_version": 1,
4+
"version": "2.0.0",
5+
"api_version": 2,
66
"default_locale": "en-us",
77
"settings": [{
88
"label": "colors_group_label",

script.js

Lines changed: 185 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
document.addEventListener('DOMContentLoaded', function() {
2+
// Key map
3+
var ENTER = 13;
4+
var ESCAPE = 27;
5+
var SPACE = 32;
6+
var UP = 38;
7+
var DOWN = 40;
8+
var TAB = 9;
9+
210
function closest (element, selector) {
311
if (Element.prototype.closest) {
412
return element.closest(selector);
@@ -72,7 +80,7 @@ document.addEventListener('DOMContentLoaded', function() {
7280
requestCommentSubmitButton = document.querySelector('.request-container .comment-container input[type=submit]');
7381

7482
if (requestMarkAsSolvedButton) {
75-
requestMarkAsSolvedButton.addEventListener('click', function () {
83+
requestMarkAsSolvedButton.addEventListener('click', function() {
7684
requestMarkAsSolvedCheckbox.setAttribute('checked', true);
7785
requestCommentSubmitButton.disabled = true;
7886
this.setAttribute('data-disabled', true);
@@ -117,7 +125,7 @@ document.addEventListener('DOMContentLoaded', function() {
117125
// Submit requests filter form on search in the request list page
118126
var quickSearch = document.querySelector('#quick-search');
119127
quickSearch && quickSearch.addEventListener('keyup', function(e) {
120-
if (e.keyCode === 13) { // Enter key
128+
if (e.keyCode === ENTER) {
121129
e.stopPropagation();
122130
saveFocus();
123131
closest(this, 'form').submit();
@@ -146,7 +154,7 @@ document.addEventListener('DOMContentLoaded', function() {
146154

147155

148156
userMenu.addEventListener('keyup', function(e) {
149-
if (e.keyCode === 27) { // Escape key
157+
if (e.keyCode === ESCAPE) {
150158
e.stopPropagation();
151159
closeNavigation(burgerMenu, this);
152160
}
@@ -167,7 +175,7 @@ document.addEventListener('DOMContentLoaded', function() {
167175
});
168176

169177
el.addEventListener('keyup', function(e) {
170-
if (e.keyCode === 27) { // Escape key
178+
if (e.keyCode === ESCAPE) {
171179
closeNavigation(toggle, this);
172180
}
173181
});
@@ -183,8 +191,8 @@ document.addEventListener('DOMContentLoaded', function() {
183191
}
184192

185193
// If a section has more than 6 subsections, we collapse the list, and show a trigger to display them all
186-
const seeAllTrigger = document.querySelector("#see-all-sections-trigger");
187-
const subsectionsList = document.querySelector(".section-list");
194+
var seeAllTrigger = document.querySelector("#see-all-sections-trigger");
195+
var subsectionsList = document.querySelector(".section-list");
188196

189197
if (subsectionsList && subsectionsList.children.length > 6) {
190198
seeAllTrigger.setAttribute("aria-hidden", false);
@@ -196,7 +204,7 @@ document.addEventListener('DOMContentLoaded', function() {
196204
}
197205

198206
// If multibrand search has more than 5 help centers or categories collapse the list
199-
const multibrandFilterLists = document.querySelectorAll(".multibrand-filter-list");
207+
var multibrandFilterLists = document.querySelectorAll(".multibrand-filter-list");
200208
Array.prototype.forEach.call(multibrandFilterLists, function(filter) {
201209
if (filter.children.length > 6) {
202210
// Display the show more button
@@ -213,12 +221,180 @@ document.addEventListener('DOMContentLoaded', function() {
213221
});
214222

215223
// If there are any error notifications below an input field, focus that field
216-
const notificationElm = document.querySelector(".notification-error");
224+
var notificationElm = document.querySelector(".notification-error");
217225
if (
218226
notificationElm &&
219227
notificationElm.previousElementSibling &&
220228
typeof notificationElm.previousElementSibling.focus === "function"
221229
) {
222230
notificationElm.previousElementSibling.focus();
223231
}
224-
});
232+
233+
// Dropdowns
234+
235+
function Dropdown(toggle, menu) {
236+
this.toggle = toggle;
237+
this.menu = menu;
238+
239+
this.menuPlacement = {
240+
top: menu.classList.contains("dropdown-menu-top"),
241+
end: menu.classList.contains("dropdown-menu-end")
242+
};
243+
244+
this.toggle.addEventListener("click", this.clickHandler.bind(this));
245+
this.toggle.addEventListener("keydown", this.toggleKeyHandler.bind(this));
246+
this.menu.addEventListener("keydown", this.menuKeyHandler.bind(this));
247+
};
248+
249+
Dropdown.prototype = {
250+
251+
get isExpanded() {
252+
return this.menu.getAttribute("aria-expanded") === "true";
253+
},
254+
255+
get menuItems() {
256+
return Array.prototype.slice.call(this.menu.querySelectorAll("[role='menuitem']"));
257+
},
258+
259+
dismiss: function() {
260+
if (!this.isExpanded) return;
261+
262+
this.menu.setAttribute("aria-expanded", false);
263+
this.menu.classList.remove("dropdown-menu-end", "dropdown-menu-top");
264+
},
265+
266+
open: function() {
267+
if (this.isExpanded) return;
268+
269+
this.menu.setAttribute("aria-expanded", true);
270+
this.handleOverflow();
271+
},
272+
273+
handleOverflow: function() {
274+
var rect = this.menu.getBoundingClientRect();
275+
276+
var overflow = {
277+
right: rect.left < 0 || rect.left + rect.width > window.innerWidth,
278+
bottom: rect.top < 0 || rect.top + rect.height > window.innerHeight
279+
};
280+
281+
if (overflow.right || this.menuPlacement.end) {
282+
this.menu.classList.add("dropdown-menu-end");
283+
}
284+
285+
if (overflow.bottom || this.menuPlacement.top) {
286+
this.menu.classList.add("dropdown-menu-top");
287+
}
288+
289+
if (this.menu.getBoundingClientRect().top < 0) {
290+
this.menu.classList.remove("dropdown-menu-top")
291+
}
292+
},
293+
294+
focusNextMenuItem: function(currentItem) {
295+
if (!this.menuItems.length) return;
296+
297+
var currentIndex = this.menuItems.indexOf(currentItem);
298+
var nextIndex = currentIndex === this.menuItems.length - 1 || currentIndex < 0 ? 0 : currentIndex + 1;
299+
300+
this.menuItems[nextIndex].focus();
301+
},
302+
303+
focusPreviousMenuItem: function(currentItem) {
304+
if (!this.menuItems.length) return;
305+
306+
var currentIndex = this.menuItems.indexOf(currentItem);
307+
var previousIndex = currentIndex <= 0 ? this.menuItems.length - 1 : currentIndex - 1;
308+
309+
this.menuItems[previousIndex].focus();
310+
},
311+
312+
clickHandler: function() {
313+
if (this.isExpanded) {
314+
this.dismiss();
315+
} else {
316+
this.open();
317+
}
318+
},
319+
320+
toggleKeyHandler: function(e) {
321+
switch (e.keyCode) {
322+
case ENTER:
323+
case SPACE:
324+
case DOWN:
325+
e.preventDefault();
326+
this.open();
327+
this.focusNextMenuItem();
328+
break;
329+
case UP:
330+
e.preventDefault();
331+
this.open();
332+
this.focusPreviousMenuItem();
333+
break;
334+
case ESCAPE:
335+
this.dismiss();
336+
this.toggle.focus();
337+
break;
338+
}
339+
},
340+
341+
menuKeyHandler: function(e) {
342+
var firstItem = this.menuItems[0];
343+
var lastItem = this.menuItems[this.menuItems.length - 1];
344+
var currentElement = e.target;
345+
346+
switch (e.keyCode) {
347+
case ESCAPE:
348+
this.dismiss();
349+
this.toggle.focus();
350+
break;
351+
case DOWN:
352+
e.preventDefault();
353+
this.focusNextMenuItem(currentElement);
354+
break;
355+
case UP:
356+
e.preventDefault();
357+
this.focusPreviousMenuItem(currentElement);
358+
break;
359+
case TAB:
360+
if (e.shiftKey) {
361+
if (currentElement === firstItem) {
362+
this.dismiss();
363+
} else {
364+
e.preventDefault();
365+
this.focusPreviousMenuItem(currentElement);
366+
}
367+
} else if (currentElement === lastItem) {
368+
this.dismiss();
369+
} else {
370+
e.preventDefault();
371+
this.focusNextMenuItem(currentElement);
372+
}
373+
break;
374+
case ENTER:
375+
case SPACE:
376+
e.preventDefault();
377+
currentElement.click();
378+
break;
379+
}
380+
}
381+
}
382+
383+
var dropdowns = [];
384+
var dropdownToggles = Array.prototype.slice.call(document.querySelectorAll(".dropdown-toggle"));
385+
386+
dropdownToggles.forEach(function(toggle) {
387+
var menu = toggle.nextElementSibling;
388+
if (menu && menu.classList.contains("dropdown-menu")) {
389+
dropdowns.push(new Dropdown(toggle, menu));
390+
}
391+
});
392+
393+
document.addEventListener("click", function(evt) {
394+
dropdowns.forEach(function(dropdown) {
395+
if (!dropdown.toggle.contains(evt.target)) {
396+
dropdown.dismiss();
397+
}
398+
});
399+
});
400+
});

0 commit comments

Comments
 (0)