Skip to content

Commit d70651e

Browse files
authored
Merge pull request #4 from geospatialem/geospatialem/feat-css-demo-links-etc
feat: misc updates
2 parents 92daafe + b2ff7c0 commit d70651e

File tree

4 files changed

+79
-60
lines changed

4 files changed

+79
-60
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ Presented at the 2025 Esri Developer Summit by Kelly Hutchins and Kitty Hurley o
88

99
## Demos
1010

11-
1. Map Description and Live Regions 🚧
11+
1. [Map Description and Live Regions](demos/description-region/index.html)
1212
- Provide context to when the map has loaded and include a description when the map is in focus to further WCAG's [1.3.1: Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html) Success Criterion.
1313
2. [Expand Component Focus Trap Disabled](demos/expand-component/index.html)
1414
- Provide users the ability to not be trapped when interacting with the Expand component to further WCAG's [2.1.2: No Keyboard Trap](https://www.w3.org/WAI/WCAG21/Understanding/no-keyboard-trap.html) Success Criterion.
1515
3. Consistent Focus 🚧
1616
- Provide a consistent focus order throughout your UI supporting WCAG's [2.4.3: Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html) and [3.2.3: Consistent Navigation](https://www.w3.org/WAI/WCAG22/Understanding/consistent-navigation.html) Success Criterion.
1717
4. [High Contrast](demos/high-contrast/index.html)
1818
- Explore contrast with your data, altering the basemap and layer effects to support the map's purpose when a user has enabled high contrast on their operating system, also supporting WCAG's [1.4.3: Contrast Minimum](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum) Success Criterion.
19-
5. Reduced Motion 🚧
19+
5. [Reduced MotioN](demos/reduced-motion/index.html)
2020
- Support reduced motion when a user has enabled reduced motion, or disabled animations on their operating system, also supporting WCAG's [2.3.3: Animation from Interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html) Success Criterion.
2121

2222
## Resources

