Skip to content

Commit 765a511

Browse files
committed
feat: navbar stub work
1 parent d9ff52f commit 765a511

File tree

11 files changed

+2270
-1
lines changed

11 files changed

+2270
-1
lines changed

packages/bootstrap-vue-3/package-lock.json

Lines changed: 2012 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bootstrap-vue-3/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"rollup": "^2.76.0",
4949
"rollup-plugin-visualizer": "5.x.x",
5050
"sass": "1.x.x",
51-
"tsconfig": "workspace:*",
5251
"typescript": "4.x.x",
5352
"vite": "2.x.x",
5453
"vite-plugin-dts": "1.x.x",

packages/bootstrap-vue-3/src/components/BCollapse.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class="collapse"
77
:class="classes"
88
:data-bs-parent="accordion || null"
9+
:is-nav="isNav"
910
>
1011
<slot :visible="modelValue" :close="close" />
1112
</component>
@@ -27,6 +28,7 @@ interface BCollapseProps {
2728
tag?: string
2829
toggle?: boolean
2930
visible?: boolean
31+
isNav?: boolean
3032
}
3133
3234
const props = withDefaults(defineProps<BCollapseProps>(), {
@@ -35,6 +37,7 @@ const props = withDefaults(defineProps<BCollapseProps>(), {
3537
tag: 'div',
3638
toggle: false,
3739
visible: false,
40+
isNav: false,
3841
})
3942
4043
interface BCollapseEmits {
@@ -51,6 +54,7 @@ const element = ref<HTMLElement>()
5154
const instance = ref<Collapse>()
5255
const classes = computed(() => ({
5356
show: props.modelValue,
57+
'navbar-collapse': props.isNav,
5458
}))
5559
5660
const close = () => emit('update:modelValue', false)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<ul class="nav" :class="classes">
3+
<slot />
4+
</ul>
5+
</template>
6+
7+
<script setup lang="ts">
8+
// import type {BNavProps} from '../types/components'
9+
import {computed} from 'vue'
10+
11+
interface BNavProps {
12+
align?: string
13+
fill?: boolean
14+
justified?: boolean
15+
pills?: boolean
16+
tabs?: boolean
17+
vertical?: boolean
18+
}
19+
20+
const props = withDefaults(defineProps<BNavProps>(), {
21+
fill: false,
22+
justified: false,
23+
pills: false,
24+
tabs: false,
25+
vertical: false,
26+
})
27+
28+
const classes = computed(() => ({
29+
'flex-column': props.vertical,
30+
[`justify-content-${props.align}`]: props.align,
31+
'nav-tabs': props.tabs,
32+
'nav-pills': props.pills,
33+
'nav-fill': props.fill,
34+
'nav-justified': props.justified,
35+
}))
36+
</script>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<li class="nav-item" :class="classes">
3+
<b-link
4+
:href="href"
5+
:to="to"
6+
class="nav-link"
7+
:class="classes"
8+
:tabindex="disabled ? -1 : undefined"
9+
:aria-disabled="disabled ? true : undefined"
10+
>
11+
<slot />
12+
</b-link>
13+
</li>
14+
</template>
15+
16+
<script setup lang="ts">
17+
// import type {BNavItemProps} from '../types/components'
18+
import {computed} from 'vue'
19+
import {RouteLocationRaw} from 'vue-router'
20+
import BLink from '../BLink/BLink.vue'
21+
22+
interface BNavItemProps {
23+
active?: boolean
24+
disabled?: boolean
25+
href?: string
26+
to?: RouteLocationRaw
27+
}
28+
29+
const props = withDefaults(defineProps<BNavItemProps>(), {
30+
active: false,
31+
disabled: false,
32+
})
33+
34+
const classes = computed(() => ({
35+
active: props.active,
36+
disabled: props.disabled,
37+
}))
38+
</script>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<li class="nav-item dropdown">
3+
<b-dropdown v-bind="$props">
4+
<template v-for="(_, slot) in $slots" #[slot]="scope">
5+
<slot :name="slot" v-bind="scope || {}" />
6+
</template>
7+
</b-dropdown>
8+
</li>
9+
</template>
10+
11+
<script setup lang="ts">
12+
// import type {BNavItemDropdownProps} from '../types/components'
13+
import type {ButtonVariant, Size} from '../../types'
14+
import BDropdown from '../BDropdown/BDropdown.vue'
15+
16+
interface BNavItemDropdownProps {
17+
id?: string
18+
text?: string
19+
size?: Size
20+
offset?: string
21+
autoClose?: boolean | 'inside' | 'outside'
22+
dark?: boolean
23+
dropleft?: boolean
24+
dropright?: boolean
25+
dropup?: boolean
26+
right?: boolean
27+
left?: boolean | string
28+
offsetParent?: boolean
29+
split?: boolean
30+
splitVariant?: ButtonVariant
31+
noCaret?: boolean
32+
variant?: ButtonVariant
33+
}
34+
35+
withDefaults(defineProps<BNavItemDropdownProps>(), {
36+
autoClose: true,
37+
dark: false,
38+
dropleft: false,
39+
dropright: false,
40+
dropup: false,
41+
right: false,
42+
left: false,
43+
offsetParent: false,
44+
split: false,
45+
noCaret: false,
46+
variant: 'link',
47+
})
48+
</script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<nav :class="classes">
3+
<div class="container-fluid">
4+
<slot></slot>
5+
</div>
6+
</nav>
7+
</template>
8+
9+
<script setup lang="ts">
10+
import {computed} from 'vue'
11+
import {ColorVariant} from '../../types/index'
12+
13+
interface Props {
14+
variant?: ColorVariant
15+
}
16+
17+
const props = withDefaults(defineProps<Props>(), {
18+
variant: 'light',
19+
})
20+
21+
const classes = computed(() => {
22+
const result: {[key: string]: boolean} = {
23+
'navbar': true,
24+
'navbar-expand-lg': true,
25+
'navbar-light': props.variant === 'light',
26+
'navbar-dark': props.variant !== 'light',
27+
}
28+
result[`bg-${props.variant}`] = true
29+
return result
30+
})
31+
</script>
32+
33+
<style scoped></style>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<a v-if="href" :href="href" class="navbar-brand">
3+
<slot></slot>
4+
</a>
5+
<router-link v-else-if="to" :to="to">
6+
<slot></slot>
7+
</router-link>
8+
<div v-else>
9+
<slot></slot>
10+
</div>
11+
</template>
12+
13+
<script setup lang="ts">
14+
interface Props {
15+
href?: string
16+
to?: any
17+
}
18+
19+
defineProps<Props>()
20+
</script>
21+
22+
<style scoped></style>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<ul class="navbar-nav">
3+
<slot></slot>
4+
</ul>
5+
</template>
6+
7+
<script setup lang="ts"></script>
8+
9+
<style scoped></style>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<button :class="classes" type="button" @click="onButtonClicked">
3+
<span class="navbar-toggler-icon"></span>
4+
</button>
5+
</template>
6+
7+
<script setup lang="ts">
8+
import {ref} from 'vue'
9+
10+
interface Props {
11+
target: string
12+
}
13+
14+
const props = defineProps<Props>()
15+
16+
const classes = ref({
17+
'navbar-toggler': true,
18+
'collapsed': true,
19+
})
20+
21+
function onButtonClicked() {
22+
classes.value.collapsed = !classes.value.collapsed
23+
24+
const el = document.getElementById(props.target)
25+
el?.classList.toggle('show')
26+
}
27+
</script>
28+
29+
<style scoped></style>

0 commit comments

Comments
 (0)