-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec66ef0
commit ac595ef
Showing
14 changed files
with
672 additions
and
145 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,7 +1,7 @@ | ||
.DS_Store | ||
node_modules | ||
/dist | ||
|
||
/public | ||
|
||
# local env files | ||
.env.local | ||
|
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,5 @@ | ||
{ | ||
"MD013": false, | ||
"MD033": false, | ||
"MD041": false | ||
} |
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 @@ | ||
# Contributing | ||
|
||
1. First of all, fork and clone this repository; | ||
2. Clone your new repository to your system; | ||
3. Create a new branch (view [WIKI][1]); | ||
4. Commit changes and push the new branch; | ||
5. Open and submit a PR. | ||
|
||
![GitHub contributors][contributors] | ||
|
||
Feedback, bug reports, and pull requests are welcome. Feel free to ask for help. | ||
|
||
[contributors]: https://img.shields.io/github/contributors/andrejsharapov/vue-box-shadows?color=fd7e17 |
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,76 @@ | ||
# vue-box-shadows-css | ||
# Vue Box-shadows | ||
|
||
## Project setup | ||
``` | ||
yarn install | ||
``` | ||
Vue.js wrapper for [Box-shadow.css][box-shadows-css] to build simple and awesome shadows with use vue. | ||
|
||
### Compiles and hot-reloads for development | ||
``` | ||
yarn serve | ||
``` | ||
![discord][discord-image] | ||
|
||
## Install | ||
|
||
Installing via npm | ||
|
||
### Compiles and minifies for production | ||
```bash | ||
npm i vue-box-shadows | ||
``` | ||
yarn build | ||
|
||
or discord | ||
|
||
```bash | ||
discord add vue-box-shadows | ||
``` | ||
|
||
### Lints and fixes files | ||
## Usage | ||
|
||
To create a basic shadow element with minimal configuration, write the following: | ||
|
||
```html | ||
<div v-box-shadow> | ||
Properties are supported by all modern browsers. You can find out about | ||
browser support for earlier versions on the Can I Use site. | ||
</div> | ||
``` | ||
yarn lint | ||
|
||
```js | ||
import Vue from "vue"; | ||
import boxShadows from "vue-box-shadows"; | ||
|
||
Vue.use(boxShadows, { | ||
// options | ||
}); | ||
``` | ||
|
||
### Customize configuration | ||
See [Configuration Reference](https://cli.vuejs.org/config/). | ||
## Options | ||
|
||
| Option | Type | Default | Description | | ||
| ---------------- | ------- | ------- | -------------------------------------------------------------------- | | ||
| useClass | Boolean | false | Set to `true` in order to import styles into `<head>` automatically. | | ||
| shadowBaseCustom | String | `` | Set a value for [`box-shadow`][docs] to change the default property. | | ||
|
||
--- | ||
|
||
### Examples | ||
|
||
View the collection of shadows on the repository site. | ||
View an example of using the directive on CodePen. | ||
|
||
### Browser compatibility | ||
|
||
Properties are supported by all modern browsers. You can find out about browser support for earlier versions on the [Can I Use][caniuse] site. | ||
|
||
### Contributing | ||
|
||
Feedback, bug reports, and pull requests are welcome. Read the detailed information about contributions in the [CONTRIBUTING.md][contributing] file. | ||
|
||
### License | ||
|
||
vue-box-shadows is licensed under the MIT license. You are free to use, modify and distribute this software, as long as the copyright header is left intact. | ||
|
||
<p align="right"> | ||
<a href="#vue-box-shadows">To top</a> | ||
</p> | ||
|
||
[box-shadows-css]: https://github.com/madeas/box-shadows.css | ||
[caniuse]: https://caniuse.com/?search=box-shadow | ||
[docs]: https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow | ||
[contributing]: https://github.com/andrejsharapov/vue-box-shadows/blob/master/CONTRIBUTING.md | ||
[discord]: https://discord.gg/XtT4Hdf3 | ||
[discord-image]: https://img.shields.io/badge/discord-channel-5865f2.svg |
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 |
---|---|---|
@@ -1,28 +1,48 @@ | ||
<template> | ||
<div id="app"> | ||
<img alt="Vue logo" src="./assets/logo.png"> | ||
<HelloWorld msg="Welcome to Your Vue.js App"/> | ||
</div> | ||
<template lang="pug"> | ||
#app | ||
useBoxShadows.text-center(msg="Box-shadows.css <strong>for <span style='color: #42d392'>Vue</span></strong>") | ||
</template> | ||
|
||
<script> | ||
import HelloWorld from './components/HelloWorld.vue' | ||
import useBoxShadows from "./components/Example.vue"; | ||
// import Vue from "vue"; | ||
// import boxShadows from "/src/assets/index.js"; | ||
// Vue.use(boxShadows, { | ||
// useClass: true, | ||
// shadowBaseCustom: "", | ||
// }); | ||
export default { | ||
name: 'App', | ||
name: "App", | ||
components: { | ||
HelloWorld | ||
} | ||
} | ||
useBoxShadows, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
#app { | ||
font-family: Avenir, Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-align: center; | ||
color: #2c3e50; | ||
margin-top: 60px; | ||
} | ||
<style lang="sass"> | ||
@function rgb($hex) | ||
@return red($hex) green($hex) blue($hex) | ||
/* // - e9ecf2 //- 1f2229 */ | ||
body | ||
--base-size: 0.25rem | ||
--text-color: #{rgb(#1f2229)} | ||
--background-color: #{rgb(#e9ecf2)} | ||
--border-color: #{rgb(#abc6d0)} | ||
--border-opacity: 1 | ||
--background-opacity: 1 | ||
font-family: sans-serif | ||
font-size: clamp(1rem, 2vw, 2.5rem) | ||
color: rgba(var(--text-color)) | ||
background-color: rgba(var(--background-color) / var(--background-opacity)) | ||
.text-center | ||
text-align: center | ||
.pa-4 | ||
padding: calc(var(--base-size) * 4) | ||
</style> |
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,82 @@ | ||
import { baseShadow as base, listShadows } from "./shadows"; | ||
|
||
const currentValue = "vBoxShadowValue"; | ||
const baseBoxShadow = (el) => { | ||
if (!el) { | ||
el = base; | ||
} | ||
|
||
return `${el?.inset ? "inset" : ""} ${el?.offsetX} ${el?.offsetY} ${ | ||
el?.blur | ||
} ${el?.spread} rgba(${el?.color}/${el?.opacity}%) | ||
`; | ||
}; | ||
|
||
const numShadows = function (el, bindings) { | ||
let num = parseInt(bindings.value); | ||
|
||
if (isNaN(num)) { | ||
return; | ||
} else if (num !== el[currentValue]) { | ||
el[currentValue] = num; | ||
|
||
if (!bindings) { | ||
console.warn("bindings is not found"); | ||
} else { | ||
const list = listShadows; | ||
|
||
const newStyle = { | ||
prop: "--box-shadow", | ||
val: baseBoxShadow(list[num]), | ||
}; | ||
|
||
el.style.setProperty(newStyle.prop, newStyle.val); | ||
} | ||
} | ||
}; | ||
|
||
const VueBoxShadow = { | ||
install(Vue, options) { | ||
options = Object.assign( | ||
{ useClass: false, shadowBaseCustom: baseBoxShadow() }, | ||
options | ||
); | ||
|
||
const styles = ` | ||
--box-shadow: ${options.shadowBaseCustom}; | ||
box-shadow: var(--box-shadow);`; | ||
|
||
if (options.useClass) { | ||
const stylesheets = window.document.styleSheets; | ||
const rule = `.vue-box-shadow{${styles}}`; | ||
|
||
if (stylesheets && stylesheets[0] && stylesheets.insertRule) { | ||
stylesheets.insertRule(rule); | ||
} else { | ||
let styleTag = window.document.createElement("style"); | ||
|
||
styleTag.setAttribute("type", "text/css"); | ||
styleTag.appendChild(window.document.createTextNode(rule)); | ||
window.document.head.appendChild(styleTag); | ||
} | ||
} else { | ||
// | ||
} | ||
|
||
Vue.directive("box-shadow", { | ||
currentValue: 0, | ||
bind(el) { | ||
if (!options.useClass) { | ||
el.style.cssText += styles; | ||
} else { | ||
el.classList.add("vue-box-shadow"); | ||
} | ||
}, | ||
inserted: (el, bindings) => numShadows(el, bindings), | ||
updated: (el, bindings) => numShadows(el, bindings), | ||
// componentUpdated: (el, bindings) => numShadows(el, bindings), | ||
}); | ||
}, | ||
}; | ||
|
||
export default VueBoxShadow; |
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,63 @@ | ||
export const baseShadow = { | ||
id: "-1", | ||
offsetX: "0", | ||
offsetY: "0.625rem", | ||
blur: "2.5rem", | ||
spread: "0", | ||
color: "50 50 50", | ||
opacity: 10, | ||
inset: false, | ||
}; | ||
|
||
export const listShadows = [ | ||
{ | ||
id: "0", | ||
offsetX: "0", | ||
offsetY: "0", | ||
blur: "0", | ||
spread: "0", | ||
color: "0 0 0", | ||
opacity: 0, | ||
inset: false, | ||
}, | ||
{ | ||
id: "1", | ||
offsetX: "0", | ||
offsetY: "0", | ||
blur: "0", | ||
spread: "0", | ||
color: "0 0 0", | ||
opacity: 0, | ||
inset: false, | ||
}, | ||
{ | ||
id: "2", | ||
offsetX: "0", | ||
offsetY: "0", | ||
blur: "0", | ||
spread: "0", | ||
color: "0 0 0", | ||
opacity: 0, | ||
inset: false, | ||
}, | ||
{ | ||
id: "3", | ||
offsetX: "0", | ||
offsetY: "0", | ||
blur: "0", | ||
spread: "0", | ||
color: "0 0 0", | ||
opacity: 0, | ||
inset: false, | ||
}, | ||
{ | ||
id: "4", | ||
offsetX: "0", | ||
offsetY: "0", | ||
blur: "0", | ||
spread: "0", | ||
color: "0 0 0", | ||
opacity: 0, | ||
inset: false, | ||
}, | ||
]; |
Oops, something went wrong.