jabroni-outfit 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +92 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,41 +5,122 @@
5
5
  <img src="https://i.imgur.com/hCyUJvd.png" alt="Sublime's custom image"/>
6
6
  </p>
7
7
 
8
- ## How to use
8
+ ### Introduction
9
+
10
+ The `jabroni-outfit` library is a versatile tool for creating user interfaces with persistent state management. It provides a simple and efficient way to define state variables, build UI controls, and automatically update the UI based on state changes.
11
+
12
+ ### Key Features
13
+
14
+ - **State Management:**
15
+ - Define state variables with properties like `value`, `persistent`, and `watch`.
16
+ - Easily manage and update state values throughout your application.
17
+ - **UI Creation:**
18
+ - Create UI controls (e.g., text inputs, checkboxes) based on state variables.
19
+ - Automatically update the UI whenever state values change.
20
+ - **Persistence:**
21
+ - Store state values persistently across application sessions.
22
+ - **Flexibility:**
23
+ - Customize the UI and state management to fit your specific needs.
24
+
25
+ ### Usage
26
+
27
+ **1. Import the Library:**
28
+
29
+ ```javascript
30
+ import { JabroniOutfitStore, JabroniOutfitUI } from 'jabroni-outfit';
9
31
  ```
32
+ or umd cdn:
33
+ ```javascript
10
34
  <script src="https://unpkg.com/jabroni-outfit@latest/dist/jabroni-outfit.umd.js"></script>
35
+ ...
36
+ const { JabroniOutfitStore, JabroniOutfitUI } = window.jabronioutfit;
37
+ ```
38
+
39
+ **2. Define State Variables:**
40
+
41
+ Create an object containing state variables. Each variable has properties:
42
+
43
+ - `value`: The current value of the state variable.
44
+ - `persistent`: Boolean indicating if the value should be stored persistently.
45
+ - `watch`: Boolean indicating if the UI should update when the value changes.
46
+
47
+ ```javascript
48
+ const myState = {
49
+ gradientColor1: { value: "red", persistent: false, watch: true },
50
+ // ... other state variables
51
+ };
52
+ ```
53
+
54
+ **3. Create a Store:**
55
+
56
+ Instantiate a `JabroniOutfitStore` object with your state definition.
57
+
58
+ ```javascript
59
+ const store = new JabroniOutfitStore(myState);
60
+ ```
61
+
62
+ **4. Create UI Controls:**
63
+
64
+ Define an object mapping state variables to UI control configurations.
65
+
66
+ ```javascript
67
+ const uiConfig = {
68
+ gradientColor1: [{ type: "text", model: "stateLocale.gradientColor1" }],
69
+ // ... other UI controls
70
+ };
71
+ ```
72
+
73
+ **5. Create the UI:**
74
+
75
+ Instantiate a `JabroniOutfitUI` object with the store and UI configuration.
76
+
77
+ ```javascript
78
+ const ui = new JabroniOutfitUI(store, uiConfig);
11
79
  ```
12
80
 
81
+ **6. Subscribe to reactive data:**
82
+
83
+ Use the `subscribe` method on the store to trigger updates whenever the state changes.
84
+
85
+ ```javascript
86
+ store.subscribe(() => {
87
+ // ...
88
+ });
13
89
  ```
90
+
91
+ ### Example
92
+
93
+ ```javascript
14
94
  const {
15
95
  JabroniOutfitStore,
16
96
  JabroniOutfitUI,
17
97
  defaultStateWithDurationAndPrivacy,
18
98
  defaultSchemeWithPrivateFilter
19
- } = window.jabronioutfit;
99
+ } = window.jabronioutfit;
20
100
 
21
- const myState = {
101
+ const myState = {
22
102
  gradientColor1: { value: "red", persistent: false, watch: true },
23
103
  gradientColor2: { value: "coral", persistent: false, watch: true },
24
104
  gradientColor3: { value: "orange", persistent: false, watch: true },
25
105
  gradientEnabled: { value: true, persistent: false, watch: true },
26
106
  uiEnabled: { value: true, persistent: true, watch: true }
27
- }
28
- const store = new JabroniOutfitStore(myState);
107
+ }
108
+
109
+ const store = new JabroniOutfitStore(myState);
29
110
 
30
- const ui = new JabroniOutfitUI(store, {
111
+ const ui = new JabroniOutfitUI(store, {
31
112
  gradientColor1: [{ type: "text", model: "stateLocale.gradientColor1", placeholder: "color", labelBefore: "color1" }],
32
113
  gradientColor2: [{ type: "text", model: "stateLocale.gradientColor2", placeholder: "color", labelBefore: "color2" }],
33
114
  gradientColor3: [{ type: "text", model: "stateLocale.gradientColor3", placeholder: "color", labelBefore: "color3" }],
34
115
  gradientEnabled: [{ type: "checkbox", model: "stateLocale.gradientEnabled", labelBefore: "gradient enabled" }],
35
- });
116
+ });
36
117
 
37
- function drawGradient() {
118
+ function drawGradient() {
38
119
  const { gradientColor1, gradientColor2, gradientColor3, gradientEnabled } = store.stateLocale;
39
120
  if (!gradientEnabled) { document.body.style.background = 'coral'; return; }
40
121
  document.body.style.background = `radial-gradient(${gradientColor1}, ${gradientColor2}, ${gradientColor3})`;
41
- }
122
+ }
42
123
 
43
- drawGradient();
44
- store.subscribe(drawGradient);
124
+ drawGradient();
125
+ store.subscribe(drawGradient);
45
126
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jabroni-outfit",
3
3
  "description": "out-of-the-box gui and persistent-state library based on vue",
4
- "version": "1.4.8",
4
+ "version": "1.4.9",
5
5
  "license": "MIT",
6
6
  "keywords": ["gui", "tweaks", "ui", "persistent-state", "state-management", "typescript", "vue"],
7
7
  "author": "smartacephale atm.mormon@protonmail.com (https://github.com/smartacephale)",