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

FTP-1383:Design-systems-components-buttons #26

Merged
merged 7 commits into from
Oct 13, 2022

Conversation

tushar8184
Copy link
Contributor

Screenshot 2022-10-03 at 12 23 21 PM

@vercel
Copy link

vercel bot commented Oct 3, 2022

@tushar8184 is attempting to deploy a commit to the grocery-plus Team on Vercel.

To accomplish this, @tushar8184 needs to request access to the Team.

Afterwards, an owner of the Team is required to accept their membership request.

If you're already a member of the respective Vercel Team, make sure that your Personal Vercel Account is connected to your GitHub account.

Comment on lines 54 to 65
<Image
className={iconClasses}
// bag-img
// src="/vector.png"

// save-img
// src="/save.png"

// left_arrow-img
// src="/left_arrow.png"

// right_arrow-img
Copy link
Contributor

Choose a reason for hiding this comment

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

@tushar8184 Please remove the comments.

// src="/left_arrow.png"

// right_arrow-img
src="/right_arrow.png"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be passed as a prop (iconName)

Comment on lines 69 to 70
width={17}
height={19.6}
Copy link
Contributor

Choose a reason for hiding this comment

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

Set these using tailwind classes

)}
<span className={textColor + ' mx-auto ' + textClasses}>{text}</span>
{iconRight && (
<Image
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of the next.js component, lets use

Comment on lines 45 to 50
<Image
className={iconClasses}
src="/vector.png"
width={9.92}
height={11.46}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as below

return <button>{children}</button>;
const Button = ({
variant,
text = 'Button',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove the default value

@skippednote
Copy link
Contributor

Please export SVG icons instead.
Please make the tests pass.

@vercel
Copy link

vercel bot commented Oct 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
grocery-plus ✅ Ready (Inspect) Visit Preview Oct 4, 2022 at 1:35PM (UTC)

@@ -1,14 +1,13 @@
import { render, screen } from '@testing-library/react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the required changes

Comment on lines 3 to 15
describe('Test Button component', () => {
it('renders the component', () => {
render(<Button>Test data</Button>);
render(<button>Test data</button>);
const button = screen.getByRole('button');
expect(button).toBeInTheDocument();
});
it('renders the correct child data', () => {
render(<Button>Test data</Button>);
render(<button>Test data</button>);
const button = screen.getByRole('button');
expect(button).toHaveTextContent(/test data/i);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Add more tests to check all variants and other props

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have added one more test to check all the variants.

return <button>{children}</button>;
const Button = ({
variant,
text = '',
Copy link
Contributor

Choose a reason for hiding this comment

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

let's use children instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return <button>{children}</button>;
const Button = ({
variant,
text = '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Text shouldn't have a default value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 39 to 46
<div
className={classes + ' ' + extraClasses}
onClick={() => (onClick != null ? onClick : null)}
>
{iconLeft && <img className="w-7" src={iconName} />}
<span className={textColor + ' mx-auto ' + textClasses}>{text}</span>
{iconRight && <img className="w-7" src={iconName} />}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the Icon component here

@@ -0,0 +1,10 @@
export type ButtonType = {
variant: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the values instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to list all the variant names here instead of string

Comment on lines 15 to 47
it('renders the component based on variant', () => {
render(<Button variant="primary" />);
const button = screen.getByRole('button');
expect(button).toHaveClass('bg-green-primary h-12');
});
it('renders the component based on variant', () => {
render(<Button variant="primary-small" />);
const button = screen.getByRole('button');
expect(button).toHaveClass('bg-green-primary h-9');
});
it('renders the component based on variant', () => {
render(<Button variant="secondary" />);
const button = screen.getByRole('button');
expect(button).toHaveClass('bg-red-primary h-12');
});
it('renders the component based on variant', () => {
render(<Button variant="secondary-small" />);
const button = screen.getByRole('button');
expect(button).toHaveClass('bg-red-primary h-9');
});
it('renders the component based on variant', () => {
render(<Button variant="tertiary" />);
const button = screen.getByRole('button');
expect(button).toHaveClass('bg-light-off h-12');
});
it('renders the component based on variant', () => {
render(<Button variant="tertiary-small" />);
const button = screen.getByRole('button');
expect(button).toHaveClass('bg-light-off h-9');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the variant name in the it string

@@ -0,0 +1,10 @@
export type ButtonType = {
variant: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to list all the variant names here instead of string

components/button/Button.test.tsx Show resolved Hide resolved
@skippednote
Copy link
Contributor

Please remove the icons in this pr

Comment on lines 17 to 31
it('display an alert onClick', () => {
render(
<Button
variant="primary"
text="test data"
onClick={(event) => {
event.currentTarget.classList.add('clicked');
}}
/>,
);
const button = screen.getByRole('button');
fireEvent.click(button);
expect(button).toHaveClass('clicked');
});

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this test to the bottom

Copy link
Contributor Author

Choose a reason for hiding this comment

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

move to the bottom

const button = screen.getByRole('button');
expect(button).toHaveTextContent(/test data/i);
});

it('display an alert onClick', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('display an alert onClick', () => {
it('add class on onClick', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added 'add class on'

textClasses,
onClick,
}: ButtonType) => {
let classes = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let classes = '';
let classes = defaultClasses';

const defaultClasses =
'flex items-center w-full px-4 py-3 rounded-xs cursor-pointer';
if (variant === 'primary') {
classes = `${defaultClasses} bg-green-primary h-12`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
classes = `${defaultClasses} bg-green-primary h-12`;
classes += ` bg-green-primary h-12`;

@tushar8184 tushar8184 force-pushed the FTP-1383-design-systems-components-buttons branch from 7f1f2b6 to 7f37c87 Compare October 12, 2022 09:12
@skippednote skippednote merged commit 598b6a7 into main Oct 13, 2022
@skippednote skippednote deleted the FTP-1383-design-systems-components-buttons branch October 13, 2022 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants