-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🎨 Add loading backdrop for sync catalog table (#15671)
- Loading branch information
Showing
13 changed files
with
169 additions
and
47 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
airbyte-webapp/src/components/LoadingBackdrop/LoadingBackdrop.module.scss
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,28 @@ | ||
@use "../../scss/colors"; | ||
|
||
%cover { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.loadingBackdropContainer { | ||
@extend %cover; | ||
position: relative; | ||
|
||
.backdrop { | ||
@extend %cover; | ||
position: absolute; | ||
background-color: colors.$white; | ||
opacity: 0.6; | ||
z-index: 1; | ||
} | ||
|
||
.spinnerContainer { | ||
@extend %cover; | ||
position: absolute; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
z-index: 2; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
airbyte-webapp/src/components/LoadingBackdrop/LoadingBackdrop.test.tsx
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,17 @@ | ||
import { render } from "@testing-library/react"; | ||
|
||
import { LoadingBackdrop } from "./LoadingBackdrop"; | ||
|
||
describe("<LoadingBackdrop />", () => { | ||
it("loading backdrop is active", () => { | ||
const { getByTestId } = render(<LoadingBackdrop loading />); | ||
|
||
expect(getByTestId("loading-backdrop")).toBeInTheDocument(); | ||
}); | ||
|
||
it("loading backdrop is not active", () => { | ||
const { queryByTestId } = render(<LoadingBackdrop loading={false} />); | ||
|
||
expect(queryByTestId("loading-backdrop")).toBeNull(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
airbyte-webapp/src/components/LoadingBackdrop/LoadingBackdrop.tsx
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,24 @@ | ||
import React from "react"; | ||
|
||
import Spinner from "../Spinner/Spinner"; | ||
import styles from "./LoadingBackdrop.module.scss"; | ||
|
||
interface LoadingBackdropProps { | ||
loading: boolean; | ||
small?: boolean; | ||
} | ||
export const LoadingBackdrop: React.FC<LoadingBackdropProps> = ({ loading, small, children }) => { | ||
return ( | ||
<div className={styles.loadingBackdropContainer}> | ||
{loading && ( | ||
<> | ||
<div className={styles.backdrop} data-testid="loading-backdrop" /> | ||
<div className={styles.spinnerContainer}> | ||
<Spinner small={small} /> | ||
</div> | ||
</> | ||
)} | ||
{children} | ||
</div> | ||
); | ||
}; |
23 changes: 23 additions & 0 deletions
23
airbyte-webapp/src/components/LoadingBackdrop/index.stories.tsx
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,23 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
|
||
import { LoadingBackdrop } from "./LoadingBackdrop"; | ||
|
||
export default { | ||
title: "Ui/LoadingBackdrop", | ||
component: LoadingBackdrop, | ||
argTypes: { | ||
loading: { type: "boolean", required: true }, | ||
small: { type: "boolean", required: false }, | ||
}, | ||
} as ComponentMeta<typeof LoadingBackdrop>; | ||
|
||
const Template: ComponentStory<typeof LoadingBackdrop> = (args) => ( | ||
<div style={{ height: 200, width: 200, border: "1px solid blue" }}> | ||
<LoadingBackdrop {...args}> | ||
<div style={{ padding: 15 }}> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore | ||
</div> | ||
</LoadingBackdrop> | ||
</div> | ||
); | ||
export const Primary = Template.bind({}); |
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 { LoadingBackdrop } from "./LoadingBackdrop"; |
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,23 @@ | ||
@use "../../scss/colors"; | ||
|
||
@keyframes spin { | ||
from { | ||
transform: rotate(0); | ||
} | ||
to { | ||
transform: rotate(359deg); | ||
} | ||
} | ||
.spinner { | ||
width: 42px; | ||
height: 42px; | ||
border: 4px solid colors.$blue-100; | ||
border-top: 4px solid transparent; | ||
border-radius: 50%; | ||
animation: spin 1.5s linear 0s infinite; | ||
} | ||
|
||
.small { | ||
width: 30px; | ||
height: 30px; | ||
} |
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,11 @@ | ||
import { render } from "@testing-library/react"; | ||
|
||
import Spinner from "./Spinner"; | ||
|
||
describe("<Spinner />", () => { | ||
it("should render without crash", () => { | ||
const { asFragment } = render(<Spinner />); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
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,43 +1,14 @@ | ||
import classnames from "classnames"; | ||
import React from "react"; | ||
import styled, { keyframes } from "styled-components"; | ||
|
||
interface IProps { | ||
backgroundColor?: string; | ||
import styles from "./Spinner.module.scss"; | ||
|
||
interface SpinnerProps { | ||
small?: boolean; | ||
} | ||
|
||
export const SpinAnimation = keyframes` | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
`; | ||
|
||
const SpinnerWheel = styled.div<{ small?: boolean }>` | ||
display: inline-block; | ||
height: ${({ small }) => (small ? 30 : 42)}px; | ||
width: ${({ small }) => (small ? 30 : 42)}px; | ||
border-radius: 50%; | ||
border: 4px solid ${({ theme }) => theme.primaryColor12}; | ||
position: relative; | ||
animation: ${SpinAnimation} 1.5s linear 0s infinite; | ||
`; | ||
|
||
const BreakRec = styled.div<IProps>` | ||
width: 13px; | ||
height: 7px; | ||
background: ${({ theme, backgroundColor }) => (backgroundColor ? backgroundColor : theme.whiteColor)}; | ||
top: -4px; | ||
position: relative; | ||
margin: 0 auto; | ||
`; | ||
|
||
const Spinner: React.FC<IProps> = ({ backgroundColor, small }) => ( | ||
<SpinnerWheel small={small}> | ||
<BreakRec backgroundColor={backgroundColor} /> | ||
</SpinnerWheel> | ||
const Spinner: React.FC<SpinnerProps> = ({ small }) => ( | ||
<div className={classnames(styles.spinner, { [styles.small]: small })} /> | ||
); | ||
|
||
export default Spinner; |
9 changes: 9 additions & 0 deletions
9
airbyte-webapp/src/components/Spinner/__snapshots__/Spinner.test.tsx.snap
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Spinner /> should render without crash 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="spinner" | ||
/> | ||
</DocumentFragment> | ||
`; |
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,15 @@ | ||
import { ComponentStory, ComponentMeta } from "@storybook/react"; | ||
|
||
import SpinnerComponent from "./Spinner"; | ||
|
||
export default { | ||
title: "Ui/Spinner", | ||
component: SpinnerComponent, | ||
argTypes: { | ||
small: { type: "boolean", required: false }, | ||
}, | ||
} as ComponentMeta<typeof SpinnerComponent>; | ||
|
||
const Template: ComponentStory<typeof SpinnerComponent> = (args) => <SpinnerComponent {...args} />; | ||
|
||
export const Primary = Template.bind({}); |
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