diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 6ec6c3a..93fd13e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -47,11 +47,11 @@ function getComponents() { { text: 'ListGroup', link: 'components/listGroup/listGroup.md' }, { text: 'Toast', link: 'components/toast/toast.md' }, { text: 'Modal', link: 'components/modal/modal.md' }, + { text: 'Navbar', link: 'components/navbar/navbar.md' }, { text: '- Accordion', link: 'components/accordion/accordion.md' }, { text: '- Carousel', link: 'components/carousel/carousel.md' }, { text: '- Footer', link: 'components/footer/footer.md' }, - { text: '- Navbar', link: 'components/navbar/navbar.md' }, { text: '- Pagination', link: 'components/pagination/pagination.md' }, { text: '- Progress', link: 'components/progress/progress.md' }, { text: '- Rating', link: 'components/rating/rating.md' }, diff --git a/docs/components/navbar/examples/NavbarActionButtonExample.vue b/docs/components/navbar/examples/NavbarActionButtonExample.vue new file mode 100644 index 0000000..1b63d8b --- /dev/null +++ b/docs/components/navbar/examples/NavbarActionButtonExample.vue @@ -0,0 +1,25 @@ + + diff --git a/docs/components/navbar/examples/NavbarCustomMobileIconExample.vue b/docs/components/navbar/examples/NavbarCustomMobileIconExample.vue new file mode 100644 index 0000000..7d6d71b --- /dev/null +++ b/docs/components/navbar/examples/NavbarCustomMobileIconExample.vue @@ -0,0 +1,25 @@ + + diff --git a/docs/components/navbar/examples/NavbarExample.vue b/docs/components/navbar/examples/NavbarExample.vue index b4084d5..2cf866c 100644 --- a/docs/components/navbar/examples/NavbarExample.vue +++ b/docs/components/navbar/examples/NavbarExample.vue @@ -1,8 +1,22 @@ diff --git a/docs/components/navbar/examples/NavbarSolidExample.vue b/docs/components/navbar/examples/NavbarSolidExample.vue new file mode 100644 index 0000000..fd2608f --- /dev/null +++ b/docs/components/navbar/examples/NavbarSolidExample.vue @@ -0,0 +1,22 @@ + + diff --git a/docs/components/navbar/navbar.md b/docs/components/navbar/navbar.md index d79936e..f78300a 100644 --- a/docs/components/navbar/navbar.md +++ b/docs/components/navbar/navbar.md @@ -1,15 +1,119 @@ -# Vue Navbar Component - Flowbite +# Navbar Component – Flowbite +The navbar component can be used to show a list of navigation links positioned on the top side of your page based on multiple layouts, sizes, and dropdowns + +## Default navbar ```vue ``` + +## Solid navbar +```vue + + +``` + + + +## Navbar with action button +```vue + + +``` + + + +## Navbar with custom mobile icon +```vue + + +``` + diff --git a/package.json b/package.json index d125f2d..cefb186 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "typecheck": "vue-tsc --noEmit" }, "peerDependencies": { - "vue": "^3", - "tailwindcss": "^3" + "tailwindcss": "^3", + "vue": "^3.2.41" }, "devDependencies": { "@types/lodash": "^4.14.182", @@ -41,30 +41,29 @@ "@typescript-eslint/eslint-plugin": "^5.30.0", "@typescript-eslint/parser": "^5.30.0", "@vitejs/plugin-vue": "^2.3.3", - "@vue/compiler-sfc": "^3.2.37", "@vue/test-utils": "^2.0.0", "@vue/tsconfig": "^0.1.3", "c8": "^7.11.3", - "class-names": "^1.0.0", "eslint": "^8.18.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-vue": "^9.1.1", - "flowbite": "^1.4.2", + "flowbite": "^1.5.3", "jsdom": "^20.0.0", "lodash": "^4.17.21", "postcss": "^8.4.14", "postcss-prefix-selector": "^1.16.0", "prettier": "^2.3.2", - "tailwindcss": "^3", + "tailwindcss": "^3.1.8", "tsc-alias": "^1.7.0", - "typescript": "^4.7.3", + "typescript": "4.7.3", "vite": "^2.4.3", "vitest": "^0.16.0", "vue-eslint-parser": "^9.0.3", - "vue-tsc": "^0.30.0" + "vue-tsc": "0.30.0" }, "dependencies": { - "@vueuse/core": "^8.9.1", - "vitepress": "^1.0.0-alpha.4" + "@vueuse/core": "9.3.0", + "classnames": "^2.3.2", + "vitepress": "1.0.0-alpha.19" } } diff --git a/src/components/Navbar/Navbar.vue b/src/components/Navbar/Navbar.vue index a91e072..70d4759 100644 --- a/src/components/Navbar/Navbar.vue +++ b/src/components/Navbar/Navbar.vue @@ -1,61 +1,27 @@ diff --git a/src/components/Navbar/NavbarCollapse.vue b/src/components/Navbar/NavbarCollapse.vue new file mode 100644 index 0000000..46e5ce0 --- /dev/null +++ b/src/components/Navbar/NavbarCollapse.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/components/Navbar/NavbarLink.ts b/src/components/Navbar/NavbarLink.ts new file mode 100644 index 0000000..10c44fc --- /dev/null +++ b/src/components/Navbar/NavbarLink.ts @@ -0,0 +1,61 @@ +import { defineComponent, h } from 'vue' +import classNames from 'classnames' + +export default defineComponent({ + name: 'NavbarLink', + props: { + link: { + type: String, + default: '/', + }, + isActive: { + type: Boolean, + default: false, + }, + component: { + type: [Object, String], + default: 'a', + }, + linkAttr: { + type: String, + default: 'href', + }, + disabled: { + type: Boolean, + default: false, + }, + }, + emits: [ + 'click', + ], + setup(props, { slots, emit }) { + const currentPageClasses = 'bg-blue-700 md:bg-transparent text-white md:text-blue-700 dark:text-white' + const defaultStateClasses = 'text-gray-700 hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 dark:text-gray-400 md:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent' + const defaultClasses = 'block py-2 pr-4 pl-3 rounded md:p-0' + const linkClasses = classNames( + defaultClasses, + props.isActive ? currentPageClasses : defaultStateClasses, + ) + const handleClick = (event: Event) => { + if (props.disabled) { + return + } + emit('click', event) + } + return () => + h('li', null, h( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + props.component, + { + ...props, + class: linkClasses, + [props.linkAttr]: props.link, + onClick: handleClick, + }, + { + default: () => slots.default && slots.default(), + }, + )) + }, +}) diff --git a/src/components/Navbar/NavbarLogo.ts b/src/components/Navbar/NavbarLogo.ts new file mode 100644 index 0000000..2d51de0 --- /dev/null +++ b/src/components/Navbar/NavbarLogo.ts @@ -0,0 +1,60 @@ +import { defineComponent, h } from 'vue' + +export default defineComponent({ + name: 'NavbarLogo', + props: { + link: { + type: String, + default: '/', + }, + imageUrl: { + type: String, + default: '/assets/logo.svg', + }, + alt: { + type: String, + default: 'Logo', + }, + component: { + type: [Object, String], + default: 'a', + }, + linkAttr: { + type: String, + default: 'href', + }, + }, + emits: [ + 'click', + ], + setup(props, { slots }) { + return () => + h( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + props.component, + { + [props.linkAttr]: props.link, + class: 'flex items-center', + }, + { + default: () => [ + h( + 'img', + { + src: props.imageUrl, + class: 'mr-3 h-6 sm:h-10', + alt: props.alt, + }, + ), + h( + 'span', + { + class: 'self-center text-xl font-semibold whitespace-nowrap dark:text-white', + }, + slots, + )], + }, + ) + }, +}) diff --git a/src/index.ts b/src/index.ts index 89206e9..627797b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,9 @@ export { default as ListGroup } from './components/ListGroup/ListGroup.vue' export { default as ListGroupItem } from './components/ListGroup/components/ListGroupItem/ListGroupItem.vue' export { default as Modal } from './components/Modal/Modal.vue' export { default as Navbar } from './components/Navbar/Navbar.vue' +export { default as NavbarLogo } from './components/Navbar/NavbarLogo' +export { default as NavbarCollapse } from './components/Navbar/NavbarCollapse.vue' +export { default as NavbarLink } from './components/Navbar/NavbarLink' export { default as Pagination } from './components/Pagination/Pagination.vue' export { default as Progress } from './components/Progress/Progress.vue' export { default as Rating } from './components/Rating/Rating.vue'