Skip to content

Commit cfeb129

Browse files
committed
🎉 init.
0 parents  commit cfeb129

17 files changed

+12756
-0
lines changed

.browserslistrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
current node
2+
last 2 versions and > 2%
3+
ie > 10

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
*.zip
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
15+
# Editor directories and files
16+
.idea
17+
!.vscode
18+
.vscode/*
19+
!.vscode/settings.json
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw*

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Zkerhcy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# digital-clock-vue
2+
3+
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/zkerhcy/digital-clock-vue/blob/master/LICENSE)
4+
5+
> ️A digital clock simulation build on Vue.
6+
7+
![digital-clock](asserts/img1.gif)
8+
9+
without seconds:
10+
11+
![digital-clock-without-seconds](asserts/img2.gif)
12+
13+
You can also use the [digital-number](src/digital-number.vue) component.
14+
15+
![digital-number](asserts/img3.png)
16+
17+
## Installation
18+
19+
Via NPM:
20+
21+
```shell
22+
npm install --save digital-clock-vue
23+
```
24+
25+
Via Yarn:
26+
27+
```shell
28+
yarn add digital-clock-vue
29+
```
30+
31+
## Usage
32+
33+
```js
34+
import DigitalClockVue from 'digital-clock-vue'
35+
export default {
36+
components: { DigitalClockVue }
37+
}
38+
```
39+
40+
## Examples
41+
42+
```html
43+
<!-- recommned aspect ratio 4:1 -->
44+
<digital-clock-vue
45+
color="red"
46+
showSeconds
47+
style="background: black; width: 400px; height: 100px;"
48+
/>
49+
50+
<!-- recommned aspect ratio when without seconds 8:3 -->
51+
<digital-clock-vue
52+
color="#39af78"
53+
style="background: #2f4053; width: 240px; height: 90px;"
54+
/>
55+
56+
<!-- digital number -->
57+
<div>
58+
<digital-number
59+
:key="item"
60+
:num="item"
61+
color="#1973de"
62+
style="width: 45px; height:75px; margin-left: 2px;"
63+
v-for="item in Array.apply(null, {length: 10}).map((_, i) => i)"
64+
></digital-number>
65+
</div>
66+
```
67+
68+
## License
69+
70+
[MIT](http://opensource.org/licenses/MIT)

asserts/img1.gif

15.5 KB
Loading

asserts/img2.gif

1.71 KB
Loading

asserts/img3.png

10.9 KB
Loading

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@babel/preset-env',
4+
],
5+
};

build/rollup.config.js

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
// rollup.config.js
2+
import fs from 'fs'
3+
import path from 'path'
4+
import vue from 'rollup-plugin-vue'
5+
import alias from '@rollup/plugin-alias'
6+
import commonjs from '@rollup/plugin-commonjs'
7+
import replace from '@rollup/plugin-replace'
8+
import babel from 'rollup-plugin-babel'
9+
import { terser } from 'rollup-plugin-terser'
10+
import minimist from 'minimist'
11+
12+
// Get browserslist config and remove ie from es build targets
13+
const esbrowserslist = fs
14+
.readFileSync('./.browserslistrc')
15+
.toString()
16+
.split('\n')
17+
.filter(entry => entry && entry.substring(0, 2) !== 'ie')
18+
19+
const argv = minimist(process.argv.slice(2))
20+
21+
const projectRoot = path.resolve(__dirname, '..')
22+
23+
const baseConfig = {
24+
input: 'src/entry.js',
25+
plugins: {
26+
preVue: [
27+
replace({
28+
'process.env.NODE_ENV': JSON.stringify('production')
29+
}),
30+
alias({
31+
resolve: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
32+
entries: {
33+
'@': path.resolve(projectRoot, 'src')
34+
}
35+
})
36+
],
37+
vue: {
38+
css: true,
39+
template: {
40+
isProduction: true
41+
}
42+
},
43+
babel: {
44+
exclude: 'node_modules/**',
45+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue']
46+
}
47+
}
48+
}
49+
50+
// ESM/UMD/IIFE shared settings: externals
51+
// Refer to https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
52+
const external = [
53+
// list external dependencies, exactly the way it is written in the import statement.
54+
// eg. 'jquery'
55+
'vue'
56+
]
57+
58+
// UMD/IIFE shared settings: output.globals
59+
// Refer to https://rollupjs.org/guide/en#output-globals for details
60+
const globals = {
61+
// Provide global variable names to replace your external imports
62+
// eg. jquery: '$'
63+
vue: 'Vue'
64+
}
65+
66+
// Customize configs for individual targets
67+
const buildFormats = []
68+
if (!argv.format || argv.format === 'es') {
69+
const esConfig = {
70+
...baseConfig,
71+
external,
72+
output: {
73+
file: 'dist/digital-clock-vue.esm.js',
74+
format: 'esm',
75+
exports: 'named'
76+
},
77+
plugins: [
78+
...baseConfig.plugins.preVue,
79+
vue(baseConfig.plugins.vue),
80+
babel({
81+
...baseConfig.plugins.babel,
82+
presets: [
83+
[
84+
'@babel/preset-env',
85+
{
86+
targets: esbrowserslist
87+
}
88+
]
89+
]
90+
}),
91+
commonjs()
92+
]
93+
}
94+
buildFormats.push(esConfig)
95+
}
96+
97+
if (!argv.format || argv.format === 'cjs') {
98+
const umdConfig = {
99+
...baseConfig,
100+
external,
101+
output: {
102+
compact: true,
103+
file: 'dist/digital-clock-vue.ssr.js',
104+
format: 'cjs',
105+
name: 'DigitalClockVue',
106+
exports: 'named',
107+
globals
108+
},
109+
plugins: [
110+
...baseConfig.plugins.preVue,
111+
vue({
112+
...baseConfig.plugins.vue,
113+
template: {
114+
...baseConfig.plugins.vue.template,
115+
optimizeSSR: true
116+
}
117+
}),
118+
babel(baseConfig.plugins.babel),
119+
commonjs()
120+
]
121+
}
122+
buildFormats.push(umdConfig)
123+
}
124+
125+
if (!argv.format || argv.format === 'iife') {
126+
const unpkgConfig = {
127+
...baseConfig,
128+
external,
129+
output: {
130+
compact: true,
131+
file: 'dist/digital-clock-vue.min.js',
132+
format: 'iife',
133+
name: 'DigitalClockVue',
134+
exports: 'named',
135+
globals
136+
},
137+
plugins: [
138+
...baseConfig.plugins.preVue,
139+
vue(baseConfig.plugins.vue),
140+
babel(baseConfig.plugins.babel),
141+
commonjs(),
142+
terser({
143+
output: {
144+
ecma: 5
145+
}
146+
})
147+
]
148+
}
149+
buildFormats.push(unpkgConfig)
150+
}
151+
152+
// Export config
153+
export default buildFormats

0 commit comments

Comments
 (0)