-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Progress): new component (#697)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
- Loading branch information
1 parent
f5f76cc
commit 2c5559b
Showing
9 changed files
with
634 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
docs/components/content/examples/ProgressExampleAnimation.vue
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,34 @@ | ||
<template> | ||
<UProgress class="progress"> | ||
<template #indicator> | ||
<div class="text-right text-amber-500"> | ||
🔥 This is too hot! | ||
</div> | ||
</template> | ||
</UProgress> | ||
</template> | ||
|
||
<style scoped> | ||
.progress:deep(progress:indeterminate.animation-default) { | ||
&:after { | ||
@apply w-full text-red-500; | ||
animation: my-glow-animation 3s ease-in-out infinite; | ||
} | ||
&::-webkit-progress-value { | ||
@apply w-full text-red-500; | ||
animation: my-glow-animation 3s ease-in-out infinite; | ||
} | ||
&::-moz-progress-bar { | ||
@apply w-full text-red-500; | ||
animation: my-glow-animation 3s ease-in-out infinite; | ||
} | ||
} | ||
@keyframes my-glow-animation { | ||
50% { | ||
@apply text-amber-400; | ||
} | ||
} | ||
</style> |
25 changes: 25 additions & 0 deletions
25
docs/components/content/examples/ProgressExampleSlotIndicator.vue
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,25 @@ | ||
<script setup> | ||
const temp = ref(35) | ||
const color = computed(() => { | ||
switch (true) { | ||
case temp.value < 10: return 'blue' | ||
case temp.value < 20: return 'amber' | ||
case temp.value < 30: return 'orange' | ||
default: return 'red' | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<UProgress :value="temp" :max="40" :color="color"> | ||
<template #indicator="{ percent }"> | ||
<div class="text-right" :style="{ width: `${percent}%` }"> | ||
<span v-if="temp < 10" class="text-blue-500">Too cold!</span> | ||
<span v-else-if="temp < 20" class="text-amber-500">Warm</span> | ||
<span v-else-if="temp < 30" class="text-orange-500">Hot</span> | ||
<span v-else class="text-red-500 font-bold">🔥 Too hot!</span> | ||
</div> | ||
</template> | ||
</UProgress> | ||
</template> |
31 changes: 31 additions & 0 deletions
31
docs/components/content/examples/ProgressExampleSlotStep.vue
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,31 @@ | ||
<script setup> | ||
const task = ref(1) | ||
const steps = [ | ||
'Cloning...', | ||
'Migrating...', | ||
'Deploying...' | ||
] | ||
</script> | ||
|
||
<template> | ||
<UProgress :value="task" :max="steps" indicator> | ||
<template #step-0="{ step }"> | ||
<span class="text-lime-500"> | ||
<UIcon name="i-heroicons-arrow-down-circle" /> {{ step }} | ||
</span> | ||
</template> | ||
|
||
<template #step-1="{ step }"> | ||
<span class="text-amber-500"> | ||
<UIcon name="i-heroicons-circle-stack" /> {{ step }} | ||
</span> | ||
</template> | ||
|
||
<template #step-2="{ step }"> | ||
<span class="text-blue-500"> | ||
<UIcon name="i-heroicons-hand-thumb-up" /> {{ step }} | ||
</span> | ||
</template> | ||
</UProgress> | ||
</template> |
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,153 @@ | ||
--- | ||
title: 'Progress' | ||
description: Show a horizontal bar to indicate task progression. | ||
navigation: | ||
badge: New | ||
links: | ||
- label: GitHub | ||
icon: i-simple-icons-github | ||
to: https://github.com/nuxt/ui/blob/dev/src/runtime/components/elements/Progress.vue | ||
--- | ||
|
||
## Usage | ||
|
||
Pass an integer as the `value` from `0` to `100` to the Progress bar component. | ||
|
||
::component-card | ||
--- | ||
props: | ||
value: 70 | ||
--- | ||
:: | ||
|
||
::callout{icon="i-heroicons-light-bulb"} | ||
Check out the [Range](/forms/range) component for forms. | ||
:: | ||
|
||
### Max | ||
|
||
You may also set the `max` number to set the maximum progress value, which will be relative to 100% percent. | ||
|
||
::component-card | ||
--- | ||
props: | ||
value: 2 | ||
max: 5 | ||
options: | ||
- name: max | ||
restriction: only | ||
values: | ||
- 3 | ||
- 4 | ||
- 5 | ||
- 6 | ||
- 7 | ||
--- | ||
:: | ||
|
||
### Steps | ||
|
||
You can set an array of named steps in the `max` prop to show the active step, at the same time it sets the maximum value. | ||
|
||
The first step is always shown at `0%`, making the last `100%`. | ||
|
||
::component-card | ||
--- | ||
props: | ||
value: 0 | ||
max: | ||
- Waiting to start | ||
- Cloning... | ||
- Migrating... | ||
- Deployed! | ||
excludedProps: | ||
- max | ||
--- | ||
:: | ||
|
||
### Progress indicator | ||
|
||
You can add a numeric indicator, which will show the percent on top the progress track. | ||
|
||
::component-card | ||
--- | ||
props: | ||
value: 20 | ||
indicator: true | ||
--- | ||
:: | ||
|
||
### Indeterminate | ||
|
||
By not setting a `value`, or setting it as `null`, the progress bar becomes _indeterminate_. The bar will be animated as a carousel, but you can change it using the `animation` prop for an inverse carousel, a swinging bar or an elastic bar. | ||
|
||
::component-card | ||
--- | ||
baseProps: | ||
value: null | ||
props: | ||
animation: 'carousel' | ||
options: | ||
- name: animation | ||
restriction: only | ||
values: | ||
- 'carousel' | ||
- 'carousel-inverse' | ||
- 'swing' | ||
- 'elastic' | ||
--- | ||
:: | ||
|
||
### Size | ||
|
||
Use the `size` prop to change the size of the progress bar. | ||
|
||
::component-card | ||
--- | ||
baseProps: | ||
value: 70 | ||
props: | ||
size: 'sm' | ||
indicator: false | ||
excludedProps: | ||
- value | ||
--- | ||
:: | ||
|
||
### Style | ||
|
||
Use the `color` prop to change the visual style of the Progress bar. The `color` can be any color from the `ui.colors` object. | ||
|
||
::component-card | ||
--- | ||
baseProps: | ||
value: 70 | ||
props: | ||
color: 'primary' | ||
indicator: false | ||
excludedProps: | ||
- modelValue | ||
--- | ||
:: | ||
|
||
## Slots | ||
|
||
### `indicator` | ||
|
||
You can use the `#indicator` slot to show a custom indicator above the progress bar. It receives the current `percent` of progress. | ||
|
||
:component-example{component="progress-example-slot-indicator"} | ||
|
||
### `step-<index>` | ||
|
||
Use the `#step-<index>` to alter the HTML being shown for each step. | ||
|
||
:component-example{component="progress-example-slot-step"} | ||
|
||
## Props | ||
|
||
:component-props | ||
|
||
## Preset | ||
|
||
:component-preset |
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
Oops, something went wrong.
2c5559b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ui – ./
ui-git-dev-nuxt-js.vercel.app
ui-nuxt-js.vercel.app
ui.nuxt.com