Skip to content

Commit

Permalink
refactor(RadialProgress): Remove scss
Browse files Browse the repository at this point in the history
Refactors `RadialProgress` to use styled components instead of scss files.
  • Loading branch information
aresnik11 authored Feb 5, 2025
1 parent d7a63fa commit 7638bb7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
37 changes: 27 additions & 10 deletions packages/gamut/src/RadialProgress/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { theme } from '@codecademy/gamut-styles';
import cx from 'classnames';
import { css, theme } from '@codecademy/gamut-styles';
import styled from '@emotion/styled';
import { SVGProps } from 'react';
import * as React from 'react';

import { FlexBox } from '../Box';
import { Text } from '../Typography';
// eslint-disable-next-line gamut/no-css-standalone
import styles from './styles.module.scss';

export interface RadialProgressProps extends SVGProps<SVGSVGElement> {
size?: number | string;
Expand All @@ -25,6 +24,15 @@ const offsetDelta = offsetForEmptyProgress - offsetForFullProgress;
const convertPercentToOffset = (percent: number) =>
offsetForEmptyProgress - Math.floor(offsetDelta * (percent / 100));

const RadialProgressWrapper = styled.figure<{ size: number | string }>(
({ size }) =>
css({
position: 'relative',
height: size,
width: size,
})
);

/**
* @deprecated
* This component is deprecated and is no longer supported.
Expand Down Expand Up @@ -89,10 +97,7 @@ export const RadialProgress: React.FC<RadialProgressProps> = ({
const svgViewBoxStr = `${viewBox.minX} ${viewBox.minY} ${viewBox.width} ${viewBox.height}`;

return (
<figure
className={cx(styles.radialProgress, className)}
style={{ height: size, width: size }}
>
<RadialProgressWrapper size={size} className={className}>
<Text as="figcaption" screenreader>{`${labelPercent}% progress`}</Text>
<svg viewBox={svgViewBoxStr} height={size} width={size} {...props}>
<circle
Expand Down Expand Up @@ -157,7 +162,19 @@ export const RadialProgress: React.FC<RadialProgressProps> = ({
)}
</circle>
</svg>
{children && <div className={styles.children}>{children}</div>}
</figure>
{children && (
<FlexBox
alignItems="center"
justifyContent="center"
position="absolute"
height={1}
width={1}
left={0}
top={0}
>
{children}
</FlexBox>
)}
</RadialProgressWrapper>
);
};
16 changes: 0 additions & 16 deletions packages/gamut/src/RadialProgress/styles.module.scss

This file was deleted.

0 comments on commit 7638bb7

Please sign in to comment.