Git Product home page Git Product logo

xstate-catalogue's Introduction

XState Catalogue

All Contributors

XState Catalogue

XState Catalogue is a collection of professionally designed state machines you can drop into your XState projects.

We're accepting contributions! We'd love to hear your ideas for new machines and ways to improve the catalogue.

Check out the full site for the full browsing experience.

Setting up the repo

  1. Run yarn install
  2. Run yarn dev to run it on localhost:3000

Contributing a new machine

  1. Run yarn generate to generate the boilerplate for a new machine.
  2. Follow the instructions in the CLI.
  3. Just like that, you can start editing the files and write a new machine.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Mark Chandler

πŸ’»

Matt Pocock

πŸ’» πŸ€” πŸ’‘ 🎨

Henri Maurer

πŸ’» πŸ€”

Bernhard Mayr

πŸ’» πŸ€”

Damien Sedgwick

πŸ’»

RubΓ©n Moya

πŸ’»

Nicolai Bjerre Pedersen

πŸ’»

Tim Deschryver

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

xstate-catalogue's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xstate-catalogue's Issues

Broken in Safari

When you use the trackpad for scrolling, arrows are disconnected ...

Xstate-visualizer

Great project, thank you!

[Idea] Permutations of examples

Just throwing out an idea that it could be useful to see slight permutations of the same machine adding additional functionality. A simple example would be to permute the β€œ Simple Data Fetch” machine to use the AbortController to actual cancel the request.

This would allow use to start with trivial examples and build up more complex, intricate examples while allowing someone new to start from an easy to understand example.

I think there are some examples in the catalogue where we are implicitly doing this, but i suspect modifying the current design could help make it more explicit that a group of example build on each other.

Copy button on mobile hides content

Description

When viewing any machine src on mobile, the Copy to Clipboard button covers content in the code block, making it difficult to see the first few lines of the machine src.

image

Audio player machine

I'm creating a finite state machine for handling the audio player component of the new version of Podhouse and I'd like to contribute to this project.

Here's the link for the visualizer of the Audio player machine

There's a lot of space for improvement here but so far I think this is a good starter.

I few ideas as next steps for this state machine:

  • Use the Web Audio API and set the audio element on context.
  • Set the properties such as volume, rate, seek (this one might be complex), mute, and loop on context.

Confused about simpleDataFetch example - no hint of actual implementation

As a XState newbie, I'm a bit confused when finding the simpleDataFetch example -
there is no hint at all about how to actually implement actual (real or mock) data fetching:

  • where should the fetch code live? (In the empty services: fetchData method, I guess...)
  • how should I notify the machine about a sucessful fetch request? (sending an RECEIVE_DATA event together with the associated data:Data field back to the machine, I guess...)
  • how should I notify the machine about a data loading error? (No idea, there is no error type event...)
  • how can the Variables type be used? (No idea...)

At least, the simpleDataFetch example should have some commented out implementation example lines to give the user (me!) an idea about how to get some actual data flowing.

Best! / Jonas

New State Machine: Quiz or Test

Hi @mattpocock, thanks for this project, really cool! πŸ™Œ So amazing to see high quality examples of state machines - great for learners like our bootcamp students at @upleveled.

I'm not sure if you're accepting suggestions for new state machines, but I wanted to open an issue just in case.

It would be cool to have a state machine in the catalogue that would represent a quiz or test, including features such as:

  • start screen with start button
  • "answering single-answer question" state during quiz (also with the number of the question?)
  • "answering multi-answer question" state during quiz (also with the number of the question?)
  • end screen with restart button (also with the results of the quiz questions?)

I'm kind of new to designing state machines, so the parts in parentheses above may be better implemented in a different way.

This is amazing

Just wanted to say that this is one of the most well put together and useful community projects I have ever seen:

  • bravo πŸ‘
  • thank you so much for the hard work
  • I will use it very frequently

xstate-catalogue CatalogueSearcher modal keyboard shortcut `ctrl + k` conflicts with chrome and firefox keyboard default shortcuts

While using a Windows 10 machine [version 19042.906], user attempts to open the "search machines" modal with the ctrl + k chord trigger the Focus Address bar for Web Search (writes "? " there) search shortcut in Firefox (Version 87.0 (64-bit))[1] and the Search from anywhere on the page address bar shortcut in Chrome (version 89.0.4389.114) [2]

macOS users do not appear to have a similar conflict.

[1] - https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly
[2] - https://support.google.com/chrome/answer/157179?co=GENIE.Platform%3DDesktop&hl=en#zippy=%2Caddress-bar-shortcuts

Screen Recording
https://user-images.githubusercontent.com/6540117/113804474-d5b12680-971b-11eb-92da-a23b0cfd9764.mp4
Chrome Result Firefox Result
chrome firefox
Chrome Shortcuts Firefox Shortcuts
chrome-shortcuts firefox-keyboard-shortcuts

Add 'tags' to machines for easy concept searching

Machines should have 'tags' relating to different XState advanced concepts, like 'nested states', 'actor spawning', 'invoked callback', 'guards'.

The tags should be shown on the machine's page, as well as in search results and on the home page.

Events in sidebar not working for drag and drop, pagination and offline queue machines

While working in #13 I stumbled upon a problem with the current eventPayloads implementation.

