Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
jerosoler committed Jun 15, 2021
1 parent 3520177 commit 5b198ea
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

custom: ["https://paypal.me/jerosoler"]
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/
index.html
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Jero Soler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
[![GitHub license](https://img.shields.io/github/license/jerosoler/css-houdini-pixel-box)](https://github.com/jerosoler/css-houdini-pixel-box/blob/main/LICENSE)

# PixelBox

CSS Houdini library.

[PLAY DEMO](https://jerosoler.github.io/css-houdini-pixel-box/)

![Demo buttons](https://github.com/jerosoler/css-houdini-pixel-box/raw/main/docs/buttons.png)

![Demo combine](https://github.com/jerosoler/css-houdini-pixel-box/raw/main/docs/combine.png)

## CDN

```html
<script src="https://cdn.jsdelivr.net/gh/jerosoler/css-houdini-pixel-box/pixelbox.js"></script>
```

## NPM

```bash
npm install css-houdini-pixel-box
```

## How to use

Download `pixelbox.js` file.

### Polyfill

View support in [caniuse](https://caniuse.com/mdn-api_css_paintworklet)

```html
<script src="https://unpkg.com/css-paint-polyfill"></script>
```

### Javascript:

```javascript
if (
"paintWorklet" in CSS &&
"registerProperty" in CSS &&
"CSSUnitValue" in window
) {
CSS.registerProperty({
name: "--pixelbox-border",
syntax: "<length>",
initialValue: "2px",
inherits: false,
});

CSS.registerProperty({
name: "--pixelbox-border-radius",
syntax: "<length>",
initialValue: "0px",
inherits: false,
});

CSS.registerProperty({
name: "--pixelbox-border-color",
syntax: "<color>",
initialValue: "#000000",
inherits: false,
});

CSS.registerProperty({
name: "--pixelbox-background-color",
syntax: "<color>",
initialValue: "#ffffff",
inherits: false,
});

CSS.registerProperty({
name: "--pixelbox-background-shadow-border",
syntax: "<length>",
initialValue: "0px",
inherits: false,
});

CSS.registerProperty({
name: "--pixelbox-background-shadow-color",
syntax: "<color>",
initialValue: "#adafbc",
inherits: false,
});

/*CSS.registerProperty({
name: '--pixelbox-background-shadow-position',
syntax: '<string>',
initialValue: 'bottom-right',
inherits: false
});
*/
} else {
console.log("Not Supported");
}
CSS.paintWorklet.addModule("pixelbox.js");
```

### CSS

```css
div {
display: inline-block;
width: 200px;
height: 200px;
text-align: center;
line-height: 200px;
color: white;
background-image: paint(pixelbox);
--pixelbox-border: 10px;
--pixelbox-border-radius: 5px;
--pixelbox-border-color: #a0a0a0;
--pixelbox-background-color: #000000;
--pixelbox-background-shadow-border: 20px;
--pixelbox-background-shadow-color: #494949;
--pixelbox-background-shadow-position: bottom-right;
}
```
Binary file added docs/buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/combine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 57 additions & 29 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pixel Box - Css Houdini - Jero Soler</title>
<meta description="CSS Houdini - Pixel Box - Jero Soler">

</head>
<body>
<a href="https://github.com/jerosoler/css-houdini-pixel-box" class="github-corner" target="_blank">
Expand All @@ -22,7 +23,14 @@ <h3>CSS Houdini</h3>

<div class="box">
<h3>Info</h3>
laslaslasdasd ssadas dasldsadlasdas
<div>
<p>Create a pixel boxes with border radius and shadows</p>
<p>Pixel box is css houdini <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Houdini">read more</a></p>
<p>View repo on <a target="_blank" href="https://github.com/jerosoler/css-houdini-pixel-box">github</a></p>
<p>Inspired in <a target="_blank" href="https://nostalgic-css.github.io/NES.css/">NES.CSS Framework.</a></p>
<br>
<p><a target="_blank" href="https://github.com/jerosoler/css-houdini-pixel-box">View install instructions</a></p>
</div>

</div>

Expand Down Expand Up @@ -127,7 +135,7 @@ <h3>Combine</h3>

</div>
<div class="footer">
<h3>Developed by Jero Soler</h3>
<h3>Developed by <a href="https://github.com/jerosoler">Jero Soler</a></h3>
</div>
<style>
*, *::before, *::after {
Expand All @@ -146,16 +154,24 @@ <h3>Developed by Jero Soler</h3>
font-size: 16px;
font-family: "PS2P";
}
.header h1,.header h3 {
text-align: center;
}
.footer h3 {
text-align: center;
line-height: 30px;
}

.footer h3 a {
color: white;
}

body {
padding: 0px;

width: 100vw;
margin: 0px;
font-family: "PS2P",-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;


color: black;
overflow-x: hidden;
margin: 0px;
font-family: "PS2P",-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;
color: black;
overflow-x: hidden;
}
.container {
padding-top: 30px;
Expand All @@ -181,30 +197,46 @@ <h3>Developed by Jero Soler</h3>
}
.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}

@media only screen and (max-width: 600px) {
body .container {
padding: 0px 10px;
}

.footer {
padding: 10px;
}

.github-corner {
display: none;
}
}

</style>

<style>

.box {
position: relative;
display: flex;
justify-content: space-between;
padding: 30px;
min-height: 70px;
margin-top:50px;
margin-bottom:50px;
background-image: paint(pixelbox);
--pixelbox-border: 10px;
--pixelbox-border-radius: 1;
--pixelbox-border: 4px;
--pixelbox-border-radius: 1px;
--pixelbox-border-color: #000000;
--pixelbox-background-color: #ffffff;
--pixelbox-background-shadow-border: 10px;
--pixelbox-background-shadow-border: 8px;
--pixelbox-background-shadow-color: #adafbc;
--pixelbox-background-shadow-position: bottom-right;
transition: --pixelbox-background-shadow-border 0.5s;

}

.box:hover {
--pixelbox-background-shadow-border: 20px;
--pixelbox-background-shadow-border: 16px;
}

.box:nth-child(3) {
Expand All @@ -223,7 +255,7 @@ <h3>Developed by Jero Soler</h3>
.box h3 {
text-align: center;
position:absolute;
top: -20px;
top: -24px;
left: 50px;
padding: 0px 15px;
background-color: white;
Expand Down Expand Up @@ -317,10 +349,12 @@ <h3>Developed by Jero Soler</h3>
min-height: 70px;
text-align: center;
line-height: 70px;
--pixelbox-background-shadow-border: 0px;
}

.boxr.onep {
--pixelbox-border-radius: 1px;
--pixelbox-background-shadow-border: 0px;
}
.boxr.twop {
--pixelbox-border-radius: 2px;
Expand All @@ -330,6 +364,7 @@ <h3>Developed by Jero Soler</h3>
}
.boxr.shadow {
--pixelbox-background-shadow-border: 5px;
--pixelbox-background-shadow-color: #adafbc;
}

.boxr.shadow:hover {
Expand Down Expand Up @@ -425,7 +460,7 @@ <h3>Developed by Jero Soler</h3>
--pixelbox-border-color: #2eff05;
--pixelbox-background-color: #1700e9;
--pixelbox-background-shadow-border: 0px;
--pixelbox-background-shadow-color: #a30655;
--pixelbox-background-shadow-color: #030957;
--pixelbox-background-shadow-position: top-right;

}
Expand Down Expand Up @@ -453,14 +488,6 @@ <h3>Developed by Jero Soler</h3>
}

@media only screen and (max-width: 600px) {
body .container {
padding: 0px 10px;
}

.footer {
padding: 10px;
}

.box {
display: flex;
flex-direction: column;
Expand All @@ -478,8 +505,10 @@ <h3>Developed by Jero Soler</h3>

</style>

<script src="https://unpkg.com/css-paint-polyfill"></script>
<script>
if ('paintWorklet' in CSS && 'registerProperty' in CSS && 'CSSUnitValue' in window) {

CSS.registerProperty({
name: '--pixelbox-border',
syntax: '<length>',
Expand Down Expand Up @@ -529,13 +558,12 @@ <h3>Developed by Jero Soler</h3>
inherits: false
});
*/

CSS.paintWorklet.addModule('pixelbox.js');

} else {
console.log("Not Supported");
alert("Not Supported");
}
}
CSS.paintWorklet.addModule('pixelbox.js');
</script>


</body>
</html>
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "css-houdini-pixel-box",
"version": "0.0.1",
"description": "CSS Houdini PixelBox",
"main": "pixelbox.js",
"directories": {
"doc": "docs"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jerosoler/css-houdini-pixel-box.git"
},
"keywords": [
"CSS",
"Houdini",
"pixelbox",
"8bit",
"retro",
"paintworklet"
],
"author": "Jero Soler",
"license": "MIT",
"bugs": {
"url": "https://github.com/jerosoler/css-houdini-pixel-box/issues"
},
"homepage": "https://jerosoler.github.io/css-houdini-pixel-box/"
}

0 comments on commit 5b198ea

Please sign in to comment.