-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #19 from frankiefu/master
tabs component, simplify togglebutton and more unit tests
- Loading branch information
Showing
11 changed files
with
168 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
@host { | ||
display: block; | ||
height: 28px; | ||
line-height: 28px; | ||
border: 0; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
.vertical { | ||
display: inline-block; | ||
width: 71px; | ||
height: 100%; | ||
border: 0; | ||
border-right: 1px solid #ccc; | ||
} | ||
|
||
.tabContainer > * { | ||
display: inline-block; | ||
min-width: 54px; | ||
height: 27px; | ||
line-height: 27px; | ||
text-align: center; | ||
padding: 0 8px; | ||
cursor: default; | ||
border: 1px solid transparent; | ||
border-radius: 2px 2px 0 0; | ||
-webkit-transition: all 0.218s; | ||
} | ||
|
||
.vertical .tabContainer > * { | ||
border-radius: 2px 0 0 2px; | ||
} | ||
|
||
.tabContainer > :hover { | ||
color: #555; | ||
} | ||
|
||
.tabContainer > .selected { | ||
color: #202020; | ||
border: 1px solid #ccc; | ||
} |
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,25 @@ | ||
<!-- | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
--> | ||
<element name="g-tabs" extends="g-selector" attributes="selected, multi, vertical" handlers="click: clickHandler"> | ||
<link rel="components" href="g-selector.html"> | ||
<link rel="stylesheet" href="css/g-tabs.css" /> | ||
<template> | ||
<div class="tabContainer"> | ||
<shadow></shadow> | ||
</div> | ||
</template> | ||
<script> | ||
this.component({ | ||
prototype: { | ||
verticalChanged: function() { | ||
this.classList.enable('vertical', this.vertical); | ||
} | ||
} | ||
}); | ||
</script> | ||
</element> |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('g-togglebutton', function() { | ||
var togglebutton; | ||
|
||
setup(function() { | ||
togglebutton = document.createElement('g-togglebutton'); | ||
work.appendChild(togglebutton); | ||
}); | ||
|
||
teardown(function() { | ||
work.textContent = ''; | ||
}); | ||
|
||
test('initial value', function() { | ||
expect(togglebutton.value).to.not.be.ok(); | ||
}); | ||
|
||
test('toggle', function() { | ||
var t = ShadowDOM.localQuery(togglebutton.shadow, '.toggle'); | ||
togglebutton.toggle(); | ||
expect(t.classList.contains('on')).to.be(true); | ||
togglebutton.toggle(); | ||
expect(t.classList.contains('on')).to.be(false); | ||
}); | ||
|
||
suite('attributes', function() { | ||
test('value', function() { | ||
var t = ShadowDOM.localQuery(togglebutton.shadow, '.toggle'); | ||
togglebutton.value = true; | ||
expect(t.classList.contains('on')).to.be(true); | ||
togglebutton.value = false; | ||
expect(t.classList.contains('on')).to.be(false); | ||
}); | ||
}); | ||
}); |
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,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Tabs</title> | ||
<script src="../../polyfills/Components/components-polyfill.js" shadow="shim"></script> | ||
<link rel="components" href="../../toolkit/src/g-tabs.html"> | ||
</head> | ||
<body> | ||
<g-tabs> | ||
<span>One</span> | ||
<span>Two</span> | ||
<span>Three</span> | ||
<span>Four</span> | ||
</g-tabs> | ||
<br><br> | ||
<g-tabs vertical="true"> | ||
<span>One</span> | ||
<span>Two</span> | ||
<span>Three</span> | ||
<span>Four</span> | ||
</g-tabs> | ||
</body> | ||
</html> |