mirror of
https://github.com/wekan/wekan.git
synced 2026-03-07 06:10:15 +01:00
Replace templates:tabs Atmosphere package with inline Blaze implementation
Drop the templates:tabs dependency as part of Meteor 3.0 migration prep. The package is replaced by a lightweight inline basicTabs/tabContent template pair with identical API, so no consumer template changes needed.
This commit is contained in:
parent
ff7729fc35
commit
81d3a08b9b
7 changed files with 91 additions and 7 deletions
11
client/components/lib/basicTabs.jade
Normal file
11
client/components/lib/basicTabs.jade
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
template(name="basicTabs")
|
||||
.basicTabs-container(class="{{name}}")
|
||||
ul.tabs-list
|
||||
each tabs
|
||||
li.tab-item(class="{{isActiveTab slug}} {{class}}") {{name}}
|
||||
.tabs-content-container
|
||||
+Template.contentBlock
|
||||
|
||||
template(name="tabContent")
|
||||
section.tabs-content(class="{{isActiveTab slug}}" data-tab="{{slug}}")
|
||||
+Template.contentBlock
|
||||
50
client/components/lib/basicTabs.js
Normal file
50
client/components/lib/basicTabs.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
const { ReactiveVar } = require('meteor/reactive-var');
|
||||
|
||||
Template.basicTabs.onCreated(function () {
|
||||
const activeTab = this.data.activeTab
|
||||
? { slug: this.data.activeTab }
|
||||
: this.data.tabs[0];
|
||||
this._activeTab = new ReactiveVar(activeTab);
|
||||
|
||||
this.isActiveSlug = (slug) => {
|
||||
const current = this._activeTab.get();
|
||||
return current && current.slug === slug;
|
||||
};
|
||||
});
|
||||
|
||||
Template.basicTabs.helpers({
|
||||
isActiveTab(slug) {
|
||||
if (Template.instance().isActiveSlug(slug)) {
|
||||
return 'active';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.basicTabs.events({
|
||||
'click .tab-item'(e, t) {
|
||||
t._activeTab.set(this);
|
||||
},
|
||||
});
|
||||
|
||||
function findBasicTabsInstance() {
|
||||
let view = Blaze.currentView;
|
||||
while (view) {
|
||||
if (view.name === 'Template.basicTabs' && view.templateInstance) {
|
||||
const inst = view.templateInstance();
|
||||
if (inst && inst.isActiveSlug) {
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
view = view.parentView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Template.tabContent.helpers({
|
||||
isActiveTab(slug) {
|
||||
const inst = findBasicTabsInstance();
|
||||
if (inst && inst.isActiveSlug(slug)) {
|
||||
return 'active';
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -477,9 +477,39 @@ a:not(.disabled).is-active i.fa {
|
|||
.viewer a:hover {
|
||||
color: #333;
|
||||
}
|
||||
.basicTabs-container .tabs-list {
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
.basicTabs-container .tabs-list .tab-item {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
display: inline-block;
|
||||
padding: 13px 15px;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
.basicTabs-container .tabs-list .tab-item.active {
|
||||
border-radius: 5px 5px 0 0;
|
||||
border: 1px solid #ddd;
|
||||
border-bottom: none;
|
||||
margin-bottom: -1px !important;
|
||||
padding: 12px 14px 14px 14px !important;
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
}
|
||||
.basicTabs-container .tabs-content-container {
|
||||
padding: 0;
|
||||
padding-top: 15px;
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
.basicTabs-container .tabs-content {
|
||||
display: none;
|
||||
}
|
||||
.basicTabs-container .tabs-content.active {
|
||||
display: block;
|
||||
}
|
||||
.no-scrollbars {
|
||||
scrollbar-width: none;
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
// XXX Since Blaze doesn't have a clean high component API, component API are
|
||||
// also tweaky to use. I guess React would be a solution.
|
||||
const template = 'basicTabs';
|
||||
ReactiveTabs.createInterface({ template });
|
||||
Loading…
Add table
Add a link
Reference in a new issue