Skip to content

Commit 24dc674

Browse files
committed
fix: table support dark theme
1 parent 6301559 commit 24dc674

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

src/components/editor_panel/editor_panel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ export const EditorPanel = (props) => {
2424
const onEditorDidMount: OnMount = (editor, monaco) => {
2525
editorRef.current = editor;
2626
const bgColor = rgba2hex(color.bgCommonLower);
27+
const errorColor = rgba2hex(color.bgDangerDefault);
2728
monaco.editor.defineTheme("customTheme", {
2829
base: monacoTheme,
2930
inherit: true,
3031
rules: [{ background: bgColor, token: "" }],
3132
colors: {
3233
"editor.background": bgColor,
34+
"editorError.foreground": errorColor,
3335
},
3436
});
3537
monaco.editor.setTheme("customTheme");
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import styled, { css } from 'styled-components';
3+
import { BaseTable, BaseTableProps } from 'ali-react-table';
4+
import { ThemeName, deepPurple, getThemeName } from '@apitable/components';
5+
import { applyDefaultTheme } from '../utils';
6+
7+
const ThemeBaseTable: any = styled(BaseTable).attrs(applyDefaultTheme)`
8+
&.scriptTable {
9+
${props => {
10+
const { isDark } = props.colorConfig;
11+
const { lowestBg, lineColor, firstLevelText, defaultBg } = props.theme.color;
12+
const hoverBgColor = isDark ? '#393649' : deepPurple[50];
13+
14+
return css`
15+
--border-color: ${lineColor};
16+
--header-bgcolor: ${lowestBg};
17+
--header-color: ${firstLevelText};
18+
--color: ${firstLevelText};
19+
--bgcolor: ${defaultBg};
20+
--header-hover-bgcolor: ${hoverBgColor};
21+
--hover-bgcolor: ${hoverBgColor};
22+
`;
23+
}}
24+
--font-size: 13px;
25+
cursor: auto;
26+
}
27+
.art-table-header-cell {
28+
font-weight: bold;
29+
}
30+
`;
31+
32+
export const CustomBaseTable = React.forwardRef<BaseTable, BaseTableProps>((props, ref) => {
33+
return (
34+
<ThemeBaseTable
35+
ref={ref}
36+
className={'scriptTable'}
37+
colorConfig={{
38+
isDark: getThemeName() === ThemeName.Dark
39+
}}
40+
{...props}
41+
/>
42+
);
43+
});

src/render_components/components/table/table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { isObject } from 'lodash';
22
import React, { FC, useMemo } from 'react';
3-
import { BaseTable } from 'ali-react-table';
43
import { StyleSheetManager } from 'styled-components';
54
import { IContentWindow } from '../../render_base';
65
import { Strings } from '../../../utils';
76
import { t } from '@apitable/widget-sdk';
7+
import { CustomBaseTable } from './styled';
88

99
interface ITableProps {
1010
data: (string | number | Object)[];
@@ -51,7 +51,7 @@ export const Table: FC<ITableProps> = (props) => {
5151
<StyleSheetManager
5252
target={window.document.head}
5353
>
54-
<BaseTable
54+
<CustomBaseTable
5555
dataSource={data}
5656
columns={columns}
5757
hasHeader={isItemObject}

0 commit comments

Comments
 (0)