Skip to content

Commit

Permalink
Simplify loading indicator styles (#3719)
Browse files Browse the repository at this point in the history
Leverage currentColor for loading indicator dots -- makes styling easier, and more consistent, for consumers
  • Loading branch information
jossmac committed Aug 16, 2019
1 parent c22a4b2 commit 270cc01
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
1 change: 1 addition & 0 deletions .changeset/five-lions-melt/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "releases": [{ "name": "react-select", "type": "patch" }], "dependents": [] }
1 change: 1 addition & 0 deletions .changeset/five-lions-melt/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Leverage currentColor for loading indicator dots -- makes styling easier, and more consistent, for consumers
35 changes: 13 additions & 22 deletions packages/react-select/src/components/indicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,18 @@ export const loadingIndicatorCSS = ({
verticalAlign: 'middle',
});

type DotProps = { color: string, delay: number, offset: boolean };
const LoadingDot = ({ color, delay, offset }: DotProps) => (
type DotProps = { delay: number, offset: boolean };
const LoadingDot = ({ delay, offset }: DotProps) => (
<span
css={{
animation: `${loadingDotAnimations} 1s ease-in-out ${delay}ms infinite;`,
backgroundColor: color,
borderRadius: '1em;',
display: 'inline-block;',
marginLeft: offset ? '1em;' : null,
height: '1em;',
verticalAlign: 'top;',
width: '1em;',
backgroundColor: 'currentColor',
borderRadius: '1em',
display: 'inline-block',
marginLeft: offset ? '1em' : null,
height: '1em',
verticalAlign: 'top',
width: '1em',
}}
/>
);
Expand All @@ -205,16 +205,7 @@ export type LoadingIconProps = {
size: number,
};
export const LoadingIndicator = (props: LoadingIconProps) => {
const {
className,
cx,
getStyles,
innerProps,
isFocused,
isRtl,
theme: { colors },
} = props;
const color = isFocused ? colors.neutral80 : colors.neutral20;
const { className, cx, getStyles, innerProps, isRtl } = props;

return (
<div
Expand All @@ -228,9 +219,9 @@ export const LoadingIndicator = (props: LoadingIconProps) => {
className
)}
>
<LoadingDot color={color} delay={0} offset={isRtl} />
<LoadingDot color={color} delay={160} offset />
<LoadingDot color={color} delay={320} offset={!isRtl} />
<LoadingDot delay={0} offset={isRtl} />
<LoadingDot delay={160} offset />
<LoadingDot delay={320} offset={!isRtl} />
</div>
);
};
Expand Down

0 comments on commit 270cc01

Please sign in to comment.