Skip to content

Commit 53ee78c

Browse files
feat: initial release
0 parents  commit 53ee78c

11 files changed

+550
-0
lines changed

.babelrc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"presets": [
3+
[
4+
"vue-app",
5+
{
6+
"modules": false
7+
}
8+
]
9+
],
10+
"env": {
11+
"test": {
12+
"presets": [
13+
[
14+
"vue-app",
15+
{
16+
"targets": {
17+
"node": 8
18+
}
19+
}
20+
]
21+
]
22+
}
23+
}
24+
}

.eslintrc.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
sourceType: 'module'
5+
},
6+
env: {
7+
browser: true,
8+
node: true,
9+
jest: true
10+
},
11+
extends: 'standard',
12+
plugins: [
13+
'jest',
14+
'vue'
15+
],
16+
rules: {
17+
// Allow paren-less arrow functions
18+
'arrow-parens': 0,
19+
// Allow async-await
20+
'generator-star-spacing': 0,
21+
// Allow debugger during development
22+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
23+
// Do not allow console.logs etc...
24+
'no-console': 2
25+
},
26+
globals: {
27+
'jest/globals': true,
28+
jasmine: true
29+
}
30+
}

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.idea/**
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pids
8+
*.pid
9+
*.seed
10+
*.pid.lock
11+
lib-cov
12+
coverage
13+
.nyc_output
14+
.grunt
15+
bower_components
16+
.lock-wscript
17+
build/Release
18+
node_modules/
19+
package-lock.json
20+
jspm_packages/
21+
typings/
22+
.npm
23+
.eslintcache
24+
.node_repl_history
25+
*.tgz
26+
.yarn-integrity
27+
.env
28+
.next
29+
dist

.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: node_js
2+
node_js:
3+
- "8"
4+
- "9"
5+
- "10"
6+
cache:
7+
npm: true
8+
directories:
9+
- node_modules
10+
install:
11+
- npm install
12+
script:
13+
- npm t
14+
after_success:
15+
- npm run coverage

CONTRIBUTING.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Contributing to VueNextLevelScroll
2+
3+
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
4+
2. Install the dependencies: `npm install`.
5+
3. Develop your feature/bugfix.
6+
4. Add tests into `test` directory and try them with `npm test`.
7+
5. Send the PR!

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Alexander Lichter ([@manniL](https://github.com/manniL))
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

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# VueLink - One component to link them all!
2+
3+
<p align="center">
4+
<a href="https://travis-ci.com/Developmint/vue-link"><img src="https://travis-ci.com/Developmint/vue-link.svg?branch=master" alt="Build Status"></a>
5+
<a href="https://codecov.io/gh/Developmint/vue-link"><img src="https://codecov.io/gh/Developmint/vue-link/branch/master/graph/badge.svg" alt="Code coverage"></a>
6+
<a href="https://www.npmjs.com/package/vue-link"><img src="https://img.shields.io/npm/dm/vue-link.svg" alt="Downloads"></a>
7+
<a href="https://www.npmjs.com/package/vue-link"><img src="https://img.shields.io/npm/v/vue-link.svg" alt="Version"></a>
8+
<a href="https://www.npmjs.com/package/vue-link"><img src="https://img.shields.io/npm/l/vue-link.svg" alt="License"></a>
9+
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="We use Conventional Commits"></a>
10+
</p>
11+
12+
> Lightweight wrapper component for external and vue-router links.
13+
14+
## :fire: Features
15+
16+
- **Tiny functional component**
17+
- SSR-safe (works with Nuxt.js)
18+
- Well tested and **documented**
19+
- Compatible with Node 8.0+
20+
- Vue (and vue-router) as the only dependencies
21+
- Highly customizable
22+
23+
## :mag_right: Getting started
24+
25+
26+
### :package: Through NPM
27+
28+
```
29+
$ npm install vue-link
30+
```
31+
32+
#### Synchronous import
33+
34+
```js
35+
import VueLink from 'vue-link'
36+
37+
export default {
38+
components: {
39+
VueLink
40+
}
41+
}
42+
43+
```
44+
45+
#### Async import
46+
47+
```js
48+
export default {
49+
components: {
50+
VueLink: () => import('vue-link')
51+
}
52+
}
53+
54+
```
55+
56+
### :link::x: Using a CDN
57+
58+
Sorry! No CDN available for VueLink by now.
59+
60+
## :hammer_and_wrench: Usage
61+
62+
### Handling
63+
64+
Before going into detail, keep in mind that you can customize the component
65+
as you can do it with a normal `<a>` or `<vue-link>`/`<nuxt-link>` tag.
66+
67+
All props will be passed down to the internal implementation of `vue-link`
68+
in case the link is not external.
69+
70+
### Link detection
71+
72+
If the passed link starts with `http`, it'll be treated as external link.
73+
You can use the `external` prop to force treating it as external link as well.
74+
75+
### Prop overview
76+
77+
78+
| Prop | External only? | Comment |
79+
| --- | --- | --- |
80+
| to | :x: | The target of the link. If not set, the link will not be bound (no "empty href")|
81+
| rel |:white_check_mark:| Will be passed as `rel` attribute to the anchor tag|
82+
|newTag|:white_check_mark:| If truthy, set `target` attribute to `_blank`|
83+
|target|:white_check_mark:| Will be passed as `target` attribute to the anchor tag|
84+
85+
86+
### Example usage
87+
88+
```js
89+
<vue-link
90+
:to="`/feed.xml`"
91+
:external="true"
92+
:new-tab="true"
93+
class="block mt-4 lg:inline-block lg:mt-0 w-6 h-6 mr-6 no-underline">
94+
This is the link text ;)
95+
</vue-link>
96+
```
97+
## :gear: Contributing
98+
99+
Please see our [CONTRIBUTING.md](./CONTRIBUTING.md)
100+
101+
102+
## :bookmark_tabs: License
103+
104+
[MIT License](./LICENSE.md) - Copyright (c) Developmint - Alexander Lichter

commitlint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

lib/VueLink.vue

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script>
2+
export default {
3+
functional: true,
4+
render (h, { data, children, props }) {
5+
6+
// If no to is set, treat as "external" to remove "link style" and bindings.
7+
// Quite useful if you want to bind a link dynamically and don't want to have it clicked and styled when not bound
8+
const isExternal = props => !props.to
9+
|| props.to.startsWith('http')
10+
|| props.external
11+
12+
return isExternal(props)
13+
? h('a', {
14+
...data,
15+
attrs: {
16+
href: props.to || undefined,
17+
rel: props.rel || undefined,
18+
target: props.target || (props.newTab ? '_blank' : undefined)
19+
}
20+
}, children)
21+
: h('router-link', data, children)
22+
}
23+
}
24+
</script>

package.json

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"name": "vue-link",
3+
"version": "1.0.0",
4+
"description": "One component to link them all!",
5+
"author": "Alexander Lichter <[email protected]>",
6+
"license": "MIT",
7+
"main": "lib/VueLink.vue",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/Developmint/vue-link"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/Developmint/vue-link/issues"
14+
},
15+
"scripts": {
16+
"dev": "nuxt test/fixture",
17+
"lint": "eslint lib test",
18+
"test": "npm run lint && jest",
19+
"release": "standard-version && git push --follow-tags && npm publish",
20+
"commitlint": "commitlint -e $GIT_PARAMS",
21+
"coverage": "codecov"
22+
},
23+
"files": [
24+
"lib"
25+
],
26+
"keywords": [
27+
"vue",
28+
"vuejs",
29+
"link",
30+
"nuxt",
31+
"nuxtjs",
32+
"component",
33+
"plugin"
34+
],
35+
"engines": {
36+
"node": ">=8.0.0",
37+
"npm": ">=5.0.0"
38+
},
39+
"jest": {
40+
"moduleFileExtensions": [
41+
"js",
42+
"json",
43+
"vue"
44+
],
45+
"transform": {
46+
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
47+
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
48+
},
49+
"moduleNameMapper": {
50+
"^@/(.*)$": "<rootDir>/lib/$1"
51+
},
52+
"snapshotSerializers": [
53+
"<rootDir>/node_modules/jest-serializer-vue"
54+
],
55+
"collectCoverage": true,
56+
"coveragePathIgnorePatterns": [
57+
"/node_modules/",
58+
"/test/fixtures"
59+
]
60+
},
61+
"devDependencies": {
62+
"@commitlint/cli": "^6.1.3",
63+
"@commitlint/config-conventional": "^6.1.3",
64+
"@vue/server-test-utils": "^1.0.0-beta.15",
65+
"@vue/test-utils": "^1.0.0-beta.15",
66+
"babel-core": "^6.26.0",
67+
"babel-jest": "^22.4.3",
68+
"babel-loader": "^7.1.2",
69+
"babel-preset-vue-app": "^2.0.0",
70+
"cheerio": "^1.0.0-rc.2",
71+
"codecov": "latest",
72+
"cross-env": "^5.0.5",
73+
"eslint": "^4.19.1",
74+
"eslint-config-standard": "^12.0.0-alpha.0",
75+
"eslint-plugin-import": "^2.11.0",
76+
"eslint-plugin-jest": "latest",
77+
"eslint-plugin-node": "^6.0.1",
78+
"eslint-plugin-promise": "^3.7.0",
79+
"eslint-plugin-standard": "^3.1.0",
80+
"eslint-plugin-vue": "latest",
81+
"flush-promises": "^1.0.0",
82+
"husky": "^1.0.0-rc.2",
83+
"jest": "latest",
84+
"jest-serializer-vue": "^1.0.0",
85+
"jsdom": "latest",
86+
"standard-version": "latest",
87+
"vue-jest": "^2.5.0",
88+
"vue-loader": "^15.0.9",
89+
"vue-router": "^3.0.1",
90+
"vue-server-renderer": "^2.5.17-beta.0",
91+
"vue-template-compiler": "^2.5.17-beta.0",
92+
"webpack": "^4.8.1",
93+
"webpack-dev-server": "^3.1.4"
94+
},
95+
"dependencies": {
96+
"vue": "^2.5.17-beta.0"
97+
},
98+
"husky": {
99+
"hooks": {
100+
"pre-commit": "npm run lint",
101+
"commit-msg": "npm run commitlint"
102+
}
103+
}
104+
}

0 commit comments

Comments
 (0)