Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit a099e39

Browse files
committed
optimized toc active style and fixed typos
1 parent a1eb4bf commit a099e39

File tree

5 files changed

+54
-40
lines changed

5 files changed

+54
-40
lines changed

docs/packages/core/features/state/Methods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Returns the [State](./Introduction.md) it was called on.
357357

358358
## `watch()`
359359

360-
A `callback` that observes the State on changes.
360+
Creates a `callback` that observes the State on changes.
361361
The provided `callback` function will be fired on every State `value` mutation.
362362
For instance if we update the State value from 'jeff' to 'hans'.
363363
```ts {1-4}
File renamed without changes.

docs/packages/react/features/Hooks.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ console.log(myState); // Returns 'jeff'
3636
```ts
3737
const [myCoolState1, myCoolState2] = useAgile([MY_COOL_STATE1, MY_COOL_STATE2]);
3838
```
39-
Now it returns an array of State `values` that can be destructured.
39+
In which case it returns an array of State `values` that can be destructured.
4040
```ts {6}
4141
const MY_STATE = App.createState('jeff');
4242
const MY_STATE_2 = App.createState('frank');
@@ -47,9 +47,9 @@ const [myState, myState2] = useAgile([MY_STATE, MY_STATE_2]);
4747
console.log(myState); // Returns 'jeff'
4848
console.log(myState2); // Returns 'frank'
4949
```
50-
Binding multiple States to a Component in a single `useAgile()` Hook has one advantage.
51-
In some cases, it can lower the rerender count of the React Component.
52-
This is due to the fact that simultaneously triggered rerender of different States can be combined into one single rerender
50+
Binding multiple States to a Component using a single `useAgile()` Hook has one advantage.
51+
In some cases, it can reduce the rerender count of the React Component triggered by AgileTs.
52+
This is due to the fact that simultaneously triggered rerenders of different States are combined into one single rerender
5353
if the States share the same `SubscriptionContainer`.
5454
Each `useAgile()` Hook creates its own `SubscriptionContainer`,
5555
which serves as an interface to the Component in order to trigger rerender on it.
@@ -81,8 +81,8 @@ Instances that can be bound to a React Component via the `useAgile()` Hook:
8181
console.log(myComputed); // Returns 'hello there'
8282
```
8383
- ### [`Collection`](../../core/features/collection/Introduction.md)
84-
**Note:** The Collection has no own `observer`.
85-
But `useAgile()` is smart enough, to identify a Collection under the hood
84+
**Note:** The Collection has no own `Observer`.
85+
But `useAgile()` is smart enough, to identify a Collection
8686
and binds the [`defualt` Group](../../core/features/collection/group/Introduction.md#-default-group) to the Component instead.
8787
The `default` Group represents the default pattern of the Collection.
8888
```ts {7}
@@ -184,16 +184,24 @@ type SubscribableAgileInstancesType = State | Collection | Observer | undefined;
184184
### 📄 Return
185185

186186
`useAgile()` returns the current `output` of the passed [Agile Sub Instance](../../../main/Introduction.md#agile-sub-instance).
187-
```ts {6,9}
188-
const MY_STATE = App.State(1);
189-
const MY_STATE_2 = App.State(2);
190-
const MY_STATE_3 = App.State(3);
187+
```ts {5}
188+
const MY_STATE = App.createState('jeff');
189+
190+
// myComponent.jsx
191191

192-
// One passed Agile Sub Instance
193-
useAgile(MY_STATE); // Returns 3
192+
const myState = useAgile(MY_STATE);
193+
console.log(myState); // Returns 'jeff'
194+
```
195+
When passing multiple Agile Sub Instances, an array of `outputs` matching the passed Instances is returned.
196+
```ts {6}
197+
const MY_STATE = App.createState('jeff');
198+
const MY_STATE_2 = App.createState('frank');
199+
200+
// myComponent.jsx
194201

195-
// Multiple passed Agile Sub Instances
196-
useAgile([MY_STATE, MY_STATE_2, MY_STATE_3]); // Returns [1, 2, 3]
202+
const [myState, myState2] = useAgile([MY_STATE, MY_STATE_2]);
203+
console.log(myState); // Returns 'jeff'
204+
console.log(myState2); // Returns 'frank'
197205
```
198206

199207

@@ -207,17 +215,17 @@ useAgile([MY_STATE, MY_STATE_2, MY_STATE_3]); // Returns [1, 2, 3]
207215

208216

209217
## `useWatcher()`
210-
A `callback` that observes the State on changes.
218+
Creates a `callback` that observes the State on changes.
211219
The provided `callback` function will be fired on every State `value` mutation.
212220
For instance if we update the State value from 'jeff' to 'hans'.
213221
```ts
214-
useWatcher(MY_STATE, (value, key) => {
222+
useWatcher(MY_STATE, (value) => {
215223
console.log(value); // Returns current State Value
216-
console.log(key); // Key of Watcher ("Aj2pB")
217224
});
218225
```
219226
It is a synonym to the [`watch()`](../../core/features/state/Methods.md#watch) method.
220-
But it has some advantages. It automatically cleans up the created watcher callback when the React Component unmounts
227+
However, it has some advantages.
228+
For example, it automatically cleans up the created watcher callback when the React Component unmounts
221229
and might be cleaner to read in 'UI-Component-Code'.
222230

223231
### 🔴 Example

src/css/custom.scss

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -284,27 +284,6 @@ body {
284284
}
285285
}
286286

287-
// ==============================================================================
288-
// Table of Contents
289-
// ==============================================================================
290-
291-
.table-of-contents {
292-
.table-of-contents__link--active {
293-
font-weight: 500;
294-
margin-left: -16px;
295-
padding: 6px 8px 6px 12px;
296-
border-top-right-radius: var(--ifm-code-border-radius);
297-
border-bottom-right-radius: var(--ifm-code-border-radius);
298-
color: var(--ifm-font-color-base);
299-
border-left: 4px solid var(--ifm-color-primary);
300-
background-color: rgba(121, 118, 171, 0.2);
301-
302-
code {
303-
color: var(--ifm-font-color-base);
304-
}
305-
}
306-
}
307-
308287
// ==============================================================================
309288
// Toastify
310289
// ==============================================================================

src/theme/DocPage/styles.module.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,30 @@
9494
max-width: var(--ifm-container-width);
9595
}
9696
}
97+
98+
:global(.table-of-contents) {
99+
border-left-width: 3px;
100+
}
101+
102+
:global(.table-of-contents li) {
103+
position: relative;
104+
}
105+
106+
:global(.table-of-contents__link--active::before) {
107+
position: absolute;
108+
top: 0;
109+
bottom: 0;
110+
left: -19px;
111+
width: 3px;
112+
content: " ";
113+
background: var(--ifm-color-primary-lightest);
114+
}
115+
116+
:global(.table-of-contents__link--active) {
117+
color: var(--ifm-color-primary-lightest);
118+
font-weight: bold;
119+
}
120+
121+
ul ul :global(.table-of-contents__link--active::before) {
122+
left: -35px;
123+
}

0 commit comments

Comments
 (0)