Skip to content

Commit

Permalink
💄 style: Update colors
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Dec 15, 2024
1 parent 68b0a61 commit 357cc08
Show file tree
Hide file tree
Showing 26 changed files with 56 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/AreaChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import CustomYAxisTick from '@/common/CustomYAxisTick';
import NoData from '@/common/NoData';
import { constructCategoryColors, getYAxisDomain, hasOnlyOneValueForThisKey } from '@/common/utils';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import { CurveType } from '@/types';
import { CurveType } from '@/types/charts';
import { defaultValueFormatter } from '@/utils';
import { getMaxLabelLength } from '@/utils/getMaxLabelLength';

Expand Down
2 changes: 1 addition & 1 deletion src/BarList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { HTMLAttributes, ReactNode, forwardRef, useMemo } from 'react';
import { Flexbox } from 'react-layout-kit';

import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';
import { defaultValueFormatter } from '@/utils';

import { useStyles } from './styles';
Expand Down
2 changes: 1 addition & 1 deletion src/DataBars/CategoryBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { forwardRef, memo, useMemo } from 'react';
import { Flexbox, FlexboxProps } from 'react-layout-kit';

import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';
import { defaultValueFormatter, sumNumericArray } from '@/utils';

import { useStyles } from './styles';
Expand Down
2 changes: 1 addition & 1 deletion src/DataBars/DeltaBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Tooltip } from '@lobehub/ui';
import { ReactNode, forwardRef } from 'react';
import { Flexbox, FlexboxProps } from 'react-layout-kit';

import { DeltaTypes } from '@/types';
import { DeltaTypes } from '@/types/charts';
import { mapInputsToDeltaType } from '@/utils';

import { useStyles } from './styles';
Expand Down
2 changes: 1 addition & 1 deletion src/DonutChart/DonutChartTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Flexbox } from 'react-layout-kit';

import ChartTooltipFrame from '@/common/ChartTooltip/ChartTooltipFrame';
import ChartTooltipRow from '@/common/ChartTooltip/ChartTooltipRow';
import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';

export interface DonutChartTooltipProps {
active: boolean | undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/DonutChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type BaseAnimationTimingProps from '@/common/BaseAnimationTimingProps';
import { CustomTooltipProps } from '@/common/CustomTooltipProps';
import NoData, { type NoDataProps } from '@/common/NoData';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import type { EventProps } from '@/types';
import { ValueFormatter } from '@/types';
import type { EventProps } from '@/types/charts';
import { ValueFormatter } from '@/types/charts';
import { defaultValueFormatter, isOnSeverSide } from '@/utils';

import { DonutChartTooltip } from './DonutChartTooltip';
Expand Down
2 changes: 1 addition & 1 deletion src/DonutChart/inputParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';
import { sumNumericArray } from '@/utils';

const calculateDefaultLabel = (data: any[], category: string) =>
Expand Down
2 changes: 1 addition & 1 deletion src/Heatmaps/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Tooltip } from '@lobehub/ui';
import { keyframes } from 'antd-style';
import { Fragment, ReactNode, memo } from 'react';

import type { Activity, Labels, Week } from '@/types';
import type { Activity, Labels, Week } from '@/types/charts';

interface CalendarProps {
blockMargin: number;
Expand Down
2 changes: 1 addition & 1 deletion src/Heatmaps/ChartLabels.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { memo } from 'react';

import type { Labels, Week } from '@/types';
import type { Labels, Week } from '@/types/charts';
import { getMonthLabels } from '@/utils/calendar';

import { useStyles } from './styles';
Expand Down
2 changes: 1 addition & 1 deletion src/Heatmaps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Flexbox, FlexboxProps } from 'react-layout-kit';

import NoData, { NoDataProps } from '@/common/NoData';
import { usePrefersReducedMotion } from '@/hooks/usePrefersReducedMotion';
import type { Activity, Labels, Week } from '@/types';
import type { Activity, Labels, Week } from '@/types/charts';
import { isOnSeverSide } from '@/utils';
import {
DEFAULT_LABELS,
Expand Down
2 changes: 1 addition & 1 deletion src/LineChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import CustomYAxisTick from '@/common/CustomYAxisTick';
import NoData from '@/common/NoData';
import { constructCategoryColors, getYAxisDomain, hasOnlyOneValueForThisKey } from '@/common/utils';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import { CurveType } from '@/types';
import { CurveType } from '@/types/charts';
import { defaultValueFormatter } from '@/utils';
import { getMaxLabelLength } from '@/utils/getMaxLabelLength';

Expand Down
2 changes: 1 addition & 1 deletion src/ScatterChart/ScatterChartTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import { ChartTooltipFrame } from '@/common/ChartTooltip/ChartTooltipFrame';
import { ScatterChartValueFormatter } from '@/types';
import { ScatterChartValueFormatter } from '@/types/charts';
import { defaultValueFormatter } from '@/utils';

import ScatterChartTooltipRow from './ScatterChartTooltipRow';
Expand Down
4 changes: 2 additions & 2 deletions src/ScatterChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
getYAxisDomain,
} from '@/common/utils';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import type { EventProps } from '@/types';
import { IntervalType, ValueFormatter } from '@/types';
import type { EventProps } from '@/types/charts';
import { IntervalType, ValueFormatter } from '@/types/charts';
import { defaultValueFormatter } from '@/utils';
import { getMaxLabelLength } from '@/utils/getMaxLabelLength';

