From a5d799c5d5d8cd2d4aed3b93a9bb3b08c360e304 Mon Sep 17 00:00:00 2001 From: Iury Nogueira Date: Thu, 10 Nov 2022 15:45:11 -0300 Subject: [PATCH] refactor: remove default msg when button is loading :hammer: #281 (#282) * refactor: remove default msg when button is loading :hammer: #281 * fix: workflow chromatic :ambulance: * style: fix right side icon --- .github/workflows/chromatic.yml | 3 +- .../ion/src/lib/button/button.component.html | 4 +- .../src/lib/button/button.component.spec.ts | 4 +- .../ion/src/lib/button/button.component.ts | 2 +- stories/Button.stories.mdx | 41 ------------------- 5 files changed, 7 insertions(+), 47 deletions(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 146bd13ad..77393bee7 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -16,7 +16,8 @@ jobs: - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: ${{ matrix.node-version }} + - uses: actions/checkout@v1 - name: Install dependencies run: yarn diff --git a/projects/ion/src/lib/button/button.component.html b/projects/ion/src/lib/button/button.component.html index f05586829..040e1e78d 100644 --- a/projects/ion/src/lib/button/button.component.html +++ b/projects/ion/src/lib/button/button.component.html @@ -6,7 +6,7 @@ [class.loading]="loading" [class.circular-button]="!loading && circularButton" [class.ion-remove-space]="iconType && !!!label" - [class.right-side-icon]="rightSideIcon || !options" + [class.right-side-icon]="rightSideIcon" [disabled]="disabled" (click)="handleClick()" > @@ -23,7 +23,7 @@ class="icon" > {{ - loading ? loadingMessage : label + loadingMessage || label }} { }); describe('load ButtonComponent', () => { - it('should render a loading button when loading="true" is passed and show default message "Carregando..."', async () => { + it('should render a loading button when loading="true" is passed and keep label', async () => { const button = await sut({ label: defaultName, loading: true }); expect(button).toHaveClass('loading'); expect(button.children[0]).toHaveClass('spinner'); - expect(button.children[1].textContent).toContain('Carregando...'); + expect(button.children[1].textContent).toContain(defaultName); }); it('should render a loading button with message "aguarde ..."', async () => { diff --git a/projects/ion/src/lib/button/button.component.ts b/projects/ion/src/lib/button/button.component.ts index 60239b507..ce4a4eb6b 100644 --- a/projects/ion/src/lib/button/button.component.ts +++ b/projects/ion/src/lib/button/button.component.ts @@ -46,7 +46,7 @@ export class ButtonComponent implements OnInit { @Input() danger? = false; @Input() disabled? = false; @Input() loading? = false; - @Input() loadingMessage = 'Carregando...'; + @Input() loadingMessage?: string; @Input() multiple? = false; @Input() iconType? = ''; @Input() rightSideIcon? = false; diff --git a/stories/Button.stories.mdx b/stories/Button.stories.mdx index b457182ee..b4b50ebcd 100644 --- a/stories/Button.stories.mdx +++ b/stories/Button.stories.mdx @@ -755,47 +755,6 @@ E 6 outras propriedades adicionais. -Ainda é possível configurar uma mensagem ser exibida no loading, caso não deseje a mensagem padrão 'Carregando...'. Basta configurar uma mensagem no `loadingMessage`. - - - - {{ - template: ``, - }} - - - {{ - template: ``, - }} - - - - `ionOnClick`. Emite um evento ao clicar no botão. Basta criar uma função no arquivo.ts e repassá-la no arquivo.html.