-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(badge): functional component #820
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { mergeData } from "../utils"; | ||
|
||
export const props = { | ||
tag: { | ||
type: String, | ||
default: "span" | ||
}, | ||
variant: { | ||
type: String, | ||
default: "default" | ||
}, | ||
pill: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}; | ||
|
||
export default { | ||
functional: true, | ||
props, | ||
render(h, { props, data, children }) { | ||
return h( | ||
props.tag, | ||
mergeData(data, { | ||
staticClass: "badge", | ||
class: [ | ||
!props.variant ? "badge-default" : `badge-${props.variant}`, | ||
{ "badge-pill": Boolean(props.pill) } | ||
] | ||
}), | ||
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,7 +1,8 @@ | ||
import addEventListenerOnce from "./addEventListenerOnce" | ||
import * as array from "./array" | ||
import * as object from "./object" | ||
import observeDom from "./observe-dom" | ||
import warn from "./warn" | ||
import addEventListenerOnce from "./addEventListenerOnce"; | ||
import * as array from "./array"; | ||
import * as object from "./object"; | ||
import mergeData from "vue-functional-data-merge/dist/lib.common.js"; | ||
import observeDom from "./observe-dom"; | ||
import warn from "./warn"; | ||
|
||
export { addEventListenerOnce, array, object, observeDom, warn } | ||
export { addEventListenerOnce, array, mergeData, object, observeDom, warn }; |
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,42 +1,35 @@ | ||
import { loadFixture, testVM } from '../helpers' | ||
import { loadFixture, testVM } from "../helpers"; | ||
|
||
const variantList = [ | ||
'default', | ||
'primary', | ||
'success', | ||
'info', | ||
'warning', | ||
'danger', | ||
].map(variant => { | ||
return { ref: `badge_${variant}`, variant } | ||
}) | ||
const variantList = ["default", "primary", "success", "info", "warning", "danger"].map(variant => { | ||
return { ref: `badge_${variant}`, variant }; | ||
}); | ||
|
||
describe('badge', async() => { | ||
beforeEach(loadFixture('badge')) | ||
testVM() | ||
describe("badge", async () => { | ||
beforeEach(loadFixture("badge")); | ||
testVM(); | ||
|
||
it('should apply variant classes', async() => { | ||
const { app: { $refs, $el } } = window | ||
it("should apply variant classes", async () => { | ||
const { app: { $refs } } = window; | ||
|
||
expect($refs.badge_pill).toHaveAllClasses(['badge', 'badge-pill']) | ||
expect($refs.badge_pill).toHaveAllClasses(["badge", "badge-pill"]); | ||
|
||
variantList.forEach(({ ref, variant }) => { | ||
const vm = $refs[ref][0] | ||
expect(vm).toHaveAllClasses(['badge', `badge-${variant}`]) | ||
}) | ||
}) | ||
const vm = $refs[ref][0]; | ||
expect(vm).toHaveAllClasses(["badge", `badge-${variant}`]); | ||
}); | ||
}); | ||
|
||
it('should apply secondary pill class when not passed variant', async() => { | ||
const { app: { $refs, $el } } = window | ||
it("should apply default pill class when not passed variant", async () => { | ||
const { app: { $refs } } = window; | ||
|
||
const vm = $refs.no_props | ||
expect(vm).toHaveClass('badge-secondary') | ||
}) | ||
const vm = $refs.no_props; | ||
expect(vm).toHaveClass("badge-default"); | ||
}); | ||
|
||
it('should not apply pill class when not passed pill boolean prop', async() => { | ||
const { app: { $refs, $el } } = window | ||
it("should not apply pill class when not passed pill boolean prop", async () => { | ||
const { app: { $refs } } = window; | ||
|
||
const vm = $refs.no_props | ||
expect(vm).not.toHaveClass('badge-pill') | ||
}) | ||
const vm = $refs.no_props; | ||
expect(vm).not.toHaveClass("badge-pill"); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize we have a jQuery dependency now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... when did that get in there? Is that in master?
Nope, not in master. Is someone working on something that uses that? I'm gonna kill it and we'll find out later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be in there for a temp solution for something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not in
dev
branch either. only 1.x branchThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Say bye-bye 👋