Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Checkbox): add component #1405

Merged
merged 13 commits into from
Jun 3, 2019
Merged

feat(Checkbox): add component #1405

merged 13 commits into from
Jun 3, 2019

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented May 28, 2019

Fixes #634.

This PR adds a base implementation of Checkbox component with basiccheckboxBehavior. Also adds stardust-checkmark icon that is used for Checkbox component.

<Checkbox checked />

image

<Checkbox checked toogle />

image

Playground

checkbox

@layershifter layershifter force-pushed the feat/checkbox branch 2 times, most recently from b4f14b1 to c9e09f8 Compare May 29, 2019 14:33
@layershifter layershifter changed the title [WIP] feat(Checkbox): add component feat(Checkbox): add component May 30, 2019
@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #1405 into master will decrease coverage by 0.35%.
The diff coverage is 13.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1405      +/-   ##
==========================================
- Coverage   73.59%   73.23%   -0.36%     
==========================================
  Files         787      794       +7     
  Lines        5888     5923      +35     
  Branches     1737     1726      -11     
==========================================
+ Hits         4333     4338       +5     
- Misses       1549     1579      +30     
  Partials        6        6
Impacted Files Coverage Δ
packages/react/src/index.ts 100% <ø> (ø) ⬆️
packages/react/src/themes/teams/index.tsx 90.9% <ø> (ø) ⬆️
...act/src/themes/teams/components/Icon/iconStyles.ts 16.12% <ø> (+0.97%) ⬆️
...react/src/themes/base/components/Icon/iconNames.ts 75% <ø> (ø) ⬆️
...emes/base/components/Checkbox/checkboxVariables.ts 0% <0%> (ø)
...mes/teams/components/Checkbox/checkboxVariables.ts 0% <0%> (ø)
.../themes/base/components/Checkbox/checkboxStyles.ts 10% <10%> (ø)
...ms/components/Icon/svg/icons/stardustCheckmark.tsx 100% <100%> (ø)
...cessibility/Behaviors/Checkbox/checkboxBehavior.ts 100% <100%> (ø)
...ackages/react/src/components/Checkbox/Checkbox.tsx 4.76% <4.76%> (ø)
... and 8 more

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 bdade88...3e8727b. Read the comment docs.

@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #1405 into master will decrease coverage by 0.11%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1405      +/-   ##
==========================================
- Coverage    73.6%   73.49%   -0.12%     
==========================================
  Files         787      793       +6     
  Lines        5907     5949      +42     
  Branches     1744     1735       -9     
==========================================
+ Hits         4348     4372      +24     
- Misses       1553     1571      +18     
  Partials        6        6
Impacted Files Coverage Δ
packages/react/src/index.ts 100% <ø> (ø) ⬆️
packages/react/src/themes/teams/index.tsx 90.9% <ø> (ø) ⬆️
...react/src/themes/base/components/Icon/iconNames.ts 75% <ø> (ø) ⬆️
...emes/base/components/Checkbox/checkboxVariables.ts 0% <0%> (ø)
...mes/teams/components/Checkbox/checkboxVariables.ts 0% <0%> (ø)
.../themes/base/components/Checkbox/checkboxStyles.ts 10% <10%> (ø)
...cessibility/Behaviors/Checkbox/checkboxBehavior.ts 100% <100%> (ø)
...themes/teams/components/Checkbox/checkboxStyles.ts 50% <50%> (ø)
...ackages/react/src/components/Checkbox/Checkbox.tsx 77.77% <77.77%> (ø)
... and 5 more

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 882f293...75b62ed. Read the comment docs.


export default (siteVars: any): CheckboxVariables => ({
checkboxBackground: 'transparent',
checkboxBorderColor: siteVars.colors.grey[300],
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 try to use the color scheme here, as this is a fresh new component ;)

Copy link
Contributor

@mnajdova mnajdova May 30, 2019

Choose a reason for hiding this comment

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

I meant in teams theme :)

Copy link
Contributor

Choose a reason for hiding this comment

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

As we decided not to add the color scheme now and make the component red-lined, let's be sure to track this work


handleClick = (e: React.MouseEvent | React.KeyboardEvent) => {
const { disabled } = this.props
const checked = !this.state.checked
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, could be moved in the if statement

Copy link
Member Author

Choose a reason for hiding this comment

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

Will keep as it is for now :)

import { Accessibility } from '../../lib/accessibility/types'
import { checkboxBehavior } from '../../lib/accessibility'

export interface CheckboxProps extends UIComponentProps, ChildrenComponentProps {
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 add conformat test for the new component.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added, have to add an additional handler for onChange. Decided to keep it flat to be more obvious

root: {
'aria-checked': props.checked,
role: 'checkbox',
tabIndex: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be sure, we should not add any attribute if the checkbox is disabled?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://www.w3.org/TR/wai-aria-practices/examples/checkbox/checkbox-1/checkbox-1.html

I don't see this in the spec, so decided to skip for the initial implementation

className={classes.root}
onClick={this.handleClick}
onChange={this.handleChange}
onFocus={this.handleFocus}
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this the thing missing for the focus styles? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep :) No IDE highlight 😭

@layershifter layershifter merged commit dfd26e5 into master Jun 3, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/checkbox branch June 3, 2019 13:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I am missing a checkbox component.
2 participants