Skip to content

Commit 5344868

Browse files
author
Matthew Phillips
committed
move remaining docs over
1 parent 82b7dfe commit 5344868

28 files changed

+2123
-212
lines changed
8.64 KB
Loading
10.8 KB
Loading

docs2/src/components/DocsSidebar.astro

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,29 @@ const activeItem = undefined;
1313
{ title: "ACTIONS", id: "actions" }
1414
],
1515
'GUIDES': [
16-
{ title: "QUICK_START", id: "quick-start" },
17-
{ title: "MIGRATION", id: "migration" },
18-
{ title: "BEST_PRACTICES", id: "best-practices" }
16+
{ title: "COMPOSITION", id: "composition", slug: "composition" },
17+
{ title: "NESTED_STATES", id: "nested-states", slug: "nested-states" },
18+
{ title: "ASYNC_EXECUTION", id: "awaiting-asynchronous-execution", slug: "awaiting-asynchronous-execution" },
19+
{ title: "VS_XSTATE", id: "comparison-with-xstate", slug: "comparison-with-xstate" }
1920
],
2021
'INTEGRATIONS': [
21-
{ title: "REACT", id: "react" },
22-
{ title: "VUE", id: "vue" },
23-
{ title: "SVELTE", id: "svelte" }
22+
{ title: "REACT_ROBOT", id: "react-robot", slug: "react-robot" },
23+
{ title: "PREACT_ROBOT", id: "preact-robot", slug: "preact-robot" },
24+
{ title: "SVELTE_ROBOT", id: "svelte-robot-factory", slug: "svelte-robot-factory" },
25+
{ title: "LIT_ROBOT", id: "lit-robot", slug: "lit-robot" },
26+
{ title: "HAUNTED_ROBOT", id: "haunted-robot", slug: "haunted-robot" },
27+
{ title: "ROBOT_HOOKS", id: "robot-hooks", slug: "robot-hooks" }
2428
],
2529
'API': [
26-
{ title: 'createMachine', id: 'create-machine', slug: 'createMachine' }
30+
{ title: 'createMachine', id: 'create-machine', slug: 'createMachine' },
31+
{ title: 'state', id: 'state', slug: 'state' },
32+
{ title: 'transition', id: 'transition', slug: 'transition' },
33+
{ title: 'guard', id: 'guard', slug: 'guard' },
34+
{ title: 'action', id: 'action', slug: 'action' },
35+
{ title: 'reduce', id: 'reduce', slug: 'reduce' },
36+
{ title: 'invoke', id: 'invoke', slug: 'invoke' },
37+
{ title: 'interpret', id: 'interpret', slug: 'interpret' },
38+
{ title: 'immediate', id: 'immediate', slug: 'immediate' }
2739
]
2840
};
2941
---

docs2/src/components/FeatureCard.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="group bg-gray-900 p-8 rounded-xl border-2 border-cyan-500 hover:border-pink-500 transition-colors relative overflow-hidden">
22
<div class="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-cyan-400 to-pink-500 transform -translate-x-full group-hover:translate-x-0 transition-transform duration-300" />
33
<div class="w-12 h-12 bg-cyan-500/20 rounded-lg flex items-center justify-center mb-4 group-hover:scale-110 transition-transform">
4-
{Astro.props.icon}
4+
<slot />
55
</div>
66
<h3 class="text-xl font-bold mb-2 font-mono text-cyan-400">{Astro.props.title}</h3>
77
<p class="text-gray-400">{Astro.props.description}</p>

