Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/itsjonq/controls

🎛 A control panel for developing/prototyping React UI
https://github.com/itsjonq/controls

configuration control control-panel development knobs prototyping rapid-development rapid-prototyping react ui

Last synced: 3 months ago
JSON representation

🎛 A control panel for developing/prototyping React UI

Awesome Lists containing this project

README

        

# 🎛 Controls

[![Build Status](https://travis-ci.org/ItsJonQ/controls.svg?branch=master)](https://travis-ci.org/ItsJonQ/controls)

> A control panel to develop and prototype React UI

- [Installation](#installation)
- [Usage](#usage)
- [Fields](#fields)
- ["Controlled" Fields](#controlled-fields)

## Installation

```
npm install @itsjonq/controls
```

## Usage

```jsx
import React from 'react';
import { useControls, Controls } from '@itsjonq/controls';

function Example() {
const { text, number } = useControls();
const title = text('Title', 'My Title');
const amount = number('Amount', 10, { min: 0, max: 50 });

return (



{title}


{amount}



);
}
```

### Fields

```jsx
import React from 'react';
import { useControls, Controls } from '@itsjonq/controls';

function Example() {
const {
// Fields
boolean,
color,
date,
number,
select,
text,
textarea,
// All attributes
attributes,
} = useControls();

boolean('checked', true);
color('mainColor', 'red');
date('publishDate', 'December 8, 2019');
number('amount', 10, { min: 0, max: 50 });
select(
'status',
{
Published: 'published',
Draft: 'draft',
Private: 'private',
},
'published',
);
text('title', 'My Title');
textarea('description', 'Words...');

// The names of the attributes registered with the fields
const {
checked,
mainColor,
publishDate,
amount,
status,
title,
description,
} = attributes;

return

...
;
}
```

### "Controlled" Fields

To manually update a field (or fields), use the `updateField` or `updateFields` function.

```jsx
import React from 'react';
import {
useControls,
Controls,
updateField,
updateFields,
} from '@itsjonq/controls';

function Example() {
const { text } = useControls();

text('title', 'My Title');
text('description', 'My Description');
text('caption', 'My Caption');

// The names of the attributes registered with the fields
const { title, description, caption } = attributes;

const handleOnManualUpdateFields = () => {
// Update a single field
updateField('title', 'New Title');
// Update multiple fields
updateFields({
description: 'New Description',
caption: 'New Caption',
});
};

return

...
;
}
```