Skip to content

Commit

Permalink
feat(moda): options to disable buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-rosa-jsm committed Sep 5, 2024
1 parent add00f6 commit 262cba6
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 3 deletions.
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 @@ -695,6 +697,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

@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

0 comments on commit 262cba6

Please sign in to comment.