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

Add DataCube dark mode #3785

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ import {
getDataForAllNodes,
} from '../../../stores/view/grid/DataCubeGridClientEngine.js';

function getBaseGridProps<
T extends DataCubeEditorColumnSelectorColumnState,
>(): AgGridReactProps<T> {
function getBaseGridProps<T extends DataCubeEditorColumnSelectorColumnState>(
darkMode: boolean,
): AgGridReactProps<T> {
return {
modules: [AllCommunityModule],
className: 'ag-theme-quartz',
className: darkMode ? 'ag-theme-quartz-dark' : 'ag-theme-quartz',
animateRows: false,
getRowId: (params) => params.data.name,
editType: 'fullRow',
Expand Down Expand Up @@ -157,6 +157,7 @@ export const DataCubeEditorColumnSelector = observer(
T extends DataCubeEditorColumnSelectorColumnState,
>(props: {
selector: DataCubeEditorColumnSelectorState<T>;
darkMode: boolean;
columnLabelRenderer?:
| ((p: {
selector: DataCubeEditorColumnSelectorState<T>;
Expand All @@ -173,6 +174,7 @@ export const DataCubeEditorColumnSelector = observer(
}) {
const {
selector,
darkMode,
columnLabelRenderer,
columnActionRenderer,
noColumnsSelectedRenderer,
Expand Down Expand Up @@ -320,7 +322,7 @@ export const DataCubeEditorColumnSelector = observer(
<div className="h-[calc(100%_-_24px)]">
<AgGridReact
theme="legacy"
{...getBaseGridProps<T>()}
{...getBaseGridProps<T>(darkMode)}
// Disable managed row-dragging to disallow changing the order of columns
// and to make sure the row data and the available columns state are in sync
rowDragManaged={false}
Expand Down Expand Up @@ -505,7 +507,7 @@ export const DataCubeEditorColumnSelector = observer(
<div className="h-[calc(100%_-_24px)]">
<AgGridReact
theme="legacy"
{...getBaseGridProps<T>()}
{...getBaseGridProps<T>(darkMode)}
// NOTE: technically, we don't want to enable managed row-dragging here
// but enabling this gives us free row moving management and interaction
// comes out of the box from ag-grid, we will just sync the state with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const DataCubeEditorColumnsPanel = observer(
(props: { view: DataCubeViewState }) => {
const { view } = props;
const panel = view.editor.columns;
const darkMode = view.editor.generalProperties.configuration.darkMode;

useEffect(() => () => panel.propagateChanges(), [panel]);

Expand Down Expand Up @@ -104,6 +105,7 @@ export const DataCubeEditorColumnsPanel = observer(
<div className="flex h-[calc(100%_-_24px)] w-full">
<DataCubeEditorColumnSelector
selector={panel.selector}
darkMode={darkMode}
noColumnsSelectedRenderer={() => (
<div className="flex items-center border-[1.5px] border-neutral-200 p-2 font-semibold text-neutral-400">
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ import {
DataCubeFontFormatUnderlineVariant,
DataCubeFontTextAlignment,
DataCubeQuerySortDirection,
DEFAULT_BACKGROUND_COLOR,
DEFAULT_ERROR_FOREGROUND_COLOR,
DEFAULT_FOREGROUND_COLOR,
DEFAULT_GRID_LINE_COLOR,
DEFAULT_NEGATIVE_FOREGROUND_COLOR,
DEFAULT_ROW_HIGHLIGHT_BACKGROUND_COLOR,
DEFAULT_ZERO_FOREGROUND_COLOR,
DEFAULT_BACKGROUND_COLOR_DARK,
DEFAULT_ERROR_FOREGROUND_COLOR_DARK,
DEFAULT_FOREGROUND_COLOR_DARK,
DEFAULT_GRID_LINE_COLOR_DARK,
DEFAULT_NEGATIVE_FOREGROUND_COLOR_DARK,
DEFAULT_ROW_HIGHLIGHT_BACKGROUND_COLOR_DARK,
DEFAULT_ZERO_FOREGROUND_COLOR_DARK,
DEFAULT_BACKGROUND_COLOR_LIGHT,
DEFAULT_ERROR_FOREGROUND_COLOR_LIGHT,
DEFAULT_FOREGROUND_COLOR_LIGHT,
DEFAULT_GRID_LINE_COLOR_LIGHT,
DEFAULT_NEGATIVE_FOREGROUND_COLOR_LIGHT,
DEFAULT_ROW_HIGHLIGHT_BACKGROUND_COLOR_LIGHT,
DEFAULT_ZERO_FOREGROUND_COLOR_LIGHT,
EMPTY_VALUE_PLACEHOLDER,
} from '../../../stores/core/DataCubeQueryEngine.js';
import {
Expand All @@ -52,6 +59,7 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
const { view } = props;
const panel = view.editor.generalProperties;
const configuration = panel.configuration;
const darkMode = configuration.darkMode;
const [
openTreeColumnSortOperatorDropdown,
closeTreeColumnSortOperatorDropdown,
Expand Down Expand Up @@ -276,7 +284,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
</div>
<FormColorPickerButton
color={configuration.gridLineColor}
defaultColor={DEFAULT_GRID_LINE_COLOR}
defaultColor={
darkMode
? DEFAULT_GRID_LINE_COLOR_DARK
: DEFAULT_GRID_LINE_COLOR_LIGHT
}
onChange={(value) => configuration.setGridLineColor(value)}
/>
</div>
Expand Down Expand Up @@ -315,7 +327,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<FormColorPickerButton
disabled={!configuration.alternateRows}
color={configuration.alternateRowsColor}
defaultColor={DEFAULT_ROW_HIGHLIGHT_BACKGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_ROW_HIGHLIGHT_BACKGROUND_COLOR_DARK
: DEFAULT_ROW_HIGHLIGHT_BACKGROUND_COLOR_LIGHT
}
onChange={(value) => configuration.setAlternateRowsColor(value)}
/>
<div className="ml-1 flex h-full flex-shrink-0 items-center text-sm">
Expand All @@ -338,6 +354,18 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(

<div className="my-2 h-[1px] w-full bg-neutral-200" />

<div className="mt-2 flex h-5 w-full items-center">
<div className="flex h-full w-32 flex-shrink-0 items-center text-sm">
Dark Mode?
</div>
<FormCheckbox
checked={configuration.darkMode}
onChange={() =>
configuration.setDarkMode(!configuration.darkMode)
}
/>
</div>

<div className="mt-2 flex h-5 w-full items-center">
<div className="flex h-full w-32 flex-shrink-0 items-center text-sm">
Default Font:
Expand Down Expand Up @@ -692,7 +720,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.normalForegroundColor}
defaultColor={DEFAULT_FOREGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_FOREGROUND_COLOR_DARK
: DEFAULT_FOREGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setNormalForegroundColor(value)
}
Expand All @@ -701,7 +733,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.negativeForegroundColor}
defaultColor={DEFAULT_NEGATIVE_FOREGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_NEGATIVE_FOREGROUND_COLOR_DARK
: DEFAULT_NEGATIVE_FOREGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setNegativeForegroundColor(value)
}
Expand All @@ -710,7 +746,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.zeroForegroundColor}
defaultColor={DEFAULT_ZERO_FOREGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_ZERO_FOREGROUND_COLOR_DARK
: DEFAULT_ZERO_FOREGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setZeroForegroundColor(value)
}
Expand All @@ -719,7 +759,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.errorForegroundColor}
defaultColor={DEFAULT_ERROR_FOREGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_ERROR_FOREGROUND_COLOR_DARK
: DEFAULT_ERROR_FOREGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setErrorForegroundColor(value)
}
Expand All @@ -733,7 +777,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.normalBackgroundColor}
defaultColor={DEFAULT_BACKGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_BACKGROUND_COLOR_DARK
: DEFAULT_BACKGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setNormalBackgroundColor(value)
}
Expand All @@ -742,7 +790,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.negativeBackgroundColor}
defaultColor={DEFAULT_BACKGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_BACKGROUND_COLOR_DARK
: DEFAULT_BACKGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setNegativeBackgroundColor(value)
}
Expand All @@ -751,7 +803,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.zeroBackgroundColor}
defaultColor={DEFAULT_BACKGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_BACKGROUND_COLOR_DARK
: DEFAULT_BACKGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setZeroBackgroundColor(value)
}
Expand All @@ -760,7 +816,11 @@ export const DataCubeEditorGeneralPropertiesPanel = observer(
<div className="flex h-full w-12 flex-shrink-0 items-center justify-center">
<FormColorPickerButton
color={configuration.errorBackgroundColor}
defaultColor={DEFAULT_BACKGROUND_COLOR}
defaultColor={
darkMode
? DEFAULT_BACKGROUND_COLOR_DARK
: DEFAULT_BACKGROUND_COLOR_LIGHT
}
onChange={(value) =>
configuration.setErrorBackgroundColor(value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const DataCubeEditorHorizontalPivotsPanel = observer(
(props: { view: DataCubeViewState }) => {
const { view } = props;
const panel = view.editor.horizontalPivots;
const darkMode = view.editor.generalProperties.configuration.darkMode;

useEffect(() => () => panel.propagateChanges(), [panel]);

Expand All @@ -50,6 +51,7 @@ export const DataCubeEditorHorizontalPivotsPanel = observer(
<div className="flex h-[calc(100%_-_24px)] w-full">
<DataCubeEditorColumnSelector
selector={panel.selector}
darkMode={darkMode}
columnActionRenderer={(p) => (
<PivotColumnSortDirectionDropdown {...p} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const DataCubeEditorSortsPanel = observer(
(props: { view: DataCubeViewState }) => {
const { view } = props;
const panel = view.editor.sorts;
const darkMode = view.editor.generalProperties.configuration.darkMode;

return (
<div className="h-full w-full select-none p-2">
Expand All @@ -130,6 +131,7 @@ export const DataCubeEditorSortsPanel = observer(
<div className="flex h-[calc(100%_-_24px)] w-full">
<DataCubeEditorColumnSelector
selector={panel.selector}
darkMode={darkMode}
columnLabelRenderer={(p) => <SortColumnLabel {...p} />}
columnActionRenderer={(p) => <SortDirectionDropdown {...p} />}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const DataCubeEditorVerticalPivotsPanel = observer(
(props: { view: DataCubeViewState }) => {
const { view } = props;
const panel = view.editor.verticalPivots;
const darkMode = view.editor.generalProperties.configuration.darkMode;

return (
<div className="h-full w-full select-none p-2">
Expand All @@ -35,7 +36,10 @@ export const DataCubeEditorVerticalPivotsPanel = observer(
</div>
</div>
<div className="flex h-[calc(100%_-_24px)] w-full">
<DataCubeEditorColumnSelector selector={panel.selector} />
<DataCubeEditorColumnSelector
selector={panel.selector}
darkMode={darkMode}
/>
</div>
</div>
);
Expand Down
Loading
Loading