Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nuxt): added loading indicator error #27176

Merged
merged 2 commits into from
May 16, 2024

Conversation

dethdkn
Copy link
Contributor

@dethdkn dethdkn commented May 12, 2024

馃敆 Linked issue

resolves #27175

馃摎 Description

This PR adds an error option to finish function from useLoadingIndicator
It can be called with

<script setup lang="ts">
const { start, finish, error } = useLoadingIndicator()

start()

finish({ error: true })

console.log(error.value)
</script>

When finish is called with error set to true, the error ref from useLoadingIndicator will be set to true until the next start(), where it is set back to false

The color of the error can also be change with errorColor prop on NuxtLoadingIndicator component

<template>
  <NuxtLoadingIndicator errorColor="blue" />
</template>

example:
loading

<script setup lang="ts">
const { start, finish, isLoading, error } = useLoadingIndicator()
</script>

<template>
  <NuxtLoadingIndicator :height="5" />
  <div>
    Nuxt 3 Playground
  </div>
  <button @click="start">
    Start
  </button>
  <button @click="finish">
    Finish
  </button>
  <button @click="finish({ error: true })">
    Error
  </button>
  <p :style="isLoading ? 'color: green;' : 'color: red;'">
    isLoading: {{ isLoading }}
  </p>
  <p :style="error ? 'color: green;' : 'color: red;'">
    error: {{ error }}
  </p>
</template>

Before creating the pull request, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way. If you find a duplicate, please help us reviewing it.
  • Read the contribution docs at https://nuxt.com/docs/community/contribution
  • Ensure that PR title follows conventional commits (https://www.conventionalcommits.org)
  • Update the corresponding documentation if needed.
  • Include relevant tests that fail without this PR but pass with it.

Copy link

stackblitz bot commented May 12, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@dethdkn dethdkn changed the title feat: Added loading indicator error feat(nuxt): added loading indicator error May 12, 2024
@dethdkn dethdkn mentioned this pull request May 13, 2024
4 tasks
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea and very nicely implemented. 馃憣

@danielroe danielroe merged commit 5842377 into nuxt:main May 16, 2024
64 of 65 checks passed
@github-actions github-actions bot mentioned this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] useLoadingIndicator error
2 participants