Skip to content

Commit

Permalink
refactor: icon to icons for inderteminatecheckbox icon (apache#15397)
Browse files Browse the repository at this point in the history
* initial commit

* fix cypress tests

* Update superset-frontend/src/components/IndeterminateCheckbox/index.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

* Update index.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
  • Loading branch information
2 people authored and cccs-RyanS committed Dec 17, 2021
1 parent 2c256c9 commit 10a9c6d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Expand Up @@ -51,11 +51,11 @@ describe('chart list view', () => {
it('should bulk delete correctly', () => {
cy.get('[data-test="listview-table"]').should('be.visible');
cy.get('[data-test="bulk-select"]').eq(0).click();
cy.get('[data-test="checkbox-off"]').eq(1).siblings('input').click();
cy.get('[data-test="checkbox-off"]').eq(2).siblings('input').click();
cy.get('[aria-label="checkbox-off"]').eq(1).siblings('input').click();
cy.get('[aria-label="checkbox-off"]').eq(2).siblings('input').click();
cy.get('[data-test="bulk-select-action"]').eq(0).click();
cy.get('[data-test="delete-modal-input"]').eq(0).type('DELETE');
cy.get('[data-test="modal-confirm-button"]').eq(0).click();
cy.get('[data-test="checkbox-on"]').should('not.exist');
cy.get('[aria-label="checkbox-on"]').should('not.exist');
});
});
Expand Up @@ -51,11 +51,11 @@ describe('dashboard list view', () => {
it('should bulk delete correctly', () => {
cy.get('[data-test="listview-table"]').should('be.visible');
cy.get('[data-test="bulk-select"]').eq(0).click();
cy.get('[data-test="checkbox-off"]').eq(1).siblings('input').click();
cy.get('[data-test="checkbox-off"]').eq(2).siblings('input').click();
cy.get('[aria-label="checkbox-off"]').eq(1).siblings('input').click();
cy.get('[aria-label="checkbox-off"]').eq(2).siblings('input').click();
cy.get('[data-test="bulk-select-action"]').eq(0).click();
cy.get('[data-test="delete-modal-input"]').eq(0).type('DELETE');
cy.get('[data-test="modal-confirm-button"]').eq(0).click();
cy.get('[data-test="checkbox-on"]').should('not.exist');
cy.get('[aria-label="checkbox-on"]').should('not.exist');
});
});
22 changes: 16 additions & 6 deletions superset-frontend/src/components/IndeterminateCheckbox/index.tsx
Expand Up @@ -18,7 +18,7 @@
*/
import React from 'react';
import { styled } from '@superset-ui/core';
import Icon from 'src/components/Icon';
import Icons from 'src/components/Icons';

export interface IndeterminateCheckboxProps {
indeterminate: boolean;
Expand All @@ -35,8 +35,18 @@ const CheckboxLabel = styled.label`
margin-bottom: 0;
`;

const IconWithColor = styled(Icon)`
color: ${({ theme }) => theme.colors.primary.dark1};
const CheckboxHalf = styled(Icons.CheckboxHalf)`
color: ${({ theme }) => theme.colors.primary.base};
cursor: pointer;
`;

const CheckboxOff = styled(Icons.CheckboxOff)`
color: ${({ theme }) => theme.colors.grayscale.base};
cursor: pointer;
`;

const CheckboxOn = styled(Icons.CheckboxOn)`
color: ${({ theme }) => theme.colors.primary.base};
cursor: pointer;
`;

Expand Down Expand Up @@ -79,9 +89,9 @@ const IndeterminateCheckbox = React.forwardRef(
return (
<>
<InputContainer>
{indeterminate && <IconWithColor name="checkbox-half" />}
{!indeterminate && checked && <IconWithColor name="checkbox-on" />}
{!indeterminate && !checked && <Icon name="checkbox-off" />}
{indeterminate && <CheckboxHalf />}
{!indeterminate && checked && <CheckboxOn />}
{!indeterminate && !checked && <CheckboxOff />}
<HiddenInput
name={id}
id={id}
Expand Down

0 comments on commit 10a9c6d

Please sign in to comment.