Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f1f2a12b
Commit
f1f2a12b
authored
Nov 05, 2014
by
Hixie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs: Experimental 'button' widget, work in progress
Review URL:
https://codereview.chromium.org/700023003
parent
018e6ba3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
buttons.sky
examples/calculator/buttons.sky
+79
-0
No files found.
examples/calculator/buttons.sky
0 → 100644
View file @
f1f2a12b
SKY MODULE - button widgets for calculator
<!-- TODO(ianh): implement accessibility handling once the ax service exists -->
<script>
class AbstractButton extends Element {
constructor (module) {
super(module);
let selector = new SelectorQuery('.dynamic');
this.addEventListener('pointer-down', (event) => {
selector.findAll(this.shadowRoot).every((element) => element.setAttribute('clicked'));
// TODO(ianh): track the pointer; if it leaves the button, cancel the click
// TOOD(ianh): if the pointer doesn't leave the button before being released, then fire some event on ourselves
module.application.document.addEventListener('pointer-up', function upHandler (event) {
module.application.document.removeEventListener('pointer-up', upHandler);
selector.findAll(this.shadowRoot).every((element) => element.removeAttribute('clicked'));
});
});
}
}
</script>
<template id="threed-button-shadow-tree">
<style>
/* TODO(ianh): make this shrink-wrap the contents */
div { border: solid 1px; }
#a { border-color: #666666 #333333 #333333 #666666; }
#b { border-color: #EEEEEE #666666 #666666 #EEEEEE; }
#c { border-color: #EEEEEE #666666 #666666 #EEEEEE; }
#d { border-color: #EEEEEE #999999 #999999 #EEEEEE; padding: 2px 0 0 0; background: #DDDDDD; color: black; text-align: center; }
#a[clicked] { border-color: #666666 #333333 #333333 #666666; width: 6em; }
#b[clicked] { border-color: #666666 #DDDDDD #DDDDDD #666666; border-width: 1px 0 0 1px; }
#c[clicked] { border-color: #666666 #DDDDDD #DDDDDD #666666; border-width: 1px 0 0 1px; }
#d[clicked] { border-color: #999999 #DDDDDD #DDDDDD #999999; padding: 4px 0 0 2px; }
</style>
<div class="dynamic" id="a">
<div class="dynamic" id="b">
<div class="dynamic" id="c">
<div class="dynamic" id="d">
<content/>
</div>
</div>
</div>
</div>
</template>
<template id="threed-button-shadow-tree">
<style>
div { background: green; color: yellow; }
div[clicked] { background: yellow; color: green; }
</style>
<div class=dynamic>
<content/>
</div>
</template>
<script>
module.exports = {
ThreeDButtonElement: module.registerElement({
tagName: 'graybutton',
shadow: true,
constructor: class extends AbstractButton {
constructor (module) {
super(module);
this.shadowRoot.append(module.document.findId('threed-button-shadow-tree').cloneNode(true));
}
},
}),
FlatButtonElement: module.registerElement({
tagName: 'graybutton',
shadow: true,
constructor: class extends AbstractButton {
constructor (module) {
super(module);
this.shadowRoot.append(module.document.findId('flat-shadow-tree').cloneNode(true));
}
},
}),
};
</script>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment