Skip to content

Commit 86f236f

Browse files
committed
chore: cleanup carbon
1 parent fab161d commit 86f236f

File tree

5 files changed

+142
-37
lines changed

5 files changed

+142
-37
lines changed

layouts/docs.ejs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
</a>
2525
<% } %>
2626

27-
<div class="md:bg-docs-gradient min-h-screen">
27+
<div id="docs-app" class="md:bg-docs-gradient min-h-screen">
2828
<div class="container mx-auto flex">
29-
3029
<div class="hidden md:w-1/4 md:block border-r-4 min-h-full">
31-
<div class="carbon">
32-
<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?serve=CESD42JM&placement=nativescript-vueorg" id="_carbonads_js"></script>
33-
</div>
30+
<carbon-component v-if="!isMobile"></carbon-component>
3431
<div class="pl-4 md:pl-0 py-4 md:py-8">
3532
<ul id="docs-toc" class="list-reset">
3633
<%- include('_partials/categories', { entry: { children: meta.docs_categories } }) %>
@@ -87,6 +84,8 @@
8784
</div>
8885
<% } %>
8986

87+
<carbon-component v-if="isMobile"></carbon-component>
88+
9089
<div class="markdown-body">
9190
<%- current.contents %>
9291
</div>

src/main.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
document.addEventListener('DOMContentLoaded', () => {
2+
const store = new Vue({
3+
data: {
4+
isMobile: false
5+
},
6+
methods: {
7+
_resizeListener() {
8+
this.isMobile = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) <= 768
9+
}
10+
},
11+
})
12+
13+
// attach resize listener
14+
window.addEventListener('resize', store._resizeListener);
15+
store._resizeListener();
16+
217
new Vue({
318
el: '#app',
19+
name: 'NavApp',
420

521
data: {
622
modalVisible: false,
723
modalLoaded: false,
8-
isMobile: false,
924
navOpen: false,
1025
},
11-
created() {
12-
this._resizeListener = () => {
13-
this.isMobile = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) <= 768
14-
};
15-
window.addEventListener('resize', this._resizeListener);
16-
this._resizeListener();
26+
27+
computed: {
28+
isMobile() {
29+
return store.isMobile
30+
}
1731
},
32+
1833
mounted() {
1934
const lang = document.documentElement.lang || 'en'
2035
const [version] = window.location.hostname.match(/v\d-\d-\d/) || ['master']
@@ -27,10 +42,7 @@ document.addEventListener('DOMContentLoaded', () => {
2742
debug: false
2843
})
2944
},
30-
destroyed() {
31-
window.removeEventListener('resize', this._resizeListener)
32-
},
33-
methods: {},
45+
3446
directives: {
3547
nav(el) {
3648
el.addEventListener('change', (e) => {
@@ -39,4 +51,31 @@ document.addEventListener('DOMContentLoaded', () => {
3951
}
4052
}
4153
});
54+
55+
const carbonComponent = {
56+
render: h => h('div', { class: 'carbon' }),
57+
58+
mounted() {
59+
const script = document.createElement('script')
60+
script.id = '_carbonads_js'
61+
script.src = '//cdn.carbonads.com/carbon.js?serve=CESD42JM&placement=nativescript-vueorg'
62+
63+
this.$el.appendChild(script)
64+
}
65+
}
66+
67+
new Vue({
68+
el: '#docs-app',
69+
name: 'DocsApp',
70+
71+
computed: {
72+
isMobile() {
73+
return store.isMobile
74+
}
75+
},
76+
77+
components: {
78+
carbonComponent
79+
}
80+
})
4281
});

src/styles.css

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444
}
4545

4646
.carbon {
47-
margin-bottom: -32px;
48-
padding-top: 32px;
49-
padding-right: 4px;
47+
padding-top: 16px;
5048
}
5149

5250
#carbonads {
@@ -67,7 +65,7 @@
6765
}
6866
#carbonads .carbon-wrap {
6967
display: flex;
70-
flex-direction: column;
68+
flex-direction: row;
7169
}
7270

7371
#carbonads .carbon-img {
@@ -101,6 +99,22 @@
10199
right: 0;
102100
}
103101

