Skip to content

Commit

Permalink
Use <button> element for folder titles. (#137)
Browse files Browse the repository at this point in the history
* title as button

* remove redundant properties
  • Loading branch information
georgealways authored Jul 28, 2024
1 parent 6e15da6 commit 08acb0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
10 changes: 1 addition & 9 deletions src/GUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,11 @@ export default class GUI {
* The DOM element that contains the title.
* @type {HTMLElement}
*/
this.$title = document.createElement( 'div' );
this.$title = document.createElement( 'button' );
this.$title.classList.add( 'title' );
this.$title.setAttribute( 'role', 'button' );
this.$title.setAttribute( 'aria-expanded', true );
this.$title.setAttribute( 'tabindex', 0 );

this.$title.addEventListener( 'click', () => this.openAnimated( this._closed ) );
this.$title.addEventListener( 'keydown', e => {
if ( e.code === 'Enter' || e.code === 'Space' ) {
e.preventDefault();
this.$title.click();
}
} );

// enables :active pseudo class on mobile
this.$title.addEventListener( 'touchstart', () => {}, { passive: true } );
Expand Down
8 changes: 4 additions & 4 deletions style/hierarchy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
.title {

height: var(--title-height);
line-height: calc(var(--title-height) - 4px);

font-weight: 600;
padding: 0 var(--padding);
-webkit-tap-highlight-color: transparent;
cursor: pointer;
outline: none;

width: 100%;
text-align: left;
background: none;

// we use an underline to indicate focus, don't underline arrow
text-decoration-skip: objects;
Expand Down
5 changes: 4 additions & 1 deletion style/inputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
color: var(--text-color);

width: 100%;
border: none;
}

.controller button {
height: var(--widget-height);

// todo: this is only here because three.js defines a global button style
Expand All @@ -76,7 +80,6 @@
background: var(--widget-color);
border-radius: var(--widget-border-radius);

border: none;

@include can-hover {
&:hover {
Expand Down

0 comments on commit 08acb0e

Please sign in to comment.