debut des details de la page. Vu que c'est le troisieme (euh quatrieme?) composant, c'etait un peu plus rapide, mais heureusement que claude est la pour repasser derriere mes erreurs prcq en solo je n'y arriverais pas du tout!
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Gianluca Guarini
|
||||
|
||||
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.
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
# bianco.query
|
||||
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![NPM version][npm-version-image]][npm-url]
|
||||
[![NPM downloads][npm-downloads-image]][npm-url]
|
||||
[![MIT License][license-image]][license-url]
|
||||
|
||||
Modern DOM query selectors helpers written in es2015
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import $ from 'bianco.query'
|
||||
|
||||
const footer = document.querySelector('.main-footer')
|
||||
const header = document.querySelector('.main-header')
|
||||
|
||||
// convert DOM nodes to arrays
|
||||
$(footer)
|
||||
.concat($(header))
|
||||
.forEach(el => el.classList.add('fade-in'))
|
||||
|
||||
// handle DOM queries
|
||||
$('h1', 'main').forEach(h1 => h1.classList.add('main-title'))
|
||||
```
|
||||
|
||||
[ci-image]:https://img.shields.io/github/workflow/status/biancojs/query/test?style=flat-square
|
||||
[ci-url]:https://github.com/biancojs/query/actions
|
||||
|
||||
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
|
||||
|
||||
[license-url]: LICENSE.txt
|
||||
[npm-version-image]: http://img.shields.io/npm/v/bianco.query.svg?style=flat-square
|
||||
|
||||
[npm-downloads-image]: http://img.shields.io/npm/dm/bianco.query.svg?style=flat-square
|
||||
[npm-url]: https://npmjs.org/package/bianco.query
|
||||
|
||||
## API
|
||||
|
||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
* [$](#)
|
||||
* [Parameters](#parameters)
|
||||
|
||||
### $
|
||||
|
||||
Simple helper to find DOM nodes returning them as array like loopable object
|
||||
|
||||
#### Parameters
|
||||
|
||||
* `selector` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | DOMNodeList)** either the query or the DOM nodes to arraify
|
||||
* `scope` **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** context defining where the query will search for the DOM nodes
|
||||
|
||||
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** DOM nodes found as array
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
type Scope = Element
|
||||
| Window
|
||||
| Document
|
||||
|
||||
// borrowed from DOM querySelectorAll
|
||||
declare function $<K extends keyof HTMLElementTagNameMap>(selectors: K, scope?: Scope): HTMLElementTagNameMap[K][];
|
||||
declare function $<K extends keyof SVGElementTagNameMap>(selectors: K, scope?: Scope): SVGElementTagNameMap[K][];
|
||||
declare function $<E extends Element = Element>(selectors: string, scope?: Scope): E[];
|
||||
declare function $<W extends Window>(selectors: W, scope?: Scope): [W];
|
||||
declare function $<D extends Document>(selectors: D, scope?: Scope): [D];
|
||||
|
||||
export default $
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var domToArray = require('bianco.dom-to-array');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var domToArray__default = /*#__PURE__*/_interopDefaultLegacy(domToArray);
|
||||
|
||||
/**
|
||||
* Simple helper to find DOM nodes returning them as array like loopable object
|
||||
* @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
|
||||
* @param { HTMLElement } scope - context defining where the query will search for the DOM nodes
|
||||
* @returns { Array } DOM nodes found as array
|
||||
*/
|
||||
function $(selector, scope) {
|
||||
return domToArray__default["default"](typeof selector === 'string' ?
|
||||
(scope || document).querySelectorAll(selector) :
|
||||
selector
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = $;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import domToArray from 'bianco.dom-to-array'
|
||||
|
||||
/**
|
||||
* Simple helper to find DOM nodes returning them as array like loopable object
|
||||
* @param { string|DOMNodeList } selector - either the query or the DOM nodes to arraify
|
||||
* @param { HTMLElement } scope - context defining where the query will search for the DOM nodes
|
||||
* @returns { Array } DOM nodes found as array
|
||||
*/
|
||||
export default function $(selector, scope) {
|
||||
return domToArray(typeof selector === 'string' ?
|
||||
(scope || document).querySelectorAll(selector) :
|
||||
selector
|
||||
)
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "bianco.query",
|
||||
"version": "1.1.4",
|
||||
"description": "Modern DOM query selectors helpers written in es2015",
|
||||
"main": "index.js",
|
||||
"jsnext:main": "index.next.js",
|
||||
"module": "index.next.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"prepare": "npm run build && npm test",
|
||||
"lint": "eslint index.next.js test.js rollup.config.js",
|
||||
"build": "rollup -c",
|
||||
"doc": "npx documentation readme index.next.js -s API",
|
||||
"test": "npm run lint && mocha test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.next.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/biancojs/query.git"
|
||||
},
|
||||
"keywords": [
|
||||
"es6",
|
||||
"es2015",
|
||||
"query",
|
||||
"$",
|
||||
"querySelectorAll",
|
||||
"querySelector",
|
||||
"DOM"
|
||||
],
|
||||
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/biancojs/query/issues"
|
||||
},
|
||||
"homepage": "https://github.com/biancojs/query#readme",
|
||||
"devDependencies": {
|
||||
"@gianlucaguarini/eslint-config": "^2.0.0",
|
||||
"eslint": "^8.10.0",
|
||||
"jsdom": "19.0.0",
|
||||
"jsdom-global": "3.0.2",
|
||||
"mocha": "^9.2.1",
|
||||
"rollup": "^2.70.0",
|
||||
"rollup-plugin-node-resolve": "^3.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bianco.dom-to-array": "^1.1.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user