Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Size option to Modal component #104

Merged
merged 6 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions packages/docs/app/components/demo/overlays/demo-modal.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
<DocsDemo as |demo|>
{{#demo.example name="demo-overlays.hbs"}}
<Button
{{on "click" this.toggleModal}}
<div>
<Button
{{on "click" this.toggleModal}}
>
Open Modal
</Button>
</div>

<FormRadioGroup
@containerClass="mt-6"
@isInline={{true}}
@label="Size"
@value={{this.size}}
@onChange={{this.setSize}}
as |Radio|
>
Open Modal
</Button>
<Radio @value="xs" @label="xs" />
<Radio @value="sm" @label="sm" />
<Radio @value="md" @label="md" />
<Radio @value="lg" @label="lg" />
<Radio @value="xl" @label="xl" />
<Radio @value="full" @label="full" />
</FormRadioGroup>

<Modal
@isOpen={{this.isOpen}}
@onClose={{this.toggleModal}}
@size={{this.size}}
as |m|
>
<m.Header>Title</m.Header>
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/app/components/demo/overlays/demo-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ interface DemoModalArgs {}
export default class DemoModal extends Component<DemoModalArgs> {
@tracked isOpen = false;
@tracked isLoading = false;
@tracked size = 'lg';

@action toggleModal(): void {
this.isOpen = !this.isOpen;
}

@action setSize(size: string): void {
this.size = size;
}

@action save(): void {
this.isLoading = true;

Expand Down
3 changes: 2 additions & 1 deletion packages/overlays/addon/components/modal/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@contentTransitionName={{if @transitionName @transitionName "overlay--transition--zoom"}}
>
<div
class="modal {{if @isCentered "modal--centered"}}"
class="modal {{if @isCentered "modal--centered"}} modal--{{if @size @size "lg"}}"
tabindex="0"
role="dialog"
aria-labelledby={{this.headerId}}
Expand All @@ -35,6 +35,7 @@
Header=(component "modal/header" labelledById=this.headerId)
Body=(component "modal/body")
Footer=(component "modal/footer")
headerId=this.headerId
)}}
</div>
</Overlay>
7 changes: 7 additions & 0 deletions packages/overlays/addon/components/modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ interface ModalArgs extends Omit<OverlayArgs, 'contentTransitionName'> {
* @defaultValue false
*/
isCentered?: boolean;

/*
* The Modal size.
*
* @defaultValue `lg`
*/
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
}

export default class Modal extends Component<ModalArgs> {
Expand Down
Loading