Skip to content

Commit bc75b9f

Browse files
committed
Style changes
1 parent 43ce551 commit bc75b9f

File tree

11 files changed

+66
-292
lines changed

11 files changed

+66
-292
lines changed

buildSrc/src/main/kotlin/dokka-convention.gradle.kts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,32 @@ dokka {
1111

1212
pluginsConfiguration.html {
1313
customStyleSheets.from(
14-
rootProject.file("docs/dokka-presets/css/logo-styles.css"),
1514
rootProject.file("docs/dokka-presets/css/aws-styles.css"),
1615
)
1716

1817
customAssets.from(
1918
rootProject.file("docs/dokka-presets/assets/logo-icon.svg"),
20-
rootProject.file("docs/dokka-presets/assets/aws_logo_white_59x35.png"),
2119
rootProject.file("docs/dokka-presets/scripts/accessibility.js"),
2220
)
2321

2422
footerMessage.set("© ${java.time.LocalDate.now().year}, Amazon Web Services, Inc. or its affiliates. All rights reserved.")
2523
separateInheritedMembers.set(true)
26-
templatesDir.set(rootProject.file("docs/dokka-presets/templates"))
2724
}
2825

2926
// each module can include their own top-level module documentation
3027
// see https://kotlinlang.org/docs/kotlin-doc.html#module-and-package-documentation
3128
if (project.file("API.md").exists()) {
32-
// FIXME Should we configure dokkaPublications (currently-recommended by Dokka) or dokkaSourceSets (old config)? Both compile fine...
33-
dokkaPublications.html {
34-
includes.from(project.file("API.md"))
35-
}
3629
dokkaSourceSets.configureEach {
3730
includes.from(project.file("API.md"))
3831
}
3932
}
4033

4134
dokkaSourceSets.configureEach {
42-
// FIXME Source sets 'common' and 'desktop' have the common sample roots. In Dokka K2 it will be an error.
43-
samples.from(project.file("samples").path, project.file("generated-src/samples").path)
35+
// Only configure samples on `commonMain`.
36+
// Fixes compiler warnings: "Source sets 'common' and 'desktop' have the common sample roots. In Dokka K2 it will be an error."
37+
if (name == "commonMain") {
38+
samples.from(project.file("samples").path, project.file("generated-src/samples").path)
39+
}
4440
}
4541

4642
// Configure Dokka to link to latest smithy-kotlin types
-2.22 KB
Binary file not shown.
Lines changed: 37 additions & 14 deletions
Loading

docs/dokka-presets/css/aws-styles.css

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,29 @@
44
*/
55

66
:root {
7-
--aws-color-dark: #232f3e;
8-
--horizontal-spacing-for-content: 16px;
9-
--default-font-family: JetBrains Sans, Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI,Roboto, Oxygen, Ubuntu,Cantarell, Droid Sans, Helvetica Neue, Arial, sans-serif;
10-
}
11-
12-
.menu-toggle {
13-
background: none;
14-
}
15-
16-
.menu-toggle:focus {
17-
outline: 2px solid #fff; /* White outline */
18-
outline-offset: 2px; /* Space between the outline and the button */
19-
}
20-
21-
#pages-search:focus {
22-
outline: revert;
23-
}
24-
25-
/* copied from Dokka except for background-color attribute */
26-
.navigation {
27-
display: flex;
28-
justify-content: space-between;
29-
30-
color: #fff;
31-
background-color: var(--aws-color-dark);
32-
font-family: var(--default-font-family);
33-
letter-spacing: -0.1px;
34-
35-
/* Reset margin and use padding for border */
36-
margin-left: 0;
37-
margin-right: 0;
38-
padding: 10px var(--horizontal-spacing-for-content);
39-
40-
z-index: 4;
41-
}
42-
43-
/* Styles for section tabs like "Types" and "Functions" */
44-
.section-tab:focus, .section-tab:active {
45-
outline: 2px solid var(--active-tab-border-color); /* The color appears unresolved, but it is defined in Dokka style sheets */
46-
}
47-
48-
/*
49-
Dokka does not break links or code blocks properly by default. Add word-wrap to prevent left/right scrollbar from
50-
appearing on small screens.
51-
*/
52-
.main-content a:not([data-name]) {
53-
word-wrap: break-word;
54-
}
55-
.symbol {
56-
overflow-wrap: break-word;
57-
}
58-
59-
.keyValue {
60-
display: block;
61-
}
62-
63-
/*
64-
Disable the playground run button for generated samples
65-
https://github.com/Kotlin/dokka/issues/3041
66-
*/
67-
div .compiler-info, .fold-button, .run-button {
68-
display: none;
7+
--color-background-nav: #232f3e;
8+
--dokka-logo-height: 60px;
9+
--dokka-logo-width: 90px;
6910
}
7011

