This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* default color is black for spinner now * initial page spinner * black color * page spinner setup * scss preset * way more accurate story * clean up tests
- Loading branch information
Showing
11 changed files
with
117 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.container { | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { screen, render } from "@testing-library/react"; | ||
import { PageSpinner } from "."; | ||
import { Color, colors, Size, sizes } from "../../types"; | ||
import styles from "../spinner/Spinner.module.scss"; | ||
|
||
it("by default is white", () => { | ||
render(<PageSpinner />); | ||
expect(screen.getByRole("alert")).toHaveClass(styles["is-black"]); | ||
}); | ||
|
||
it("by default is labeled with 'Loading...'", () => { | ||
render(<PageSpinner />); | ||
const spinner = screen.getByRole("alert"); | ||
expect(spinner).toHaveAttribute("aria-label", "Loading..."); | ||
}); | ||
|
||
it("supports a custom label", () => { | ||
const label = "Loading Test..."; | ||
render(<PageSpinner label={label} />); | ||
const spinner = screen.getByRole("alert"); | ||
expect(spinner).toHaveAttribute("aria-label", label); | ||
}); | ||
|
||
it.each<Color>(colors)("can be colored in %p", (color: Color) => { | ||
render(<PageSpinner color={color} />); | ||
expect(screen.getByRole("alert")).toHaveClass(styles[`is-${color}`]); | ||
}); | ||
|
||
it.each<Size>(sizes)("can be sized in %p", (size: Size) => { | ||
render(<PageSpinner size={size} />); | ||
expect(screen.getByRole("alert")).toHaveClass(styles[`is-${size}`]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Spinner, SpinnerProps } from ".."; | ||
import styles from "./PageSpinner.module.scss"; | ||
|
||
export type PageSpinnerProps = SpinnerProps; | ||
|
||
export const PageSpinner = (props: PageSpinnerProps): JSX.Element => { | ||
return ( | ||
<div className={styles.container}> | ||
<Spinner {...props} /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./PageSpinner"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.root { | ||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Story, Meta } from "@storybook/react"; | ||
import { colors, sizes } from ".."; | ||
import { PageSpinner, PageSpinnerProps } from "../components"; | ||
import "./PageSpinner.stories.scss"; | ||
|
||
export default { | ||
component: PageSpinner, | ||
title: "Example/PageSpinner", | ||
argTypes: { | ||
color: { | ||
control: { | ||
type: "select", | ||
options: colors, | ||
}, | ||
}, | ||
size: { | ||
control: { | ||
type: "select", | ||
options: sizes, | ||
}, | ||
}, | ||
}, | ||
} as Meta<PageSpinnerProps>; | ||
|
||
const Template: Story = (args) => ( | ||
<div style={{ height: "100vh" }}> | ||
<PageSpinner {...args} /> | ||
</div> | ||
); | ||
|
||
export const InteractivePageSpinner = Template.bind({}); | ||
InteractivePageSpinner.args = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
import { Story, Meta } from "@storybook/react"; | ||
import { Spinner } from "../components"; | ||
import { colors, sizes } from ".."; | ||
import { Spinner, SpinnerProps } from "../components"; | ||
|
||
export default { | ||
component: Spinner, | ||
title: "Example/Spinner", | ||
} as Meta; | ||
argTypes: { | ||
color: { | ||
control: { | ||
type: "select", | ||
options: colors, | ||
}, | ||
}, | ||
size: { | ||
control: { | ||
type: "select", | ||
options: sizes, | ||
}, | ||
}, | ||
}, | ||
} as Meta<SpinnerProps>; | ||
|
||
const Template: Story = () => <Spinner color="primary" size="medium" />; | ||
const Template: Story = (args) => <Spinner {...args} />; | ||
|
||
export const DefaultSpinner = Template.bind({}); | ||
DefaultSpinner.args = {}; | ||
export const InteractiveSpinner = Template.bind({}); | ||
InteractiveSpinner.args = {}; |