msyavuz commented on code in PR #32980:
URL: https://github.com/apache/superset/pull/32980#discussion_r2026982252
##########
superset-frontend/src/components/Checkbox/Checkbox.tsx:
##########
@@ -16,43 +16,29 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { CSSProperties } from 'react';
-import { styled } from '@superset-ui/core';
-import { CheckboxChecked, CheckboxUnchecked } from 'src/components/Checkbox';
+import { Checkbox as AntCheckbox } from 'antd-v5';
+import { ReactNode } from 'react';
export interface CheckboxProps {
checked: boolean;
onChange: (val?: boolean) => void;
- style?: CSSProperties;
- className?: string;
+ disabled?: boolean;
+ children?: ReactNode;
}
-const Styles = styled.span`
- &,
- & svg {
- vertical-align: top;
- }
-`;
-
export default function Checkbox({
checked,
onChange,
- style,
- className,
+ disabled,
+ children,
}: CheckboxProps) {
return (
- <Styles
- style={style}
- onClick={() => {
- onChange(!checked);
- }}
- role="checkbox"
- tabIndex={0}
- aria-checked={checked}
- aria-label="Checkbox"
- className={className || ''}
+ <AntCheckbox
+ checked={checked}
+ onChange={e => onChange(e.target.checked)}
+ disabled={disabled}
Review Comment:
Maybe we can use AntCheckbox as it is with it's props instead? Something
like:
```
const Checkbox = AntCheckbox;
```
That would mean no modifications needed for usages as well.
##########
superset-frontend/src/components/IndeterminateCheckbox/index.tsx:
##########
@@ -96,25 +58,17 @@ const IndeterminateCheckbox = forwardRef(
}, [resolvedRef, indeterminate]);
return (
- <>
- <InputContainer>
- {indeterminate && <CheckboxHalf />}
- {!indeterminate && checked && <CheckboxOn />}
- {!indeterminate && !checked && <CheckboxOff />}
- <HiddenInput
- name={id}
- id={id}
- type="checkbox"
- ref={resolvedRef}
- checked={checked}
- onChange={onChange}
- {...rest}
- />
- </InputContainer>
- <CheckboxLabel title={title} htmlFor={id}>
- {labelText}
- </CheckboxLabel>
- </>
+ <Checkbox
+ id={id}
+ checked={checked}
+ indeterminate={indeterminate}
+ onChange={onChange}
+ disabled={disabled}
+ ref={resolvedRef}
+ {...rest}
+ >
+ {labelText}
+ </Checkbox>
Review Comment:
Maybe we can consolidate this with the Checkbox since the only difference is
the indeterminate prop?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]