Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(btn-group): functional component for button-group (#822)
* feat(btn-group): functional component * fix(aria): rename aria-role to role
- Loading branch information
1 parent
d54a01e
commit 6891e9f
Showing
5 changed files
with
83 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { mergeData } from "../utils"; | ||
import { arrayIncludes } from "../utils/array"; | ||
|
||
export const props = { | ||
vertical: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
size: { | ||
type: String, | ||
default: null, | ||
validator: size => arrayIncludes(["sm", "", "lg"], size) | ||
}, | ||
tag: { | ||
type: String, | ||
default: "div" | ||
}, | ||
ariaRole: { | ||
type: String, | ||
default: "group" | ||
} | ||
}; | ||
|
||
export default { | ||
functional: true, | ||
props, | ||
render(h, { props, data, children }) { | ||
return h( | ||
props.tag, | ||
mergeData(data, { | ||
staticClass: "btn-group", | ||
class: { | ||
"btn-group-vertical": props.vertical, | ||
[`btn-group-${props.size}`]: Boolean(props.size) | ||
}, | ||
attrs: { "role": props.ariaRole } | ||
}), | ||
children | ||
); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,28 @@ | ||
import {loadFixture, testVM} from '../helpers'; | ||
import { loadFixture, testVM } from "../helpers"; | ||
|
||
describe('button-group', async() => { | ||
beforeEach(loadFixture('button-group')); | ||
describe("button-group", async () => { | ||
beforeEach(loadFixture("button-group")); | ||
testVM(); | ||
}); | ||
|
||
const btnRefs = ["basic", "vertical", "size"]; | ||
|
||
it("should contain base class", async () => { | ||
const { app: { $refs } } = window; | ||
|
||
btnRefs.forEach(ref => { | ||
expect($refs[ref]).toHaveClass("btn-group"); | ||
}); | ||
}); | ||
|
||
it("should apply vertical class", async () => { | ||
const { app: { $refs } } = window; | ||
|
||
expect($refs.vertical).toHaveClass("btn-group-vertical"); | ||
}); | ||
|
||
it("should apply size class", async () => { | ||
const { app: { $refs } } = window; | ||
|
||
expect($refs.size).toHaveClass("btn-group-sm"); | ||
}); | ||
}); |