npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ainias42/react-windows

v0.1.12

Published

Window Management using react

Downloads

23

Readme

React-Windows

With this library you can add different Windows to your project. These windows can be minimized, maximized or even opened in a browser popup to display them on a different screen.

Also tabs are supported! You can drag a tab anywhere to create a new window or drag it to another window to add it there instead.

How to install

The usual. Just run

npm install @ainias42/react-windows

and you are good to go!

How to use

You only really need two components. The first one is

<Window id = {"unique-window-id"}
title = {"myWindowTitle"} > {...} < /Window>

and the second one is

<WindowList / >

With <Window> you create new window data. The component itself does not render anything but will add the data and children you give it to a store in the background. Then <WindowList> displays the different windows. With this concept you can add windows in different parts of your application, but they will always be on the same z-layer and therefore can better interact with each other.

The settings (which windows are displayed as tabs inside one container ect) is saved locally. From the window itself, only the id and the corresponding container is saved. If a window in future is not present, aka not in the React-DOM, then it will not be loaded or displayed. If it is added at a later point, it will be in the same container as before. This allows conditional window display.

Props

<Window>

| Prop | type | required | default | explanation | |--------------------|-------------------------------------------------------------------------------------------------------------|----------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | id | string | x | | The unique id inside the store for the window (can be the same as a containerId. See below) | | title | string | x | | The Title of the window | | defaultContainerId | string | | undefined | When two windows have the same containerId, they will be displayed as tabs inside the same windowContainer. Keep in mind, the user can with drag and drop change the container. The user configuration will always be more important than the defaultContainerId. | | fillHeight | boolean | | false | If the content should fill all of the available window-space. This breaks the resize-to-content-function in the height. | | defaultWidth | number | | undefined | sets an initial width
| storeId | string | | 'default' | the name of the store to use. Normally you don't need this. If you want windows which should not interact with each other, use different stores for them. | | buttons | WindowButtonData[] or (state: ContainerState, defaultButtons: WindowButtonData[]) => WindowButtonData[] | | [] | Title Buttons to display at the right of a window container. See below for a definition of WindowButtonData and ContainerState

<WindowList>

| Prop | type | required | default | explanation | |---------|----------|----------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | storeId | string | | 'default' | the name of the store to use. Normally you don't need this. If you want windows which should not interact with each other, use different stores for them. |

WindowButtonData

{
    key: string;
    icon: IconSource;
    title ? : string;
    containerState ? : ContainerState;
    hideWhenMaximized ? : boolean;
    hideWhenMinimized ? : boolean;
    onClick: (mouseEvent, onClickData) => void;
    onClickData: any
}

Containerstate

enum ContainerState {
    NORMAL,
    MINIMIZED,
    MAXIMIZED,
    POPUP,
}

FAQ

My component is not working correctly when the window is opened inside a popup!

Did you use the window-object inside your component? Thats not directly possible as this library uses React-Portals to render the component inside the popup (or the window). Therefore the window-object always returns the window of the main browser-window.

But there is a solution! You just have to use useWindow() from react-bootstrap-mobile. This hook gives you undefined on the server, but a window-object on the client. Either the new popup-window or the normal browser window.