-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
378 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
# Breadcrumbs | ||
|
||
> Indicate the current page's location within a navigational hierarchy. | ||
## Example | ||
|
||
Use `items` array to create a breadcrumbs nav. `active` state of last element is automatically set if it is undefined. | ||
|
||
```html | ||
<template> | ||
<breadcrumbs :items="items"/> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data () { | ||
return { | ||
items: [ | ||
{text: 'Home', href: '#'}, | ||
{text: 'Library', href: '#'}, | ||
{text: 'Data', href: '#'} | ||
] | ||
} | ||
} | ||
} | ||
</script> | ||
<!-- Live demo --> | ||
``` | ||
|
||
|
||
## Breadcrumb Item | ||
|
||
You can also use `<breadcrumb-item>` in breadcrumbs directly. This is useful while full control of item text is need (e.g. HTML tags). | ||
|
||
Note that `active` state will not automatically set if using this mode. | ||
|
||
```html | ||
<breadcrumbs> | ||
<breadcrumb-item href="#"><b>Home</b></breadcrumb-item> | ||
<breadcrumb-item href="#">Library</breadcrumb-item> | ||
<breadcrumb-item :active="true">Data</breadcrumb-item> | ||
</breadcrumbs> | ||
<!-- Live demo --> | ||
``` | ||
|
||
## Router Link | ||
|
||
Parse `to` (String or Object) instead of `href` will create a `router-link` for the breadcrumb item, which you can use with [Vue-Router](https://router.vuejs.org/). | ||
|
||
```html | ||
<template> | ||
<breadcrumbs :items="items2"/> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data () { | ||
return { | ||
items2: [ | ||
{text: 'Home', to: '/'}, | ||
{text: 'Breadcrumbs', to: '/breadcrumbs'} | ||
] | ||
} | ||
} | ||
} | ||
</script> | ||
<!-- Live demo --> | ||
``` | ||
|
||
<!-- Live demo script | ||
<script> | ||
export default { | ||
data () { | ||
return { | ||
items: [ | ||
{text: 'Home', href: '#'}, | ||
{text: 'Library', href: '#'}, | ||
{text: 'Data', href: '#'} | ||
], | ||
items2: [ | ||
{text: 'Home', to: '/'}, | ||
{text: 'Breadcrumbs', to: '/breadcrumbs'} | ||
] | ||
} | ||
} | ||
} | ||
</script> | ||
--> | ||
|
||
# API Reference | ||
|
||
## [Breadcrumbs.vue](https://github.com/wxsms/uiv/tree/master/src/components/breadcrumbs/Breadcrumbs.vue) | ||
|
||
<div class="table-responsive"> | ||
<table class="table table-bordered"> | ||
<tbody> | ||
<tr> | ||
<td colspan="5"><span class="label label-default">Props</span></td> | ||
</tr> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Default</th> | ||
<th width="50px">Required</th> | ||
<th>Description</th> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>items</code></td> | ||
<td>Array</td> | ||
<td></td> | ||
<td></td> | ||
<td>Breadcrumb items to create. Props defined in each item object is the same with BreadcrumbItem.vue, except <code>text</code> will be replace as the breadcrumb item body.</td> | ||
</tr> | ||
</tbody> | ||
<tbody> | ||
<tr> | ||
<td colspan="5"><span class="label label-default">Slots</span></td> | ||
</tr> | ||
<tr> | ||
<th>Name</th> | ||
<th colspan="4">Description</th> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>default</code></td> | ||
<td colspan="4">The breadcrumbs body.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
## [BreadcrumbItem.vue](https://github.com/wxsms/uiv/tree/master/src/components/breadcrumbs/BreadcrumbItem.vue) | ||
|
||
<div class="table-responsive"> | ||
<table class="table table-bordered"> | ||
<tbody> | ||
<tr> | ||
<td colspan="5"><span class="label label-default">Props</span></td> | ||
</tr> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Default</th> | ||
<th width="50px">Required</th> | ||
<th>Description</th> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>acive</code></td> | ||
<td>Boolean</td> | ||
<td>false</td> | ||
<td></td> | ||
<td>Set item to active state.</td> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>href</code></td> | ||
<td>String</td> | ||
<td></td> | ||
<td></td> | ||
<td>An ordinary link will be created if this prop present.</td> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>target</code></td> | ||
<td>String</td> | ||
<td></td> | ||
<td>_self</td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>to</code></td> | ||
<td>String or Object</td> | ||
<td></td> | ||
<td></td> | ||
<td>An Vue-Router link will be created if this prop present.</td> | ||
</tr> | ||
</tbody> | ||
<tbody> | ||
<tr> | ||
<td colspan="5"><span class="label label-default">Slots</span></td> | ||
</tr> | ||
<tr> | ||
<th>Name</th> | ||
<th colspan="4">Description</th> | ||
</tr> | ||
<tr> | ||
<td nowrap="nowrap"><code>default</code></td> | ||
<td colspan="4">The breadcrumb item body.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<li :class="{active: active}"> | ||
<template v-if="active"> | ||
<slot></slot> | ||
</template> | ||
<template v-else-if="href"> | ||
<a :href="href" :target="target"> | ||
<slot></slot> | ||
</a> | ||
</template> | ||
<template v-else-if="to"> | ||
<router-link :to="to"> | ||
<slot></slot> | ||
</router-link> | ||
</template> | ||
</li> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
active: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
// <a> props | ||
href: { | ||
type: String | ||
}, | ||
target: { | ||
type: String, | ||
default: '_self' | ||
}, | ||
// <router-link> props | ||
to: {} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<ol class="breadcrumb"> | ||
<slot> | ||
<breadcrumb-item | ||
v-for="(item, index) in items" | ||
:key="item.key ? item.key : index" | ||
:active="isItemActive(item, index)" | ||
:href="item.href" | ||
:target="item.target" | ||
:to="item.to">{{item.text}}</breadcrumb-item> | ||
</slot> | ||
</ol> | ||
</template> | ||
|
||
<script> | ||
import BreadcrumbItem from './BreadcrumbItem.vue' | ||
export default { | ||
components: {BreadcrumbItem}, | ||
props: { | ||
items: { | ||
type: Array | ||
} | ||
}, | ||
methods: { | ||
isItemActive (item, index) { | ||
return typeof item.active === 'boolean' ? item.active : index === this.items.length - 1 | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './components' | ||
export * from './install' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as components from './components' | ||
import locale from './locale' | ||
|
||
const install = (Vue, options = {}) => { | ||
// Setup language, en-US for default | ||
locale.use(options.locale) | ||
locale.i18n(options.i18n) | ||
// Register components | ||
for (let key in components) { | ||
Vue.component(key, components[key]) | ||
} | ||
} | ||
|
||
// auto install | ||
if (typeof window !== 'undefined' && window.Vue) { | ||
install(window.Vue) | ||
} | ||
|
||
export { install } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.