Skip to content

Commit 347bfac

Browse files
committed
feat: init semantic structure
1 parent 27a7aab commit 347bfac

File tree

5 files changed

+26
-43
lines changed

5 files changed

+26
-43
lines changed

src/Circle/PtgCircle.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import type { ProgressProps } from '..';
33
import type { StrokeColorObject } from '../interface';
4+
import classNames from 'classnames';
45

56
interface BlockProps {
67
bg: string;
@@ -22,6 +23,7 @@ function getPtgColors(color: Record<string, string | boolean>, scale: number) {
2223

2324
export interface ColorGradientProps {
2425
prefixCls: string;
26+
className?: string;
2527
gradientId: string;
2628
style: React.CSSProperties;
2729
ptg: number;
@@ -39,6 +41,7 @@ const PtgCircle = React.forwardRef<SVGCircleElement, ColorGradientProps>((props,
3941
color,
4042
gradientId,
4143
radius,
44+
className,
4245
style: circleStyleForStack,
4346
ptg,
4447
strokeLinecap,
@@ -56,7 +59,7 @@ const PtgCircle = React.forwardRef<SVGCircleElement, ColorGradientProps>((props,
5659

5760
const circleNode = (
5861
<circle
59-
className={`${prefixCls}-circle-path`}
62+
className={classNames(`${prefixCls}-circle-path`, className)}
6063
r={radius}
6164
cx={halfSize}
6265
cy={halfSize}

src/Circle/index.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
2-
import classNames from 'classnames';
2+
import cls from 'classnames';
33
import { defaultProps, useTransitionDuration } from '../common';
44
import type { ProgressProps } from '../interface';
5-
import useId from '../hooks/useId';
5+
import useId from '@rc-component/util/lib/hooks/useId';
66
import PtgCircle from './PtgCircle';
77
import { VIEW_BOX_SIZE, getCircleStyle } from './util';
88
import getIndeterminateCircle from '../utils/getIndeterminateCircle';
@@ -16,6 +16,8 @@ const Circle: React.FC<ProgressProps> = (props) => {
1616
const {
1717
id,
1818
prefixCls,
19+
classNames = {},
20+
styles = {},
1921
steps,
2022
strokeWidth,
2123
trailWidth,
@@ -100,7 +102,7 @@ const Circle: React.FC<ProgressProps> = (props) => {
100102
radius={radius}
101103
prefixCls={prefixCls}
102104
gradientId={gradientId}
103-
style={{ ...circleStyleForStack, ...indeterminateStyleProps }}
105+
style={{ ...circleStyleForStack, ...indeterminateStyleProps, ...styles.track }}
104106
strokeLinecap={mergedStrokeLinecap}
105107
strokeWidth={strokeWidth}
106108
gapDegree={gapDegree}
@@ -148,14 +150,14 @@ const Circle: React.FC<ProgressProps> = (props) => {
148150
return (
149151
<circle
150152
key={index}
151-
className={`${prefixCls}-circle-path`}
153+
className={cls(`${prefixCls}-circle-path`, className)}
152154
r={radius}
153155
cx={halfSize}
154156
cy={halfSize}
155157
stroke={stroke}
156158
strokeWidth={strokeWidth}
157159
opacity={1}
158-
style={circleStyleForStack}
160+
style={{ ...circleStyleForStack, ...styles.track }}
159161
ref={(elem) => {
160162
paths[index] = elem;
161163
}}
@@ -166,23 +168,29 @@ const Circle: React.FC<ProgressProps> = (props) => {
166168

167169
return (
168170
<svg
169-
className={classNames(`${prefixCls}-circle`, className)}
171+
className={cls(`${prefixCls}-circle`, classNames.root, className)}
170172
viewBox={`0 0 ${VIEW_BOX_SIZE} ${VIEW_BOX_SIZE}`}
171-
style={style}
173+
style={{
174+
...styles.root,
175+
...style,
176+
}}
172177
id={id}
173178
role="presentation"
174179
{...restProps}
175180
>
176181
{!stepCount && (
177182
<circle
178-
className={`${prefixCls}-circle-trail`}
183+
className={cls(`${prefixCls}-circle-trail`, classNames.rail)}
179184
r={radius}
180185
cx={halfSize}
181186
cy={halfSize}
182187
stroke={trailColor}
183188
strokeLinecap={mergedStrokeLinecap}
184189
strokeWidth={trailWidth || strokeWidth}
185-
style={circleStyle}
190+
style={{
191+
...circleStyle,
192+
...styles.rail,
193+
}}
186194
/>
187195
)}
188196
{stepCount ? getStepStokeList() : getStokeList()}

src/Line.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from 'classnames';
33
import { useTransitionDuration, defaultProps } from './common';
44
import type { ProgressProps } from './interface';
55
import getIndeterminateLine from './utils/getIndeterminateLine';
6-
import useId from './hooks/useId';
6+
import useId from '@rc-component/util/lib/hooks/useId';
77

88
const Line: React.FC<ProgressProps> = (props) => {
99
const {

src/hooks/useId.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/interface.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
export type SemanticName = 'root' | 'rail' | 'track';
2+
13
export interface ProgressProps {
24
id?: string;
35
strokeWidth?: number;
46
trailWidth?: number;
57
className?: string;
8+
classNames?: Partial<Record<SemanticName, string>>;
9+
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
610
percent?: number | number[];
711
strokeColor?: StrokeColorType;
812
trailColor?: string;

0 commit comments

Comments
 (0)