@ritterim/skellycss
Advanced tools
Comparing version 0.0.5 to 0.1.0
@@ -1,169 +0,10 @@ | ||
// modules are defined as an array | ||
// [ module function, map of requires ] | ||
// | ||
// map of requires is short require name -> numeric require | ||
// | ||
// anything defined in a previous bundle is accessed via the | ||
// orig method which is the require for previous bundles | ||
parcelRequire = (function (modules, cache, entry, globalName) { | ||
// Save the require from previous bundle to this closure if any | ||
var previousRequire = typeof parcelRequire === 'function' && parcelRequire; | ||
var nodeRequire = typeof require === 'function' && require; | ||
/* | ||
SkellyCSS v0.1.0 | @ritterim/skellycss | ||
function newRequire(name, jumped) { | ||
if (!cache[name]) { | ||
if (!modules[name]) { | ||
// if we cannot find the module within our internal map or | ||
// cache jump to the current global require ie. the last bundle | ||
// that was added to the page. | ||
var currentRequire = typeof parcelRequire === 'function' && parcelRequire; | ||
if (!jumped && currentRequire) { | ||
return currentRequire(name, true); | ||
} | ||
A light-weight CSS framework to quickly implement skeletons into your projects. (https://github.com/ritterim/skellyCSS#readme) | ||
©2022 Ritter Insurance Marketing (https://rimdev.io) | ||
https://github.com/ritterim/skellyCSS/issues | ||
Released under the MIT license. | ||
*/ | ||
// If there are other bundles on this page the require from the | ||
// previous one is saved to 'previousRequire'. Repeat this as | ||
// many times as there are bundles until the module is found or | ||
// we exhaust the require chain. | ||
if (previousRequire) { | ||
return previousRequire(name, true); | ||
} | ||
// Try the node require function if it exists. | ||
if (nodeRequire && typeof name === 'string') { | ||
return nodeRequire(name); | ||
} | ||
var err = new Error('Cannot find module \'' + name + '\''); | ||
err.code = 'MODULE_NOT_FOUND'; | ||
throw err; | ||
} | ||
localRequire.resolve = resolve; | ||
localRequire.cache = {}; | ||
var module = cache[name] = new newRequire.Module(name); | ||
modules[name][0].call(module.exports, localRequire, module, module.exports, this); | ||
} | ||
return cache[name].exports; | ||
function localRequire(x){ | ||
return newRequire(localRequire.resolve(x)); | ||
} | ||
function resolve(x){ | ||
return modules[name][1][x] || x; | ||
} | ||
} | ||
function Module(moduleName) { | ||
this.id = moduleName; | ||
this.bundle = newRequire; | ||
this.exports = {}; | ||
} | ||
newRequire.isParcelRequire = true; | ||
newRequire.Module = Module; | ||
newRequire.modules = modules; | ||
newRequire.cache = cache; | ||
newRequire.parent = previousRequire; | ||
newRequire.register = function (id, exports) { | ||
modules[id] = [function (require, module) { | ||
module.exports = exports; | ||
}, {}]; | ||
}; | ||
var error; | ||
for (var i = 0; i < entry.length; i++) { | ||
try { | ||
newRequire(entry[i]); | ||
} catch (e) { | ||
// Save first error but execute all entries | ||
if (!error) { | ||
error = e; | ||
} | ||
} | ||
} | ||
if (entry.length) { | ||
// Expose entry point to Node, AMD or browser globals | ||
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js | ||
var mainExports = newRequire(entry[entry.length - 1]); | ||
// CommonJS | ||
if (typeof exports === "object" && typeof module !== "undefined") { | ||
module.exports = mainExports; | ||
// RequireJS | ||
} else if (typeof define === "function" && define.amd) { | ||
define(function () { | ||
return mainExports; | ||
}); | ||
// <script> | ||
} else if (globalName) { | ||
this[globalName] = mainExports; | ||
} | ||
} | ||
// Override the current require with this new one | ||
parcelRequire = newRequire; | ||
if (error) { | ||
// throw error from earlier, _after updating parcelRequire_ | ||
throw error; | ||
} | ||
return newRequire; | ||
})({"LGxd":[function(require,module,exports) { | ||
},{}],"VXhu":[function(require,module,exports) { | ||
var skeletons = document.querySelectorAll(".skeleton"); | ||
if (skeletons) { | ||
skeletons.forEach(function (skelly) { | ||
var lineCount = parseInt(skelly.dataset.lines); | ||
var animation = skelly.dataset.animation === "true"; | ||
if (!lineCount && skelly.innerHTML.trim().length == 0) { | ||
lineCount = 1; | ||
} | ||
for (var i = 0; i < lineCount; i++) { | ||
var line = document.createElement("span"); | ||
line.classList.add("skeleton__line"); | ||
if (animation === true) { | ||
var animationElement = document.createElement("span"); | ||
animationElement.classList.add("skeleton--animation"); | ||
line.append(animationElement); | ||
} | ||
skelly.append(line); | ||
} | ||
}); | ||
} | ||
var skeletonImages = document.querySelectorAll(".skeleton-image"); | ||
if (skeletonImages) { | ||
skeletonImages.forEach(function (skelly) { | ||
var animation = skelly.dataset.animation === "true"; | ||
if (animation === true) { | ||
var animationElement = document.createElement("span"); | ||
animationElement.classList.add("skeleton--animation"); | ||
skelly.append(animationElement); | ||
} | ||
}); | ||
} | ||
},{}],"fRuA":[function(require,module,exports) { | ||
"use strict"; | ||
require("./assets/scss/style.scss"); | ||
require("./assets/javascript/index.js"); | ||
},{"./assets/scss/style.scss":"LGxd","./assets/javascript/index.js":"VXhu"}]},{},["fRuA"], null) | ||
//# sourceMappingURL=dist/skelly.js.map | ||
(function(s){typeof define=="function"&&define.amd?define(s):s()})(function(){"use strict";var s="";const c=document.querySelectorAll(".skeleton");c&&c.forEach(t=>{let a=parseInt(t.dataset.lines),e=t.dataset.opacity?parseFloat(t.dataset.opacity):null,o=t.dataset.color?t.dataset.color:null;!a&&t.innerHTML.trim().length==0&&(a=1);for(let i=0;i<a;i++){const n=document.createElement("span");if(n.classList.add("skeleton__line"),t.dataset.animation==="true"){const r=document.createElement("span");r.classList.add("skeleton--animation"),n.append(r)}t.append(n)}e&&e<=1&&t.querySelectorAll(".skeleton__line").forEach(n=>n.style.opacity=e),o&&t.querySelectorAll(".skeleton__line").forEach(n=>n.style.setProperty("--skelly-color",o))});const l=document.querySelectorAll(".skeleton-image");l&&l.forEach(t=>{let a=t.dataset.animation==="true",e=t.dataset.opacity?parseFloat(t.dataset.opacity):null;if(a===!0){const o=document.createElement("span");o.classList.add("skeleton--animation"),t.append(o)}e&&e<=1&&(t.style.opacity=e)})}); |
{ | ||
"name": "@ritterim/skellycss", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "A light-weight CSS framework to quickly implement skeletons into your projects.", | ||
@@ -10,7 +10,5 @@ "main": "dist/skelly.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "parcel src/skelly.js", | ||
"build": "npm run build:full && npm run build:minify", | ||
"build:minify": "parcel build src/skelly.js --out-file skelly.min.js --public-url ./dist/", | ||
"build:full": "parcel build src/skelly.js --no-minify --public-url ./dist/" | ||
"start": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
@@ -31,11 +29,16 @@ "repository": { | ||
}, | ||
"browserslist": [ | ||
"defaults", | ||
"not IE 11", | ||
"maintained node versions" | ||
], | ||
"homepage": "https://github.com/ritterim/skellyCSS#readme", | ||
"devDependencies": { | ||
"cssnano": "^4.1.10", | ||
"parcel-bundler": "^1.12.4", | ||
"sass": "^1.30.0" | ||
}, | ||
"dependencies": { | ||
"assets": "^3.0.1" | ||
"autoprefixer": "^10.4.2", | ||
"postcss": "^8.4.5", | ||
"postcss-cli": "^9.1.0", | ||
"sass": "^1.49.0", | ||
"vite": "^2.7.13", | ||
"vite-plugin-banner": "^0.2.0" | ||
} | ||
} |
@@ -27,2 +27,4 @@ <div style="display:flex; align-items:center; justify-content:center; height:300px;"> | ||
- [JavaScript Utility](#javascript-utility) | ||
- [JavaScript Data Attributes](#javascript-data-attributes) | ||
- [All Data Attributes](#all-data-attributes) | ||
@@ -38,5 +40,5 @@ <br /> | ||
### CSS | ||
Include the skelly.css file wherever you add your CSS: | ||
Include the Skelly css file wherever you add your CSS: | ||
``` html | ||
<link rel="stylesheet" href="../dist/skelly.css"> | ||
<link rel="stylesheet" href="..@ritterim/skellycss/dist/style.css"> | ||
``` | ||
@@ -47,3 +49,3 @@ | ||
``` html | ||
<script src="../dist/skelly.js"></script> | ||
<script src="..@ritterim/skellycss/dist/skelly.js"></script> | ||
``` | ||
@@ -159,3 +161,3 @@ | ||
### Images | ||
You can create an image skeleton by adding the `.skeleton-image` class to an img tag -- do not include the `src` attribute. By default this will apply the image skeleton at 100% height and width of the parent container. | ||
You can create an image skeleton by using the `.skeleton-image` class. By default this will apply the image skeleton at 100% height and width of the parent container. | ||
@@ -189,12 +191,16 @@ #### Sizes | ||
| ------------ |------------ | ------------| | ||
| Landscape Rectangle | Sets the width of the image to 100% | `.skeleton-image--landscape` | | ||
| Portrait Rectangle | Sets the height of the image to 100% | `.skeleton-image--portrait` | | ||
| Square | Sets the image aspect ratio to 1/1 (default) | `.skeleton-image--square` | | ||
| Circle | Sets the border radius to 50% | `.skeleton-image--circle` | | ||
| Landscape Rectangle | Sets the image aspect ratio to 4/3 | `.skeleton-image--landscape` | | ||
| Portrait Rectangle | Sets the image aspect ratio to 3/4| `.skeleton-image--portrait` | | ||
| Wide Rectangle | Sets the image aspect ratio to 16/9 | `.skeleton-image--wide` | | ||
| Tall Rectangle | Sets the image aspect ratio to 9/16 | `.skeleton-image--tall` | | ||
![Image Shapes](images/image-shapes.png) | ||
``` html | ||
<img class="skeleton-image skeleton-image--lg skeleton-image--landscape" /> | ||
<img class="skeleton-image skeleton-image--lg skeleton-image--portrait" /> | ||
<img class="skeleton-image skeleton-image--lg skeleton-image--circle" /> | ||
<div class="skeleton-image skeleton-image--lg skeleton-image--square"></div> | ||
<div class="skeleton-image skeleton-image--lg skeleton-image--circle"></div> | ||
<div class="skeleton-image skeleton-image--lg skeleton-image--landscape"></div> | ||
<div class="skeleton-image skeleton-image--lg skeleton-image--portrait"></div> | ||
<div class="skeleton-image skeleton-image--lg skeleton-image--wide"></div> | ||
<div class="skeleton-image skeleton-image--lg skeleton-image--tall"></div> | ||
``` | ||
@@ -247,2 +253,24 @@ | ||
<p class="skeleton" data-lines="7" data-animation="true"></p> | ||
``` | ||
``` | ||
<br /> | ||
### JavaScript Data Attributes | ||
You can alter the way skeleton looks by utilizing other data-attributes as well, including opacity and color: | ||
``` html | ||
<!-- Opacity --> | ||
<h2 class="skeleton skeleton--md" data-animation="true"></h2> | ||
<p class="skeleton" data-lines="7" data-opacity="0.3"></p> | ||
<!-- Color --> | ||
<h2 class="skeleton skeleton--md" data-animation="true"></h2> | ||
<p class="skeleton" data-lines="7" data-color="tomato"></p> | ||
``` | ||
#### All Data Attributes | ||
| Attribute | Description | Type | | ||
| ------------ |------------ | ------------| | ||
| `data-lines` | Determines how many lines to output | Integer | | ||
| `data-animation` | Adds animation to the skeleton lines | Boolean | | ||
| `data-opacity` | Sets the opacity of the skeleton lines (sets opacity between 0 and 1) | Float | | ||
| `data-color` | Sets the color of the skeleton lines | Color | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
1
270
0
15708
6
5
34
- Removedassets@^3.0.1
- Removedassets@3.0.1(transitive)
- Removedasync@2.6.4(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcalipers@2.1.0(transitive)
- Removedcalipers-gif@2.0.0(transitive)
- Removedcalipers-jpeg@2.1.0(transitive)
- Removedcalipers-png@2.1.0(transitive)
- Removedcalipers-svg@2.0.1(transitive)
- Removedcalipers-webp@2.0.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime@2.6.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedwrappy@1.0.2(transitive)