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

Checkbox component #27

Closed
wants to merge 8 commits into from
Closed

Conversation

Hasmik8
Copy link
Contributor

@Hasmik8 Hasmik8 commented Oct 19, 2020

Description
I've created checkbox component, which has two props: checked and disabled, which are boolean parameteres.

View
Снимок экрана от 2020-10-19 14-32-30
Снимок экрана от 2020-10-19 14-34-02
Снимок экрана от 2020-10-19 14-34-12

@S-ayanide
Copy link
Contributor

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.

@S-ayanide S-ayanide linked an issue Oct 20, 2020 that may be closed by this pull request
@AVRahul
Copy link
Contributor

AVRahul commented Oct 21, 2020

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.

@Hasmik8 Hasmik8 added the enhancement New feature or request label Oct 21, 2020
src/core/CheckBox/base.ts Outdated Show resolved Hide resolved
src/core/CheckBox/CheckBox/styles.ts Outdated Show resolved Hide resolved
src/core/CheckBox/CheckBox/__tests__/CheckBox.test.tsx Outdated Show resolved Hide resolved
Signed-off-by: Hasmik8 <[email protected]>
@codesniffy
Copy link

codesniffy bot commented Oct 22, 2020

package.json has been modified

);
let checkbox = getByTestId('checkbox') as HTMLInputElement;
fireEvent.click(checkbox);
expect(checkbox.checked).toBeFalsy();
Copy link
Contributor

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]>
@codesniffy
Copy link

codesniffy bot commented Oct 23, 2020

package.json has been modified

Signed-off-by: Hasmik8 <[email protected]>
Signed-off-by: Hasmik8 <[email protected]>
@codesniffy
Copy link

codesniffy bot commented Oct 26, 2020

package.json has been modified

@@ -0,0 +1,28 @@
import { Checkbox } from '@material-ui/core';
import React, { useState } from 'react';
// import clsx from 'clsx';
Copy link
Contributor

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!

Comment on lines 8 to 10
interface CheckBoxProps extends BaseCheckboxProps {
checked: boolean;
}
Copy link
Contributor

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

checked: boolean;
}

const CheckBox: React.FC<CheckBoxProps> = ({ disabled, checked }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const CheckBox: React.FC<CheckBoxProps> = ({ disabled, checked }) => {
const CheckBox: React.FC = ({ disabled, checked }) => {

Comment on lines 1 to 3
import { CheckboxProps } from '@material-ui/core/Checkbox';

export type BaseCheckboxProps = Omit<CheckboxProps, 'checked'>;
Copy link
Contributor

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.

checkedIcon={<CheckOutlinedIcon />}
disabled={disabled}
checked={check}
icon={<span></span>}
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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?

checkedIcon={<CheckOutlinedIcon />}
disabled={disabled}
checked={check}
icon={<span></span>}
Copy link
Contributor

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?

@Hasmik8
Copy link
Contributor Author

Hasmik8 commented Oct 29, 2020

@S-ayanide
icon parameter is empty, I can add CSS code for it to work.

Signed-off-by: Hasmik8 <[email protected]>
checkedIcon={<CheckOutlinedIcon />}
disabled={disabled}
checked={check}
onChange={() => setChecked(!check)}
Copy link
Contributor

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

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CC: Checkbox
4 participants