The events in this Statechart are parametrized with the respective index that is either dragged (PICK_UP) or reaches an intersection (DRAG_REACHED_INTERSECTION). This works pretty well here:

## Test cases

### Swapping items 1 and 2

Pick up first item: <Event index={0}>PICK_UP</Event>.

Cross over second item: <Event index={1}>DRAG_REACHED_INTERSECTION</Event>.

Drop item: <Event>DROP</Event>.

Numbers one and two of the data list should have swapped places.

### Swapping items 1 and 3

Pick up first item: <Event index={0}>PICK_UP</Event>.

Cross over third item: <Event index={3}>DRAG_REACHED_INTERSECTION</Event>.

Drop item: <Event>DROP</Event>.

The first item should now be at the end.

but sadly does not work in the Sidebar. (because of the way events are distinct by their name only)

Result

The interactive documentation is one of the best features I have seen lately, maybe we can find a way with great UX to provide an event's payload, or David is already working/has already done this (πŸ˜‰). πŸš€

Affected Machines

  • Drag and Drop
  • Pagination
  • Offline Queue

edits:

  • added Affected Machines

Notifications machine

I was thinking about adding a notifications / alert machine.

Do you think that would fit in?

typescript show error message with "authentication.machine.ts"

In my vscode, the section "authentication.machine.ts" show an error with

(property) clearUserDetailsFromContext: AssignAction<{
    userDetails: undefined;
}, EventObject>
Type 'AssignAction<{ userDetails: undefined; }, AuthenticationMachineEvent>' is not assignable to type 'ActionObject<AuthenticationMachineContext, AuthenticationMachineEvent> | ActionFunction<AuthenticationMachineContext, AuthenticationMachineEvent>'.
  Type 'AssignAction<{ userDetails: undefined; }, AuthenticationMachineEvent>' is not assignable to type 'ActionObject<AuthenticationMachineContext, AuthenticationMachineEvent>'.

my ts config as below:

{
  "extends": "./node_modules/gts/tsconfig-google.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "build"
  },
  "include": [
    "src/**/*.ts",
    "test/**/*.ts"
  ]
}

ts version:

    "typescript": "^4.0.3"

Button not working on infinite scroll

Hi there,

@mattpocock as we spoke yesterday on twitter, I can't click on the received_data. I can only trigger the error.

I've tried on chrome on a windows and mac os machine.
image

And thank you very much for this project! :)

Type Errors in Debounce Machine

Found a small issue in the catalogue, it looks like the debounce machine the catalogue, has 2 type errors. I'm using typescript 4.3.2.

src/machines/debounceMachine.tsx:46:7 - error TS2322: Type 'AssignAction<{ action: undefined; }, DebounceMachineEvent>' is not assignable to type 'ActionObject<DebounceMachineContext, DebounceMachineEvent> | ActionFunction<DebounceMachineContext, DebounceMachineEvent>'.
  Type 'AssignAction<{ action: undefined; }, DebounceMachineEvent>' is not assignable to type 'ActionObject<DebounceMachineContext, DebounceMachineEvent>'.
    Types of property 'exec' are incompatible.
      Type 'ActionFunction<{ action: undefined; }, DebounceMachineEvent> | undefined' is not assignable to type 'ActionFunction<DebounceMachineContext, DebounceMachineEvent> | undefined'.
        Type 'ActionFunction<{ action: undefined; }, DebounceMachineEvent>' is not assignable to type 'ActionFunction<DebounceMachineContext, DebounceMachineEvent>'.
          Types of parameters 'context' and 'context' are incompatible.
            Type 'DebounceMachineContext' is not assignable to type '{ action: undefined; }'.

46       clearAction: assign({
         ~~~~~~~~~~~

src/machines/debounceMachine.tsx:55:16 - error TS2722: Cannot invoke an object which is possibly 'undefined'.

55         return context.action();
                  ~~~~~~~~~~~~~~


Found 2 errors.

License missing

License seems to be missing, not clear on what terms code in this repo can be used.
Other than that - that is an amazing project, thank you so much!

Searcher UX: Handle arrow keys

Right now the searcher can only be navigated using tab, which feels unexpected for that type of interaction. Most sites with an Alogolia UI or similar support arrow keys.

Obviously not the highest priority, but it's a nice bit of polish that would make search feel extra special. Plus this would probably add enough unique functionality to make the searcher machine a good one to include in the catalogue itself, while also driving the search experience. That's my kind of dogfooding!

Key Cond Action
Down Arrow Final item is focused Move focus to first item
Down Arrow - Move focus to next item
Up Arrow First item is focused Move focus to last item
Up Arrow - Move focus to previous item

syntax highlighting in inline context blocks

I implemented syntax highlighting for the "whole context" block (c.f. #18) and I am wondering if it'd make sense to also implement it for inline context. It could look something like this:

Screenshot 2021-04-07 at 10 42 49

Thoughts?

UX: navigation with mouse wheel

Navigating the examples using the mouse wheel as a scroll method, when I start to scroll with the mouse hover the inspector with the default layout (hamburger with 4 lines), the visualization moves out; especially while scrolling up.

image

I did try to solve the problem, but without success.

I'm using Firefox 89.0.2 (64-bit).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.