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

style: fix checkbox color #10970

Merged
merged 3 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import React from 'react';
import sinon from 'sinon';
import { shallow, mount } from 'enzyme';

import { supersetTheme, ThemeProvider } from '@superset-ui/core';

import CheckboxControl from 'src/explore/components/controls/CheckboxControl';
import ControlHeader from 'src/explore/components/ControlHeader';
import Checkbox from 'src/components/Checkbox';
Expand Down Expand Up @@ -48,7 +50,10 @@ describe('CheckboxControl', () => {
});

it('Checks the box when the label is clicked', () => {
const fullComponent = mount(<CheckboxControl {...defaultProps} />);
const fullComponent = mount(<CheckboxControl {...defaultProps} />, {
wrappingComponent: ThemeProvider,
wrappingComponentProps: { theme: supersetTheme },
});

const spy = sinon.spy(fullComponent.instance(), 'onChange');

Expand Down
11 changes: 9 additions & 2 deletions superset-frontend/src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ interface CheckboxProps {
}

const Styles = styled.span`
&,
& svg {
cursor: pointer;
&.primary {
color: ${({ theme }) => theme.colors.primary.base};
}
&.grayscale {
color: ${({ theme }) => theme.colors.grayscale.light1};
}
svg {
vertical-align: top;
}
`;

export default function Checkbox({ checked, onChange, style }: CheckboxProps) {
return (
<Styles
className={checked ? 'primary' : 'grayscale'}
style={style}
onClick={() => {
onChange(!checked);
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/src/components/CheckboxIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const CheckboxChecked = () => (
>
<path
d="M16 0H2C0.89 0 0 0.9 0 2V16C0 17.1 0.89 18 2 18H16C17.11 18 18 17.1 18 16V2C18 0.9 17.11 0 16 0Z"
fill="#00A699"
fill="currentColor"
/>
<path d="M7 14L2 9L3.41 7.59L7 11.17L14.59 3.58L16 5L7 14Z" fill="white" />
</svg>
Expand All @@ -44,7 +44,7 @@ export const CheckboxHalfChecked = () => (
>
<path
d="M16 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H16C17.1 18 18 17.1 18 16V2C18 0.9 17.1 0 16 0Z"
fill="#999999"
fill="currentColor"
/>
<path d="M14 10H4V8H14V10Z" fill="white" />
</svg>
Expand All @@ -60,7 +60,7 @@ export const CheckboxUnchecked = () => (
>
<path
d="M16 0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H16C17.1 18 18 17.1 18 16V2C18 0.9 17.1 0 16 0Z"
fill="#CCCCCC"
fill="currentColor"
/>
<path d="M16 2V16H2V2H16V2Z" fill="white" />
</svg>
Expand Down