Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Added Breadcrumb component #3464

Merged
merged 23 commits into from
Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4989527
Moving to new branch
mouadTaoussi Aug 15, 2021
fd9300d
Moving to new branch
mouadTaoussi Aug 15, 2021
121fc1f
added breadcrumb feature: next writing tests and docs
mouadTaoussi Aug 15, 2021
e7dee04
Merge branch 'dev' of https://github.com/mouadTaoussi/buefy into brea…
mouadTaoussi Aug 16, 2021
20044d8
added breadcrumb feature: next writing tests and docs
mouadTaoussi Aug 16, 2021
f290705
added breadcrumb feature: writing tests
mouadTaoussi Aug 17, 2021
bbc359c
added breadcrumb feature: wrote tests
mouadTaoussi Aug 17, 2021
4d31dd7
added breadcrumb feature: wrote tests
mouadTaoussi Aug 17, 2021
390f009
added breadcrumb feature: wrote tests
mouadTaoussi Aug 17, 2021
3d7d03d
Removed empty scss file
mouadTaoussi Aug 24, 2021
ac6c0ea
removed data elements
mouadTaoussi Aug 24, 2021
85f7010
removed data elements: fix failed test
mouadTaoussi Aug 24, 2021
d6d556c
removed router-link
mouadTaoussi Aug 24, 2021
58fb23e
used dynamic component instead of <a> tag
mouadTaoussi Aug 27, 2021
a6d24a1
Merge branch 'buefy:dev' into breadcrumbFeature
mouadTaoussi Sep 11, 2021
42d0963
Merge branch 'buefy:dev' into breadcrumbFeature
mouadTaoussi Sep 15, 2021
0d9e5d1
added breadcrumb-item
mouadTaoussi Sep 16, 2021
29a60a5
added breadcrumb-item
mouadTaoussi Sep 16, 2021
a095b6d
Merge branch 'buefy:dev' into breadcrumbFeature
mouadTaoussi Sep 17, 2021
ccb5ee1
Removed useless tag attribute, used attributes inheritance
mouadTaoussi Sep 17, 2021
1717576
Removed useless tag attribute, used attributes inheritance
mouadTaoussi Sep 17, 2021
a35d87c
Merge branch 'breadcrumbFeature' of https://github.com/mouadTaoussi/b…
mouadTaoussi Sep 17, 2021
a67bf16
Removed useless snippet
mouadTaoussi Sep 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/data/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{
"category": "UI components",
"pages": [
"documentation/breadcrumb",
"documentation/button",
"documentation/carousel",
"documentation/collapse",
Expand Down
12 changes: 12 additions & 0 deletions docs/data/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,18 @@
"documentation/pagination"
]
},
"documentation/breadcrumb": {
"title": "Breadcrumb",
"subtitle": "Breadcrumb component for flexible navigation through the pages of your website!",
"path": "/documentation/breadcrumb",
"githubPath": "pages/components/breadcrumb/Breadcrumb.vue",
"menu": "documentation",
"breadcrumb": [
"/",
"documentation",
"documentation/breadcrumb"
]
},
"documentation/button": {
"title": "Button",
"subtitle": "The classic button, in different colors, sizes, and states",
Expand Down
47 changes: 47 additions & 0 deletions docs/pages/components/breadcrumb/Breadcrumb.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<section>
<Example :component="ExAlignments" :code="ExAlignmentsCode" title="Alignments"/>

<Example :component="ExSeparators" :code="ExSeparatorsCode" title="Separators"/>

<Example :component="ExSizes" :code="ExSizesCode" title="Sizes"/>

<ApiView :data="api"/>
<VariablesView :data="variables"/>
</section>
</template>

<script>
import api from './api/breadcrumb'
import variables from './variables/breadcrumb'

import ExAlignments from './examples/ExAlignments'
import ExAlignmentsCode from '!!raw-loader!./examples/ExAlignments'

import ExSeparators from './examples/ExSeparators'
import ExSeparatorsCode from '!!raw-loader!./examples/ExSeparators'

import ExSizes from './examples/ExSizes'
import ExSizesCode from '!!raw-loader!./examples/ExSizes'

export default {

name: 'Breadcrumb',

data () {
return {
api,
variables,
ExAlignments,
ExAlignmentsCode,
ExSeparators,
ExSeparatorsCode,
ExSizes,
ExSizesCode,
}
}
}
</script>

<style lang="css" scoped>
</style>
47 changes: 47 additions & 0 deletions docs/pages/components/breadcrumb/api/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export default [
{
title : 'Breadcrumb',
props: [
{
name: '<code>align</code>',
description: 'Breadcrumb alignment.',
type: 'String',
values: '<code>is-left</code>, <code>is-centered</code>, <code>is-right</code>',
default: '<code>is-right</code>'
},
{
name: '<code>separator</code>',
description: 'Symbole that separates the bradcrumb items.',
type: 'String',
values: '<code>has-arrow-separator</code>, <code>has-bullet-separator</code>, <code>has-dot-separator</code>, <code>has-succeeds-separator</code>',
default: '—'
},
{
name: '<code>size</code>',
description: 'The breadcrumb size',
type: 'String',
values: '<code>is-small</code>, <code>is-medium</code>, <code>is-large</code>',
default: '<code>is-medium</code>'
}
]
},
{
title : 'Breadcrumb Item',
props: [
{
name: '<code>tag</code>',
description: "a, router-link and it's html attributes like href, to, etc...",
type: 'String',
values: '<code>router-link</code>, <code>a</code>',
default: '<code>a</code>'
},
{
name: '<code>active</code>',
description: 'is the current breadcrumb is actually the current page.',
type: 'Boolean',
values: '<code>false</code>, <code>true</code>',
default: '<code>false</code>'
}
]
}
]
36 changes: 36 additions & 0 deletions docs/pages/components/breadcrumb/examples/ExAlignments.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<section>
<!-- Left -->
<b-breadcrumb
align="is-left"
>
<b-breadcrumb-item tag='router-link' to="/">Home</b-breadcrumb-item>
<b-breadcrumb-item tag='router-link' to="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item tag='router-link' to="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Center -->
<b-breadcrumb
align="is-centered"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Right -->
<b-breadcrumb
align="is-right"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
</section>
</template>

<script>
export default {

name: 'ExAlignments',

}
</script>
50 changes: 50 additions & 0 deletions docs/pages/components/breadcrumb/examples/ExSeparators.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<section>
<!-- Default -->
<b-breadcrumb>
<b-breadcrumb-item tag='router-link' to="/">Home</b-breadcrumb-item>
<b-breadcrumb-item tag='router-link' to="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item tag='router-link' to="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Arrow -->
<b-breadcrumb
separator="has-arrow-separator"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Bullet -->
<b-breadcrumb
separator="has-bullet-separator"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Dot -->
<b-breadcrumb
separator="has-dot-separator"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Succeeds -->
<b-breadcrumb
separator="has-succeeds-separator"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
</section>
</template>

<script>
export default {

name: 'ExSeparators',

}
</script>
36 changes: 36 additions & 0 deletions docs/pages/components/breadcrumb/examples/ExSizes.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<section>
<!-- Left -->
<b-breadcrumb
size="is-small"
>
<b-breadcrumb-item tag='router-link' to="/">Home</b-breadcrumb-item>
<b-breadcrumb-item tag='router-link' to="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item tag='router-link' to="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Center -->
<b-breadcrumb
size="is-medium"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
<!-- Right -->
<b-breadcrumb
size="is-large"
>
<b-breadcrumb-item href="/">Home</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation">Docs</b-breadcrumb-item>
<b-breadcrumb-item href="/documentation/breadcrumb" active>Breadcrumb</b-breadcrumb-item>
</b-breadcrumb>
</section>
</template>

<script>
export default {

name: 'ExSizes',

}
</script>
6 changes: 6 additions & 0 deletions docs/pages/components/breadcrumb/variables/breadcrumb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default [
{
name: 'Bulma variables',
default: '<a target="_blank" href="https://bulma.io/documentation/components/breadcrumb/#variables">Link</a>'
}
]
1 change: 1 addition & 0 deletions docs/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const router = new Router({
route('documentation/upload', 'components/upload/Upload'),
route('documentation/table', 'components/table/Table'),
route('documentation/pagination', 'components/pagination/Pagination'),
route('documentation/breadcrumb', 'components/breadcrumb/Breadcrumb'),
route('documentation/button', 'components/button/Button'),
route('documentation/numberinput', 'components/numberinput/Numberinput'),
route('documentation/steps', 'components/steps/Steps'),
Expand Down
63 changes: 63 additions & 0 deletions src/components/breadcrumb/Breadcrumb.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { shallowMount, mount } from '@vue/test-utils'
import BBreadcrumb from '@components/breadcrumb/Breadcrumb'

describe('BBreadcrumb', () => {
let wrapper

beforeEach(() => {
wrapper = shallowMount(BBreadcrumb)
})

it('is called', () => {
expect(wrapper.name()).toBe('BBreadcrumb')
expect(wrapper.isVueInstance()).toBeTruthy()
})

it('render correctly', () => {
expect(wrapper.html()).toMatchSnapshot()
})

it('should set align to right', () => {
wrapper = mount(BBreadcrumb, {
propsData: {
align: 'is-right'
}
})

expect(wrapper.classes()).toContain('is-right')
})

it('should set separator to arrow', () => {
wrapper = mount(BBreadcrumb, {
propsData: {
separator: 'has-arrow-separator'
}
})

expect(wrapper.classes()).toContain('has-arrow-separator')
})

it('should set size to large', () => {
wrapper = mount(BBreadcrumb, {
propsData: {
size: 'is-large'
}
})

expect(wrapper.classes()).toContain('is-large')
})

it('computes breadcrumbClasses correctly', () => {
wrapper = mount(BBreadcrumb, {
propsData: {
align: 'is-left',
separator: 'has-dot-separator',
size: 'is-medium'
}
})

expect(wrapper.classes()).toContain('is-left')
expect(wrapper.classes()).toContain('has-dot-separator')
expect(wrapper.classes()).toContain('is-medium')
})
})
43 changes: 43 additions & 0 deletions src/components/breadcrumb/Breadcrumb.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<nav :class="breadcrumbClasses">
<ul>
<slot />
</ul>
</nav>
</template>

<script>
import config from '../../utils/config'

export default {

name: 'BBreadcrumb',

props: {
align: {
type: String,
default: () => {
return config.defaultBreadcrumbAlign
}
},
separator: {
type: String,
default: () => {
return config.defaultBreadcrumbSeparator
}
},
size: {
type: String,
default: () => {
return config.defaultBreadcrumbSize
}
}
},

computed: {
breadcrumbClasses() {
return ['breadcrumb', this.align, this.separator, this.size]
}
}
}
</script>
26 changes: 26 additions & 0 deletions src/components/breadcrumb/BreadcrumbItem.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { mount } from '@vue/test-utils'
import BBreadcrumbItem from '@components/breadcrumb/BreadcrumbItem.vue'

describe('BBreadcrumbItem', () => {
let wrapper
beforeEach(() => {
wrapper = mount(BBreadcrumbItem, {
propsData: {
tag: 'router-link',
to: '/'
}
})
})

it('is called', () => {
expect(wrapper.isVueInstance()).toBeTruthy()
})

it('render correctly', () => {
expect(wrapper.html()).toMatchSnapshot()
})

it('should have a li tag', () => {
expect(wrapper.contains('li')).toBeTruthy()
})
})
Loading