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

feat(store-ui): Checkbox atom component #813

Merged
merged 4 commits into from
Jul 9, 2021

Conversation

igorbrasileiro
Copy link
Contributor

@igorbrasileiro igorbrasileiro commented Jul 8, 2021

What's the purpose of this pull request?

Add the Checkbox atom to store-ui

How it works?

How to test it?

References

@netlify
Copy link

netlify bot commented Jul 8, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 520c767

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/60e888d0b1bf7c000733081e

😎 Browse the preview: https://deploy-preview-813--storeui.netlify.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 8, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 520c767:

Sandbox Source
Store UI Typescript Configuration

Copy link
Member

@emersonlaurentino emersonlaurentino left a comment

Choose a reason for hiding this comment

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

I think we need a data attribute to state checked.

packages/store-ui/src/atoms/Checkbox/Checkbox.tsx Outdated Show resolved Hide resolved

describe('Checkbox', () => {
it('data-store-checkbox is present', () => {
const { getByTestId } = render(<Checkbox testId="checkbox" />)
Copy link
Member

@emersonlaurentino emersonlaurentino Jul 9, 2021

Choose a reason for hiding this comment

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

Suggested change
const { getByTestId } = render(<Checkbox testId="checkbox" />)
const { getByTestId } = render(<Checkbox testId="store-checkbox" />)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing the testId, instead of using the default one, prevents break the test furthermore, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

You have a point. Maybe really better pass the testid.

it('data-store-checkbox is present', () => {
const { getByTestId } = render(<Checkbox testId="checkbox" />)

expect(getByTestId('checkbox')).toHaveAttribute('data-store-checkbox')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(getByTestId('checkbox')).toHaveAttribute('data-store-checkbox')
expect(getByTestId('store-checkbox')).toHaveAttribute('data-store-checkbox')

})

it('type checkbox is present', () => {
const { getByTestId } = render(<Checkbox testId="checkbox" />)
Copy link
Member

@emersonlaurentino emersonlaurentino Jul 9, 2021

Choose a reason for hiding this comment

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

Suggested change
const { getByTestId } = render(<Checkbox testId="checkbox" />)
const { getByTestId } = render(<Checkbox testId="store-checkbox" />)

it('type checkbox is present', () => {
const { getByTestId } = render(<Checkbox testId="checkbox" />)

expect(getByTestId('checkbox')).toHaveAttribute('type', 'checkbox')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect(getByTestId('checkbox')).toHaveAttribute('type', 'checkbox')
expect(getByTestId('store-checkbox')).toHaveAttribute('type', 'checkbox')

@igorbrasileiro
Copy link
Contributor Author

I think we need a data attribute to state checked.

But the CSS already has it [data-store-checkbox]:checked

@igorbrasileiro igorbrasileiro changed the title [WIP] Add checkbox atom component feat(store-ui): Checkbox atom component Jul 9, 2021
@emersonlaurentino emersonlaurentino marked this pull request as ready for review July 9, 2021 15:25
@emersonlaurentino emersonlaurentino requested a review from a team as a code owner July 9, 2021 15:25
@tlgimenes
Copy link
Contributor

In the storybook, is it possible to create a boolean control to check the checkbox? Also, I'd like to see if we can add an action there too so we can listen to when a checkbox has been checked
image

@igorbrasileiro igorbrasileiro force-pushed the feature/checkbox-atom branch from 664bcf2 to 5a3a164 Compare July 9, 2021 17:29
@igorbrasileiro
Copy link
Contributor Author

@tlgimenes and @emersonlaurentino I did your request changes.

@emersonlaurentino
Copy link
Member

@igorbrasileiro the tip of @tlgimenes is great!

@igorbrasileiro
Copy link
Contributor Author

@igorbrasileiro the tip of @tlgimenes is great!

If I understood well, it's to create a control for checked property and an action for the click event, I did it also.

Copy link
Contributor

@tlgimenes tlgimenes left a comment

Choose a reason for hiding this comment

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

I think we are still missing a default value. Can you set the default to false?
image

Copy link
Contributor

@tlgimenes tlgimenes left a comment

Choose a reason for hiding this comment

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

Also, is it possible to make the default story to appear with the checked option set to false?
image

@igorbrasileiro
Copy link
Contributor Author

Also, is it possible to make the default story to appear with the checked option set to false?
image

The default value is already false, but it's not explicitly defined. It seems a bug because the query string on the URL doesn't work, but you can remove the query string or navigate to another story and go back.

@igorbrasileiro igorbrasileiro merged commit 36834fa into master Jul 9, 2021
@igorbrasileiro igorbrasileiro deleted the feature/checkbox-atom branch July 9, 2021 19:33
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.

3 participants