Skip to content

Commit

Permalink
feat(button): add whatsapp color for buttons according to new design (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
esraltintas authored Sep 21, 2022
1 parent 862d413 commit 4c8917f
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 33 deletions.
58 changes: 39 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/button/src/Button.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ComponentProps {
/**
* Set the color of the button
*/
color?: 'primary' | 'tertiary';
color?: 'primary' | 'tertiary' | 'whatsapp';
/**
* View of the button
*/
Expand Down
20 changes: 20 additions & 0 deletions packages/button/src/__tests__/Button.screenshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ describe(
}),
);

describe(
'Whatsapp button colors size=middle',
screenshotTesting({
cases: [
[
'sprite',
createStorybookUrl({
packageName,
knobs: {
color: 'whatsapp',
size: 'middle',
children: 'WhatsApp',
},
}),
],
],
screenshotOpts: { clip },
}),
);

describe('Button events tests', () => {
test('Button hover event', async () => {
const pageUrl = createStorybookUrl({
Expand Down
6 changes: 6 additions & 0 deletions packages/button/src/__tests__/Button.snapshot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ describe('Button Snapshots tests', () => {
expect(render(<Button color="tertiary" />)).toMatchSnapshot();
});

it('should render whatsapp color', () => {
expect(
render(<Button color="whatsapp" children="WhatsApp" />),
).toMatchSnapshot();
});

it('should render button by default', () => {
expect(render(<Button />)).toMatchSnapshot();
});
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,84 @@ Object {
"unmount": [Function],
}
`;

exports[`Button Snapshots tests should render whatsapp color 1`] = `
Object {
"asFragment": [Function],
"baseElement": <body>
<div>
<button
class="button whatsapp contained large"
>
<span
class="text"
>
WhatsApp
</span>
</button>
</div>
</body>,
"container": <div>
<button
class="button whatsapp contained large"
>
<span
class="text"
>
WhatsApp
</span>
</button>
</div>,
"debug": [Function],
"findAllByAltText": [Function],
"findAllByDisplayValue": [Function],
"findAllByLabelText": [Function],
"findAllByPlaceholderText": [Function],
"findAllByRole": [Function],
"findAllByTestId": [Function],
"findAllByText": [Function],
"findAllByTitle": [Function],
"findByAltText": [Function],
"findByDisplayValue": [Function],
"findByLabelText": [Function],
"findByPlaceholderText": [Function],
"findByRole": [Function],
"findByTestId": [Function],
"findByText": [Function],
"findByTitle": [Function],
"getAllByAltText": [Function],
"getAllByDisplayValue": [Function],
"getAllByLabelText": [Function],
"getAllByPlaceholderText": [Function],
"getAllByRole": [Function],
"getAllByTestId": [Function],
"getAllByText": [Function],
"getAllByTitle": [Function],
"getByAltText": [Function],
"getByDisplayValue": [Function],
"getByLabelText": [Function],
"getByPlaceholderText": [Function],
"getByRole": [Function],
"getByTestId": [Function],
"getByText": [Function],
"getByTitle": [Function],
"queryAllByAltText": [Function],
"queryAllByDisplayValue": [Function],
"queryAllByLabelText": [Function],
"queryAllByPlaceholderText": [Function],
"queryAllByRole": [Function],
"queryAllByTestId": [Function],
"queryAllByText": [Function],
"queryAllByTitle": [Function],
"queryByAltText": [Function],
"queryByDisplayValue": [Function],
"queryByLabelText": [Function],
"queryByPlaceholderText": [Function],
"queryByRole": [Function],
"queryByTestId": [Function],
"queryByText": [Function],
"queryByTitle": [Function],
"rerender": [Function],
"unmount": [Function],
}
`;
28 changes: 21 additions & 7 deletions packages/button/src/docs/Description.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Container, Row, Col } from 'storybook/blocks';
import { Whatsapp } from '../../../icons/src';
import Button from '../Button';

## Variants
Expand Down Expand Up @@ -68,6 +69,7 @@ render(

Use the `color` prop to change the color of the Button.
You can set the value to solid, `primary` (default) and `tertiary`.
For whatsapp button, you can set the color value `whatsapp`

```tsx live
const buttonColors = ['primary', 'tertiary'];
Expand All @@ -82,15 +84,18 @@ render(
</Button>
</Col>
))}
<Col key="whatsapp">
<Button size="large" color="whatsapp">
WhatsApp
</Button>
</Col>
</Row>
<Row align="middle">
{buttonColors.map(color => (
<Col key={color}>
<Button size="large" variant="outlined" color={color}>
Button CTA
</Button>
</Col>
))}
<Col key="primary">
<Button size="large" variant="outlined" color="primary">
Button CTA
</Button>
</Col>
</Row>
</Container>,
);
Expand All @@ -113,6 +118,15 @@ render(
</Button>
</Col>
))}
<Col key="large">
<Button
leftIcon={<Whatsapp fontSize="20" />}
color="whatsapp"
size="large"
>
WhatsApp
</Button>
</Col>
</Row>
<Row>
<Col>
Expand Down
Loading

1 comment on commit 4c8917f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 99.36% 777/782
🟢 Branches 90.98% 111/122
🟢 Functions 97.37% 37/38
🟢 Lines 99.73% 728/730

Test suite run success

182 tests passing in 26 suites.

Report generated by 🧪jest coverage report action from 4c8917f

Please sign in to comment.