-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
website: replace details/summary in side nav with button and list
- Loading branch information
Showing
5 changed files
with
109 additions
and
19 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
website/app/components/doc/table-of-contents/collapsible-item.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="doc-table-of-contents__folder"> | ||
<button | ||
type="button" | ||
aria-controls={{if this.isOpen this.contentId: ""}} | ||
aria-expanded={{if this.isOpen "true" "false"}} | ||
class={{this.classNames}} | ||
{{on "click" this.toggleIsOpen}} | ||
>{{@name}}</button> | ||
{{#if this.isOpen}} | ||
<Doc::TableOfContents @structuredPageTree={{@item.children}} @depth={{@depth}} id={{this.contentId}} /> | ||
{{/if}} | ||
</div> |
25 changes: 25 additions & 0 deletions
25
website/app/components/doc/table-of-contents/collapsible-item.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
import Component from '@glimmer/component'; | ||
import { guidFor } from '@ember/object/internals'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
export default class DocTocCollapsibleItemComponent extends Component { | ||
@tracked isOpen = this.args.item.isOpen; | ||
@action toggleIsOpen() { | ||
this.isOpen = !this.isOpen; | ||
} | ||
|
||
contentId = 'content-' + guidFor(this); | ||
|
||
get classNames() { | ||
const classes = ['doc-table-of-contents__button']; | ||
if (this.isOpen) { | ||
classes.push('doc-table-of-contents__button--open'); | ||
} | ||
return classes.join(' '); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters