Skip to content

Commit

Permalink
drawer: refactors template and focus behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchristopherbrady committed Oct 27, 2023
1 parent 8728198 commit 90705c6
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 199 deletions.
8 changes: 2 additions & 6 deletions packages/web-components/src/drawer/drawer.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const styles = css`
max-width: 100%;
max-height: 100vh;
overflow: hidden;
width: var(--drawer-size, 592px);
width: var(--drawer-width, 592px);
}
:host([position='end']) dialog {
Expand All @@ -132,7 +132,7 @@ export const styles = css`
:host([open][type='inline']),
:host([open][modal-type='non-modal']) {
width: var(--drawer-size, 592px);
width: var(--drawer-width, 592px);
}
:host([type='overlay']) dialog {
Expand Down Expand Up @@ -187,12 +187,8 @@ export const styles = css`
}
::slotted([slot='navigation']) {
display: grid;
grid-auto-flow: column;
grid-template-columns: 1fr;
column-gap: ${spacingHorizontalS};
padding: 0 ${spacingHorizontalL};
justify-content: flex-start;
margin-bottom: ${spacingVerticalS};
}
Expand Down
15 changes: 8 additions & 7 deletions packages/web-components/src/drawer/drawer.template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ElementViewTemplate, html, ref, when } from '@microsoft/fast-element';
import type { Drawer } from './drawer.js';
import { DrawerModalType } from './drawer.options.js';

/**
* The template for the Drawer component.
Expand All @@ -10,25 +11,25 @@ export function drawerTemplate<T extends Drawer>(): ElementViewTemplate<T> {
<dialog
class="dialog"
part="dialog"
role="${x => (x.modalType === 'non-modal' || x.type === 'inline' ? 'complementary' : 'dialog')}"
aria-modal="${x => (x.modalType === 'non-modal' ? 'false' : 'true')}"
role="${x => (x.modalType === DrawerModalType.alert ? 'alertdialog' : void 0)}"
aria-modal="${x => (x.modalType === 'non-modal' || x.type === 'inline' ? void 0 : 'true')}"
aria-describedby="${x => x.ariaDescribedby}"
aria-labelledby="${x => x.ariaLabelledby}"
aria-label="${x => x.ariaLabel}"
?open="${x => x.open}"
size="${x => x.size}"
position="${x => x.position}"
modal-type="${x => x.modalType}"
type="${x => x.type}"
@click="${(x, c) => x.handleClick(c.event as MouseEvent)}"
@click="${(x, c) => x.clickHandler(c.event as MouseEvent)}"
@keydown="${(x, c) => x.keydownHandler(c.event as KeyboardEvent)}"
${ref('dialog')}
>
<div class="drawer" ${ref('drawer')}>
<div class="header">
<div class="drawer" part="drawer">
<div class="header" part="header">
<nav class="navigation">
<slot name="navigation"></slot>
</nav>
<div class="title">
<div class="title" part="title">
<slot name="title"></slot>
<slot name="action"></slot>
</div>
Expand Down
Loading

0 comments on commit 90705c6

Please sign in to comment.