demos/expand-component/app.js

Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,68 @@
1-
const toggleModeEl = document.getElementById("toggle-mode");
2-
const mapEl = document.querySelector("arcgis-map");
3-
const darkModeCss = document.getElementById("jsapi-mode-dark");
4-
const lightModeCss = document.getElementById("jsapi-mode-light");
5-
const liveRegion = document.getElementById("liveRegion");
6-
const searchEl = document.getElementById("search-el");
7-
const expandEl = document.getElementById("expand-el");
8-
9-
let mode = "light";
10-
11-
toggleModeEl.addEventListener("click", handleModeChange);
12-
13-
14-
// Initialize the mutation observer
15-
// Resource: https://developers.arcgis.com/javascript/latest/watch-for-changes/#using-a-mutation-observer
16-
const observer = new MutationObserver((mutations, observer) => {
17-
for (let mutation of mutations) {
18-
// Mutation observer change message
19-
const mutationMessage = `MutationObserver: ${mutation.attributeName} has changed to ${mutation.target[mutation.attributeName]}`;
20-
console.log(mutationMessage);
21-
// Set focus on the arcgis-search if the component is expanded
22-
// Else set focus on the arcgis-expand
23-
if (mutation.target[mutation.attributeName] == true) {
24-
searchEl.focusSearch();
25-
} else {
26-
const expandEls = document.querySelectorAll(".esri-expand__toggle > calcite-action");
27-
expandEls[0].setFocus();
28-
}
1+
require([
2+
"esri/core/reactiveUtils"
3+
], (reactiveUtils) => {
4+
5+
const toggleModeEl = document.getElementById("toggle-mode");
6+
const mapEl = document.querySelector("arcgis-map");
7+
const darkModeCss = document.getElementById("jsapi-mode-dark");
8+
const lightModeCss = document.getElementById("jsapi-mode-light");
9+
const searchEl = document.getElementById("search-el");
10+
const expandEl = document.getElementById("expand-el");
11+
12+
let mode = "light";
13+
14+
toggleModeEl.addEventListener("click", handleModeChange);
15+
16+
// reactiveUtils to watch for when the popup is opened and closed
17+
// Resource: https://developers.arcgis.com/javascript/latest/watch-for-changes/#watch-for-changes-in-the-api
18+
mapEl.addEventListener("arcgisViewReadyChange", () => {
19+
reactiveUtils.watch(() => mapEl.view.popup.visible, (visible) => {
20+
if (mapEl.view.popup.visible) {
21+
setTimeout(() => {
22+
mapEl.view.popup.focus();
23+
}, 100);
24+
} else {
25+
searchEl.focusSearch();
26+
}
27+
}
28+
);
29+
});
30+
31+
32+
// Initialize the mutation observer
33+
// Resource: https://developers.arcgis.com/javascript/latest/watch-for-changes/#using-a-mutation-observer
34+
const observer = new MutationObserver((mutations, observer) => {
35+
for (let mutation of mutations) {
36+
// Mutation observer change message
37+
const mutationMessage = `MutationObserver: ${mutation.attributeName} has changed to ${mutation.target[mutation.attributeName]}`;
38+
console.log(mutationMessage);
39+
// Set focus on the arcgis-search if the component is expanded
40+
// Else set focus on the arcgis-expand
41+
if (mutation.target[mutation.attributeName] == true) {
42+
searchEl.focusSearch();
43+
} else {
44+
const expandEls = document.querySelectorAll(".esri-expand__toggle > calcite-action");
45+
expandEls[0].setFocus();
46+
}
47+
}
48+
});
49+
50+
// Start observing the arcgis-expand's "expanded" attribute
51+
observer.observe(expandEl, {
52+
attributeFilter: ["expanded"]
53+
});
54+
55+
function handleModeChange() {
56+
mode = mode === "dark" ? "light" : "dark";
57+
const isDarkMode = mode === "dark";
58+
darkModeCss.disabled = !isDarkMode;
59+
lightModeCss.disabled = isDarkMode;
60+
toggleModeEl.icon = isDarkMode ? "moon" : "brightness";
61+
document.body.className = isDarkMode ? "calcite-mode-dark" : "";
62+
63+
document.querySelectorAll(`.calcite-mode-${isDarkMode ? "light" : "dark"}`).forEach(node =>
64+
node.classList.replace(`calcite-mode-${isDarkMode ? "light" : "dark"}`, `calcite-mode-${mode}`)
65+
);
2966
}
30-
});
31-
32-
// Start observing the arcgis-expand's "expanded" attribute
33-
observer.observe(expandEl, {
34-
attributeFilter: ["expanded"]
35-
});
36-
37-
38-
function handleModeChange() {
39-
mode = mode === "dark" ? "light" : "dark";
40-
const isDarkMode = mode === "dark";
41-
darkModeCss.disabled = !isDarkMode;
42-
lightModeCss.disabled = isDarkMode;
43-
toggleModeEl.icon = isDarkMode ? "moon" : "brightness";
44-
document.body.className = isDarkMode ? "calcite-mode-dark" : "";
45-
46-
document.querySelectorAll(`.calcite-mode-${isDarkMode ? "light" : "dark"}`).forEach(node =>
47-
node.classList.replace(`calcite-mode-${isDarkMode ? "light" : "dark"}`, `calcite-mode-${mode}`)
48-
);
49-
}
67+
68+
});

demos/expand-component/style.css

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ body.calcite-mode-dark calcite-navigation-logo{
99
--calcite-color-text-2:#C7C7C7;
1010
}
1111

12-
1312
html,
14-
body,
15-
arcgis-map {
16-
padding: 0;
13+
body {
1714
margin: 0;
1815
height: 100%;
19-
width: 100%;
2016
}
2117

2218
calcite-shell-panel[slot="panel-start"] calcite-panel {
2319
border-top: 0;
20+
}
21+
22+
/* Custom styling using Calcite's semantic tokens */
23+
/* Resource: https://developers.arcgis.com/calcite-design-system/foundations/tokens/usage */
24+
:root,
25+
:focus {
26+
--calcite-color-brand: #000;
27+
--calcite-color-focus: var(--calcite-color-brand);
2428
}

demos/high-contrast/style.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ body.calcite-mode-dark calcite-navigation-logo{
99
--calcite-color-text-2:#C7C7C7;
1010
}
1111

12-
1312
html,
14-
body,
15-
arcgis-map {
16-
padding: 0;
13+
body {
1714
margin: 0;
1815
height: 100%;
19-
width: 100%;
2016
}
2117

2218
calcite-shell-panel[slot="panel-start"] calcite-panel {

0 commit comments

Comments
 (0)