diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..357607e --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +16.6.2 diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 93fd13e..c9c0e8e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -42,6 +42,7 @@ function getComponents() { { text: 'Button Group', link: '/components/buttonGroup/buttonGroup.md' }, { text: 'Card', link: 'components/card/card.md' }, { text: 'Dropdown', link: '/components/dropdown/dropdown.md' }, + { text: 'Progress', link: 'components/progress/progress.md' }, { text: 'Spinner', link: '/components/spinner/spinner.md' }, { text: 'Tabs', link: '/components/tabs/tabs.md' }, { text: 'ListGroup', link: 'components/listGroup/listGroup.md' }, @@ -53,7 +54,6 @@ function getComponents() { { text: '- Carousel', link: 'components/carousel/carousel.md' }, { text: '- Footer', link: 'components/footer/footer.md' }, { text: '- Pagination', link: 'components/pagination/pagination.md' }, - { text: '- Progress', link: 'components/progress/progress.md' }, { text: '- Rating', link: 'components/rating/rating.md' }, { text: '- Sidebar', link: 'components/sidebar/sidebar.md' }, { text: '- Table', link: 'components/table/table.md' }, diff --git a/docs/components/progress/examples/ProgressColorExample.vue b/docs/components/progress/examples/ProgressColorExample.vue new file mode 100644 index 0000000..4015895 --- /dev/null +++ b/docs/components/progress/examples/ProgressColorExample.vue @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/docs/components/progress/examples/ProgressExample.vue b/docs/components/progress/examples/ProgressExample.vue index 62c6704..bd62efb 100644 --- a/docs/components/progress/examples/ProgressExample.vue +++ b/docs/components/progress/examples/ProgressExample.vue @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/docs/components/progress/examples/ProgressOutsideLabelExample.vue b/docs/components/progress/examples/ProgressOutsideLabelExample.vue new file mode 100644 index 0000000..7da0a2a --- /dev/null +++ b/docs/components/progress/examples/ProgressOutsideLabelExample.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/docs/components/progress/examples/ProgressSizeExample.vue b/docs/components/progress/examples/ProgressSizeExample.vue new file mode 100644 index 0000000..f79454c --- /dev/null +++ b/docs/components/progress/examples/ProgressSizeExample.vue @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/docs/components/progress/progress.md b/docs/components/progress/progress.md index 3ab4a7a..10c7707 100644 --- a/docs/components/progress/progress.md +++ b/docs/components/progress/progress.md @@ -1,15 +1,102 @@ # Vue Progress Bar Component - Flowbite +## Default + ```vue ``` + +## Sizes +You can also use different sizes by using various sizing. + +```vue + + +``` + + + +## With label inside +Here is an example of using a progress bar with the label inside the bar. + +```vue + + +``` + + + +## With label outside +And this is an example of using a progress bar outside the bar. + +```vue + + +``` + + + +## Colors +You can also apply color. + +```vue + + +``` + + \ No newline at end of file diff --git a/src/components/Button/composables/useButtonClasses.ts b/src/components/Button/composables/useButtonClasses.ts index ec71268..b83fae4 100644 --- a/src/components/Button/composables/useButtonClasses.ts +++ b/src/components/Button/composables/useButtonClasses.ts @@ -122,7 +122,6 @@ const buttonOutlineGradientClasses: ButtonClassMap = { }, } - const buttonSizeClasses: Record = { xs: 'text-xs px-2 py-1', sm: 'text-sm px-3 py-1.5', diff --git a/src/components/Progress/Progress.vue b/src/components/Progress/Progress.vue index 378c2d8..2237753 100644 --- a/src/components/Progress/Progress.vue +++ b/src/components/Progress/Progress.vue @@ -1,23 +1,37 @@ diff --git a/src/components/Progress/composables/useProgressClasses.ts b/src/components/Progress/composables/useProgressClasses.ts new file mode 100644 index 0000000..f97f30b --- /dev/null +++ b/src/components/Progress/composables/useProgressClasses.ts @@ -0,0 +1,78 @@ +import type { Ref } from 'vue' +import { computed } from 'vue' +import classNames from 'classnames' +import type { ProgressVariant, ProgressSize, ProgressLabelPosition } from '../types' + +const barColorClasses: Record = { + default: 'bg-blue-600 dark:bg-blue-600', + blue: 'bg-blue-600 dark:bg-blue-600', + dark: 'bg-gray-600 dark:bg-gray-300', + green: 'bg-green-600 dark:bg-green-500', + red: 'bg-red-600 dark:bg-red-500', + yellow: 'bg-yellow-400', + indigo: 'bg-indigo-600 dark:bg-indigo-500', + purple: 'bg-purple-600 dark:bg-purple-500', +} + +const outsideTextColorClasses: Record = { + default: '', + blue: 'text-blue-700 dark:text-blue-500', + dark: 'dark:text-white', + green: 'text-green-700 dark:text-green-500', + red: 'text-red-700 dark:text-red-500', + yellow: 'text-yellow-700 dark:text-yellow-500', + indigo: 'text-indigo-700 dark:text-indigo-500', + purple: 'text-purple-700 dark:text-purple-500', +} + +const progressSizeClasses: Record = { + sm: 'h-1.5 text-xs leading-none', + md: 'h-2.5 text-xs leading-none', + lg: 'h-4 text-sm leading-none', + xl: 'h-6 text-base leading-tight', +} + +export type UseProgressClassesProps = { + color: Ref + size: Ref + labelPosition: Ref +} + +export function useProgressClasses(props: UseProgressClassesProps): { innerClasses: Ref, outerClasses: Ref, outsideLabelClasses: Ref} { + + const bindClasses = computed(() => { + let colorClass = '' + colorClass = barColorClasses[props.color.value] + + let sizeClass = '' + sizeClass = progressSizeClasses[props.size.value] + + return classNames( + colorClass, + sizeClass, + ) + }) + + const outerClasses = computed(() => { + let outerSizeClass = '' + outerSizeClass = progressSizeClasses[props.size.value] + return classNames( + outerSizeClass + ) + }) + + const outsideLabelClasses = computed(() => { + let outsideLabelClass = '' + outsideLabelClass = outsideTextColorClasses[props.color.value] + return classNames( + outsideLabelClass + ) + }) + + + return { + innerClasses: bindClasses, + outerClasses, + outsideLabelClasses + } +} \ No newline at end of file diff --git a/src/components/Progress/types.ts b/src/components/Progress/types.ts new file mode 100644 index 0000000..ec44e3d --- /dev/null +++ b/src/components/Progress/types.ts @@ -0,0 +1,3 @@ +export type ProgressVariant = 'default' | 'dark' | 'green' | 'red' | 'yellow' | 'purple' | 'blue' | 'indigo' +export type ProgressSize = 'sm' | 'md' | 'lg' | 'xl' +export type ProgressLabelPosition = 'inside' | 'outside' | 'none'