-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented install function & modified package.json
- Loading branch information
1 parent
46b41a7
commit 10c68ad
Showing
7 changed files
with
68 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
# vue-carbonbadge | ||
Vue component for the [Website Carbon badge](https://www.websitecarbon.com/badge/). | ||
|
||
## Project setup | ||
``` | ||
npm install | ||
## Installation | ||
```shell | ||
npm install vue-carbonbadge | ||
yarn add vue-carbonbadge | ||
``` | ||
|
||
### Compiles and hot-reloads for development | ||
``` | ||
npm run serve | ||
``` | ||
## How To Use | ||
**1. Import the package into your main.js file** | ||
```js | ||
import CarbonBadge from 'vue-carbonbadge' | ||
Vue.use(CarbonBadge) | ||
``` | ||
**2. Use it in your HTML markup** | ||
```html | ||
<footer> | ||
<CarbonBadge></CarbonBadge> | ||
</footer> | ||
``` | ||
**3. You're done! 🎉** | ||
|
||
### Compiles and minifies for production | ||
``` | ||
npm run build | ||
``` | ||
|
||
### Lints and fixes files | ||
``` | ||
npm run lint | ||
## Customization | ||
**Toggling dark mode** | ||
```html | ||
<CarbonBadge :dark="true"></CarbonBadge> | ||
``` | ||
|
||
### Customize configuration | ||
See [Configuration Reference](https://cli.vuejs.org/config/). | ||
If the `dark` property is not specified, dark mode is detected as per user system preferences. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<template> | ||
<div id="wcb" :class="[dark ? 'wcb-d' : '', 'carbonbadge']"></div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'CarbonBadge', | ||
props: { | ||
dark: { | ||
type: Boolean, | ||
default: window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | ||
} | ||
}, | ||
mounted () { | ||
const script = document.createElement('script') | ||
script.setAttribute('src', 'https://unpkg.com/[email protected]/b.min.js') | ||
document.head.appendChild(script) | ||
} | ||
} | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import CarbonBadgeComponent from './components/CarbonBadge.vue' | ||
|
||
const CarbonBadge = { | ||
install(Vue) { | ||
Vue.component('CarbonBadge', CarbonBadgeComponent); | ||
} | ||
} | ||
|
||
if (typeof window !== 'undefined' && window.Vue) { | ||
window.Vue.use(CarbonBadge) | ||
} | ||
|
||
export default CarbonBadge |