-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: close only last-opened modal/detail pane when escape key is pressed
closes VPAT-735
- Loading branch information
1 parent
28918d2
commit 5e70321
Showing
11 changed files
with
471 additions
and
17 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
.storybook/stories/datagrid/modal-stacked-on-detail.stories.ts
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,75 @@ | ||
/* | ||
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import { ClrDatagridModule, ClrModalModule } from '@clr/angular'; | ||
import { Parameters } from '@storybook/addons'; | ||
import { Story } from '@storybook/angular'; | ||
import { elements } from 'helpers/elements.data'; | ||
|
||
import { setupStorybook } from '../../helpers/setup-storybook.helpers'; | ||
|
||
const story: Story = args => ({ | ||
template: ` | ||
<div><strong>This story is NOT an endorsement of this UX pattern.</strong></div> | ||
<clr-datagrid> | ||
<clr-dg-column [style.width.px]="250">Name</clr-dg-column> | ||
<clr-dg-column [style.width.px]="250">Symbol</clr-dg-column> | ||
<clr-dg-column [style.width.px]="250">Number</clr-dg-column> | ||
<clr-dg-column>Electronegativity</clr-dg-column> | ||
<clr-dg-row *clrDgItems="let element of elements; let index = index" [clrDgItem]="element"> | ||
<clr-dg-cell>{{element.name}}</clr-dg-cell> | ||
<clr-dg-cell>{{element.symbol}}</clr-dg-cell> | ||
<clr-dg-cell>{{element.number}}</clr-dg-cell> | ||
<clr-dg-cell> | ||
<div [style.width.%]="element.electronegativity * 100 / 4" class="electronegativity-container"> | ||
{{element.electronegativity}} | ||
</div> | ||
</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-detail *clrIfDetail="let element"> | ||
<clr-dg-detail-header>{{element.name}}</clr-dg-detail-header> | ||
<clr-dg-detail-body> | ||
<button type="button" class="btn btn-primary" (click)="modalOpen = true">Open Modal</button> | ||
</clr-dg-detail-body> | ||
</clr-dg-detail> | ||
<clr-dg-footer> | ||
<clr-dg-pagination #pagination> | ||
<clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">Elements per page</clr-dg-page-size> | ||
{{pagination.firstItem + 1}} - {{pagination.lastItem + 1}} of {{pagination.totalItems}} elements | ||
</clr-dg-pagination> | ||
</clr-dg-footer> | ||
</clr-datagrid> | ||
<clr-modal [(clrModalOpen)]="modalOpen"> | ||
<h3 class="modal-title">Modal</h3> | ||
<div class="modal-body"> | ||
Pressing escape should only this modal, not the detail pane. | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="modalOpen = false">Close</button> | ||
</div> | ||
</clr-modal> | ||
`, | ||
props: { ...args }, | ||
}); | ||
|
||
const parameters: Parameters = { | ||
title: 'Datagrid/Modal Stacked on Detail', | ||
argTypes: { | ||
// story helpers | ||
elements: { control: { disable: true }, table: { disable: true } }, | ||
}, | ||
args: { | ||
// story helpers | ||
elements, | ||
}, | ||
}; | ||
|
||
setupStorybook([ClrDatagridModule, ClrModalModule], story, parameters); |
95 changes: 95 additions & 0 deletions
95
.storybook/stories/datagrid/nested-detail-in-detail.stories.ts
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,95 @@ | ||
/* | ||
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import { ClrDatagridModule, ClrModalModule } from '@clr/angular'; | ||
import { Parameters } from '@storybook/addons'; | ||
import { Story } from '@storybook/angular'; | ||
import { elements } from 'helpers/elements.data'; | ||
|
||
import { setupStorybook } from '../../helpers/setup-storybook.helpers'; | ||
|
||
const story: Story = args => ({ | ||
template: ` | ||
<div><strong>This story is NOT an endorsement of this UX pattern.</strong></div> | ||
<clr-datagrid> | ||
<clr-dg-column [style.width.px]="250">Name</clr-dg-column> | ||
<clr-dg-column [style.width.px]="250">Symbol</clr-dg-column> | ||
<clr-dg-column [style.width.px]="250">Number</clr-dg-column> | ||
<clr-dg-column>Electronegativity</clr-dg-column> | ||
<clr-dg-row *clrDgItems="let element of elements" [clrDgItem]="element"> | ||
<clr-dg-cell>{{element.name}}</clr-dg-cell> | ||
<clr-dg-cell>{{element.symbol}}</clr-dg-cell> | ||
<clr-dg-cell>{{element.number}}</clr-dg-cell> | ||
<clr-dg-cell> | ||
<div [style.width.%]="element.electronegativity * 100 / 4" class="electronegativity-container"> | ||
{{element.electronegativity}} | ||
</div> | ||
</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-detail *clrIfDetail="let element"> | ||
<clr-dg-detail-header>{{element.name}}</clr-dg-detail-header> | ||
<clr-dg-detail-body> | ||
<clr-datagrid> | ||
<clr-dg-column>Key</clr-dg-column> | ||
<clr-dg-column>Value</clr-dg-column> | ||
<clr-dg-row clrDgItem="name"> | ||
<clr-dg-cell>Name</clr-dg-cell> | ||
<clr-dg-cell>{{element.name}}</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-row clrDgItem="symbol"> | ||
<clr-dg-cell>Symbol</clr-dg-cell> | ||
<clr-dg-cell>{{element.symbol}}</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-row clrDgItem="number"> | ||
<clr-dg-cell>Number</clr-dg-cell> | ||
<clr-dg-cell>{{element.number}}</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-row clrDgItem="electronegativity"> | ||
<clr-dg-cell>Electronegativity</clr-dg-cell> | ||
<clr-dg-cell>{{element.electronegativity}}</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-detail *clrIfDetail> | ||
<clr-dg-detail-header>Nested Detail</clr-dg-detail-header> | ||
<clr-dg-detail-body> | ||
Pressing escape should only close this detail pane, not the parent detail pane. | ||
</clr-dg-detail-body> | ||
</clr-dg-detail> | ||
</clr-datagrid> | ||
</clr-dg-detail-body> | ||
</clr-dg-detail> | ||
<clr-dg-footer> | ||
<clr-dg-pagination #pagination> | ||
<clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">Elements per page</clr-dg-page-size> | ||
{{pagination.firstItem + 1}} - {{pagination.lastItem + 1}} of {{pagination.totalItems}} elements | ||
</clr-dg-pagination> | ||
</clr-dg-footer> | ||
</clr-datagrid> | ||
`, | ||
props: { ...args }, | ||
}); | ||
|
||
const parameters: Parameters = { | ||
title: 'Datagrid/Nested Detail in Detail', | ||
argTypes: { | ||
// story helpers | ||
elements: { control: { disable: true }, table: { disable: true } }, | ||
}, | ||
args: { | ||
// story helpers | ||
elements, | ||
}, | ||
}; | ||
|
||
setupStorybook([ClrDatagridModule, ClrModalModule], story, parameters); |
76 changes: 76 additions & 0 deletions
76
.storybook/stories/modal/nested-datagrid-detail.stories.ts
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,76 @@ | ||
/* | ||
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import { ClrDatagridModule, ClrModalModule } from '@clr/angular'; | ||
import { Parameters } from '@storybook/addons'; | ||
import { Story } from '@storybook/angular'; | ||
import { elements } from 'helpers/elements.data'; | ||
|
||
import { setupStorybook } from '../../helpers/setup-storybook.helpers'; | ||
|
||
const story: Story = args => ({ | ||
template: ` | ||
<div><strong>This story is NOT an endorsement of this UX pattern.</strong></div> | ||
<button type="button" class="btn btn-primary" (click)="modalOpen = true">Open Modal</button> | ||
<clr-modal [(clrModalOpen)]="modalOpen"> | ||
<h3 class="modal-title">Modal</h3> | ||
<div class="modal-body"> | ||
<clr-datagrid *ngIf="modalOpen"> | ||
<clr-dg-column [style.width.px]="250">Name</clr-dg-column> | ||
<clr-dg-column [style.width.px]="250">Symbol</clr-dg-column> | ||
<clr-dg-column [style.width.px]="250">Number</clr-dg-column> | ||
<clr-dg-column>Electronegativity</clr-dg-column> | ||
<clr-dg-row *clrDgItems="let element of elements; let index = index" [clrDgItem]="element"> | ||
<clr-dg-cell>{{element.name}}</clr-dg-cell> | ||
<clr-dg-cell>{{element.symbol}}</clr-dg-cell> | ||
<clr-dg-cell>{{element.number}}</clr-dg-cell> | ||
<clr-dg-cell> | ||
<div [style.width.%]="element.electronegativity * 100 / 4" class="electronegativity-container"> | ||
{{element.electronegativity}} | ||
</div> | ||
</clr-dg-cell> | ||
</clr-dg-row> | ||
<clr-dg-detail *clrIfDetail="let element"> | ||
<clr-dg-detail-header>{{element.name}}</clr-dg-detail-header> | ||
<clr-dg-detail-body> | ||
Pressing escape should only this detail pane, not the modal.<br /> | ||
{{element | json}} | ||
</clr-dg-detail-body> | ||
</clr-dg-detail> | ||
<clr-dg-footer> | ||
<clr-dg-pagination #pagination> | ||
<clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">Elements per page</clr-dg-page-size> | ||
{{pagination.firstItem + 1}} - {{pagination.lastItem + 1}} of {{pagination.totalItems}} elements | ||
</clr-dg-pagination> | ||
</clr-dg-footer> | ||
</clr-datagrid> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="modalOpen = false">Close</button> | ||
</div> | ||
</clr-modal> | ||
`, | ||
props: { ...args }, | ||
}); | ||
|
||
const parameters: Parameters = { | ||
title: 'Modal/Nested Datagrid Detail', | ||
argTypes: { | ||
// story helpers | ||
elements: { control: { disable: true }, table: { disable: true } }, | ||
}, | ||
args: { | ||
// story helpers | ||
elements, | ||
}, | ||
}; | ||
|
||
setupStorybook([ClrModalModule, ClrDatagridModule], story, parameters); |
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,57 @@ | ||
/* | ||
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import { ClrComboboxModule, ClrDropdownModule, ClrModalModule } from '@clr/angular'; | ||
import { Parameters } from '@storybook/addons'; | ||
import { Story } from '@storybook/angular'; | ||
import { elements } from 'helpers/elements.data'; | ||
|
||
import { setupStorybook } from '../../helpers/setup-storybook.helpers'; | ||
|
||
const story: Story = args => ({ | ||
template: ` | ||
<div><strong>This story is NOT an endorsement of this UX pattern.</strong></div> | ||
<button type="button" class="btn btn-primary" (click)="modal1Open = true">Open Modal 1</button> | ||
<clr-modal [(clrModalOpen)]="modal1Open"> | ||
<h3 class="modal-title">Modal 1</h3> | ||
<div class="modal-body"> | ||
This is modal 1. | ||
<button type="button" class="btn btn-primary" (click)="modal2Open = true">Open Modal 2</button> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="modal1Open = false">Close</button> | ||
</div> | ||
</clr-modal> | ||
<clr-modal [(clrModalOpen)]="modal2Open"> | ||
<h3 class="modal-title">Modal 2</h3> | ||
<div class="modal-body"> | ||
This is modal 2. Pressing escape should only close this modal, not both. | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-primary" (click)="modal2Open = false">Close</button> | ||
</div> | ||
</clr-modal> | ||
`, | ||
props: { ...args }, | ||
}); | ||
|
||
const parameters: Parameters = { | ||
title: 'Modal/Stacked Modal', | ||
argTypes: { | ||
// story helpers | ||
elements: { control: { disable: true }, table: { disable: true } }, | ||
}, | ||
args: { | ||
// story helpers | ||
elements, | ||
}, | ||
}; | ||
|
||
setupStorybook([ClrModalModule, ClrComboboxModule, ClrDropdownModule], story, parameters); |
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
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
Oops, something went wrong.