Expand Down
2 changes: 1 addition & 1 deletion src/SparkChart/SparkAreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BaseSparkChartProps from '@/common/BaseSparkChartProps';
import NoData from '@/common/NoData';
import { constructCategoryColors, getYAxisDomain } from '@/common/utils';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import { CurveType } from '@/types';
import { CurveType } from '@/types/charts';

export interface SparkAreaChartProps extends BaseSparkChartProps {
connectNulls?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/SparkChart/SparkLineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BaseSparkChartProps from '@/common/BaseSparkChartProps';
import NoData from '@/common/NoData';
import { constructCategoryColors, getYAxisDomain } from '@/common/utils';
import { useThemeColorRange } from '@/hooks/useThemeColorRange';
import { CurveType } from '@/types';
import { CurveType } from '@/types/charts';

export interface SparkLineChartProps extends BaseSparkChartProps {
connectNulls?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/common/BaseChartProps.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentType, HTMLAttributes } from 'react';

import type { NoDataProps } from '@/common/NoData';
import { IntervalType, LabelFormatter, ValueFormatter } from '@/types';
import { IntervalType, LabelFormatter, ValueFormatter } from '@/types/charts';

import type BaseAnimationTimingProps from './BaseAnimationTimingProps';
import { CustomTooltipProps } from './CustomTooltipProps';
Expand Down
2 changes: 1 addition & 1 deletion src/common/ChartTooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createStyles } from 'antd-style';
import { ReactNode } from 'react';
import { Flexbox } from 'react-layout-kit';

import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';

import ChartTooltipFrame from './ChartTooltipFrame';
import ChartTooltipRow from './ChartTooltipRow';
Expand Down
2 changes: 1 addition & 1 deletion src/common/CustomTooltipProps.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NameType, Payload } from 'recharts/types/component/DefaultTooltipContent';

import { ScatterChartValueFormatter } from '@/ScatterChart';
import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';

export type CustomTooltipProps = {
active: boolean | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/common/CustomYAxisTick.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTheme } from 'antd-style';
import React, { memo } from 'react';

import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';

interface CustomYAxisTickProps {
align: 'left' | 'right';
Expand Down
36 changes: 22 additions & 14 deletions src/hooks/useThemeColorRange.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { useTheme } from 'antd-style';
import { useMemo } from 'react';

export const useThemeColorRange = () => {
const theme = useTheme();

return [
theme.geekblue,
theme.gold,
theme.lime,
theme.volcano,
theme.purple,
theme.blue,
theme.orange,
theme.green,
theme.red,
theme.cyan,
theme.yellow,
theme.magenta,
];
return useMemo(
() => [
theme.geekblue,
theme.gold,
theme.green,
theme.cyan,
theme.purple,
theme.red,
theme.volcano,
theme.gray,
theme.geekblue7,
theme.gold7,
theme.green7,
theme.cyan7,
theme.purple7,
theme.red7,
theme.volcano7,
theme.gray7,
],
[theme],
);
};
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export { default as LineChart, type LineChartProps } from './LineChart';
export { default as ScatterChart, type ScatterChartProps } from './ScatterChart';
export * from './SparkChart';
export { default as Tracker, type TrackerProps } from './Tracker';
export type * from './types';
export type * from './types/charts';
export { useThemeColorRange } from '@/hooks/useThemeColorRange';
File renamed without changes.
9 changes: 9 additions & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { LobeCustomStylish, LobeCustomToken } from '@lobehub/ui';
import 'antd-style';

declare module 'antd-style' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CustomToken extends LobeCustomToken {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CustomStylish extends LobeCustomStylish {}
}
2 changes: 1 addition & 1 deletion src/utils/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
subWeeks,
} from 'date-fns';

import type { Activity, Week } from '@/types';
import type { Activity, Week } from '@/types/charts';
import { isOnSeverSide } from '@/utils/index';

export const DEFAULT_MONTH_LABELS = [
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getMaxLabelLength.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueFormatter } from '@/types';
import { ValueFormatter } from '@/types/charts';
import { defaultValueFormatter, isOnSeverSide } from '@/utils/index';

export const getTextWidth = (text: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeltaTypes, ValueFormatter } from '@/types';
import { DeltaTypes, ValueFormatter } from '@/types/charts';

export const defaultValueFormatter: ValueFormatter = String;

Expand Down

0 comments on commit 357cc08

Please sign in to comment.