Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eace/magics

Alpine.js magic helpers
https://github.com/eace/magics

Last synced: about 1 month ago
JSON representation

Alpine.js magic helpers

Awesome Lists containing this project

README

        

# Alpine.js Magic helpers

This package provides some magic helpers for Alpine.js.

## Installation

### NPM

```bash
npm i https://github.com/eaCe/magics
```

### Yarn

```bash
yarn add https://github.com/eaCe/magics
```

Or copy the magics.js file from the src folder into your project and include it in your JavaScript bundle.

## Usage

```js
import Alpine from 'alpinejs';
import Magics from 'magics';

Alpine.plugin(Magics);
window.Alpine = Alpine
Alpine.start();
```

## Log Helpers

Every log-helper accepts one or two arguments.
The first argument is the value to log.
The second argument is a boolean value to clear the console before logging, if set to true.
You may pass an array of values as the first argument.

### `$log()`

Write a message to the console.

```html


Log
Clear previous logs and log

```

### `$warn()`

Write a warning message to the console.

```html


Log

```

### `$error()`

Write an error message to the console.

```html


Log

```

### `$info()`

Write an informational message to the console.

```html


Log

```

### `$table()`

Writes a table in the console view.

```html


Log

```

### `$clear()`

Clears the console.

```html


Clear previous logs and log

```

### `$group()` and `$groupEnd()`

Creates a new group in the console view.

```html


Group logs

```

## Size Helpers

### `$width` and `$width()`

Get or set the width of an element.

```html



```

### `$height` and `$height()`

Get or set the height of an element.

```html



```

## Position Helpers

### `$offset().top` and `$offset().left`

Get the offset of an element.

```html



```

## Misc Helpers

### `$hasClass()`

Checks if an element has a class.

```html


```

### `$trim()`

Trims whitespace from the beginning and end of a string.

```html


```