102+
@screen md {
103+
.carbon {
104+
margin-bottom: -32px;
105+
padding-top: 32px;
106+
padding-right: 4px;
107+
}
108+
109+
#carbonads .carbon-wrap {
110+
flex-direction: column;
111+
}
112+
113+
#carbonads .carbon-text {
114+
padding: 10px;
115+
}
116+
}
117+
104118
@screen xl {
105119
#carbonads .carbon-wrap {
106120
flex-direction: row;

static/main.js

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,37 @@
33
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
44

55
document.addEventListener('DOMContentLoaded', function () {
6+
var store = new Vue({
7+
data: {
8+
isMobile: false
9+
},
10+
methods: {
11+
_resizeListener: function _resizeListener() {
12+
this.isMobile = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) <= 768;
13+
}
14+
}
15+
});
16+
17+
// attach resize listener
18+
window.addEventListener('resize', store._resizeListener);
19+
store._resizeListener();
20+
621
new Vue({
722
el: '#app',
23+
name: 'NavApp',
824

925
data: {
1026
modalVisible: false,
1127
modalLoaded: false,
12-
isMobile: false,
1328
navOpen: false
1429
},
15-
created: function created() {
16-
var _this = this;
17-
18-
this._resizeListener = function () {
19-
_this.isMobile = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) <= 768;
20-
};
21-
window.addEventListener('resize', this._resizeListener);
22-
this._resizeListener();
30+
31+
computed: {
32+
isMobile: function isMobile() {
33+
return store.isMobile;
34+
}
2335
},
36+
2437
mounted: function mounted() {
2538
var lang = document.documentElement.lang || 'en';
2639

@@ -36,11 +49,8 @@ document.addEventListener('DOMContentLoaded', function () {
3649
debug: false
3750
});
3851
},
39-
destroyed: function destroyed() {
40-
window.removeEventListener('resize', this._resizeListener);
41-
},
4252

43-
methods: {},
53+
4454
directives: {
4555
nav: function nav(el) {
4656
el.addEventListener('change', function (e) {
@@ -49,4 +59,33 @@ document.addEventListener('DOMContentLoaded', function () {
4959
}
5060
}
5161
});
62+
63+
var carbonComponent = {
64+
render: function render(h) {
65+
return h('div', { class: 'carbon' });
66+
},
67+
68+
mounted: function mounted() {
69+
var script = document.createElement('script');
70+
script.id = '_carbonads_js';
71+
script.src = '//cdn.carbonads.com/carbon.js?serve=CESD42JM&placement=nativescript-vueorg';
72+
73+
this.$el.appendChild(script);
74+
}
75+
};
76+
77+
new Vue({
78+
el: '#docs-app',
79+
name: 'DocsApp',
80+
81+
computed: {
82+
isMobile: function isMobile() {
83+
return store.isMobile;
84+
}
85+
},
86+
87+
components: {
88+
carbonComponent: carbonComponent
89+
}
90+
});
5291
});

static/styles.css

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,9 +3329,7 @@ button,
33293329
}
33303330

33313331
.carbon {
3332-
margin-bottom: -32px;
3333-
padding-top: 32px;
3334-
padding-right: 4px;
3332+
padding-top: 16px;
33353333
}
33363334

33373335
#carbonads {
@@ -3356,7 +3354,7 @@ button,
33563354

33573355
#carbonads .carbon-wrap {
33583356
display: flex;
3359-
flex-direction: column;
3357+
flex-direction: row;
33603358
}
33613359

33623360
#carbonads .carbon-img {
@@ -3393,6 +3391,22 @@ button,
33933391
right: 0;
33943392
}
33953393

3394+
@media (min-width: 768px) {
3395+
.carbon {
3396+
margin-bottom: -32px;
3397+
padding-top: 32px;
3398+
padding-right: 4px;
3399+
}
3400+
3401+
#carbonads .carbon-wrap {
3402+
flex-direction: column;
3403+
}
3404+
3405+
#carbonads .carbon-text {
3406+
padding: 10px;
3407+
}
3408+
}
3409+
33963410
@media (min-width: 1200px) {
33973411
#carbonads .carbon-wrap {
33983412
flex-direction: row;

0 commit comments

Comments
 (0)