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

feat(modal): add options to disable buttons #563

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export namespace Components {
}
interface AtomModal {
"alertType"?: 'alert' | 'error';
"disablePrimary"?: boolean;
"disableSecondary"?: boolean;
"hasDivider"?: boolean;
"hasFooter"?: boolean;
"headerTitle"?: string;
Expand Down Expand Up @@ -696,6 +698,8 @@ declare namespace LocalJSX {
}
interface AtomModal {
"alertType"?: 'alert' | 'error';
"disablePrimary"?: boolean;
"disableSecondary"?: boolean;
"hasDivider"?: boolean;
"hasFooter"?: boolean;
"headerTitle"?: string;
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/components/modal/modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ describe('atom-modal', () => {
<atom-modal
trigger="button"
primary-text="Primary"
secondary-text="Secondary"
secondary-text="Secondary"
disable-primary="true"
>
Modal content
</atom-modal>`,
Expand All @@ -21,7 +22,7 @@ describe('atom-modal', () => {

it('should render modal with default values', async () => {
expect(page.root).toEqualHtml(`
<atom-modal primary-text="Primary" secondary-text="Secondary" trigger="button">
<atom-modal primary-text="Primary" secondary-text="Secondary" trigger="button" disable-primary="true">
<ion-modal aria-describedby="atom-modal__content" aria-labelledby="atom-modal__header-title" class="atom-modal" trigger="button">
<header class="atom-modal__header">
<div id="atom-modal__header-title"></div>
Expand All @@ -36,7 +37,7 @@ describe('atom-modal', () => {
<atom-button class="atom-modal__btn-action atom-modal__btn-action--secondary" color="secondary" fill="outline">
Secondary
</atom-button>
<atom-button class="atom-modal__btn-action atom-modal__btn-action--primary" color="primary">
<atom-button class="atom-modal__btn-action atom-modal__btn-action--primary" color="primary" disabled="">
Primary
</atom-button>
</footer>
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class AtomModal {
@Prop() alertType?: 'alert' | 'error'
@Prop() progress?: number
@Prop() hasFooter?: boolean = true
@Prop() disablePrimary?: boolean = false
@Prop() disableSecondary?: boolean = false
matheus-rosa-jsm marked this conversation as resolved.
Show resolved Hide resolved

@Event() atomCloseClick: EventEmitter
@Event() atomDidDismiss: EventEmitter
Expand Down Expand Up @@ -132,6 +134,7 @@ export class AtomModal {
<footer class='atom-modal__footer'>
<atom-button
color='secondary'
disabled={this.disableSecondary}
fill='outline'
class='atom-modal__btn-action atom-modal__btn-action--secondary'
onClick={this.handleSecondaryClick}
Expand All @@ -140,6 +143,7 @@ export class AtomModal {
</atom-button>
<atom-button
color='primary'
disabled={this.disablePrimary}
class='atom-modal__btn-action atom-modal__btn-action--primary'
onClick={this.handlePrimaryClick}
>
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/components/modal/stories/modal.args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ export const ModalStoryArgs = {
category: Category.PROPERTIES,
},
},
disableSecondary: {
control: 'boolean',
description:
'If true, the secondary button will be disabled. Default is false',
table: {
category: Category.PROPERTIES,
},
},
disablePrimary: {
control: 'boolean',
description:
'If true, the primary button will be disabled. Default is false',
table: {
category: Category.PROPERTIES,
},
},
atomCloseClick: {
action: 'atomCloseClick',
description:
Expand Down Expand Up @@ -143,4 +159,6 @@ export const ModalComponentArgs = {
primaryText: 'Primary',
secondaryText: 'Secondary',
hasDivider: false,
disableSecondary: false,
disablePrimary: false,
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const createModal = (args) => {
progress="${args.progress}"
has-footer="${args.hasFooter}"
header-title="${args.headerTitle}"
disable-secondary="${args.disableSecondary}"
disable-primary="${args.disablePrimary}"
>
<div slot="header">Custom Header</div>
<p>Modal Content</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const createModal = (args) => (
secondaryText={args.secondaryText}
trigger='open-modal'
progress={args.progress}
disablePrimary={args.disablePrimary}
disableSecondary={args.disableSecondary}
>
<div slot='header'>Custom Header</div>
<p>Modal Content</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const createModal = (args, themeColor = 'light') => ({
secondary-text="${args.secondaryText}"
trigger="open-modal"
progress="${args.progress}"
disable-primary="${args.disablePrimary}"
disable-secondary="${args.disableSecondary}"
>
{{ args.label }}
</AtomModal>
Expand Down
Loading