Skip to content

Commit 2c5e1dc

Browse files
committed
Add example
1 parent 8551e07 commit 2c5e1dc

File tree

10 files changed

+14320
-4
lines changed

10 files changed

+14320
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
node_modules/
33
npm-debug.log
4+
public

dist/vue-clock.cjs.js

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', { value: true });
4+
5+
function getHourTime(h) {
6+
return h >= 12 ? 'PM' : 'AM';
7+
}
8+
function getZeroPad(n) {
9+
return (parseInt(n, 10) >= 10 ? '' : '0') + n;
10+
}
11+
12+
//
13+
var script = {
14+
data: function data() {
15+
return {
16+
hours: '',
17+
minutes: '',
18+
seconds: '',
19+
hourtime: ''
20+
};
21+
},
22+
mounted: function mounted() {
23+
setInterval(this.updateDateTime, 1000);
24+
},
25+
methods: {
26+
updateDateTime: function updateDateTime() {
27+
var now = new Date();
28+
this.hours = now.getHours();
29+
this.minutes = getZeroPad(now.getMinutes());
30+
this.seconds = getZeroPad(now.getSeconds());
31+
this.hourtime = getHourTime(this.hours);
32+
this.hours = this.hours % 12 || 12;
33+
}
34+
}
35+
};
36+
37+
/* script */
38+
var __vue_script__ = script;
39+
/* template */
40+
41+
var __vue_render__ = function __vue_render__() {
42+
var _vm = this;
43+
44+
var _h = _vm.$createElement;
45+
46+
var _c = _vm._self._c || _h;
47+
48+
return _c("div", {
49+
staticClass: "clock"
50+
}, [_c("div", {
51+
staticClass: "clock__hours"
52+
}, [_c("span", {
53+
staticClass: "clock__hourtime",
54+
domProps: {
55+
textContent: _vm._s(_vm.hourtime)
56+
}
57+
}), _vm._v(" "), _c("span", {
58+
domProps: {
59+
textContent: _vm._s(_vm.hours)
60+
}
61+
})]), _vm._v(" "), _c("div", {
62+
staticClass: "clock__minutes",
63+
domProps: {
64+
textContent: _vm._s(_vm.minutes)
65+
}
66+
}), _vm._v(" "), _c("div", {
67+
staticClass: "clock__seconds",
68+
domProps: {
69+
textContent: _vm._s(_vm.seconds)
70+
}
71+
})]);
72+
};
73+
74+
var __vue_staticRenderFns__ = [];
75+
__vue_render__._withStripped = true;
76+
77+
var __vue_template__ = typeof __vue_render__ !== 'undefined' ? {
78+
render: __vue_render__,
79+
staticRenderFns: __vue_staticRenderFns__
80+
} : {};
81+
/* style */
82+
83+
84+
var __vue_inject_styles__ = function (inject) {
85+
if (!inject) return;
86+
inject("data-v-3b693988_0", {
87+
source: "\n.clock {\n background: #fff;\n border: .3rem solid #fff;\n border-radius: .5rem;\n display: inline-block;\n margin-bottom: 1em;\n}\n.clock__hours,\n.clock__minutes,\n.clock__seconds {\n background: linear-gradient(to bottom, #26303b 50%, #2c3540 50%);\n display: inline-block;\n color: #fff;\n font-family: 'Nunito', sans-serif;\n font-size: 3rem;\n font-weight: 300;\n padding: .5rem 1rem;\n text-align: center;\n position: relative;\n}\n.clock__hours {\n border-right: .15rem solid #fff;\n border-radius: .5rem 0 0 .5rem;\n}\n.clock__minutes {\n border-right: .15rem solid #fff;\n}\n.clock__seconds {\n border-radius: 0 .5rem .5rem 0;\n}\n.clock__hourtime {\n font-size: 1rem;\n position: absolute;\n top: 2px;\n left: 8px;\n}\n",
88+
map: undefined,
89+
media: undefined
90+
});
91+
};
92+
/* scoped */
93+
94+
95+
var __vue_scope_id__ = undefined;
96+
/* module identifier */
97+
98+
99+
var __vue_module_identifier__ = undefined;
100+
/* functional template */
101+
102+
103+
var __vue_is_functional_template__ = false;
104+
/* component normalizer */
105+
106+
function __vue_normalize__(template, style, script$$1, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) {
107+
var component = (typeof script$$1 === 'function' ? script$$1.options : script$$1) || {};
108+
109+
{
110+
component.__file = "/Users/dangvanthanh/Code/dev/vue/vue-clock/src/VueClock.vue";
111+
}
112+
113+
if (!component.render) {
114+
component.render = template.render;
115+
component.staticRenderFns = template.staticRenderFns;
116+
component._compiled = true;
117+
if (functional) component.functional = true;
118+
}
119+
120+
component._scopeId = scope;
121+
122+
{
123+
var hook;
124+
125+
if (style) {
126+
hook = function hook(context) {
127+
style.call(this, createInjector(context));
128+
};
129+
}
130+
131+
if (hook !== undefined) {
132+
if (component.functional) {
133+
// register for functional component in vue file
134+
var originalRender = component.render;
135+
136+
component.render = function renderWithStyleInjection(h, context) {
137+
hook.call(context);
138+
return originalRender(h, context);
139+
};
140+
} else {
141+
// inject component registration as beforeCreate hook
142+
var existing = component.beforeCreate;
143+
component.beforeCreate = existing ? [].concat(existing, hook) : [hook];
144+
}
145+
}
146+
}
147+
148+
return component;
149+
}
150+
/* style inject */
151+
152+
153+
function __vue_create_injector__() {
154+
var head = document.head || document.getElementsByTagName('head')[0];
155+
var styles = __vue_create_injector__.styles || (__vue_create_injector__.styles = {});
156+
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
157+
return function addStyle(id, css) {
158+
if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) return; // SSR styles are present.
159+
160+
var group = isOldIE ? css.media || 'default' : id;
161+
var style = styles[group] || (styles[group] = {
162+
ids: [],
163+
parts: [],
164+
element: undefined
165+
});
166+
167+
if (!style.ids.includes(id)) {
168+
var code = css.source;
169+
var index = style.ids.length;
170+
style.ids.push(id);
171+
172+
if (isOldIE) {
173+
style.element = style.element || document.querySelector('style[data-group=' + group + ']');
174+
}
175+
176+
if (!style.element) {
177+
var el = style.element = document.createElement('style');
178+
el.type = 'text/css';
179+
if (css.media) el.setAttribute('media', css.media);
180+
181+
if (isOldIE) {
182+
el.setAttribute('data-group', group);
183+
el.setAttribute('data-next-index', '0');
184+
}
185+
186+
head.appendChild(el);
187+
}
188+
189+
if (isOldIE) {
190+
index = parseInt(style.element.getAttribute('data-next-index'));
191+
style.element.setAttribute('data-next-index', index + 1);
192+
}
193+
194+
if (style.element.styleSheet) {
195+
style.parts.push(code);
196+
style.element.styleSheet.cssText = style.parts.filter(Boolean).join('\n');
197+
} else {
198+
var textNode = document.createTextNode(code);
199+
var nodes = style.element.childNodes;
200+
if (nodes[index]) style.element.removeChild(nodes[index]);
201+
if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode);
202+
}
203+
}
204+
};
205+
}
206+
/* style inject SSR */
207+
208+
209+
var VueClock = __vue_normalize__(__vue_template__, __vue_inject_styles__, typeof __vue_script__ === 'undefined' ? {} : __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, typeof __vue_create_injector__ !== 'undefined' ? __vue_create_injector__ : function () {}, typeof __vue_create_injector_ssr__ !== 'undefined' ? __vue_create_injector_ssr__ : function () {});
210+
211+
exports.default = VueClock;

0 commit comments

Comments
 (0)