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

Fixing positioning of loading spinner in widget header. #11258

Merged
merged 2 commits into from Sep 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css, DefaultTheme } from 'styled-components';
import styled, { css } from 'styled-components';

import { Spinner, Icon } from 'components/common';
import EditableTitle from 'views/components/common/EditableTitle';
Expand All @@ -27,15 +27,20 @@ const LoadingSpinner = styled(Spinner)`
margin-left: 10px;
`;

const Container = styled.div(({ theme, $hideDragHandle }: {theme: DefaultTheme, $hideDragHandle: boolean }) => css`
const Container = styled.div(({ theme }) => css`
font-size: ${theme.fonts.size.large};
text-overflow: ellipsis;
margin-bottom: 5px;
display: grid;
grid-template-columns: ${$hideDragHandle ? 'minmax(20px, auto) max-content' : 'max-content minmax(20px, auto) max-content'};
grid-template-columns: minmax(35px, 1fr) max-content;
align-items: center;
`);

const Col = styled.div`
display: flex;
align-items: center;
`;

const WidgetDragHandle = styled(Icon)`
cursor: move;
opacity: 0.3;
Expand All @@ -55,11 +60,13 @@ type Props = {
};

const WidgetHeader = ({ children, onRename, hideDragHandle, title, loading }: Props) => (
<Container $hideDragHandle={hideDragHandle}>
{hideDragHandle || <WidgetDragHandle name="bars" className="widget-drag-handle" />}
<EditableTitle key={title} disabled={!onRename} value={title} onChange={onRename} />
{loading && <LoadingSpinner text="" delay={0} />}
<WidgetActionDropdown className="pull-right">
<Container>
<Col>
{hideDragHandle || <WidgetDragHandle name="bars" className="widget-drag-handle" />}
<EditableTitle key={title} disabled={!onRename} value={title} onChange={onRename} />
{loading && <LoadingSpinner text="" delay={0} />}
</Col>
<WidgetActionDropdown>
{children}
</WidgetActionDropdown>
</Container>
Expand Down