|
1 | 1 | <template> |
2 | | - <div class="ad-manager" v-if="codeFundData"> |
3 | | - <div class="code-fund" :class="{ static: isStatic }"> |
4 | | - <a target="_blank" :href="codeFundData.link" class="code-fund-image"> |
5 | | - <md-ripple> |
6 | | - <img :src="codeFundData.image"> |
7 | | - </md-ripple> |
8 | | - </a> |
9 | | - |
10 | | - <div class="code-fund-data"> |
11 | | - <a target="_blank" :href="codeFundData.link" class="code-fund-header">{{ codeFundData.headline }}</a> |
12 | | - <a target="_blank" :href="codeFundData.link" class="code-fund-content">{{ codeFundData.description }}</a> |
13 | | - <a target="_blank" :href="codeFundData.poweredByLink" class="code-fund-name">ads via codefund.io</a> |
14 | | - </div> |
15 | | - |
16 | | - <img :src="codeFundData.pixel" alt="Codefund Pixel" class="code-fund-pixel"> |
17 | | - </div> |
18 | | - </div> |
| 2 | + <md-content class="ad-manager" id="ad-manager" md-theme="docs-dark"> |
| 3 | + <div id="code-fund" class="code-fund"></div> |
| 4 | + </md-content> |
19 | 5 | </template> |
20 | 6 |
|
21 | 7 | <script> |
22 | 8 | export default { |
23 | 9 | name: 'AdManager', |
24 | | - data: () => ({ |
25 | | - codeFundId: 'e2b197ea-5aca-408e-96fc-088ad5be2280', |
26 | | - codeFundData: null, |
27 | | - isStatic: false |
28 | | - }), |
29 | 10 | methods: { |
30 | | - setStatic () { |
31 | | - window.requestAnimationFrame(() => { |
32 | | - const scrollEl = document.documentElement |
33 | | - const container = document.querySelector('.container') |
| 11 | + getSponsor () { |
| 12 | + let sponsorUrl = 'https://api.codefund.app/properties/60/funder.html' |
| 13 | +
|
| 14 | + if (this.$route.name !== 'home') { |
| 15 | + sponsorUrl += '?theme=light' |
| 16 | + } |
34 | 17 |
|
35 | | - this.isStatic = scrollEl.offsetHeight >= container.offsetHeight |
| 18 | + this.$http.get(sponsorUrl).then(({ data }) => { |
| 19 | + document.getElementById('code-fund').innerHTML = data; |
36 | 20 | }) |
37 | 21 | } |
38 | 22 | }, |
39 | 23 | mounted () { |
40 | | - this.$http.get(`https://codefund.io/t/s/${this.codeFundId}/details.json`).then(({ data }) => { |
41 | | - this.$set(this, 'codeFundData', data) |
42 | | - this.setStatic() |
43 | | - }) |
44 | | - window.addEventListener('resize', this.setStatic, false) |
| 24 | + this.getSponsor() |
45 | 25 | }, |
46 | | - beforeDestroy () { |
47 | | - window.removeEventListener('resize', this.setStatic) |
| 26 | + updated () { |
| 27 | + this.getSponsor() |
48 | 28 | } |
49 | 29 | } |
50 | 30 | </script> |
|
55 | 35 | $ad-responsive-big: 1690px; |
56 | 36 | $ad-responsive-small: 768px; |
57 | 37 |
|
58 | | - @mixin ad-theme ($hue, $color) { |
59 | | - .code-fund { |
60 | | - background: md-get-palette-color(grey, $hue); |
61 | | - } |
62 | | -
|
63 | | - .code-fund-header, |
64 | | - .code-fund-content { |
65 | | - color: rgba($color, .7); |
66 | | -
|
67 | | - &:hover { |
68 | | - color: $color; |
69 | | - } |
70 | | - } |
71 | | -
|
72 | | - .code-fund-name { |
73 | | - color: rgba($color, .38); |
74 | | -
|
75 | | - &:hover { |
76 | | - color: rgba($color, .7); |
77 | | - } |
78 | | - } |
79 | | - } |
80 | | -
|
81 | 38 | .ad-manager { |
| 39 | + width: calc(100% + 32px); |
82 | 40 | margin: 0 -16px -16px; |
83 | 41 |
|
84 | 42 | @media (max-width: $ad-responsive-small) { |
|
88 | 46 |
|
89 | 47 | .code-fund { |
90 | 48 | max-width: 175px; |
91 | | - margin: 7px 16px 24px 16px; |
| 49 | + margin: 0 16px 24px 16px; |
92 | 50 | padding: 8px; |
93 | 51 | display: flex; |
94 | 52 | flex-direction: column; |
|
99 | 57 | line-height: 1.5em; |
100 | 58 |
|
101 | 59 | @media (min-width: $ad-responsive-big) { |
102 | | - &:not(.static) { |
103 | | - margin: 0; |
104 | | - position: fixed; |
105 | | - right: 16px; |
106 | | - bottom: 16px; |
107 | | - z-index: 1000; |
108 | | - } |
| 60 | + margin: 0; |
| 61 | + position: fixed; |
| 62 | + top: 80px; |
| 63 | + right: 24px; |
| 64 | + z-index: 1000; |
109 | 65 | } |
110 | 66 |
|
111 | 67 | @media (max-width: $ad-responsive-small) { |
112 | 68 | max-width: none; |
113 | | - margin-bottom: 16px; |
| 69 | + margin: 8px auto 16px; |
114 | 70 | float: none; |
115 | 71 | } |
116 | 72 |
|
117 | 73 | .splash-container & { |
118 | 74 | @media (max-width: $ad-responsive-big) { |
119 | 75 | max-width: 530px; |
120 | 76 | min-height: 100px; |
121 | | - margin: 8px auto; |
| 77 | + margin: 60px auto 8px; |
122 | 78 | float: none; |
123 | 79 | background: none !important; |
124 | 80 | } |
125 | 81 | } |
126 | | -
|
127 | | - a { |
128 | | - display: block; |
129 | | - } |
130 | | - } |
131 | | -
|
132 | | - .code-fund-image { |
133 | | - color: #fff !important; |
134 | | -
|
135 | | - &:hover { |
136 | | - opacity: .85; |
137 | | - } |
138 | | - } |
139 | | -
|
140 | | - .code-fund-header { |
141 | | - margin-top: .5em; |
142 | | - font-weight: 600; |
143 | | - line-height: 1.3em; |
144 | | - } |
145 | | -
|
146 | | - .code-fund-content { |
147 | | - margin-top: 1em; |
148 | | -
|
149 | | - &:hover { |
150 | | - text-decoration: none; |
151 | | - } |
152 | | - } |
153 | | -
|
154 | | - .code-fund-name { |
155 | | - margin-top: .5em; |
156 | | - font-size: 11px; |
157 | | - } |
158 | | -
|
159 | | - .code-fund-name, |
160 | | - .code-fund-description { |
161 | | - &:hover { |
162 | | - text-decoration: underline; |
163 | | - } |
164 | | - } |
165 | | -
|
166 | | - .code-fund-pixel { |
167 | | - width: 1px; |
168 | | - height: 1px; |
169 | | - margin: -1px; |
170 | | - padding: 0; |
171 | | - position: absolute; |
172 | | - overflow: hidden; |
173 | | - clip: rect(0 0 0 0); |
174 | | - border: 0; |
175 | | - } |
176 | | -
|
177 | | - .main-container { |
178 | | - @include ad-theme(200, #000); |
179 | | - } |
180 | | -
|
181 | | - .splash-container { |
182 | | - @media (min-width: $ad-responsive-big) { |
183 | | - @include ad-theme(800, #fff); |
184 | | - } |
185 | 82 | } |
186 | 83 | </style> |
0 commit comments