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

chore: Add checkbox-controlled example #950

Merged
merged 1 commit into from
Dec 23, 2021

Conversation

AlexMunoz
Copy link
Contributor

@AlexMunoz AlexMunoz commented Dec 12, 2021

Add controlled checkbox example #939

The default example is when the checkbox is uncontrolled. #949

@vercel
Copy link

vercel bot commented Dec 12, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

reakit – ./

🔍 Inspect: https://vercel.com/ariakit/reakit/ANLjFvaPET8mw5GRLEyBjCYKYZ1q
✅ Preview: Canceled

[Deployment for eb47aea canceled]

ariakit – ./

🔍 Inspect: https://vercel.com/ariakit/ariakit/79fhpg59qvFtdUxMda4mE7Lc2y7m
✅ Preview: https://ariakit-git-fork-alexmunoz-chore-controlled-chec-b672fe-ariakit.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 12, 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.

@codecov
Copy link

codecov bot commented Dec 12, 2021

Codecov Report

Merging #950 (eb47aea) into v2 (db52841) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v2     #950      +/-   ##
==========================================
+ Coverage   42.12%   42.17%   +0.05%     
==========================================
  Files         155      156       +1     
  Lines        4107     4111       +4     
  Branches     1158     1158              
==========================================
+ Hits         1730     1734       +4     
  Misses       2376     2376              
  Partials        1        1              
Impacted Files Coverage Δ
...heckbox/__examples__/checkbox-controlled/index.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db52841...eb47aea. Read the comment docs.

@diegohaz
Copy link
Member

Also, let's rename the example to checkbox-controlled to keep the convention component-stuff.

<Checkbox
className="checkbox"
checked={checked}
onChange={(e) => setChecked(e.target.checked)}
Copy link
Member

Choose a reason for hiding this comment

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

Let's be more explicit since it's going to be part of the documentation. I'll see if there's an eslint rule for this.

Suggested change
onChange={(e) => setChecked(e.target.checked)}
onChange={(event) => setChecked(event.target.checked)}

Comment on lines 1 to 7
.label {
@apply flex flex-row items-center gap-2;
}

.checkbox {
@apply ariakit-focus-visible:ariakit-outline;
}
Copy link
Member

Choose a reason for hiding this comment

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

Does it work if we just import the base checkbox styles?

Suggested change
.label {
@apply flex flex-row items-center gap-2;
}
.checkbox {
@apply ariakit-focus-visible:ariakit-outline;
}
@import url("../checkbox/style.css");

Comment on lines 5 to 6
render(<Example />);
expect(getByRole("checkbox")).toMatchInlineSnapshot(`
Copy link
Member

Choose a reason for hiding this comment

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

I guess we should use container here.

Suggested change
render(<Example />);
expect(getByRole("checkbox")).toMatchInlineSnapshot(`
const { container } = render(<Example />);
expect(container).toMatchInlineSnapshot(`

@diegohaz diegohaz changed the title chore: add controlled checkbox example chore: Add checkbox-controlled example Dec 14, 2021
@AlexMunoz AlexMunoz force-pushed the chore/controlled-checkbox-example branch from d5d4840 to 9b438a3 Compare December 23, 2021 19:22
@vercel vercel bot temporarily deployed to Preview – reakit December 23, 2021 19:22 Inactive
@AlexMunoz AlexMunoz force-pushed the chore/controlled-checkbox-example branch from 9b438a3 to 49cb06b Compare December 23, 2021 19:28
@vercel vercel bot temporarily deployed to Preview – reakit December 23, 2021 19:28 Inactive
Copy link
Member

@diegohaz diegohaz left a comment

Choose a reason for hiding this comment

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

Thank you @AlexMunoz! ❤️

@diegohaz diegohaz merged commit ad77c40 into ariakit:v2 Dec 23, 2021
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