Spaces and Windows
Kitten is a Window Manager, which means it can manage multiple windows, or “windows”. This is a feature that is common in many operating systems, and it allows you to organize your applications into different spaces. This can be useful for organizing your work, or for separating different tasks.
Let’s add some windows to our spaces on our previous example.
We’ll use BasicWindow
component to create a window. It takes title
, initialPosition
, initialSize
, opened
props and children node.
We’ll work on the Cat.tsx
file for this.
First, we need an opened
state that will be used to control the visibility of the window and a button to toggle it.
Here is the opened
state:
And here is the button:
Now, we need to add a BasicWindow
component to the Cat
component. It will be dependent on the opened
state.
Note
Window
andBasicWindow
components can be placed in anywhere in the component tree. They don’t need to be direct children of theSpace
component. You can also have nestedWindow
components.
This shows the window only when the opened
state is true
. Let’s see the full code with React’s fragment syntax (<>
):
Now, you can open and close the window by clicking the button.
Contents on Spaces
Spaces can also have contents other than windows. You can add any component to a space like the following:
Congratulations! 🥳 You’ve just learned how to deal with a complicated scenario!
Now you can move forward for more advanced topics or practice what you’ve learned by building your own projects.
- Installing dependencies
- Starting http server