docs2/src/components/Footer.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import Heart from '../icons/Heart.astro';
44
---
55
<footer class="border-t border-cyan-500/20 bg-gray-900/50 backdrop-blur-sm mt-16">
66
<div class="container mx-auto px-4 py-8">
7-
<div class="grid md:grid-cols-3 gap-8">
7+
<div class="grid md:grid-cols-3 gap-8 text-center">
88
<div>
99
<h3 class="font-mono text-cyan-400 font-bold mb-4 text-sm">CONNECT</h3>
1010
<div class="space-y-2">
11-
<a href="https://github.com" class="flex items-center gap-2 text-gray-200 hover:text-cyan-400 transition-colors">
11+
<a href="https://github.com" class="flex items-center justify-center gap-2 text-gray-200 hover:text-cyan-400 transition-colors">
1212
<Github size={16} />
1313
<span>GitHub</span>
1414
</a>
1515
</div>
1616
</div>
17-
17+
1818
<div>
1919
<h3 class="font-mono text-cyan-400 font-bold mb-4 text-sm">DOCS</h3>
2020
<div class="space-y-2">
@@ -23,7 +23,7 @@ import Heart from '../icons/Heart.astro';
2323
<a href="/docs/examples" class="block text-gray-200 hover:text-cyan-400 transition-colors">Examples</a>
2424
</div>
2525
</div>
26-
26+
2727
<div>
2828
<h3 class="font-mono text-cyan-400 font-bold mb-4 text-sm">RESOURCES</h3>
2929
<div class="space-y-2">
@@ -34,7 +34,7 @@ import Heart from '../icons/Heart.astro';
3434

3535
<div class="flex justify-center mt-8 pt-8 border-t border-cyan-500/20">
3636
<p class="text-gray-200 text-sm">
37-
© 2024 Robot. Built with <Heart size={12} class="inline text-cyan-400" /> by developers.
37+
© 2025 Robot. Built with 🔧 by developers.
3838
</p>
3939
</div>
4040
</div>

docs2/src/content/config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { z, defineCollection } from 'astro:content';
33
const docs = defineCollection({
44
schema: z.object({
55
title: z.string(),
6-
tags: z.string()
6+
tags: z.string(),
7+
layout: z.string().optional(),
8+
permalink: z.string().optional(),
9+
shortTitle: z.string().optional(),
10+
date: z.string().optional(),
11+
id: z.string().optional(),
12+
section: z.enum(['api', 'guides', 'integrations', 'core']).optional()
713
})
814
});
915

docs2/src/content/docs/action.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: action
3+
tags: api
4+
permalink: api/action.html
5+
section: api
6+
---
7+
8+
# action
9+
10+
__action__ takes a function that will be run during a [transition](/docs/transition/). The primary purpose of using action is to perform *side-effects*.
11+
12+
This example triggers an event on an element when transitioning to the next state.
13+
14+
```js
15+
import { createMachine, action, state, transition } from 'robot3';
16+
17+
function dispatchOn(ctx) {
18+
const { element } = ctx;
19+
element.dispatchEvent(new CustomEvent('toggled'));
20+
}
21+
22+
const machine = createMachine({
23+
on: state(
24+
transition('toggle', 'off')
25+
),
26+
off: state(
27+
transition('toggle', 'on',
28+
action(dispatchOn)
29+
)
30+
)
31+
}, () => ({
32+
element: document.querySelector('#toggler')
33+
}));
34+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Awaiting asynchronous execution
3+
tags: guide
4+
permalink: guides/awaiting-asynchronous-execution.html
5+
section: guides
6+
---
7+
8+
# Awaiting asynchronous execution
9+
10+
In a scenario where it's necessary to `await` the machine to enter a `final`
11+
state (a state which has no transitions), the `onChange` callback (the second argument to `interpret`) can be used
12+
to resolve a promise. The promise can be externally awaited.
13+
14+
```js
15+
let resolve;
16+
let promise = new Promise(_resolve => {
17+
resolve = _resolve;
18+
})
19+
20+
service = interpret(machine, () => {
21+
if(machine.state.value.final) {
22+
resolve();
23+
}
24+
});
25+
26+
await promise;
27+
// All done!
28+
```
29+
30+
This is particularly useful for state machines which consist entirely
31+
of `immediate` and `invoke` states: these model execution flows which do
32+
not depend on external events for their execution and state transition.

0 commit comments

Comments
 (0)