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

refactor: remove defaultprops warning #23

Merged
Merged
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
10 changes: 4 additions & 6 deletions src/SpinnerCircular.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import './SpinnerCircular.css';
export type SpinnerCircularProps = SpinnersProps & SecondaryColorSpinnerProps;

const Component = ({
secondaryColor,
speed,
still,
thickness,
secondaryColor = secondaryColorDefaultProps.secondaryColor,
speed = secondaryColorDefaultProps.speed,
still = secondaryColorDefaultProps.still,
thickness = secondaryColorDefaultProps.thickness,
...svgProps
}: SecondaryColorSpinnerProps) => {
const strokeWidth = 4 * (thickness / 100);
Expand Down Expand Up @@ -44,6 +44,4 @@ const Component = ({
);
};

Component.defaultProps = secondaryColorDefaultProps;

export const SpinnerCircular = withSharedProps(Component);
10 changes: 4 additions & 6 deletions src/SpinnerCircularFixed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import './SpinnerCircularFixed.css';
export type SpinnerCircularFixedProps = SpinnersProps & SecondaryColorSpinnerProps;

const Component = ({
secondaryColor,
speed,
still,
thickness,
secondaryColor = secondaryColorDefaultProps.secondaryColor,
speed = secondaryColorDefaultProps.speed,
still = secondaryColorDefaultProps.still,
thickness = secondaryColorDefaultProps.thickness,
...svgProps
}: SecondaryColorSpinnerProps) => {
const strokeWidth = 4 * (thickness / 100);
Expand Down Expand Up @@ -44,6 +44,4 @@ const Component = ({
);
};

Component.defaultProps = secondaryColorDefaultProps;

export const SpinnerCircularFixed = withSharedProps(Component);
10 changes: 4 additions & 6 deletions src/SpinnerCircularSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import './SpinnerCircularSplit.css';
export type SpinnerCircularSplitProps = SpinnersProps & SecondaryColorSpinnerProps;

const Component = ({
secondaryColor,
speed,
still,
thickness,
secondaryColor = secondaryColorDefaultProps.secondaryColor,
speed = secondaryColorDefaultProps.speed,
still = secondaryColorDefaultProps.still,
thickness = secondaryColorDefaultProps.thickness,
...svgProps
}: SecondaryColorSpinnerProps) => {
const strokeWidth = 4 * (thickness / 100);
Expand Down Expand Up @@ -45,6 +45,4 @@ const Component = ({
);
};

Component.defaultProps = secondaryColorDefaultProps;

export const SpinnerCircularSplit = withSharedProps(Component);
10 changes: 4 additions & 6 deletions src/SpinnerDiamond.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const coords = [
export type SpinnerDiamondProps = SpinnersProps & SecondaryColorSpinnerProps;

const Component = ({
secondaryColor,
speed,
still,
thickness,
secondaryColor = secondaryColorDefaultProps.secondaryColor,
speed = secondaryColorDefaultProps.speed,
still = secondaryColorDefaultProps.still,
thickness = secondaryColorDefaultProps.thickness,
...svgProps
}: SecondaryColorSpinnerProps) => {
const diamondStyle: CSSProperties = {
Expand All @@ -62,7 +62,5 @@ const Component = ({
);
};

Component.defaultProps = secondaryColorDefaultProps;

export const SpinnerRomb = withSharedProps(Component);
export const SpinnerDiamond = withSharedProps(Component);
8 changes: 3 additions & 5 deletions src/SpinnerDotted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const coords = [
export type SpinnerDottedProps = SpinnersProps & SpinnerProps;

export const Component = ({
speed,
still,
thickness,
speed = defaultProps.speed,
still = defaultProps.still,
thickness = defaultProps.thickness,
...svgProps
}: SpinnerProps) => {
const duration = 200 / speed;
Expand Down Expand Up @@ -60,6 +60,4 @@ export const Component = ({
);
};

Component.defaultProps = defaultProps;

export const SpinnerDotted = withSharedProps(Component);
10 changes: 4 additions & 6 deletions src/SpinnerInfinity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import './SpinnerInfinity.css';
export type SpinnerInfinityProps = SpinnersProps & SecondaryColorSpinnerProps;

const Component = ({
secondaryColor,
speed,
still,
thickness,
secondaryColor = secondaryColorDefaultProps.secondaryColor,
speed = secondaryColorDefaultProps.speed,
still = secondaryColorDefaultProps.still,
thickness = secondaryColorDefaultProps.thickness,
...svgProps
}: SecondaryColorSpinnerProps) => {
const strokeWidth = 7 * (thickness / 100);
Expand Down Expand Up @@ -41,6 +41,4 @@ const Component = ({
);
};

Component.defaultProps = secondaryColorDefaultProps;

export const SpinnerInfinity = withSharedProps(Component);
8 changes: 3 additions & 5 deletions src/SpinnerRound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import './SpinnerRound.css';
export type SpinnerRoundProps = SpinnersProps & SpinnerProps;

const Component = ({
speed,
still,
thickness,
speed = defaultProps.speed,
still = defaultProps.still,
thickness = defaultProps.thickness,
...svgProps
}: SpinnerProps) => {
const strokeWidth = 3 * (thickness / 100);
Expand All @@ -35,6 +35,4 @@ const Component = ({
);
};

Component.defaultProps = defaultProps;

export const SpinnerRound = withSharedProps(Component);
8 changes: 3 additions & 5 deletions src/SpinnerRoundFilled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const animations = [
export type SpinnerRoundFilledProps = SpinnersProps & SpinnerProps;

const Component = ({
speed,
still,
thickness,
speed = defaultProps.speed,
still = defaultProps.still,
thickness = defaultProps.thickness,
...svgProps
}: SpinnerProps) => (
<svg fill="none" {...svgProps} viewBox="0 0 66 66">
Expand All @@ -48,6 +48,4 @@ const Component = ({
</svg>
);

Component.defaultProps = defaultProps;

export const SpinnerRoundFilled = withSharedProps(Component);
8 changes: 3 additions & 5 deletions src/SpinnerRoundOutlined.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const animations = [
export type SpinnerRoundOutlinedProps = SpinnersProps & SpinnerProps;

const Component = ({
speed,
still,
thickness,
speed = defaultProps.speed,
still = defaultProps.still,
thickness = defaultProps.thickness,
...svgProps
}: SpinnerProps) => {
const strokeWidth = 3 * (thickness / 100);
Expand All @@ -48,6 +48,4 @@ const Component = ({
);
};

Component.defaultProps = defaultProps;

export const SpinnerRoundOutlined = withSharedProps(Component);
8 changes: 5 additions & 3 deletions src/withSharedProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export type SpinnersProps = Partial<typeof defaultProps>;
export const withSharedProps = <P extends SpinnersProps>(Component: ComponentType<P>) => {
const Wrapper = (props: P) => {
const {
color, enabled, size, style, ...otherProps
color = defaultProps.color,
enabled = defaultProps.enabled,
size = defaultProps.size,
style = defaultProps.style,
...otherProps
} = props;
const componentProps = {
...otherProps,
Expand All @@ -34,7 +38,5 @@ export const withSharedProps = <P extends SpinnersProps>(Component: ComponentTyp
return <Component {...componentProps as P} />;
};

Wrapper.defaultProps = defaultProps;

return Wrapper;
};