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

Standardise CircularProgress sizes to theme spacing #454

Merged
merged 2 commits into from
Dec 28, 2018
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
44 changes: 31 additions & 13 deletions src/components/CircularProgress/CircularProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,40 @@ const DotSpinner = styled.div`
transform: translateZ(0);

${props =>
props.scale &&
props.size === 'small' &&
`
margin: ${15 * props.scale}px;
font-size: ${5 * props.scale}px;
width: ${5 * props.scale}px;
height: ${5 * props.scale}px;
margin: ${props.theme.spacing.small};
font-size: 3px;
width: 3px;
height: 3px;
`};
${props =>
props.size === 'medium' &&
`
margin: ${props.theme.spacing.base};
font-size: ${props.theme.spacing.xxs};
width: ${props.theme.spacing.xxs};
height: ${props.theme.spacing.xxs};
`};
`;

const ProgressContainer = styled.div`
display: inline-block;
`;

const ProgressWrapper = styled.div`
width: ${props => props.size}px;
height: ${props => props.size}px;
${props =>
props.size === 'small' &&
`
width: ${props.theme.spacing.medium};
height: ${props.theme.spacing.medium};
`};
${props =>
props.size === 'medium' &&
`
width: ${props.theme.spacing.large};
height: ${props.theme.spacing.large};
`};

${props =>
props.inline &&
Expand All @@ -81,14 +99,14 @@ const ProgressWrapper = styled.div`
`;

/**
* Size is set in px
* Size "small" or "medium"
* ```javascript
* import React from 'react';
* import { CircularProgress } from 'weaveworks-ui-components'
*
* React.render(
* <div>
* <CircularProgress size={35} />
* <CircularProgress size="small" />
* <CircularProgress inline /> Inline
* <CircularProgress center />
* </div>
Expand All @@ -98,22 +116,22 @@ const ProgressWrapper = styled.div`
const CircularProgress = props => (
<ProgressWrapper {...props}>
<ProgressContainer>
<DotSpinner scale={props.size / 35} />
<DotSpinner size={props.size} />
</ProgressContainer>
</ProgressWrapper>
);

CircularProgress.propTypes = {
/** Size of spinner in px */
size: PropTypes.number,
/** Size of spinner : 'small' or 'medium' */
size: PropTypes.string,
/** Whether to display the spinner inline */
inline: PropTypes.bool,
/** Whether to center the spinner horizontally */
center: PropTypes.bool,
};

CircularProgress.defaultProps = {
size: 30,
size: 'medium',
inline: false,
center: false,
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/CircularProgress/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export default class Name extends React.Component {
return (
<div>
<Example>
<Info>Default</Info>
<CircularProgress />
<Info>Small</Info>
<CircularProgress size="small" />
</Example>
<Example>
<Info>Bigger</Info>
<CircularProgress size={45} />
<Info>Medium (Default)</Info>
<CircularProgress />
</Example>
<Example>
<Info>Aligned with inline text</Info>
Expand Down