Skip to content

Commit d843fef

Browse files
authored
fix(theming): More theming bugs/regressions (apache#34507)
1 parent f45654c commit d843fef

File tree

33 files changed

+177
-193
lines changed

33 files changed

+177
-193
lines changed

superset-frontend/cypress-base/cypress/e2e/dashboard/horizontalFilterBar.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe('Horizontal FilterBar', () => {
155155
]);
156156
setFilterBarOrientation('horizontal');
157157

158-
cy.get('.filter-item-wrapper').should('have.length', 3);
158+
cy.get('.filter-item-wrapper').should('have.length', 4);
159159
openMoreFilters();
160160
cy.getBySel('form-item-value').should('have.length', 12);
161161
cy.getBySel('filter-control-name').contains('test_3').should('be.visible');

superset-frontend/packages/superset-ui-core/src/components/Badge/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const Badge = styled((props: BadgeProps) => <AntdBadge {...props} />)`
2424
${({ theme, color, count }) => `
2525
& > sup,
2626
& > sup.ant-badge-count {
27+
box-shadow: none;
2728
${
2829
count !== undefined ? `background: ${color || theme.colorPrimary};` : ''
2930
}

superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/index.tsx

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -17,96 +17,23 @@
1717
* under the License.
1818
*/
1919
import {
20-
CSSProperties,
2120
cloneElement,
2221
forwardRef,
23-
ReactElement,
2422
RefObject,
2523
useEffect,
2624
useImperativeHandle,
2725
useLayoutEffect,
2826
useMemo,
2927
useState,
3028
useRef,
31-
ReactNode,
3229
useCallback,
3330
} from 'react';
3431

3532
import { Global } from '@emotion/react';
3633
import { css, t, useTheme, usePrevious } from '@superset-ui/core';
3734
import { useResizeDetector } from 'react-resize-detector';
3835
import { Badge, Icons, Button, Tooltip, Popover } from '..';
39-
/**
40-
* Container item.
41-
*/
42-
export interface DropdownItem {
43-
/**
44-
* String that uniquely identifies the item.
45-
*/
46-
id: string;
47-
/**
48-
* The element to be rendered.
49-
*/
50-
element: ReactElement;
51-
}
52-
53-
/**
54-
* Horizontal container that displays overflowed items in a dropdown.
55-
* It shows an indicator of how many items are currently overflowing.
56-
*/
57-
export interface DropdownContainerProps {
58-
/**
59-
* Array of items. The id property is used to uniquely identify
60-
* the elements when rendering or dealing with event handlers.
61-
*/
62-
items: DropdownItem[];
63-
/**
64-
* Event handler called every time an element moves between
65-
* main container and dropdown.
66-
*/
67-
onOverflowingStateChange?: (overflowingState: {
68-
notOverflowed: string[];
69-
overflowed: string[];
70-
}) => void;
71-
/**
72-
* Option to customize the content of the dropdown.
73-
*/
74-
dropdownContent?: (overflowedItems: DropdownItem[]) => ReactElement;
75-
/**
76-
* Dropdown ref.
77-
*/
78-
dropdownRef?: RefObject<HTMLDivElement>;
79-
/**
80-
* Dropdown additional style properties.
81-
*/
82-
dropdownStyle?: CSSProperties;
83-
/**
84-
* Displayed count in the dropdown trigger.
85-
*/
86-
dropdownTriggerCount?: number;
87-
/**
88-
* Icon of the dropdown trigger.
89-
*/
90-
dropdownTriggerIcon?: ReactElement;
91-
/**
92-
* Text of the dropdown trigger.
93-
*/
94-
dropdownTriggerText?: string;
95-
/**
96-
* Text of the dropdown trigger tooltip
97-
*/
98-
dropdownTriggerTooltip?: ReactNode | null;
99-
/**
100-
* Main container additional style properties.
101-
*/
102-
style?: CSSProperties;
103-
/**
104-
* Force render popover content before it's first opened
105-
*/
106-
forceRender?: boolean;
107-
}
108-
109-
export type DropdownRef = HTMLDivElement & { open: () => void };
36+
import { DropdownContainerProps, DropdownItem, DropdownRef } from './types';
11037

11138
const MAX_HEIGHT = 500;
11239

@@ -428,8 +355,13 @@ export const DropdownContainer = forwardRef(
428355
<Button
429356
buttonStyle="secondary"
430357
data-test="dropdown-container-btn"
358+
icon={dropdownTriggerIcon}
359+
css={css`
360+
padding-left: ${theme.paddingXS}px;
361+
padding-right: ${theme.paddingXXS}px;
362+
gap: ${theme.sizeXXS}px;
363+
`}
431364
>
432-
{dropdownTriggerIcon}
433365
{dropdownTriggerText}
434366
<Badge
435367
count={dropdownTriggerCount ?? overflowingCount}
@@ -461,3 +393,5 @@ export const DropdownContainer = forwardRef(
461393
);
462394
},
463395
);
396+
397+
export { DropdownItem, DropdownContainerProps, DropdownRef } from './types';

superset-frontend/packages/superset-ui-core/src/components/DropdownContainer/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919
import type { CSSProperties, ReactElement, RefObject, ReactNode } from 'react';
20+
import { IconType } from '../Icons';
2021

2122
/**
2223
* Container item.
@@ -69,7 +70,7 @@ export interface DropdownContainerProps {
6970
/**
7071
* Icon of the dropdown trigger.
7172
*/
72-
dropdownTriggerIcon?: ReactElement;
73+
dropdownTriggerIcon?: IconType;
7374
/**
7475
* Text of the dropdown trigger.
7576
*/

superset-frontend/packages/superset-ui-core/src/components/Select/styles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ export const StyledHeader = styled.span<{ headerPosition: string }>`
3232
`;
3333

3434
export const StyledContainer = styled.div<{ headerPosition: string }>`
35-
${({ headerPosition }) => `
35+
${({ headerPosition, theme }) => `
3636
display: flex;
37+
gap: ${theme.sizeUnit}px;
3738
flex-direction: ${headerPosition === 'top' ? 'column' : 'row'};
3839
align-items: ${headerPosition === 'left' ? 'center' : undefined};
3940
width: 100%;

superset-frontend/packages/superset-ui-core/src/components/TableCollection/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ interface TableCollectionProps<T extends object> {
5252
const StyledTable = styled(Table)`
5353
${({ theme }) => `
5454
th.ant-column-cell {
55-
min-width: fit-content;
55+
overflow: hidden;
56+
text-overflow: ellipsis;
57+
white-space: nowrap;
5658
}
5759
.actions {
5860
opacity: 0;
@@ -83,7 +85,6 @@ const StyledTable = styled(Table)`
8385
font-feature-settings: 'tnum' 1;
8486
text-overflow: ellipsis;
8587
overflow: hidden;
86-
max-width: 320px;
8788
line-height: 1;
8889
vertical-align: middle;
8990
padding-left: ${theme.sizeUnit * 4}px;
@@ -149,7 +150,7 @@ function TableCollection<T extends object>({
149150
size={size}
150151
data-test="listview-table"
151152
pagination={false}
152-
tableLayout="auto"
153+
tableLayout="fixed"
153154
rowKey="rowId"
154155
rowSelection={rowSelection}
155156
locale={{ emptyText: null }}

superset-frontend/packages/superset-ui-core/src/components/TableCollection/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function mapColumns<T extends object>(
9494
dataIndex: column.id?.includes('.') ? column.id.split('.') : column.id,
9595
hidden: column.hidden,
9696
key: column.id,
97-
minWidth: column.size ? COLUMN_SIZE_MAP[column.size] : COLUMN_SIZE_MAP.md,
97+
width: column.size ? COLUMN_SIZE_MAP[column.size] : COLUMN_SIZE_MAP.md,
9898
ellipsis: !columnsForWrapText?.includes(column.id),
9999
defaultSortOrder: (isSorted
100100
? isSortedDesc

superset-frontend/src/SqlLab/components/RunQueryActionButton/index.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { useMemo, FC, ReactElement } from 'react';
2121
import { t, styled, useTheme, SupersetTheme } from '@superset-ui/core';
2222

2323
import { Button, DropdownButton } from '@superset-ui/core/components';
24-
import { Icons } from '@superset-ui/core/components/Icons';
24+
import { IconType, Icons } from '@superset-ui/core/components/Icons';
2525
import { detectOS } from 'src/utils/common';
2626
import { QueryButtonProps } from 'src/SqlLab/types';
2727
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
@@ -40,23 +40,24 @@ export interface RunQueryActionButtonProps {
4040
overlayCreateAsMenu: ReactElement | null;
4141
}
4242

43-
const buildText = (
43+
const buildTextAndIcon = (
4444
shouldShowStopButton: boolean,
4545
selectedText: string | undefined,
4646
theme: SupersetTheme,
47-
): string | JSX.Element => {
48-
if (shouldShowStopButton) {
49-
return (
50-
<>
51-
<Icons.Square iconSize="xs" iconColor={theme.colorIcon} />
52-
{t('Stop')}
53-
</>
54-
);
55-
}
47+
): { text: string; icon?: IconType } => {
48+
let text = t('Run');
49+
let icon: IconType | undefined;
5650
if (selectedText) {
57-
return t('Run selection');
51+
text = t('Run selection');
52+
}
53+
if (shouldShowStopButton) {
54+
text = t('Stop');
55+
icon = <Icons.Square iconSize="xs" iconColor={theme.colorIcon} />;
5856
}
59-
return t('Run');
57+
return {
58+
text,
59+
icon,
60+
};
6061
};
6162

6263
const onClick = (
@@ -130,6 +131,11 @@ const RunQueryActionButton = ({
130131
[userOS],
131132
);
132133

134+
const { text, icon } = useMemo(
135+
() => buildTextAndIcon(shouldShowStopBtn, selectedText, theme),
136+
[shouldShowStopBtn, selectedText, theme],
137+
);
138+
133139
return (
134140
<StyledButton>
135141
<ButtonComponent
@@ -159,9 +165,10 @@ const RunQueryActionButton = ({
159165
}
160166
: {
161167
buttonStyle: shouldShowStopBtn ? 'danger' : 'primary',
168+
icon,
162169
})}
163170
>
164-
{buildText(shouldShowStopBtn, selectedText, theme)}
171+
{text}
165172
</ButtonComponent>
166173
</StyledButton>
167174
);

superset-frontend/src/components/Datasource/Field.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ import {
2626
FormLabel,
2727
} from '@superset-ui/core/components';
2828

29-
const formItemInlineCss = css`
30-
.ant-form-item-control-input-content {
31-
display: flex;
32-
flex-direction: row;
33-
}
34-
`;
3529
interface FieldProps<V> {
3630
fieldKey: string;
3731
value?: V;
@@ -64,10 +58,6 @@ export default function Field<V>({
6458
[onChange, fieldKey],
6559
);
6660

67-
const hookedControl = cloneElement(control, {
68-
value,
69-
onChange: onControlChange,
70-
});
7161
const theme = useTheme();
7262
const extra = !compact && description ? description : undefined;
7363
const infoTooltip =
@@ -83,13 +73,24 @@ export default function Field<V>({
8373
<Icons.InfoCircleOutlined
8474
iconSize="s"
8575
css={css`
86-
margin-left: ${theme.sizeUnit}px;
76+
margin-left: ${theme.marginXXS}px;
8777
`}
8878
iconColor={theme.colorTextTertiary}
8979
/>
9080
</Tooltip>
9181
) : undefined;
9282

83+
const hookedControl = cloneElement(control, {
84+
value,
85+
onChange: onControlChange,
86+
label: (
87+
<FormLabel>
88+
{label || fieldKey}
89+
{infoTooltip}
90+
</FormLabel>
91+
),
92+
});
93+
9394
return (
9495
<div
9596
css={
@@ -101,22 +102,23 @@ export default function Field<V>({
101102
>
102103
{additionalControl}
103104
<FormItem
104-
label={
105-
<FormLabel>
106-
{label || fieldKey}
107-
{infoTooltip}
108-
</FormLabel>
109-
}
110-
css={inline && formItemInlineCss}
111105
extra={extra}
106+
css={
107+
!inline &&
108+
css`
109+
.ControlHeader {
110+
margin-bottom: ${theme.marginXXS}px;
111+
}
112+
`
113+
}
112114
>
113115
{hookedControl}
114116
</FormItem>
115117
{errorMessage && (
116118
<div
117119
css={(theme: SupersetTheme) => ({
118120
color: theme.colorText,
119-
[inline ? 'marginLeft' : 'marginTop']: theme.sizeUnit,
121+
[inline ? 'marginLeft' : 'marginTop']: theme.marginXXS,
120122
})}
121123
>
122124
{errorMessage}

superset-frontend/src/components/Datasource/Fieldset.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { ReactNode, useCallback } from 'react';
2020
import { Divider, Form, Typography } from '@superset-ui/core/components';
21+
import { css } from '@superset-ui/core';
2122
import { recurseReactClone } from './utils';
2223
import Field from './Field';
2324

@@ -57,7 +58,12 @@ export default function Fieldset({
5758
return (
5859
<Form className="CRUD" layout="vertical">
5960
{title && (
60-
<Typography.Title level={5}>
61+
<Typography.Title
62+
level={5}
63+
css={css`
64+
margin-top: 0.5em;
65+
`}
66+
>
6167
{title} <Divider />
6268
</Typography.Title>
6369
)}

0 commit comments

Comments
 (0)