Skip to content

Commit

Permalink
feat: 兼容暗黑模式
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Nov 20, 2023
1 parent 2f68e70 commit 04a13c0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
8 changes: 6 additions & 2 deletions packages/s2-core/src/theme/palette/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { Palette } from '../../common';

export const paletteDark: Palette = {
brandColor: '#255dff',
basicColorRelations: [],
semanticColors: {
red: '#FF4D4F',
green: '#29A294',
yellow: '#FAAD14',
},
basicColors: [
'#ffffff',
'#151a27',
Expand All @@ -20,5 +24,5 @@ export const paletteDark: Palette = {
'#f0f0f0',
'#dcdcdc',
],
semanticColors: { red: '#FF4D4F', green: '#29A294', yellow: '#FAAD14' },
basicColorRelations: [],
};
11 changes: 6 additions & 5 deletions packages/s2-react/playground/components/Mobile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { customMerge, type S2DataConfig } from '@antv/s2';
import { customMerge, SpreadSheet, type S2DataConfig } from '@antv/s2';
import { MobileSheet } from '../../src/components/sheets/mobile-sheet';
import { defaultOptions, pivotSheetDataCfg } from '../config';
import type { SheetComponentOptions, SheetComponentsProps } from '../../src';
Expand All @@ -9,9 +9,9 @@ const MobileDataCfg: S2DataConfig = {
...pivotSheetDataCfg,
};

export const MobileSheetComponent: React.FC<Partial<SheetComponentsProps>> = (
props,
) => {
export const MobileSheetComponent: React.FC<
Partial<SheetComponentsProps> & React.RefAttributes<SpreadSheet>
> = React.forwardRef((props, ref) => {
const context = usePlaygroundContext();
const mobileOptions: SheetComponentOptions = {
width: 400,
Expand All @@ -35,10 +35,11 @@ export const MobileSheetComponent: React.FC<Partial<SheetComponentsProps>> = (

return (
<MobileSheet
ref={ref}
dataCfg={MobileDataCfg}
options={options}
{...props}
{...context}
/>
);
};
});
14 changes: 7 additions & 7 deletions packages/s2-react/playground/context/playground.context.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import type { SpreadSheet, ThemeCfg } from '@antv/s2';
import { noop } from 'lodash';
import React from 'react';
import type { SpreadSheet } from '@antv/s2';
import type { SheetComponentsProps } from '../../src';

export const PlaygroundContext = React.createContext<{
ref?: React.MutableRefObject<SpreadSheet | null>;
onMounted: SheetComponentsProps['onMounted'];
themeCfg: ThemeCfg;
}>({
export const PlaygroundContext = React.createContext<
Partial<SheetComponentsProps> & {
ref?: React.MutableRefObject<SpreadSheet | null>;
}
>({
onMounted: noop,
themeCfg: { name: 'default' },
});
Expand Down
9 changes: 6 additions & 3 deletions packages/s2-react/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ function MainLayout() {
);
}, [sheetType, tableSheetColumnType]);

const onSheetDestroy = logHandler('onDestroy', () => {
clearInterval(scrollTimer.current!);
});

// ================== Config ========================

const mergedOptions: SheetComponentOptions = customMerge(
Expand Down Expand Up @@ -346,6 +350,7 @@ function MainLayout() {
value={{
ref: s2Ref,
onMounted: onSheetMounted,
onDestroy: onSheetDestroy,
themeCfg,
}}
>
Expand Down Expand Up @@ -1247,9 +1252,7 @@ function MainLayout() {
onRangeSort={logHandler('onRangeSort')}
onRangeSorted={logHandler('onRangeSorted')}
onMounted={onSheetMounted}
onDestroy={logHandler('onDestroy', () => {
clearInterval(scrollTimer.current!);
})}
onDestroy={onSheetDestroy}
onColCellClick={onColCellClick}
onRowCellClick={logHandler('onRowCellClick')}
onCornerCellClick={logHandler(
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-react/src/context/SpreadSheetContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import type { SpreadSheet } from '@antv/s2';

export const SpreadSheetContext = React.createContext<SpreadSheet | undefined>(
export const SpreadSheetContext = React.createContext<SpreadSheet>(
null as unknown as SpreadSheet,
);

Expand Down

0 comments on commit 04a13c0

Please sign in to comment.