Skip to content

Commit 14ac243

Browse files
feat(ProgressGroup): new component (#6860)
1 parent a630c94 commit 14ac243

26 files changed

Lines changed: 2347 additions & 22 deletions

docs/app/components/content/ComponentProps.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
6666
6767
// @ts-expect-error - Type is not correct
6868
prop.type = !prop.type.startsWith('boolean') && prop.schema?.kind === 'enum' && Object.keys(prop.schema.schema)?.length ? Object.values(prop.schema.schema).map(schema => schema?.type ? schema.type : schema).join(' | ') : prop.type
69+
// `(string & {})` widens a literal union while keeping autocompletion, display it as plain `string`
70+
prop.type = prop.type.replace(/\(?string & \{\}\)?/g, 'string')
6971
return prop
7072
}).sort((a, b) => {
7173
if (a.name === 'as') {

docs/app/components/content/ComponentPropsSchema.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ function getSchemaProps(schema: PropertyMeta['schema']): any {
1414
return []
1515
}
1616
17+
// `string & {}` widens a literal union, its object schema only lists String.prototype methods
18+
if (schema.type === 'string & {}') {
19+
return []
20+
}
21+
1722
if (schema.kind === 'object') {
1823
return Object.values(schema.schema).filter(prop => !props.ignore?.includes(prop.name))
1924
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<script setup lang="ts">
2+
import type { ProgressGroupItem } from '@nuxt/ui'
3+
4+
const max = 128
5+
6+
const items: ProgressGroupItem[] = [
7+
{ label: 'System prompt', value: 4.2, color: 'var(--color-neutral-400)' },
8+
{ label: 'Tool definitions', value: 18.4, color: 'var(--color-violet-400)' },
9+
{ label: 'Rules', value: 12.8, color: 'var(--color-green-400)' },
10+
{ label: 'Skills', value: 7.1, color: 'var(--color-amber-400)' },
11+
{ label: 'MCP & dynamic tools', value: 17.1, color: 'var(--color-rose-400)' },
12+
{ label: 'Subagent definitions', value: 5.5, color: 'var(--color-sky-400)' },
13+
{ label: 'Conversation', value: 24.6, color: 'var(--color-orange-400)' }
14+
]
15+
16+
const used = items.reduce((total, item) => total + (item.value ?? 0), 0)
17+
</script>
18+
19+
<template>
20+
<UProgressGroup :items="items" :max="max" status class="w-96" :ui="{ status: 'w-full justify-between' }">
21+
<template #status="{ percent }">
22+
<p>{{ percent }}% Full</p>
23+
<p class="text-muted">
24+
~{{ used.toFixed(1) }}K / {{ max }}K Tokens
25+
</p>
26+
</template>
27+
28+
<template #item-trailing="{ item }">
29+
{{ item.value }}K
30+
</template>
31+
</UProgressGroup>
32+
</template>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import type { ProgressGroupItem } from '@nuxt/ui'
3+
4+
const items: ProgressGroupItem[] = [
5+
{ label: 'System', value: 24, color: 'neutral' },
6+
{ label: 'Apps', value: 8, color: 'error' },
7+
{ label: 'Documents', value: 12, color: 'warning' },
8+
{ label: 'Multimedia', value: 42, color: 'success' }
9+
]
10+
</script>
11+
12+
<template>
13+
<UProgressGroup :items="items" :max="128" class="w-96">
14+
<template #item-label="{ item }">
15+
<span class="font-medium">{{ item.label }}</span>
16+
</template>
17+
18+
<template #item-trailing="{ item }">
19+
{{ item.value }}GB
20+
</template>
21+
</UProgressGroup>
22+
</template>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script setup lang="ts">
2+
import type { ProgressGroupItem } from '@nuxt/ui'
3+
4+
const max = 128
5+
6+
const items: ProgressGroupItem[] = [
7+
{ label: 'System', value: 24, color: 'neutral', icon: 'i-lucide-cog' },
8+
{ label: 'Apps', value: 8, color: 'error', icon: 'i-lucide-app-window' },
9+
{ label: 'Documents', value: 12, color: 'warning', icon: 'i-lucide-file' },
10+
{ label: 'Multimedia', value: 42, color: 'success', icon: 'i-lucide-film' }
11+
]
12+
13+
const used = items.reduce((total, item) => total + (item.value ?? 0), 0)
14+
</script>
15+
16+
<template>
17+
<UProgressGroup :items="items" :max="max" status class="w-96" :ui="{ status: 'w-full justify-between' }">
18+
<template #status>
19+
<p>{{ used }}GB used</p>
20+
<p class="text-muted">
21+
{{ max - used }}GB remaining
22+
</p>
23+
</template>
24+
</UProgressGroup>
25+
</template>

0 commit comments

Comments
 (0)