-
Notifications
You must be signed in to change notification settings - Fork 11
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
Checkbox component #27
Conversation
Can you please resolve the DeepScan issues and also update your branch to the latest which has Kubera Portal and Kuber Core themes too. Also, update your stories accordingly. |
c2ccb79
to
d7301c9
Compare
d7301c9
to
f8206c9
Compare
Based on the displayed screenshots, In the mentioned issue #11 there were more states present like Inactive, Active, hover, etc. Please check the Figma design once. |
Signed-off-by: Hasmik8 <[email protected]>
package.json has been modified |
); | ||
let checkbox = getByTestId('checkbox') as HTMLInputElement; | ||
fireEvent.click(checkbox); | ||
expect(checkbox.checked).toBeFalsy(); |
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.
how come if the initial value is false....after clicking it becomes false again (toBeFalsy)
Can you explain the test cases in the comments on what is being done...
I might have misunderstood it too...apologies for that...if that's the case...but regardless explanation for test cases is good
Signed-off-by: Hasmik8 <[email protected]>
package.json has been modified |
Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
package.json has been modified |
src/core/CheckBox/CheckBox.tsx
Outdated
@@ -0,0 +1,28 @@ | |||
import { Checkbox } from '@material-ui/core'; | |||
import React, { useState } from 'react'; | |||
// import clsx from 'clsx'; |
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 you please remove commented lines!
src/core/CheckBox/CheckBox.tsx
Outdated
interface CheckBoxProps extends BaseCheckboxProps { | ||
checked: boolean; | ||
} |
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.
Checkbox API already provides checked
thus there is no requirement of creating it again. The API
src/core/CheckBox/CheckBox.tsx
Outdated
checked: boolean; | ||
} | ||
|
||
const CheckBox: React.FC<CheckBoxProps> = ({ disabled, checked }) => { |
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.
const CheckBox: React.FC<CheckBoxProps> = ({ disabled, checked }) => { | |
const CheckBox: React.FC = ({ disabled, checked }) => { |
src/core/CheckBox/base.ts
Outdated
import { CheckboxProps } from '@material-ui/core/Checkbox'; | ||
|
||
export type BaseCheckboxProps = Omit<CheckboxProps, 'checked'>; |
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.
Here checked
is Omitted but again declared as a type in checkbox.tsx
. If we need checked
there is no need to Omit it.
This base.ts
file is not required.
src/core/CheckBox/CheckBox.tsx
Outdated
checkedIcon={<CheckOutlinedIcon />} | ||
disabled={disabled} | ||
checked={check} | ||
icon={<span></span>} |
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 is not required. It's an empty span.
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.
@S-ayanide This icon appears when checkbox is unchecked and when I delete that icon design breaks,this empty span is required
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.
I think there is a way around. if you take a look at the third checkbox from Basic Checkbox
here you'll find they don't use icons as a parameter at all still you can check and uncheck without breaking the design.
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 have a workaround for this icon
parameter! Did the above reference help?
Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
src/core/CheckBox/CheckBox.tsx
Outdated
checkedIcon={<CheckOutlinedIcon />} | ||
disabled={disabled} | ||
checked={check} | ||
icon={<span></span>} |
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 have a workaround for this icon
parameter! Did the above reference help?
@S-ayanide |
Signed-off-by: Hasmik8 <[email protected]>
checkedIcon={<CheckOutlinedIcon />} | ||
disabled={disabled} | ||
checked={check} | ||
onChange={() => setChecked(!check)} |
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.
With this change if I pass Checkbox check={true}
and mutate the state here then checkbox would be unchecked but the place where we have implemented it still would remain true
which is a loophole
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.
@S-ayanide When passing the checkox checked paraemeter=true via props, then checkbox is being checked and when clicking on the checkbox, it becomes unchecked. And vica versa. If there is an issue, let me know pls
Description
I've created checkbox component, which has two props: checked and disabled, which are boolean parameteres.
View