Skip to content

Commit

Permalink
Add Ninja Spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
raczyk authored Jul 8, 2020
1 parent 4682234 commit 17833be
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
.env.development.local
.env.test.local
.env.production.local
.history

npm-debug.log*
yarn-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nordcloud/gnui",
"version": "0.4.8",
"version": "0.4.9",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git://github.com/nordcloud/gnui.git",
Expand Down
23 changes: 17 additions & 6 deletions src/components/spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { color } from "styled-system";
import styled, { css } from "styled-components";
import theme from "../../theme";
import { Text } from "../text";
import ninjaGif from "../../utils/img/ninja.gif";

export interface SpinnerProps {
caption?: string;
Expand All @@ -11,6 +12,7 @@ export interface SpinnerProps {
color?: string;
onClick?: (e: any) => void;
onChange?: (e: React.FormEvent<HTMLInputElement>) => void;
ninja?: boolean;
}

const SpinnerContainer = styled.div<SpinnerProps>`
Expand Down Expand Up @@ -69,19 +71,28 @@ const StyledRing = styled.div<SpinnerProps>`
}
`;

const Image = styled.img<SpinnerProps>`
zoom: ${({ size }) => (size ? `${size}` : `1`)};
`;

export const Spinner: FunctionComponent<SpinnerProps> = ({
caption,
color,
size,
ninja,
}) => {
return (
<SpinnerContainer caption={caption}>
<StyledRing color={color} size={size}>
<div></div>
<div></div>
<div></div>
<div></div>
</StyledRing>
{ninja ? (
<Image size={size} src={ninjaGif}></Image>
) : (
<StyledRing color={color} size={size}>
<div></div>
<div></div>
<div></div>
<div></div>
</StyledRing>
)}
{caption && <Text>{caption}</Text>}
</SpinnerContainer>
);
Expand Down
8 changes: 8 additions & 0 deletions src/stories/Spinner.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,11 @@ Named:
</Button>
</Story>
</Preview>

## Ninja

<Preview>
<Story name="ninja">
<Spinner ninja size="0.2" color="white" caption="Spinner" />
</Story>
</Preview>
Binary file added src/utils/img/ninja.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 17833be

Please sign in to comment.