Skip to content

Commit

Permalink
refactor: ion button (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: Iury Nogueira <nogueiraiury20@gmail.com>
  • Loading branch information
danilo-moreira-brisa and iurynogueira authored Apr 8, 2024
1 parent f71f38a commit 64b0015
Show file tree
Hide file tree
Showing 10 changed files with 538 additions and 373 deletions.
6 changes: 6 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "2"
checks:
similar-code:
enabled: false
exclude_patterns:
- "**/styles.ts"
8 changes: 4 additions & 4 deletions src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { StatusType } from '../../core/types/status';
import ErrorBoundary from '../error/error-boundary';

Expand Down Expand Up @@ -40,7 +40,7 @@ export const IonAlert = ({
const icon = getIcon(type);

if (!isValidLabel(message)) {
return <ErrorBoundary msg="Message cannot be empty" />;
return <ErrorBoundary msg='Message cannot be empty' />;
}

if (!showAlert) {
Expand All @@ -49,15 +49,15 @@ export const IonAlert = ({

return (
<AlertStyled
data-testid="ion-alert"
data-testid='ion-alert'
type={type}
hideBackground={hideBackground}
>
<IonIcon type={icon} size={sizeIcon}></IonIcon>
<span>{message}</span>
{closable && (
<div onClick={() => setShowAlert(false)}>
<IonIcon type="close" size={sizeIcon}></IonIcon>
<IonIcon type='close' size={sizeIcon}></IonIcon>
</div>
)}
</AlertStyled>
Expand Down
245 changes: 245 additions & 0 deletions src/components/button/__snapshots__/button.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button Button Sizes should render button with lg size variation 1`] = `
.c0 {
appearance: none;
font-family: Source Sans Pro,sans-serif;
font-weight: 600;
border-radius: 10px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 0px;
flex-direction: row;
padding: 8px 20px;
font-size: 1.6rem;
line-height: 2.4rem;
background-color: #0858ce;
color: #fcfcfd;
border: 1px solid #0858ce;
}
.c0 svg {
fill: #fcfcfd;
}
.c0:hover,
.c0:focus-visible {
background-color: #146ff5;
border: 1px solid #146ff5;
}
.c0:active {
background-color: #06439d;
border: 1px solid #06439d;
}
.c0:disabled {
background-color: #e4e6eb;
color: #aeb2bd;
border: 1px solid #e4e6eb;
cursor: not-allowed;
}
.c0:disabled svg {
fill: #aeb2bd;
}
.c0:focus-visible {
outline: 2px solid #146ff5;
outline-offset: 2px;
}
<button
class="c0"
data-testid="ion-button"
>
<span>
Button
</span>
</button>
`;

exports[`Button Button Sizes should render button with md size variation 1`] = `
.c0 {
appearance: none;
font-family: Source Sans Pro,sans-serif;
font-weight: 600;
border-radius: 6px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 0px;
flex-direction: row;
padding: 6px 16px;
font-size: 1.4rem;
line-height: 2rem;
background-color: #0858ce;
color: #fcfcfd;
border: 1px solid #0858ce;
}
.c0 svg {
fill: #fcfcfd;
}
.c0:hover,
.c0:focus-visible {
background-color: #146ff5;
border: 1px solid #146ff5;
}
.c0:active {
background-color: #06439d;
border: 1px solid #06439d;
}
.c0:disabled {
background-color: #e4e6eb;
color: #aeb2bd;
border: 1px solid #e4e6eb;
cursor: not-allowed;
}
.c0:disabled svg {
fill: #aeb2bd;
}
.c0:focus-visible {
outline: 2px solid #146ff5;
outline-offset: 2px;
}
<button
class="c0"
data-testid="ion-button"
>
<span>
Button
</span>
</button>
`;

exports[`Button Button Sizes should render button with sm size variation 1`] = `
.c0 {
appearance: none;
font-family: Source Sans Pro,sans-serif;
font-weight: 600;
border-radius: 6px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 0px;
flex-direction: row;
padding: 4px 12px;
font-size: 1.2rem;
line-height: 1.6rem;
background-color: #0858ce;
color: #fcfcfd;
border: 1px solid #0858ce;
}
.c0 svg {
fill: #fcfcfd;
}
.c0:hover,
.c0:focus-visible {
background-color: #146ff5;
border: 1px solid #146ff5;
}
.c0:active {
background-color: #06439d;
border: 1px solid #06439d;
}
.c0:disabled {
background-color: #e4e6eb;
color: #aeb2bd;
border: 1px solid #e4e6eb;
cursor: not-allowed;
}
.c0:disabled svg {
fill: #aeb2bd;
}
.c0:focus-visible {
outline: 2px solid #146ff5;
outline-offset: 2px;
}
<button
class="c0"
data-testid="ion-button"
>
<span>
Button
</span>
</button>
`;

exports[`Button Button Sizes should render button with xl size variation 1`] = `
.c0 {
appearance: none;
font-family: Source Sans Pro,sans-serif;
font-weight: 600;
border-radius: 10px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
gap: 0px;
flex-direction: row;
padding: 12px 24px;
font-size: 1.6rem;
line-height: 2.4rem;
background-color: #0858ce;
color: #fcfcfd;
border: 1px solid #0858ce;
}
.c0 svg {
fill: #fcfcfd;
}
.c0:hover,
.c0:focus-visible {
background-color: #146ff5;
border: 1px solid #146ff5;
}
.c0:active {
background-color: #06439d;
border: 1px solid #06439d;
}
.c0:disabled {
background-color: #e4e6eb;
color: #aeb2bd;
border: 1px solid #e4e6eb;
cursor: not-allowed;
}
.c0:disabled svg {
fill: #aeb2bd;
}
.c0:focus-visible {
outline: 2px solid #146ff5;
outline-offset: 2px;
}
<button
class="c0"
data-testid="ion-button"
>
<span>
Button
</span>
</button>
`;
Loading

0 comments on commit 64b0015

Please sign in to comment.