Skip to content

Commit

Permalink
chore: Moves Fade component into TableElement (#13458)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Apr 8, 2021
1 parent b5e5b3a commit 784d29b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { supersetTheme, ThemeProvider } from '@superset-ui/core';
import Collapse from 'src/common/components/Collapse';

import { IconTooltip } from 'src/components/IconTooltip';
import Fade from 'src/common/components/Fade';
import TableElement from 'src/SqlLab/components/TableElement';
import ColumnElement from 'src/SqlLab/components/ColumnElement';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
Expand Down Expand Up @@ -88,11 +87,15 @@ describe('TableElement', () => {
},
);
expect(wrapper.find(TableElement).state().hovered).toBe(false);
expect(wrapper.find(Fade).props().hovered).toBe(false);
expect(wrapper.find('[data-test="fade"]').first().props().hovered).toBe(
false,
);
wrapper.find('.header-container').hostNodes().simulate('mouseEnter');
await waitForComponentToPaint(wrapper, 300);
expect(wrapper.find(TableElement).state().hovered).toBe(true);
expect(wrapper.find(Fade).props().hovered).toBe(true);
expect(wrapper.find('[data-test="fade"]').first().props().hovered).toBe(
true,
);
});
it('sorts columns', () => {
const wrapper = mount(
Expand Down
7 changes: 6 additions & 1 deletion superset-frontend/src/SqlLab/components/TableElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import shortid from 'shortid';
import { t, styled } from '@superset-ui/core';
import { debounce } from 'lodash';

import Fade from 'src/common/components/Fade';
import { Tooltip } from 'src/common/components/Tooltip';
import CopyToClipboard from '../../components/CopyToClipboard';
import { IconTooltip } from '../../components/IconTooltip';
Expand All @@ -52,6 +51,11 @@ const StyledSpan = styled.span`
cursor: pointer;
`;

const Fade = styled.div`
transition: all ${({ theme }) => theme.transitionTiming}s;
opacity: ${props => (props.hovered ? 1 : 0)};
`;

class TableElement extends React.PureComponent {
constructor(props) {
super(props);
Expand Down Expand Up @@ -215,6 +219,7 @@ class TableElement extends React.PureComponent {
<Loading position="inline" />
) : (
<Fade
data-test="fade"
hovered={this.state.hovered}
onClick={e => e.stopPropagation()}
>
Expand Down
28 changes: 0 additions & 28 deletions superset-frontend/src/common/components/Fade.tsx

This file was deleted.

0 comments on commit 784d29b

Please sign in to comment.