Skip to content

Commit 3729b9b

Browse files
authored
Merge pull request framer#470 from framer/airtable-spinner
Add loading spinner to Airtable log in button
2 parents e933634 + 4ee7746 commit 3729b9b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

plugins/airtable/src/Login.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "./App.css"
22

33
import { framer } from "framer-plugin"
4-
import { useLayoutEffect, useRef } from "react"
4+
import { useLayoutEffect, useRef, useState } from "react"
55
import auth from "./auth"
66
import { showLoginUI } from "./ui"
77

@@ -10,6 +10,7 @@ interface AuthenticationProps {
1010
}
1111

1212
export function Authenticate({ onAuthenticated }: AuthenticationProps) {
13+
const [isLoading, setIsLoading] = useState(false)
1314
const pollInterval = useRef<number | ReturnType<typeof setInterval>>()
1415

1516
useLayoutEffect(() => {
@@ -35,6 +36,8 @@ export function Authenticate({ onAuthenticated }: AuthenticationProps) {
3536
const login = (event: React.FormEvent<HTMLFormElement>) => {
3637
event.preventDefault()
3738

39+
setIsLoading(true)
40+
3841
const task = async () => {
3942
try {
4043
// Retrieve the auth URL and a set of read and write keys
@@ -49,6 +52,8 @@ export function Authenticate({ onAuthenticated }: AuthenticationProps) {
4952
onAuthenticated()
5053
} catch (e) {
5154
framer.notify(e instanceof Error ? e.message : "An unknown error ocurred")
55+
} finally {
56+
setIsLoading(false)
5257
}
5358
}
5459

@@ -67,8 +72,8 @@ export function Authenticate({ onAuthenticated }: AuthenticationProps) {
6772
<li>Map the table fields to the CMS</li>
6873
</ol>
6974

70-
<button className="action-button" type="submit">
71-
Log In
75+
<button className="action-button" type="submit" aria-label={isLoading ? "Logging in" : "Log in"}>
76+
{isLoading ? <div className="framer-spinner" /> : "Log In"}
7277
</button>
7378
</form>
7479
)

0 commit comments

Comments
 (0)