Skip to content

Commit

Permalink
feat(BaseProgress): add colors, add classes prop, update class bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
driss-chelouati committed Feb 22, 2024
1 parent 8daab5e commit 0ba373b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .playground/pages/tests/base/progress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ const progressCircle = ref(25)
:value="78"
color="danger"
/>
<BaseProgress
title="dark progress bar"
size="sm"
:value="78"
color="dark"
/>
<BaseProgress
title="black progress bar"
size="sm"
:value="78"
color="black"
/>
</div>
</NuiPreview>

Expand Down
39 changes: 34 additions & 5 deletions components/base/BaseProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ const props = withDefaults(
*
* @default 'primary'
*/
color?: 'primary' | 'info' | 'success' | 'warning' | 'danger'
color?:
| 'primary'
| 'info'
| 'success'
| 'warning'
| 'danger'
| 'light'
| 'dark'
| 'black'
/**
* The radius of the progress bar.
Expand All @@ -40,6 +48,21 @@ const props = withDefaults(
* The maximum value of the progress bar.
*/
max?: number
/**
* Optional CSS classes to apply to the component inner elements.
*/
classes?: {
/**
* CSS classes to apply to the wrapper element.
*/
wrapper?: string | string[]
/**
* CSS classes to apply to the progress element.
*/
progress?: string | string[]
}
}>(),
{
size: undefined,
Expand All @@ -48,6 +71,7 @@ const props = withDefaults(
rounded: undefined,
value: undefined,
max: 100,
classes: () => ({}),
},
)
Expand All @@ -62,6 +86,9 @@ const colors = {
success: 'nui-progress-success',
warning: 'nui-progress-warning',
danger: 'nui-progress-danger',
light: 'nui-progress-light',
dark: 'nui-progress-dark',
black: 'nui-progress-black',
} as Record<string, string>
const contrasts = {
Expand All @@ -71,10 +98,10 @@ const contrasts = {
const radiuses = {
none: '',
sm: 'nui-progress-rounded',
md: 'nui-progress-smooth',
lg: 'nui-progress-curved',
full: 'nui-progress-full',
sm: 'nui-progress-rounded-sm',
md: 'nui-progress-rounded-md',
lg: 'nui-progress-rounded-lg',
full: 'nui-progress-rounded-full',
} as Record<string, string>
const sizes = {
Expand Down Expand Up @@ -106,13 +133,15 @@ const value = computed(() => {
contrast && contrasts[contrast],
color && colors[color],
rounded && radiuses[rounded],
props.classes?.wrapper,
]"
>
<div
class="nui-progress-bar"
:class="[
value === null &&
'nui-progress-indeterminate animate-nui-progress-indeterminate',
props.classes?.progress,
]"
:style="value !== null ? `width: ${value}%` : 'width: 100%'"
></div>
Expand Down

0 comments on commit 0ba373b

Please sign in to comment.