-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: timer indicator for
spinner
(#230)
Co-authored-by: Nate Moore <[email protected]>
- Loading branch information
1 parent
251518b
commit 613179d
Showing
4 changed files
with
72 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
'@clack/prompts': minor | ||
--- | ||
|
||
Adds a new `indicator` option to `spinner`, which supports the original `"dots"` loading animation or a new `"timer"` loading animation. | ||
|
||
```ts | ||
import * as p from '@clack/prompts'; | ||
|
||
const spin = p.spinner({ indicator: 'timer' }); | ||
spin.start('Loading'); | ||
await sleep(3000); | ||
spin.stop('Loaded'); |
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,26 @@ | ||
import * as p from '@clack/prompts'; | ||
|
||
p.intro('spinner start...'); | ||
|
||
async function main() { | ||
const spin = p.spinner({ indicator: 'timer' }); | ||
|
||
spin.start('First spinner'); | ||
|
||
await sleep(3_000); | ||
|
||
spin.stop('Done first spinner'); | ||
|
||
spin.start('Second spinner'); | ||
await sleep(5_000); | ||
|
||
spin.stop('Done second spinner'); | ||
|
||
p.outro('spinner stop.'); | ||
} | ||
|
||
function sleep(ms: number) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
main(); |
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