FFNM/README.md

202 lines
3.5 KiB
Markdown
Raw Normal View History

2020-06-29 19:55:01 +02:00
# FFNM (Front-End for the next master)
2020-07-05 13:04:55 +02:00
![example](media/example.png)
2020-07-05 10:48:26 +02:00
Simple utility to **avoid writing Javascript** when working with **classes**. It only takes up **1Kb**!
2020-06-29 19:55:01 +02:00
2020-07-05 11:01:25 +02:00
## DEMOS
[Click](https://codepen.io/androsfenollosa/pen/dyGdRVE)
2020-06-29 20:03:05 +02:00
## Documentation
2020-06-29 20:03:31 +02:00
- [English](#user-content-english)
- [Spanish/Español](#user-content-spanishespañol)
2020-06-29 19:58:17 +02:00
2020-06-29 19:55:01 +02:00
---
2020-07-05 10:44:00 +02:00
## English
### Install
Add to your `<head>` the following tag.
```html
2020-07-05 10:48:26 +02:00
<script src="https://cdn.jsdelivr.net/gh/tanrax/FFNM@v1.0.0/dist/ffnm.min.js"></script>
2020-07-05 10:44:00 +02:00
```
### Examples
#### Click
##### Add the class `show` to the `#nav` selector when the button is pressed.
```html
<button i-click="class:add('show', '#nav')">open</button>
```
##### Remove the `show` class from the `#nav` selector when the button is pressed.
```html
<button i-click="class:remove('show', '#nav')">close</button>
```
##### Switch the `show` class to the `#nav` selector when the button is pressed.
```html
<button i-click="class:toggle('show', '#nav')">view</button>
```
2020-07-16 00:44:52 +02:00
#### Scroll up
##### Add the class `show` to `nav` when the scroll goes up.
```html
<nav i-scroll-up="class:add('show')"></nav>
```
##### Remove the `show` class from `nav` when the scroll goes up.
```html
<nav i-scroll-up="class:remove('show')"></nav>
```
#### Scroll down
##### Add the class `show` to `nav` when the scroll down.
```html
<nav i-scroll-down="class:add('show')"></nav>
```
##### Remove the `show` class from `nav` when the scroll down.
```html
<nav i-scroll-down="class:remove('show')"></nav>
```
2020-07-05 10:44:00 +02:00
#### Classes without events
##### Add the class `show` to the `#nav` selector
```javascript
class:add('show', '#nav')
```
##### Remove the `show` class from the `#nav` selector
```javascript
class:remove('show', '#nav')
```
##### Switch the class `show` to the `#nav` selector
```javascript
class:toggle('show', '#nav')
```
---
2020-06-29 19:55:01 +02:00
## Spanish/Español
### Instalar
Añade a tu `<head>` la siguiente etiqueta.
```html
2020-07-04 16:57:28 +02:00
<script src="https://cdn.jsdelivr.net/gh/tanrax/FFNM@v1.0.0/ffnm.min.js"></script>
2020-06-29 19:55:01 +02:00
```
### Ejemplos de uso
#### Clic
##### Añadir la clase `show` al selector `#menu` cuando sea pulsado el botón.
```html
<button i-click="class:add('show', '#menu')">abrir</button>
```
##### Quitar la clase `show` al selector `#menu` cuando sea pulsado el botón.
```html
<button i-click="class:remove('show', '#menu')">cerrar</button>
```
##### Intercambiar la clase `show` al selector `#menu` cuando sea pulsado el botón.
```html
<button i-click="class:toggle('show', '#menu')">ver</button>
```
2020-07-16 00:44:52 +02:00
#### Subir scroll
##### Añadir la clase `show` al selector `nav` cuando el scroll sube.
```html
<nav i-scroll-up="class:add('show')"></nav>
```
##### Quitar la clase `show` al selector `nav` cuando el scroll sube.
```html
<nav i-scroll-up="class:remove('show')"></nav>
```
#### Bajar scroll
##### Añadir la clase `show` al selector `nav` cuando el scroll baja.
```html
<nav i-scroll-down="class:add('show')"></nav>
```
##### Quitar la clase `show` al selector `nav` cuando el scroll baja.
```html
<nav i-scroll-down="class:remove('show')"></nav>
```
2020-06-29 19:55:01 +02:00
#### Clases sin eventos
##### Añadir la clase `show` al selector `#menu`
```javascript
class:add('show', '#menu')
```
##### Quitar la clase `show` al selector `#menu`
```javascript
class:remove('show', '#menu')
```
##### Intercambiar la clase `show` al selector `#menu`
```javascript
class:toggle('show', '#menu')
```
2020-07-05 10:44:00 +02:00
---
2020-06-30 10:12:43 +02:00
## Development
2020-07-02 10:40:34 +02:00
### Install
```javascript
npm i
```
2020-06-30 10:12:43 +02:00
### Build
```javascript
2020-07-02 10:40:34 +02:00
gulp
2020-06-30 10:12:43 +02:00
```
### Watch mode
```javascript
2020-07-02 10:40:34 +02:00
gulp dev
2020-06-30 10:12:43 +02:00
```