-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
tushar8184
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. |
components/button/Button.tsx
Outdated
<Image | ||
className={iconClasses} | ||
// bag-img | ||
// src="/vector.png" | ||
|
||
// save-img | ||
// src="/save.png" | ||
|
||
// left_arrow-img | ||
// src="/left_arrow.png" | ||
|
||
// right_arrow-img |
There was a problem hiding this comment.
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.
components/button/Button.tsx
Outdated
// src="/left_arrow.png" | ||
|
||
// right_arrow-img | ||
src="/right_arrow.png" |
There was a problem hiding this comment.
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)
components/button/Button.tsx
Outdated
width={17} | ||
height={19.6} |
There was a problem hiding this comment.
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
components/button/Button.tsx
Outdated
)} | ||
<span className={textColor + ' mx-auto ' + textClasses}>{text}</span> | ||
{iconRight && ( | ||
<Image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/button/Button.tsx
Outdated
<Image | ||
className={iconClasses} | ||
src="/vector.png" | ||
width={9.92} | ||
height={11.46} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below
components/button/Button.tsx
Outdated
return <button>{children}</button>; | ||
const Button = ({ | ||
variant, | ||
text = 'Button', |
There was a problem hiding this comment.
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
Please export SVG icons instead. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
components/button/Button.test.tsx
Outdated
@@ -1,14 +1,13 @@ | |||
import { render, screen } from '@testing-library/react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the required changes
components/button/Button.test.tsx
Outdated
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); | ||
}); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
components/button/Button.tsx
Outdated
return <button>{children}</button>; | ||
const Button = ({ | ||
variant, | ||
text = '', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
components/button/Button.tsx
Outdated
return <button>{children}</button>; | ||
const Button = ({ | ||
variant, | ||
text = '', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
components/button/Button.tsx
Outdated
<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> |
There was a problem hiding this comment.
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
@types/button.types.ts
Outdated
@@ -0,0 +1,10 @@ | |||
export type ButtonType = { | |||
variant: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the values instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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
Outdated
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'); | ||
}); |
There was a problem hiding this comment.
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
@types/button.types.ts
Outdated
@@ -0,0 +1,10 @@ | |||
export type ButtonType = { | |||
variant: string; |
There was a problem hiding this comment.
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
Please remove the icons in this pr |
components/button/Button.test.tsx
Outdated
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'); | ||
}); | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to the bottom
components/button/Button.test.tsx
Outdated
const button = screen.getByRole('button'); | ||
expect(button).toHaveTextContent(/test data/i); | ||
}); | ||
|
||
it('display an alert onClick', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('display an alert onClick', () => { | |
it('add class on onClick', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added 'add class on'
components/button/Button.tsx
Outdated
textClasses, | ||
onClick, | ||
}: ButtonType) => { | ||
let classes = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let classes = ''; | |
let classes = defaultClasses'; |
components/button/Button.tsx
Outdated
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`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classes = `${defaultClasses} bg-green-primary h-12`; | |
classes += ` bg-green-primary h-12`; |
7f1f2b6
to
7f37c87
Compare