Comparing version 0.3.0 to 0.3.1
@@ -1,359 +0,387 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Dropmic = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
"use strict"; | ||
/*! | ||
* Dropmic.js v0.3.0 | ||
* (c) 2016-2020 Agence Webup | ||
* Released under the MIT License. | ||
*/ | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.Dropmic = factory()); | ||
}(this, (function () { 'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
var dropmicClassShow = "dropmic--show"; | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
var Dropmic = function () { | ||
function Dropmic(target, options) { | ||
_classCallCheck(this, Dropmic); | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
this.target = target; | ||
this.btn = target.querySelector('[data-dropmic-btn]'); | ||
this.container = null; | ||
return obj; | ||
} | ||
this.defaults = _defineProperty({ | ||
onOpen: null, | ||
onClose: null, | ||
beforeClose: null | ||
}, "beforeClose", null); | ||
var dropmicClassShow = "dropmic--show"; | ||
this.options = this.extendObject({}, this.defaults, options); | ||
var Dropmic = | ||
/*#__PURE__*/ | ||
function () { | ||
function Dropmic(target, options) { | ||
_classCallCheck(this, Dropmic); | ||
this.list = null; | ||
this.custom = null; | ||
this.initialized = false; | ||
this.init(); | ||
this.target = target; | ||
this.btn = target.querySelector('[data-dropmic-btn]'); | ||
this.container = null; | ||
this.defaults = _defineProperty({ | ||
onOpen: null, | ||
onClose: null, | ||
beforeClose: null | ||
}, "beforeClose", null); | ||
this.options = this.extendObject({}, this.defaults, options); | ||
this.list = null; | ||
this.custom = null; | ||
this.initialized = false; | ||
this.init(); | ||
} | ||
_createClass(Dropmic, [{ | ||
key: "init", | ||
value: function init() { | ||
this._bindEvents(); | ||
} | ||
key: "init", | ||
value: function init() { | ||
this._bindEvents(); | ||
} | ||
}, { | ||
key: "_findAncestor", | ||
value: function _findAncestor(el, cls) { | ||
while ((el = el.parentElement) && !el.classList.contains(cls)) {} | ||
return el; | ||
key: "_findAncestor", | ||
value: function _findAncestor(el, cls) { | ||
while ((el = el.parentElement) && !el.classList.contains(cls)) { | ||
} | ||
return el; | ||
} | ||
}, { | ||
key: "_bindEvents", | ||
value: function _bindEvents() { | ||
var self = this; | ||
// Show menu | ||
this.btn.addEventListener("click", function (event) { | ||
event.preventDefault(); | ||
if (!self.target.classList.contains(dropmicClassShow)) { | ||
self.open(); | ||
} else { | ||
self.close(); | ||
} | ||
}); | ||
key: "_bindEvents", | ||
value: function _bindEvents() { | ||
var self = this; // Show menu | ||
// Close menu when mouthclick outside menu | ||
document.addEventListener("click", function (event) { | ||
if (!(self._findAncestor(event.target, 'dropmic') === self.target)) { | ||
if (self.target.classList.contains(dropmicClassShow)) { | ||
self.close.call(self); | ||
} | ||
} | ||
}); | ||
this.btn.addEventListener("click", function (event) { | ||
event.preventDefault(); | ||
// Close menu with escape key | ||
this.target.addEventListener("keydown", function (event) { | ||
if (event.keyCode === 27) { | ||
self.close(); | ||
self.btn.focus(); | ||
} | ||
}); | ||
if (!self.target.classList.contains(dropmicClassShow)) { | ||
self.open(); | ||
} else { | ||
self.close(); | ||
} | ||
}); // Close menu when mouthclick outside menu | ||
this.target.addEventListener("keydown", function (event) { | ||
if (self.target.classList.contains(dropmicClassShow)) { | ||
// Tab navigation | ||
var elementList = self.target.querySelectorAll(".dropmic-menu__listContent"); | ||
var elementLast = elementList.length - 1; | ||
if (event.keyCode === 9 && document.activeElement === elementList[elementLast]) { | ||
event.preventDefault(); | ||
elementList[0].focus(); | ||
} | ||
document.addEventListener("click", function (event) { | ||
if (!(self._findAncestor(event.target, 'dropmic') === self.target)) { | ||
if (self.target.classList.contains(dropmicClassShow)) { | ||
self.close.call(self); | ||
} | ||
} | ||
}); // Close menu with escape key | ||
// Arrow Up/Down navigation | ||
if (event.keyCode === 38 || event.keyCode === 40) { | ||
event.preventDefault(); | ||
var currentItemIndex = self._getCurrentItemIndex(elementList, document.activeElement); | ||
if (currentItemIndex === undefined) { | ||
elementList[0].focus(); | ||
} else { | ||
if (event.keyCode === 38) { | ||
elementList[self._getPreviousItemIndex(elementList, currentItemIndex)].focus(); | ||
} else { | ||
elementList[self._getNextItemIndex(elementList, currentItemIndex)].focus(); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
this.target.addEventListener("keydown", function (event) { | ||
if (event.keyCode === 27) { | ||
self.close(); | ||
self.btn.focus(); | ||
} | ||
}); | ||
this.target.addEventListener("keydown", function (event) { | ||
if (self.target.classList.contains(dropmicClassShow)) { | ||
// Tab navigation | ||
var elementList = self.target.querySelectorAll(".dropmic-menu__listContent"); | ||
var elementLast = elementList.length - 1; | ||
// Navigation function | ||
if (event.keyCode === 9 && document.activeElement === elementList[elementLast]) { | ||
event.preventDefault(); | ||
elementList[0].focus(); | ||
} // Arrow Up/Down navigation | ||
}, { | ||
key: "_getCurrentItemIndex", | ||
value: function _getCurrentItemIndex(list, element) { | ||
for (var i = 0; i < list.length; i++) { | ||
if (element === list[i]) { | ||
return i; | ||
if (event.keyCode === 38 || event.keyCode === 40) { | ||
event.preventDefault(); | ||
var currentItemIndex = self._getCurrentItemIndex(elementList, document.activeElement); | ||
if (currentItemIndex === undefined) { | ||
elementList[0].focus(); | ||
} else { | ||
if (event.keyCode === 38) { | ||
elementList[self._getPreviousItemIndex(elementList, currentItemIndex)].focus(); | ||
} else { | ||
elementList[self._getNextItemIndex(elementList, currentItemIndex)].focus(); | ||
} | ||
} | ||
} | ||
return undefined; | ||
} | ||
}); | ||
} // Navigation function | ||
}, { | ||
key: "_getCurrentItemIndex", | ||
value: function _getCurrentItemIndex(list, element) { | ||
for (var i = 0; i < list.length; i++) { | ||
if (element === list[i]) { | ||
return i; | ||
} | ||
} | ||
return undefined; | ||
} | ||
}, { | ||
key: "_getPreviousItemIndex", | ||
value: function _getPreviousItemIndex(list, currentItemIndex) { | ||
if (currentItemIndex > 0) { | ||
return currentItemIndex - 1; | ||
} else { | ||
return list.length - 1; | ||
} | ||
key: "_getPreviousItemIndex", | ||
value: function _getPreviousItemIndex(list, currentItemIndex) { | ||
if (currentItemIndex > 0) { | ||
return currentItemIndex - 1; | ||
} else { | ||
return list.length - 1; | ||
} | ||
} | ||
}, { | ||
key: "_getNextItemIndex", | ||
value: function _getNextItemIndex(list, currentItemIndex) { | ||
if (currentItemIndex === list.length - 1) { | ||
return 0; | ||
} else { | ||
return currentItemIndex + 1; | ||
} | ||
key: "_getNextItemIndex", | ||
value: function _getNextItemIndex(list, currentItemIndex) { | ||
if (currentItemIndex === list.length - 1) { | ||
return 0; | ||
} else { | ||
return currentItemIndex + 1; | ||
} | ||
/** | ||
* Constructors | ||
*/ | ||
} | ||
/** | ||
* Constructors | ||
*/ | ||
// Initialize dropdown if you want to generate it with JS | ||
// Initialize dropdown if you want to generate it with JS | ||
}, { | ||
key: "_isInitialized", | ||
value: function _isInitialized() { | ||
if (this.initialized === false) { | ||
this._constructDropdown(); | ||
}, { | ||
key: "_isInitialized", | ||
value: function _isInitialized() { | ||
if (this.initialized === false) { | ||
this._constructDropdown(); | ||
this.initialized = true; | ||
} | ||
this.initialized = true; | ||
} | ||
} // Construct dropdown struture | ||
// Construct dropdown struture | ||
}, { | ||
key: "_constructDropdown", | ||
value: function _constructDropdown() { | ||
this.container = document.createElement("div"); | ||
this.container.classList.add("dropmic-menu"); | ||
this.container.setAttribute("aria-hidden", "true"); | ||
this.target.appendChild(this.container); | ||
} // Construct list if it doesn't exist | ||
}, { | ||
key: "_constructDropdown", | ||
value: function _constructDropdown() { | ||
this.container = document.createElement("div"); | ||
this.container.classList.add("dropmic-menu"); | ||
this.container.setAttribute("aria-hidden", "true"); | ||
this.target.appendChild(this.container); | ||
key: "_constructList", | ||
value: function _constructList() { | ||
if (this.list === null) { | ||
this.list = document.createElement("ul"); | ||
this.list.classList.add("dropmic-menu__list"); | ||
this.list.setAttribute("role", "menu"); | ||
this.container.appendChild(this.list); | ||
} | ||
// Construct list if it doesn't exist | ||
return this.list; | ||
} // Construct a list item | ||
}, { | ||
key: "_constructList", | ||
value: function _constructList() { | ||
if (this.list === null) { | ||
this.list = document.createElement("ul"); | ||
this.list.classList.add("dropmic-menu__list"); | ||
this.list.setAttribute("role", "menu"); | ||
this.container.appendChild(this.list); | ||
} | ||
return this.list; | ||
} | ||
key: "_constructItem", | ||
value: function _constructItem(content) { | ||
var listItem = document.createElement("li"); | ||
listItem.classList.add("dropmic-menu__listItem"); | ||
this.list.setAttribute("role", "menuitem"); | ||
listItem.appendChild(content); | ||
return listItem; | ||
} // Construct custom content | ||
// Construct a list item | ||
}, { | ||
key: "_constructItem", | ||
value: function _constructItem(content) { | ||
var listItem = document.createElement("li"); | ||
listItem.classList.add("dropmic-menu__listItem"); | ||
this.list.setAttribute("role", "menuitem"); | ||
listItem.appendChild(content); | ||
return listItem; | ||
key: "_constructCustom", | ||
value: function _constructCustom(content) { | ||
if (this.custom === null) { | ||
this.custom = document.createElement("div"); | ||
this.custom.classList.add("dropmic-menu__custom"); | ||
this.custom.innerHTML = content; | ||
this.container.appendChild(this.custom); | ||
} else { | ||
this.custom.innerHTML = content; | ||
} | ||
} | ||
/** | ||
* Callback methods | ||
*/ | ||
// Construct custom content | ||
}, { | ||
key: "_constructCustom", | ||
value: function _constructCustom(content) { | ||
if (this.custom === null) { | ||
this.custom = document.createElement("div"); | ||
this.custom.classList.add("dropmic-menu__custom"); | ||
this.custom.innerHTML = content; | ||
this.container.appendChild(this.custom); | ||
} else { | ||
this.custom.innerHTML = content; | ||
} | ||
key: "_onOpen", | ||
value: function _onOpen() { | ||
if (this.options.onOpen) { | ||
this.options.onOpen(); | ||
} | ||
/** | ||
* Callback methods | ||
*/ | ||
} | ||
}, { | ||
key: "_onOpen", | ||
value: function _onOpen() { | ||
if (this.options.onOpen) { | ||
this.options.onOpen(); | ||
} | ||
key: "_onClose", | ||
value: function _onClose() { | ||
if (this.options.onClose) { | ||
this.options.onClose(); | ||
} | ||
} | ||
}, { | ||
key: "_onClose", | ||
value: function _onClose() { | ||
if (this.options.onClose) { | ||
this.options.onClose(); | ||
} | ||
key: "_beforeOpen", | ||
value: function _beforeOpen() { | ||
if (this.options.beforeOpen) { | ||
this.options.beforeOpen(); | ||
} | ||
} | ||
}, { | ||
key: "_beforeOpen", | ||
value: function _beforeOpen() { | ||
if (this.options.beforeOpen) { | ||
this.options.beforeOpen(); | ||
} | ||
key: "_beforeClose", | ||
value: function _beforeClose() { | ||
if (this.options.beforeClose) { | ||
this.options.beforeClose(); | ||
} | ||
} | ||
/** | ||
* Helpers | ||
*/ | ||
}, { | ||
key: "_beforeClose", | ||
value: function _beforeClose() { | ||
if (this.options.beforeClose) { | ||
this.options.beforeClose(); | ||
key: "extendObject", | ||
value: function extendObject() { | ||
for (var i = 1; i < arguments.length; i++) { | ||
for (var key in arguments[i]) { | ||
if (arguments[i].hasOwnProperty(key)) { | ||
arguments[0][key] = arguments[i][key]; | ||
} | ||
} | ||
} | ||
/** | ||
* Helpers | ||
*/ | ||
return arguments[0]; | ||
} | ||
/** | ||
* Public methods to generate menu | ||
*/ | ||
// Add a link | ||
}, { | ||
key: "extendObject", | ||
value: function extendObject() { | ||
for (var i = 1; i < arguments.length; i++) { | ||
for (var key in arguments[i]) { | ||
if (arguments[i].hasOwnProperty(key)) { | ||
arguments[0][key] = arguments[i][key]; | ||
} | ||
} | ||
} | ||
return arguments[0]; | ||
} | ||
key: "addLink", | ||
value: function addLink(label, url) { | ||
this._isInitialized(); | ||
/** | ||
* Public methods to generate menu | ||
*/ | ||
var link = document.createElement("a"); | ||
link.classList.add("dropmic-menu__listContent"); | ||
link.setAttribute("href", url); | ||
link.setAttribute("tabindex", "-1"); | ||
link.innerHTML = label; | ||
// Add a link | ||
this._constructList().appendChild(this._constructItem(link)); | ||
} // Add a button | ||
}, { | ||
key: "addLink", | ||
value: function addLink(label, url) { | ||
this._isInitialized(); | ||
var link = document.createElement("a"); | ||
link.classList.add("dropmic-menu__listContent"); | ||
link.setAttribute("href", url); | ||
link.setAttribute("tabindex", "-1"); | ||
link.innerHTML = label; | ||
this._constructList().appendChild(this._constructItem(link)); | ||
key: "addBtn", | ||
value: function addBtn(label, callback) { | ||
this._isInitialized(); | ||
if (!(typeof callback === "function")) { | ||
console.warning('callback is not a function'); | ||
return; | ||
} | ||
// Add a button | ||
var btn = document.createElement("button"); | ||
btn.classList.add("dropmic-menu__listContent"); | ||
btn.setAttribute("tabindex", "-1"); | ||
btn.innerHTML = label; | ||
this._constructList().appendChild(this._constructItem(btn)); | ||
btn.addEventListener('click', function (event) { | ||
callback(event); | ||
}); | ||
return btn; | ||
} // Add only a text in a span | ||
}, { | ||
key: "addBtn", | ||
value: function addBtn(label, callback) { | ||
this._isInitialized(); | ||
if (!(typeof callback === "function")) { | ||
console.warning('callback is not a function'); | ||
return; | ||
} | ||
key: "addLabel", | ||
value: function addLabel(text) { | ||
this._isInitialized(); | ||
var btn = document.createElement("button"); | ||
btn.classList.add("dropmic-menu__listContent"); | ||
btn.setAttribute("tabindex", "-1"); | ||
btn.innerHTML = label; | ||
this._constructList().appendChild(this._constructItem(btn)); | ||
btn.addEventListener('click', function (event) { | ||
callback(event); | ||
}); | ||
return btn; | ||
} | ||
var label = document.createElement("span"); | ||
label.classList.add("dropmic-menu__listContent"); | ||
label.innerHTML = text; | ||
// Add only a text in a span | ||
this._constructList().appendChild(this._constructItem(label)); | ||
} // Add custom content (not in list), just have fun | ||
}, { | ||
key: "addLabel", | ||
value: function addLabel(text) { | ||
this._isInitialized(); | ||
var label = document.createElement("span"); | ||
label.classList.add("dropmic-menu__listContent"); | ||
label.innerHTML = text; | ||
this._constructList().appendChild(this._constructItem(label)); | ||
} | ||
key: "setCustomContent", | ||
value: function setCustomContent(content) { | ||
this._isInitialized(); | ||
// Add custom content (not in list), just have fun | ||
this._constructCustom(content); | ||
} // Update target button content | ||
}, { | ||
key: "setCustomContent", | ||
value: function setCustomContent(content) { | ||
this._isInitialized(); | ||
this._constructCustom(content); | ||
} | ||
key: "updateTargetBtn", | ||
value: function updateTargetBtn(content) { | ||
this.btn.innerHTML = content; | ||
} // Open dropdown | ||
// Update target button content | ||
}, { | ||
key: "updateTargetBtn", | ||
value: function updateTargetBtn(content) { | ||
this.btn.innerHTML = content; | ||
} | ||
key: "open", | ||
value: function open() { | ||
this._beforeOpen(); | ||
// Open dropdown | ||
this.target.classList.add(dropmicClassShow); | ||
this.target.querySelector("[aria-hidden]").setAttribute("aria-hidden", "false"); | ||
var listItems = this.target.querySelectorAll(".dropmic-menu__listContent"); | ||
[].forEach.call(listItems, function (el) { | ||
el.setAttribute("tabindex", "0"); | ||
}); | ||
this._onOpen(); | ||
} // Close dropdown | ||
}, { | ||
key: "open", | ||
value: function open() { | ||
this._beforeOpen(); | ||
this.target.classList.add(dropmicClassShow); | ||
this.target.querySelector("[aria-hidden]").setAttribute("aria-hidden", "false"); | ||
var listItems = this.target.querySelectorAll(".dropmic-menu__listContent"); | ||
[].forEach.call(listItems, function (el) { | ||
el.setAttribute("tabindex", "0"); | ||
}); | ||
this._onOpen(); | ||
} | ||
key: "close", | ||
value: function close() { | ||
this._beforeClose(); | ||
// Close dropdown | ||
this.target.classList.remove(dropmicClassShow); | ||
this.target.querySelector("[aria-hidden]").setAttribute("aria-hidden", "true"); | ||
var listItems = this.target.querySelectorAll(".dropmic-menu__listContent"); | ||
[].forEach.call(listItems, function (el) { | ||
el.setAttribute("tabindex", "-1"); | ||
}); | ||
}, { | ||
key: "close", | ||
value: function close() { | ||
this._beforeClose(); | ||
this.target.classList.remove(dropmicClassShow); | ||
this.target.querySelector("[aria-hidden]").setAttribute("aria-hidden", "true"); | ||
var listItems = this.target.querySelectorAll(".dropmic-menu__listContent"); | ||
[].forEach.call(listItems, function (el) { | ||
el.setAttribute("tabindex", "-1"); | ||
}); | ||
this._onClose(); | ||
} | ||
this._onClose(); | ||
} | ||
}]); | ||
return Dropmic; | ||
}(); | ||
}(); | ||
module.exports = Dropmic; | ||
return Dropmic; | ||
},{}]},{},[1])(1) | ||
}); | ||
}))); |
{ | ||
"name": "dropmic", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A lightweight dropdown plugin", | ||
"main": "dist/dropmic.js", | ||
"module": "dist/dropmic.esm.js", | ||
"style": "dist/dropmic.min.css", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"babel-preset-env": "^1.6.0", | ||
"babelify": "^7.3.0", | ||
"browser-sync": "^2.18.0", | ||
"browserify": "^14.4.0", | ||
"gulp": "^3.9.1", | ||
"gulp-autoprefixer": "^3.1.1", | ||
"gulp-babel": "^7.0.0", | ||
"gulp-clean-css": "^2.0.12", | ||
"gulp-uglify": "^3.0.0", | ||
"@babel/cli": "^7.8.3", | ||
"@babel/core": "^7.8.3", | ||
"@babel/preset-env": "^7.8.3", | ||
"autoprefixer": "^9.7.3", | ||
"babel-preset-es2015-rollup": "^3.0.0", | ||
"browser-sync": "^2.26.7", | ||
"clean-css-cli": "^4.3.0", | ||
"concurrently": "^5.0.2", | ||
"globby": "^11.0.0", | ||
"onchange": "^6.1.0", | ||
"postcss-cli": "^7.1.0", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^1.29.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"vinyl-source-stream": "^1.1.0" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"clean": "rimraf dist", | ||
"prefix": "postcss src/dropmic.css --use=autoprefixer --map=false --output=dist/dropmic.css", | ||
"minify": "cleancss --level=1 --source-map --source-map-inline-sources --output dist/dropmic.min.css dist/dropmic.css", | ||
"css": "npm run prefix && npm run minify", | ||
"build:umd": "rollup --config build/umd.js && rollup --config build/umd.min.js", | ||
"build:esm": "rollup --config build/esm.js", | ||
"build": "npm run clean && npm run build:umd && npm run build:esm && npm run css", | ||
"watch:js": "onchange 'src/**/*.js' -- npm run build:umd", | ||
"watch:css": "onchange 'src/**/*.css' -- npm run css", | ||
"dev": "npm run build & browser-sync 'demo' 'dist' -w --no-open & npm run watch:js & npm run watch:css" | ||
}, | ||
@@ -22,0 +39,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
# dropmic | ||
![Logo dropmic](logo.png) | ||
@@ -26,3 +26,3 @@ ## Introduction | ||
```html | ||
<link rel="stylesheet" href="dist/dropmic.css"> | ||
<link rel="stylesheet" href="dist/dropmic.min.css"> | ||
``` | ||
@@ -33,5 +33,12 @@ | ||
```html | ||
<script src="dist/dropmic.js"></script> | ||
<!-- Browser build --> | ||
<script src="dist/dropmic.min.js"></script> | ||
``` | ||
Or as a JS module: | ||
```js | ||
// ES6 module build | ||
import dropmic from 'dropmic' | ||
``` | ||
### Use | ||
@@ -58,2 +65,3 @@ | ||
<button data-dropmic-btn>click me</button> | ||
<div class="dropmic-menu" aria-hidden="true">quality content</div> | ||
</div> | ||
@@ -70,3 +78,3 @@ ``` | ||
Use this template (`<div class="dropmic-menu">` is needed, otherwise you can completely customize his content) | ||
Use this template (`<div class="dropmic-menu" aria-hidden="true">` is needed, otherwise you can completely customize his content) | ||
@@ -136,2 +144,9 @@ ```html | ||
## Modify dropmic | ||
1. Setup dependencies: `npm i` (or `npm ci` if you don't want to impact package-lock) | ||
2. Run hot-reloads server for development `npm run dev` | ||
3. (Build for production `npm run build`) | ||
## Roadmap | ||
@@ -147,2 +162,1 @@ - [x] Add open and close public method in the API | ||
Released under the [MIT LICENSE](http://opensource.org/licenses/MIT) | ||
Developed by [Robin Parisi](https://github.com/robinparisi/) and [Théotix](https://github.com/theotix/) |
const dropmicClassShow = "dropmic--show"; | ||
class Dropmic { | ||
export default class Dropmic { | ||
@@ -294,3 +294,1 @@ constructor(target, options) { | ||
} | ||
module.exports = Dropmic; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
23
1734
1
157
0
104792
16
1