diff --git a/frontend/javascript/controllers/sidebar_controller.js b/frontend/javascript/controllers/sidebar_controller.js index 1bf3612e..b1d094c7 100644 --- a/frontend/javascript/controllers/sidebar_controller.js +++ b/frontend/javascript/controllers/sidebar_controller.js @@ -13,8 +13,15 @@ export default class Sidebar extends Controller { toggle(event) { event.preventDefault() - const targetId = event.currentTarget.getAttribute("aria-controls") + const button = event.currentTarget + const targetId = button.getAttribute("aria-controls") const target = document.getElementById(targetId) - target.getAttribute("aria-expanded") === "true" ? target.setAttribute("aria-expanded", false) : target.setAttribute("aria-expanded", true) + if (target.getAttribute("aria-expanded") === "true") { + target.setAttribute("aria-expanded", false) + button.setAttribute("aria-label", "Hide list") + } else { + target.setAttribute("aria-expanded", true) + button.setAttribute("aria-label", "Expand list") + } } } diff --git a/frontend/styles/layout.css b/frontend/styles/layout.css index 06d8d227..6ddd5cab 100644 --- a/frontend/styles/layout.css +++ b/frontend/styles/layout.css @@ -24,12 +24,48 @@ body > footer { grid-area: footer; } -body.help { +body.with-sidebar { display: grid; grid-template-areas: "header header" "aside main" "footer footer"; + + main { + box-sizing: border-box; + padding: var(--spacing-8) var(--spacing-10); + width: calc(100vw - var(--doc-sidebar-width) - var(--doc-sidebar-padding)); + + button { + display: none; + width: fit-content; + } + + img { + max-width: 100%; + } + } + + @media(max-width: 800px) { + main { + grid-column: 1 / -1; + width: 100%; + + button { + display: inline-flex; + } + } + } + + @container main (width < 800px) { + .main-content { + grid-template-columns: 1fr; + } + + #markdown-toc { + display: none; + } + } } .wrapper { diff --git a/frontend/styles/pages/help.css b/frontend/styles/pages/help.css index 9ba9df9e..b5330323 100644 --- a/frontend/styles/pages/help.css +++ b/frontend/styles/pages/help.css @@ -5,22 +5,10 @@ main { align-content: start; align-items: start; - box-sizing: border-box; display: grid; gap: var(--gap-medium); justify-content: center; overflow-y: scroll; - padding: var(--spacing-8) var(--spacing-10); - width: calc(100vw - var(--doc-sidebar-width)); - - button { - display: none; - width: fit-content; - } - - img { - max-width: 100%; - } } .main-content { @@ -39,11 +27,11 @@ h1 { font-size: 2rem; } - + h2 { font-size: 1.5rem; } - + h3 { font-size: 1.25rem; } @@ -64,25 +52,4 @@ margin-inline: auto; } } - - @media(max-width: 800px) { - main { - grid-column: 1 / -1; - width: 100%; - - button { - display: inline-flex; - } - } - } - - @container main (width < 800px) { - .main-content { - grid-template-columns: 1fr; - } - - #markdown-toc { - display: none; - } - } } diff --git a/frontend/styles/variables/sizes.css b/frontend/styles/variables/sizes.css index 277c3eba..999d9153 100644 --- a/frontend/styles/variables/sizes.css +++ b/frontend/styles/variables/sizes.css @@ -1,5 +1,6 @@ :root { --doc-sidebar-width: 300px; + --doc-sidebar-padding: var(--spacing-16); --doc-content-width: 80ch; --gap-xsmall: var(--spacing-1); diff --git a/src/_components/help/sidebar.rb b/src/_components/help/sidebar.rb deleted file mode 100644 index 4ebec19a..00000000 --- a/src/_components/help/sidebar.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Help::Sidebar < Bridgetown::Component - def initialize(metadata:, current:) - @metadata = metadata - @current = current - @site = Bridgetown::Current.site - end -end diff --git a/src/_components/help/sidebar.css b/src/_components/shared/sidebar.css similarity index 72% rename from src/_components/help/sidebar.css rename to src/_components/shared/sidebar.css index 34f705db..c8e1aefc 100644 --- a/src/_components/help/sidebar.css +++ b/src/_components/shared/sidebar.css @@ -1,6 +1,7 @@ side-bar { border-right: var(--border-default); overflow-y: scroll; + padding-inline-start: var(--spacing-16); width: var(--doc-sidebar-width); z-index: 90; @@ -12,6 +13,19 @@ side-bar { } } + :is(h1) { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + font-size: var(--text-l); + margin-block-end: var(--spacing-4); + + span { + color: var(--text-color-secondary); + font-size: var(--text-base); + } + } + ul { list-style-type: none; margin: 0; @@ -46,7 +60,7 @@ side-bar { border-left: 2px solid transparent; border-radius: 0 var(--border-radius-medium) var(--border-radius-medium) 0; margin-left: -1px; - padding-left: var(--spacing-5); + padding-left: var(--spacing-3); } } @@ -58,6 +72,7 @@ side-bar { max-height: 100vh; overflow-y: scroll; overscroll-behavior: contain; + padding-inline-start: revert; position: fixed; transition: all 0.4s ease-in-out; top: 0; @@ -66,17 +81,16 @@ side-bar { left: 0; } - button { + aside > button { align-items: center; background: transparent; - border: 0; display: flex; - margin-bottom: var(--spacing-10); - margin-top: var(--spacing-16); - } + margin-bottom: var(--spacing-6); + margin-top: var(--spacing-12); - button svg { - transform: rotate(180deg); + svg { + transform: rotate(180deg); + } } } } diff --git a/src/_components/help/sidebar.erb b/src/_components/shared/sidebar.erb similarity index 78% rename from src/_components/help/sidebar.erb rename to src/_components/shared/sidebar.erb index 2b451c6c..d9a3cee7 100644 --- a/src/_components/help/sidebar.erb +++ b/src/_components/shared/sidebar.erb @@ -4,12 +4,14 @@ Hide menu + <%= slotted :before %>
+ <%= slotted :after %> diff --git a/src/_components/shared/sidebar.rb b/src/_components/shared/sidebar.rb new file mode 100644 index 00000000..08572172 --- /dev/null +++ b/src/_components/shared/sidebar.rb @@ -0,0 +1,7 @@ +class Shared::Sidebar < Bridgetown::Component + def initialize(data:, current:) + @data = data + @current = current + @site = Bridgetown::Current.site + end +end diff --git a/src/_components/help/sidebar/item.css b/src/_components/shared/sidebar/item.css similarity index 100% rename from src/_components/help/sidebar/item.css rename to src/_components/shared/sidebar/item.css diff --git a/src/_components/help/sidebar/item.erb b/src/_components/shared/sidebar/item.erb similarity index 86% rename from src/_components/help/sidebar/item.erb rename to src/_components/shared/sidebar/item.erb index 2bba3496..c4c7259e 100644 --- a/src/_components/help/sidebar/item.erb +++ b/src/_components/shared/sidebar/item.erb @@ -11,7 +11,7 @@ <% end %> <% if @items.present? %> -