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

More Label touchups (margins) #10722

Merged
merged 4 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/LimitControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class LimitControl extends React.PureComponent<
render() {
return (
<div>
<Label className="pointer" onClick={this.handleToggle}>
<Label onClick={this.handleToggle}>
LIMIT {this.props.value || this.props.maxRow}
</Label>
<Overlay
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/CachedLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CacheLabel extends React.PureComponent {
return (
<TooltipWrapper tooltip={this.state.tooltipContent} label="cache-desc">
<Label
className={`${this.props.className} m-r-5 pointer`}
className={`${this.props.className}`}
bsStyle={labelStyle}
onClick={this.props.onClick}
onMouseOver={this.mouseOver.bind(this)}
Expand Down
7 changes: 1 addition & 6 deletions superset-frontend/src/components/Label/Label.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ export const bsStyleKnob = {
export const LabelGallery = () => (
<>
{Object.values(bsStyleKnob.options).map(opt => (
<Label
key={opt}
bsStyle={opt}
style={{ marginRight: '10px' }}
onClick={action('clicked')}
>
<Label key={opt} bsStyle={opt} onClick={action('clicked')}>
{`style: "${opt}"`}
</Label>
))}
Expand Down
20 changes: 17 additions & 3 deletions superset-frontend/src/components/Label/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import React from 'react';
import { Label as BootstrapLabel } from 'react-bootstrap';
import styled from '@superset-ui/style';
import cx from 'classnames';

export type OnClickHandler = React.MouseEventHandler<BootstrapLabel>;

export interface LabelProps {
key?: string;
className?: string;
id?: string;
tooltip?: string;
placement?: string;
onClick?: OnClickHandler;
Expand All @@ -34,6 +36,15 @@ export interface LabelProps {
}

const SupersetLabel = styled(BootstrapLabel)`
/* un-bunch them! */
margin-right: ${({ theme }) => theme.gridUnit}px;
&:first-of-type {
margin-left: 0;
}
&:last-of-type {
margin-right: 0;
}

cursor: ${({ onClick }) => (onClick ? 'pointer' : 'default')};
transition: background-color ${({ theme }) => theme.transitionTiming}s;
&.label-warning {
Expand Down Expand Up @@ -103,9 +114,12 @@ export default function Label(props: LabelProps) {
bsStyle: officialBootstrapStyles.includes(props.bsStyle || '')
? props.bsStyle
: 'default',
className: officialBootstrapStyles.includes(props.bsStyle || '')
? undefined
: `label-${props.bsStyle}`,
className: cx({
[`${props.className}`]: props.className,
rusackas marked this conversation as resolved.
Show resolved Hide resolved
[`label-${props.bsStyle}`]: !officialBootstrapStyles.includes(
props.bsStyle || '',
),
}),
};
return <SupersetLabel {...labelProps}>{props.children}</SupersetLabel>;
}
4 changes: 1 addition & 3 deletions superset-frontend/src/components/TableSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ export default class TableSelector extends React.PureComponent {
renderDatabaseOption(db) {
return (
<span title={db.database_name}>
<Label bsStyle="default" className="m-r-5">
{db.backend}
</Label>
<Label bsStyle="default">{db.backend}</Label>
{db.database_name}
</span>
);
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/components/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React, { useEffect, useState } from 'react';
import { Label } from 'react-bootstrap';
import Label from 'src/components/Label';

import { now, fDuration } from '../modules/dates';

Expand Down Expand Up @@ -73,7 +73,7 @@ export default function Timer({
});

return (
<Label id="timer" className="m-r-5" bsStyle={status}>
<Label id="timer" bsStyle={status}>
{clockStr}
</Label>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ const StyledHeader = styled.div`
align-items: center;
justify-content: flex-end;

.btn-group {
> .btn-group {
flex: 0 0 auto;
margin-left: ${({ theme }) => theme.gridUnit}px;
}
}
`;
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/explore/components/RowCountLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function RowCountLabel({ rowcount, limit, suffix }) {
);
return (
<TooltipWrapper label="tt-rowcount" tooltip={tooltip}>
<Label bsStyle={bsStyle} className="m-r-5 pointer">
<Label bsStyle={bsStyle}>
{formattedRowCount} {suffix}
</Label>
</TooltipWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class FixedOrMetricControl extends React.Component {
return (
<div>
<ControlHeader {...this.props} />
<Label className="pointer" onClick={this.toggle}>
<Label onClick={this.toggle}>
{this.state.type === controlTypes.fixed && (
<span>{this.state.fixedValue}</span>
)}
Expand Down