Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from glorious-codes/button
Improve Button
- Loading branch information
Showing
15 changed files
with
176 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,5 +160,5 @@ assets/js/ | |
# Tests generated files | ||
./coverage/ | ||
./screenshots/ | ||
/docs | ||
spec/visual/results/ | ||
./docs/ |
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
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,7 @@ | ||
const _public = {}; | ||
|
||
_public.buildTagName = (propValue, isValidPropValue, { defaultTagName }) => { | ||
return propValue && isValidPropValue(propValue) ? propValue : defaultTagName; | ||
}; | ||
|
||
export default _public; |
24 changes: 24 additions & 0 deletions
24
src/base/services/prop-based-tag-name/prop-based-tag-name.test.js
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,24 @@ | ||
import propBaseTagNameService from './prop-based-tag-name'; | ||
|
||
describe('Prop Based Tag Name Service', () => { | ||
it('should return prop value if given prop is valid', () => { | ||
const defaultTagName = 'button'; | ||
const isValidTagName = prop => ['a', 'button'].includes(prop); | ||
const tagName = propBaseTagNameService.buildTagName('a', isValidTagName, { defaultTagName }); | ||
expect(tagName).toEqual('a'); | ||
}); | ||
|
||
it('should return default tag name if given prop is not valid', () => { | ||
const defaultTagName = 'button'; | ||
const isValidTagName = prop => ['a', 'button'].includes(prop); | ||
const tagName = propBaseTagNameService.buildTagName('ul', isValidTagName, { defaultTagName }); | ||
expect(tagName).toEqual('button'); | ||
}); | ||
|
||
it('should return default tag name if prop has not been given', () => { | ||
const defaultTagName = 'button'; | ||
const isValidTagName = prop => ['a', 'button'].includes(prop); | ||
const tagName = propBaseTagNameService.buildTagName(undefined, isValidTagName, { defaultTagName }); | ||
expect(tagName).toEqual('button'); | ||
}); | ||
}); |
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
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
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,3 +1,3 @@ | ||
<button :class="classes"> | ||
<component :is="tagName" :class="classes"> | ||
<slot></slot> | ||
</button> | ||
</component> |
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