7112
.skip-to-content {
13+
position: absolute; /* Remove from normal flow */
14+
top: 0; /* Position off-screen */
15+
left: 0;
7216
width: 1px;
7317
height: 1px;
7418
overflow: hidden;
7519
opacity: 0;
20+
z-index: -1; /* Ensure it's not visible */
7621
}
7722

7823
.skip-to-content:focus,
7924
.skip-to-content:active {
25+
position: static; /* Restore to normal flow when focused */
8026
width: auto;
8127
height: auto;
8228
opacity: 1;
83-
z-index: 999; /* Ensure the skip link is on top of other content */
84-
}
85-
86-
.aws-toggle-content-btn {
87-
font-size: 24px;
88-
background: none;
89-
border: none;
90-
cursor: pointer;
91-
padding: 8px;
29+
z-index: 999; /* Ensure it's on top */
9230
}
9331

9432
@media (max-width: 550px) {

docs/dokka-presets/css/logo-styles.css

Lines changed: 0 additions & 39 deletions
This file was deleted.

docs/dokka-presets/scripts/accessibility.js

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* Check for elements with a navButton class, which indicates the sidebar has finished loading.
2+
* Check for elements with a `toc--button` class, which indicates the sidebar has finished loading.
33
*/
44
async function dispatchNavigationLoadedEvent() {
5-
while (!document.querySelectorAll('.navButton').length > 0) {
5+
while (!document.querySelectorAll('.toc--button').length > 0) {
66
await new Promise(resolve => setTimeout(resolve, 100));
77
}
88
window.dispatchEvent(new Event('navigationLoaded'));
@@ -12,14 +12,14 @@ document.addEventListener('DOMContentLoaded', dispatchNavigationLoadedEvent);
1212
if (document.readyState === "interactive" || document.readyState === "complete" ) { dispatchNavigationLoadedEvent() }
1313

1414
/**
15-
* Apply "skip to main content" buttons after each active left sidebar `sideMenuPart`.
15+
* Apply "skip to main content" buttons after each active left sidebar `toc--part`.
1616
* These are invisible and only accessible via keyboard
1717
* Fixes accessibility violation: "Provide a mechanism for skipping past repetitive content"
1818
*/
1919
function applySkipLinks() {
2020
document.querySelectorAll('#content').forEach(function(contentDiv) {
21-
contentDiv.setAttribute('role', 'main');
22-
contentDiv.setAttribute('tabindex', '-1');
21+
contentDiv.setAttribute('role', 'main');
22+
contentDiv.setAttribute('tabindex', '-1');
2323
});
2424

2525
function insertSkipLink(element) {
@@ -42,20 +42,20 @@ function applySkipLinks() {
4242

4343
function handleChanges(mutationsList) {
4444
for (const mutation of mutationsList) {
45-
if (mutation.type === 'attributes' && mutation.target.classList.contains('sideMenuPart') && !mutation.target.classList.contains('hidden')) {
45+
if (mutation.type === 'attributes' && mutation.target.classList.contains('toc--part') && !mutation.target.classList.contains('toc--part_hidden')) {
4646
insertSkipLink(mutation.target);
4747
}
4848
}
49+
}
4950

50-
// Insert a skip link on all sideMenuParts with [data-active] property
51-
document.querySelectorAll('.sideMenuPart[data-active]').forEach(function(sideMenuPart) {
52-
insertSkipLink(sideMenuPart)
53-
});
51+
// Insert a skip link on all visible toc-parts
52+
document.querySelectorAll('.toc--part:not(.toc--part_hidden)').forEach(function(sideMenuPart) {
53+
insertSkipLink(sideMenuPart)
54+
});
5455

55-
// Insert a skip link on the first sideMenuPart
56-
const firstSideMenuPart = document.getElementById("sideMenu").children[0].querySelectorAll(".sideMenuPart")[0]
57-
insertSkipLink(firstSideMenuPart)
58-
}
56+
// Insert a skip link on the first toc-part, regardless of visibility.
57+
const firstSideMenuPart = document.getElementById("sideMenu").children[0].querySelectorAll(".toc--part")[0]
58+
insertSkipLink(firstSideMenuPart)
5959

6060
const observer = new MutationObserver(handleChanges);
6161
const observerConfig = {
@@ -68,59 +68,14 @@ function applySkipLinks() {
6868
}
6969
window.addEventListener('navigationLoaded', applySkipLinks);
7070

71-
/**
72-
* Ensure `navButton` elements are interactable and have proper accessibility properties
73-
* Fixes accessibilty violation: "Ensure all interactive functionality is operable with the keyboard"
74-
*/
75-
function ensureNavButtonInteractable() {
76-
const navButtons = document.querySelectorAll('.navButton');
77-
78-
navButtons.forEach(function(navButton) {
79-
if (navButton.hasAttribute('aria-expanded')) {
80-
return;
81-
}
82-
83-
// Make the navButton focusable, add accessibility information
84-
navButton.setAttribute('tabindex', '0');
85-
navButton.setAttribute('role', 'button');
86-
87-
const sideMenuPartParent = navButton.closest(".sideMenuPart")
88-
const navButtonExpanded = sideMenuPartParent ? (sideMenuPartParent.classList.contains('hidden') ? 'false' : 'true') : 'false'
89-
navButton.setAttribute('aria-expanded', navButtonExpanded);
90-
91-
// Grab the page ID, use it for aria-label and aria-controls
92-
const sectionName = navButton.parentElement.parentElement.getAttribute('pageid')
93-
// Remove the page ID suffix auto-generated by Dokka
94-
const cleanedSectionName = sectionName.substring(0, sectionName.indexOf("////PointingToDeclaration"))
95-
navButton.setAttribute('aria-label', cleanedSectionName);
96-
97-
const sectionID = navButton.parentElement.parentElement.id
98-
navButton.setAttribute('aria-controls', sectionID);
99-
100-
// Add event listener for Enter and Space keys
101-
navButton.addEventListener('keydown', function(event) {
102-
if (event.key === 'Enter' || event.key === ' ') {
103-
event.preventDefault(); // Prevent the default action to avoid navigation
104-
this.click(); // Trigger the onclick event
105-
}
106-
});
107-
108-
// Update aria-expanded attribute on click
109-
navButton.addEventListener('click', function() {
110-
const isExpanded = navButton.getAttribute('aria-expanded') === 'true';
111-
navButton.setAttribute('aria-expanded', (!isExpanded).toString());
112-
});
113-
});
114-
}
115-
window.addEventListener('navigationLoaded', ensureNavButtonInteractable);
116-
11771
/**
11872
* Ensure that content (specifically, code blocks) reflows on small page sizes.
11973
* Fixes accessibility violation: "Ensure pages reflow without requiring two-dimensional scrolling without loss of content or functionality"
12074
*/
12175
function ensureContentReflow() {
12276
// Ensure `content` sections are reflowable
12377
document.querySelectorAll('.content[data-togglable]').forEach(function(content) {
78+
console.log("Adding content.style.display = 'block' to " + content.id)
12479
content.style.display = 'block'
12580
});
12681
}

0 commit comments

Comments
 (0)