diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..77bc3cf --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,55 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + pull_request: + branches: [ "main" ] + +jobs: + docs-build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm i + - run: npm run build + lint: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm i + - run: npm run lint + build-pkg: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm i + - run: npm run build:package diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index bd71107..38db977 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -34,45 +34,44 @@ function buildSidebar() { function getComponents() { return [ - { text: 'Accordion', link: 'components/accordion/accordion.md' }, - { text: 'Alert', link: '/components/alert/alert.md' }, - { text: 'Avatar', link: 'components/avatar/avatar.md' }, - { text: 'Breadcrumb', link: 'components/breadcrumb/breadcrumb.md' }, - { text: 'Button', link: '/components/button/button.md' }, - { text: 'Badge', link: 'components/badge/badge.md' }, - { text: 'Button Group', link: '/components/buttonGroup/buttonGroup.md' }, - { text: 'Card', link: 'components/card/card.md' }, - { text: 'Carousel', link: 'components/carousel/carousel.md' }, - { text: 'Dropdown', link: '/components/dropdown/dropdown.md' }, - { text: 'Progress', link: 'components/progress/progress.md' }, - { text: 'Spinner', link: '/components/spinner/spinner.md' }, - { text: 'Table', link: 'components/table/table.md' }, - { text: 'Tabs', link: '/components/tabs/tabs.md' }, - { text: 'ListGroup', link: 'components/listGroup/listGroup.md' }, - { text: 'Toast', link: 'components/toast/toast.md' }, - { text: 'Tooltip', link: 'components/tooltip/tooltip.md' }, - { text: 'Modal', link: 'components/modal/modal.md' }, - { text: 'Navbar', link: 'components/navbar/navbar.md' }, + { text: 'Accordion', link: 'components/accordion' }, + { text: 'Alert', link: '/components/alert' }, + { text: 'Avatar', link: 'components/avatar' }, + { text: 'Breadcrumb', link: 'components/breadcrumb' }, + { text: 'Button', link: '/components/button' }, + { text: 'Badge', link: 'components/badge' }, + { text: 'Button Group', link: '/components/button-group' }, + { text: 'Card', link: 'components/card.md' }, + { text: 'Carousel', link: 'components/carousel' }, + { text: 'Dropdown', link: '/components/dropdown' }, + { text: 'Progress', link: 'components/progress' }, + { text: 'Rating', link: 'components/rating' }, + { text: 'Spinner', link: '/components/spinner' }, + { text: 'Table', link: 'components/table' }, + { text: 'Tabs', link: '/components/tabs' }, + { text: 'ListGroup', link: 'components/list-group' }, + { text: 'Toast', link: 'components/toast' }, + { text: 'Tooltip', link: 'components/tooltip' }, + { text: 'Modal', link: 'components/modal' }, + { text: 'Navbar', link: 'components/navbar' }, - { text: '- Footer', link: 'components/footer/footer.md' }, - { text: '- Pagination', link: 'components/pagination/pagination.md' }, - { text: '- Rating', link: 'components/rating/rating.md' }, - { text: '- Sidebar', link: 'components/sidebar/sidebar.md' }, - { text: '- Timeline', link: 'components/timeline/timeline.md' }, + { text: '- Footer', link: 'components/footer' }, + { text: '- Pagination', link: 'components/pagination' }, + { text: '- Sidebar', link: 'components/sidebar' }, + { text: '- Timeline', link: 'components/timeline' }, ] } function getFormComponents() { return [ - { text: 'Input', link: 'components/input/input.md' }, + { text: 'Input', link: 'components/input' }, ] } function getUtils() { return [ { text: 'Flowbite Themable', link: '/components/flowbiteThemable/flowbiteThemable.md' }, - { text: 'Toast Provider', link: '/components/toastProvider/toastProvider.md' }, - { text: 'PLAYGROUND', link: '/components/PLAYGROUND/PLAYGROUND.md' }, + { text: 'Toast Provider', link: '/components/toastProvider/toastProvider.md' } ] } diff --git a/docs/components/accordion/accordion.md b/docs/components/accordion.md similarity index 96% rename from docs/components/accordion/accordion.md rename to docs/components/accordion.md index 2e2209c..425f0da 100644 --- a/docs/components/accordion/accordion.md +++ b/docs/components/accordion.md @@ -1,8 +1,8 @@ # Vue Accordion Component - Flowbite @@ -14,7 +14,7 @@ Original reference: [https://flowbite.com/docs/components/accordion/](https://fl ::: ## Default accordion -Use this example to basic accordion. +Use this example to basic accordion. ```vue # Vue Alert Component - Flowbite @@ -29,7 +29,7 @@ defineProps({ type: { type: String as PropType, default: 'info', - }, + }, }) ``` @@ -58,7 +58,7 @@ defineProps({ title: { type: String, default: '', - }, + }, }) ``` @@ -87,7 +87,7 @@ defineProps({ closable: { type: Boolean, default: false, - }, + }, }) ``` @@ -116,7 +116,7 @@ defineProps({ border: { type: Boolean, default: false, - }, + }, }) ``` @@ -145,7 +145,7 @@ defineProps({ icon: { type: Boolean, default: true, - }, + }, }) ``` @@ -174,7 +174,7 @@ defineProps({ inline: { type: Boolean, default: true, - }, + }, }) ``` diff --git a/docs/components/avatar/avatar.md b/docs/components/avatar.md similarity index 89% rename from docs/components/avatar/avatar.md rename to docs/components/avatar.md index 9a65c1e..38b64ab 100644 --- a/docs/components/avatar/avatar.md +++ b/docs/components/avatar.md @@ -1,13 +1,13 @@ # Vue Avatar Component - Flowbite diff --git a/docs/components/badge/badge.md b/docs/components/badge.md similarity index 88% rename from docs/components/badge/badge.md rename to docs/components/badge.md index 9cf1905..af4c332 100644 --- a/docs/components/badge/badge.md +++ b/docs/components/badge.md @@ -1,9 +1,9 @@ # Vue Badge Component - Flowbite diff --git a/docs/components/breadcrumb/breadcrumb.md b/docs/components/breadcrumb.md similarity index 81% rename from docs/components/breadcrumb/breadcrumb.md rename to docs/components/breadcrumb.md index 4127852..3c16336 100644 --- a/docs/components/breadcrumb/breadcrumb.md +++ b/docs/components/breadcrumb.md @@ -1,7 +1,7 @@ # Vue Breadcrumb Component - Flowbite The breadcrumb component is an important part of any website or application that can be used to show the current location of a page in a hierarchical structure of pages. diff --git a/docs/components/buttonGroup/buttonGroup.md b/docs/components/button-group.md similarity index 89% rename from docs/components/buttonGroup/buttonGroup.md rename to docs/components/button-group.md index 54ad533..4cdf35c 100644 --- a/docs/components/buttonGroup/buttonGroup.md +++ b/docs/components/button-group.md @@ -1,6 +1,6 @@ # Vue Button Group Component - Flowbite diff --git a/docs/components/button/button.md b/docs/components/button.md similarity index 91% rename from docs/components/button/button.md rename to docs/components/button.md index dadc71f..8663abe 100644 --- a/docs/components/button/button.md +++ b/docs/components/button.md @@ -1,18 +1,18 @@ # Vue Button Component - Flowbite @@ -37,7 +37,7 @@ defineProps({ color: { type: String as PropType, default: 'default', - }, + }, }) ``` diff --git a/docs/components/card/card.md b/docs/components/card.md similarity index 90% rename from docs/components/card/card.md rename to docs/components/card.md index 4358c58..2793278 100644 --- a/docs/components/card/card.md +++ b/docs/components/card.md @@ -1,7 +1,7 @@ # Vue Card Components - Flowbite diff --git a/docs/components/carousel/carousel.md b/docs/components/carousel.md similarity index 85% rename from docs/components/carousel/carousel.md rename to docs/components/carousel.md index 83f7474..874c21f 100644 --- a/docs/components/carousel/carousel.md +++ b/docs/components/carousel.md @@ -1,10 +1,10 @@ # Vue Carousel Component - Flowbite @@ -166,4 +166,4 @@ const pictures = [ -``` \ No newline at end of file +``` diff --git a/docs/components/dropdown/dropdown.md b/docs/components/dropdown.md similarity index 95% rename from docs/components/dropdown/dropdown.md rename to docs/components/dropdown.md index 9a570de..ee9af0b 100644 --- a/docs/components/dropdown/dropdown.md +++ b/docs/components/dropdown.md @@ -1,7 +1,7 @@ # Vue Dropdown Component - Flowbite diff --git a/docs/components/footer/footer.md b/docs/components/footer.md similarity index 75% rename from docs/components/footer/footer.md rename to docs/components/footer.md index 897328a..acdb1f8 100644 --- a/docs/components/footer/footer.md +++ b/docs/components/footer.md @@ -1,5 +1,5 @@ # Vue Footer Component - Flowbite diff --git a/docs/components/input/input.md b/docs/components/input.md similarity index 87% rename from docs/components/input/input.md rename to docs/components/input.md index 026f765..c938039 100644 --- a/docs/components/input/input.md +++ b/docs/components/input.md @@ -1,10 +1,10 @@ # Vue Input Components - Flowbite diff --git a/docs/components/listGroup/listGroup.md b/docs/components/list-group.md similarity index 94% rename from docs/components/listGroup/listGroup.md rename to docs/components/list-group.md index 6793a10..72f0650 100644 --- a/docs/components/listGroup/listGroup.md +++ b/docs/components/list-group.md @@ -1,8 +1,8 @@ # Vue List Group Component - Flowbite diff --git a/docs/components/modal/modal.md b/docs/components/modal.md similarity index 96% rename from docs/components/modal/modal.md rename to docs/components/modal.md index a0a760e..a6caeb4 100644 --- a/docs/components/modal/modal.md +++ b/docs/components/modal.md @@ -1,6 +1,6 @@ # Vue Modal Component - Flowbite diff --git a/docs/components/navbar/navbar.md b/docs/components/navbar.md similarity index 92% rename from docs/components/navbar/navbar.md rename to docs/components/navbar.md index f78300a..4fb5e1d 100644 --- a/docs/components/navbar/navbar.md +++ b/docs/components/navbar.md @@ -1,8 +1,8 @@ # Navbar Component – Flowbite diff --git a/docs/components/pagination/pagination.md b/docs/components/pagination.md similarity index 73% rename from docs/components/pagination/pagination.md rename to docs/components/pagination.md index 9b8fbe2..c4388f2 100644 --- a/docs/components/pagination/pagination.md +++ b/docs/components/pagination.md @@ -1,5 +1,5 @@ # Vue Pagination Component - Flowbite diff --git a/docs/components/progress/progress.md b/docs/components/progress.md similarity index 83% rename from docs/components/progress/progress.md rename to docs/components/progress.md index 10c7707..f377cbe 100644 --- a/docs/components/progress/progress.md +++ b/docs/components/progress.md @@ -1,9 +1,9 @@ @@ -99,4 +99,4 @@ import { Progress } from 'flowbite-vue' ``` - \ No newline at end of file + diff --git a/docs/components/rating.md b/docs/components/rating.md new file mode 100644 index 0000000..09dbffb --- /dev/null +++ b/docs/components/rating.md @@ -0,0 +1,77 @@ + +# Vue Rating Component - Flowbite + +## Default rating +Use this simple example of a star rating component for showing review results. +```vue + + +``` + + + +## Rating with text +If you also want to show a text near the stars you can use this example as a reference. +```vue + + +``` + + + +## Rating count +Aggregate more results by using this example to show the amount of reviews and the average score. +```vue + + +``` + + + +## Star sizes +Check out the different sizing options for the star review component from small, medium, and large. +```vue + + +``` + + diff --git a/docs/components/rating/examples/RatingCountExample.vue b/docs/components/rating/examples/RatingCountExample.vue new file mode 100644 index 0000000..08cc1b9 --- /dev/null +++ b/docs/components/rating/examples/RatingCountExample.vue @@ -0,0 +1,17 @@ + + diff --git a/docs/components/rating/examples/RatingExample.vue b/docs/components/rating/examples/RatingExample.vue index 7da2976..cb1626d 100644 --- a/docs/components/rating/examples/RatingExample.vue +++ b/docs/components/rating/examples/RatingExample.vue @@ -1,6 +1,6 @@ diff --git a/docs/components/rating/examples/RatingWithTextExample.vue b/docs/components/rating/examples/RatingWithTextExample.vue new file mode 100644 index 0000000..aa7230c --- /dev/null +++ b/docs/components/rating/examples/RatingWithTextExample.vue @@ -0,0 +1,12 @@ + + diff --git a/docs/components/rating/rating.md b/docs/components/rating/rating.md deleted file mode 100644 index 98b3a4c..0000000 --- a/docs/components/rating/rating.md +++ /dev/null @@ -1,15 +0,0 @@ - -# Vue Rating Component - Flowbite - -```vue - - -``` - - diff --git a/docs/components/sidebar/sidebar.md b/docs/components/sidebar.md similarity index 75% rename from docs/components/sidebar/sidebar.md rename to docs/components/sidebar.md index 98dcea5..b7c644b 100644 --- a/docs/components/sidebar/sidebar.md +++ b/docs/components/sidebar.md @@ -1,5 +1,5 @@ # Vue Sidebar Component - Flowbite diff --git a/docs/components/spinner/spinner.md b/docs/components/spinner.md similarity index 89% rename from docs/components/spinner/spinner.md rename to docs/components/spinner.md index b5cbe05..ea2a9a1 100644 --- a/docs/components/spinner/spinner.md +++ b/docs/components/spinner.md @@ -1,7 +1,7 @@ # Vue Spinner Component - Flowbite diff --git a/docs/components/table/table.md b/docs/components/table.md similarity index 95% rename from docs/components/table/table.md rename to docs/components/table.md index 9e8e5ba..3d9f3a2 100644 --- a/docs/components/table/table.md +++ b/docs/components/table.md @@ -1,8 +1,8 @@ # Vue Table Component - Flowbite diff --git a/docs/components/tabs/tabs.md b/docs/components/tabs.md similarity index 92% rename from docs/components/tabs/tabs.md rename to docs/components/tabs.md index 33926b0..8fa5c33 100644 --- a/docs/components/tabs/tabs.md +++ b/docs/components/tabs.md @@ -1,7 +1,7 @@ # Vue Tabs Component - Flowbite diff --git a/docs/components/timeline/timeline.md b/docs/components/timeline.md similarity index 74% rename from docs/components/timeline/timeline.md rename to docs/components/timeline.md index 8d552d7..6516756 100644 --- a/docs/components/timeline/timeline.md +++ b/docs/components/timeline.md @@ -1,5 +1,5 @@ # Vue Timeline Component - Flowbite diff --git a/docs/components/toast/toast.md b/docs/components/toast.md similarity index 93% rename from docs/components/toast/toast.md rename to docs/components/toast.md index b8ddf84..b766be5 100644 --- a/docs/components/toast/toast.md +++ b/docs/components/toast.md @@ -1,10 +1,10 @@ # Vue Toast Component - Flowbite diff --git a/docs/components/tooltip/tooltip.md b/docs/components/tooltip.md similarity index 95% rename from docs/components/tooltip/tooltip.md rename to docs/components/tooltip.md index ab4949d..d578559 100644 --- a/docs/components/tooltip/tooltip.md +++ b/docs/components/tooltip.md @@ -1,8 +1,8 @@ # Vue Tooltip Component - Flowbite diff --git a/package.json b/package.json index 4f738b5..4fba9f5 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "build:package": "vite build", "build:types": "vue-tsc --declaration --emitDeclarationOnly && tsc-alias -p tsconfig.json", "build:production": "npm run build:types && npm run build:package", - "lint": "eslint --ext .ts,.vue --ignore-path .gitignore --fix src", + "lint": "eslint --ext .ts,.vue --ignore-path .gitignore", + "lint-fix": "eslint --ext .ts,.vue --ignore-path .gitignore --fix src", "clear": "rm -fr ./dist && rm -fr ./dist_types", "format": "prettier . --write", "test": "vitest", diff --git a/src/components/Rating/Rating.vue b/src/components/Rating/Rating.vue index be45f18..c6ece2f 100644 --- a/src/components/Rating/Rating.vue +++ b/src/components/Rating/Rating.vue @@ -1,21 +1,81 @@ + diff --git a/src/components/Rating/composables/useRatingClasses.ts b/src/components/Rating/composables/useRatingClasses.ts new file mode 100644 index 0000000..c25c8f4 --- /dev/null +++ b/src/components/Rating/composables/useRatingClasses.ts @@ -0,0 +1,28 @@ +import type { Ref } from 'vue' +import { computed } from 'vue' +import classNames from 'classnames' +import type { RatingSize } from '../types' + +const ratingSizeClasses: Record = { + sm: 'w-5 h-5', + md: 'w-7 h-7', + lg: 'w-10 h-10', +} + +export type UseRatingClassesProps = { + size: Ref +} + +export function useRatingClasses(props: UseRatingClassesProps):{ + sizeClasses: Ref +}{ + const sizeClasses = computed(() => { + return classNames( + ratingSizeClasses[props.size.value] ?? '', + ) + }) + + return { + sizeClasses, + } +} diff --git a/src/components/Rating/types.ts b/src/components/Rating/types.ts new file mode 100644 index 0000000..f6f279e --- /dev/null +++ b/src/components/Rating/types.ts @@ -0,0 +1 @@ +export type RatingSize = 'sm' | 'md' | 'lg' \ No newline at end of file