Skip to content

Commit

Permalink
💄 style: Update styles
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Nov 8, 2024
1 parent edcc8cc commit 611b092
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/AreaChart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const useStyles = createStyles(({ css, token }) => ({
stroke-width: 1;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
fill: ${token.colorTextDescription};
`,
strongLabel: css`
font-size: 14px;
font-size: 12px;
font-weight: 500;
line-height: 16px;
fill: ${token.colorTextSecondary};
Expand Down
4 changes: 2 additions & 2 deletions src/BarChart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const useStyles = createStyles(({ css, token }) => ({
stroke-width: 1;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
fill: ${token.colorTextDescription};
`,
strongLabel: css`
font-size: 14px;
font-size: 12px;
font-weight: 500;
line-height: 16px;
fill: ${token.colorTextSecondary};
Expand Down
2 changes: 1 addition & 1 deletion src/BarList/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useStyles = createStyles(({ css, token }) => ({
white-space: nowrap;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
color: ${token.colorTextDescription};
`,
Expand Down
2 changes: 1 addition & 1 deletion src/DataBars/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useStyles = createStyles(({ css, token }) => ({
white-space: nowrap;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
fill: ${token.colorTextDescription};
`,
Expand Down
35 changes: 33 additions & 2 deletions src/DonutChart/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { css } from 'antd-style';
import { css, useThemeMode } from 'antd-style';
import { CSSProperties, ComponentType, MouseEvent, forwardRef, useEffect, useState } from 'react';
import { Flexbox } from 'react-layout-kit';
import { Pie, PieChart as ReChartsDonutChart, ResponsiveContainer, Tooltip } from 'recharts';
Expand Down Expand Up @@ -29,6 +29,7 @@ export interface DonutChartProps extends BaseAnimationTimingProps {
};
customTooltip?: ComponentType<CustomTooltipProps>;
data: any[];
donutLabel?: string;
index?: string;
label?: string;
noDataText?: NoDataProps['noDataText'];
Expand Down Expand Up @@ -64,8 +65,10 @@ const DonutChart = forwardRef<HTMLDivElement, DonutChartProps>((props, ref) => {
height = '10rem',
style,
customCategories,
donutLabel,
...rest
} = props;
const { isDarkMode } = useThemeMode();
const CustomTooltip = customTooltip;
const isDonut = variant === 'donut';
const parsedLabelInput = parseLabelInput(label, valueFormatter, data, category);
Expand Down Expand Up @@ -141,7 +144,9 @@ const DonutChart = forwardRef<HTMLDivElement, DonutChartProps>((props, ref) => {
x="50%"
y="50%"
>
{parsedLabelInput}
{donutLabel || typeof activeIndex === 'number'
? valueFormatter(data?.[activeIndex as any]?.[category])
: parsedLabelInput}
</text>
) : null}
<Pie
Expand All @@ -167,6 +172,32 @@ const DonutChart = forwardRef<HTMLDivElement, DonutChartProps>((props, ref) => {
stroke: theme.colorBgContainer,
}}
/>
{isDonut && (
<Pie
activeIndex={activeIndex}
animationDuration={animationDuration}
cx="50%"
cy="50%"
data={parseData(
[{ [category]: 1 }],
[isDarkMode ? 'rgba(0,0,0,.33)' : 'rgba(0,0,0,.1)'],
)}
dataKey={category}
endAngle={-270}
inactiveShape={renderInactiveShape}
innerRadius={isDonut ? '75%' : '0%'}
isAnimationActive={false}
nameKey={index}
outerRadius="80%"
startAngle={90}
stroke=""
strokeLinejoin="round"
style={{
outline: 'none',
pointerEvents: 'none',
}}
/>
)}
<Tooltip
content={
showTooltip
Expand Down
2 changes: 1 addition & 1 deletion src/DonutChart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const useStyles = createStyles(({ css, token }) => ({
stroke-width: 1;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
fill: ${token.colorTextDescription};
`,
Expand Down
2 changes: 1 addition & 1 deletion src/Heatmaps/demos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default () => {
},
fontSize: {
step: 1,
value: 14,
value: 12,
},
hideColorLegend: false,
hideMonthLabels: false,
Expand Down
2 changes: 1 addition & 1 deletion src/Heatmaps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Heatmaps = forwardRef<HTMLDivElement, HeatmapsProps>((props, ref) => {
blockRadius = 2,
blockSize = 12,
onValueChange,
fontSize = 14,
fontSize = 12,
hideColorLegend = false,
hideMonthLabels = false,
hideTotalCount = false,
Expand Down
4 changes: 2 additions & 2 deletions src/Legend/LegendItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const useStyles = createStyles(({ css, token }) => ({
}
`,
itemContent: css`
font-size: 14px;
font-size: 12px;
color: inherit;
`,
}));
Expand All @@ -44,7 +44,7 @@ const LegendItem = memo<LegendItemProps>(({ label, name, color, onClick, activeL
return (
<Flexbox
className={cx(styles.container, hasOnValueChange && styles.hasOnValueChange)}
gap={8}
gap={6}
horizontal
onClick={(e) => {
e.stopPropagation();
Expand Down
4 changes: 2 additions & 2 deletions src/LineChart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const useStyles = createStyles(({ css, token }) => ({
stroke-width: 1;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
fill: ${token.colorTextDescription};
`,
strongLabel: css`
font-size: 14px;
font-size: 12px;
font-weight: 500;
line-height: 16px;
fill: ${token.colorTextSecondary};
Expand Down
4 changes: 2 additions & 2 deletions src/ScatterChart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const useStyles = createStyles(({ css, token }) => ({
stroke-width: 1;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
fill: ${token.colorTextDescription};
`,
strongLabel: css`
font-size: 14px;
font-size: 12px;
font-weight: 500;
line-height: 16px;
fill: ${token.colorTextSecondary};
Expand Down
4 changes: 2 additions & 2 deletions src/Tracker/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export const useStyles = createStyles(({ css, token }) => ({
white-space: nowrap;
`,
label: css`
font-size: 14px;
font-size: 12px;
line-height: 16px;
color: ${token.colorTextDescription};
`,
strongLabel: css`
font-size: 14px;
font-size: 12px;
font-weight: 500;
line-height: 16px;
fill: ${token.colorTextSecondary};
Expand Down
2 changes: 1 addition & 1 deletion src/common/CustomYAxisTick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CustomYAxisTick = memo<CustomYAxisTickProps>(
<text
dy={4}
fill={theme.colorTextDescription}
fontSize={14}
fontSize={12}
textAnchor={align === 'left' ? 'start' : 'end'}
x={0}
y={0}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getMaxLabelLength.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getTextWidth = (text: string) => {
const span = document.createElement('span');

// 设置样式使其不可见
span.style.fontSize = '14px';
span.style.fontSize = '12px';
span.style.position = 'absolute';
span.style.visibility = 'hidden';
span.style.whiteSpace = 'nowrap';
Expand Down

0 comments on commit 611b092

Please sign in to comment.