Move src to dashboard (#152)
This commit is contained in:
parent
012a2743f2
commit
2783fb6006
187 changed files with 29 additions and 29 deletions
33
app/javascript/dashboard/components/ui/Tabs/Tabs.js
Normal file
33
app/javascript/dashboard/components/ui/Tabs/Tabs.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* eslint no-unused-vars: ["error", { "args": "none" }] */
|
||||
|
||||
export default {
|
||||
name: 'WootTabs',
|
||||
props: {
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
render(h) {
|
||||
const Tabs = this.$slots.default
|
||||
.filter(
|
||||
node =>
|
||||
node.componentOptions &&
|
||||
node.componentOptions.tag === 'woot-tabs-item'
|
||||
)
|
||||
.map((node, index) => {
|
||||
const data = node.componentOptions.propsData;
|
||||
data.index = index;
|
||||
return node;
|
||||
});
|
||||
return (
|
||||
<ul
|
||||
class={{
|
||||
tabs: true,
|
||||
}}
|
||||
>
|
||||
{Tabs}
|
||||
</ul>
|
||||
);
|
||||
},
|
||||
};
|
88
app/javascript/dashboard/components/ui/Tabs/TabsItem.js
Normal file
88
app/javascript/dashboard/components/ui/Tabs/TabsItem.js
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* eslint no-unused-vars: ["error", { "args": "none" }] */
|
||||
/* eslint prefer-template: 0 */
|
||||
/* eslint no-console: 0 */
|
||||
/* eslint func-names: 0 */
|
||||
import TWEEN from 'tween.js';
|
||||
|
||||
export default {
|
||||
name: 'WootTabsItem',
|
||||
props: {
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
count: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
animatedNumber: 0,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
active() {
|
||||
return this.index === this.$parent.index;
|
||||
},
|
||||
|
||||
getItemCount() {
|
||||
return this.animatedNumber || this.count;
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
count(newValue, oldValue) {
|
||||
let animationFrame;
|
||||
const animate = time => {
|
||||
TWEEN.update(time);
|
||||
animationFrame = window.requestAnimationFrame(animate);
|
||||
};
|
||||
const that = this;
|
||||
new TWEEN.Tween({ tweeningNumber: oldValue })
|
||||
.easing(TWEEN.Easing.Quadratic.Out)
|
||||
.to({ tweeningNumber: newValue }, 500)
|
||||
.onUpdate(function() {
|
||||
that.animatedNumber = this.tweeningNumber.toFixed(0);
|
||||
})
|
||||
.onComplete(() => {
|
||||
window.cancelAnimationFrame(animationFrame);
|
||||
})
|
||||
.start();
|
||||
animationFrame = window.requestAnimationFrame(animate);
|
||||
},
|
||||
},
|
||||
|
||||
render(h) {
|
||||
return (
|
||||
<li
|
||||
class={{
|
||||
'tabs-title': true,
|
||||
'is-active': this.active,
|
||||
'uk-disabled': this.disabled,
|
||||
}}
|
||||
>
|
||||
<a
|
||||
on-click={event => {
|
||||
event.preventDefault();
|
||||
if (!this.disabled) {
|
||||
this.$parent.$emit('change', this.index);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{`${this.name} (${this.getItemCount})`}
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue