1.1.2 • Published 6 years ago

react-win32dialog v1.1.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

React component library for modeless, resizeable and moveable dialog boxes with a classic Windows look-and-feel. Comes with a light-weight window manager that supports multiple dialog boxes and stacking.

NPM npm bundle size (minified + gzip) GitHub

Overview

Win32Dialog windows act a lot like classic Windows OS dialog boxes.

They can be resized by left-clicking and dragging from any edge.

red-border

They can be moved around by left-clicking and dragging the titlebar.

red-titlebar

They can be minimized, maximized and closed by using the titlebar buttons.

red-buttons

Check out the tutorial

Note that this component relies heavily on mouse events, so it might not work as intended in environments that don't use mouse pointers.

Install

npm install --save react-win32dialog

Usage

import React from 'react';
import Win32Dialog from 'react-win32dialog';

class Example extends React.Component {
    static blurText = "Dialog doesn't have focus!";
    static focusText = "Dialog has focus!";

    constructor(props) {
        super(props);

        this.state = {
            text: Example.blurText,
        };
    }

    _onFocus = () => {
        this.setState({
            text: Example.focusText
        });
    }

    _onBlur = () => {
        this.setState({
            text: Example.blurText
        });
    }

    render () {
        return (
            <Win32Dialog
                x={500}
                y={500}
                width={200}
                height={200}
                minWidth={150}
                minHeight={50}
                title="My first react-win32dialog box!"
                icon="myicon.jpg"
                onExit={() => true}
                onBlur={this._onBlur}
                onFocus={this._onFocus}
                >
                <div>
                    {this.state.text}
                </div>
            </Win32Dialog>
        );
    }
}

Props

PropertyTypeDefaultDescription
xnumber1Initial x position of the dialog.
ynumber1Initial y position of the dialog.
widthnumberminWidthInitial width if it's larger than minWidth.
heightnumberminHeightInitial height if it's larger than minHeight.
minWidthnumberSee rect.js/defaultRectMinimum width that the dialog can have.
minHeightnumberSee rect.js/defaultRectMinimum height that the dialog can have.
borderWidthnumberSee rect.js/defaultRectWidth of the dialog's outer border.
titlestringReact Win32 dialog boxText that is displayed on the dialog's titlebar.
iconstringassets/default-titlebar-icon.pngIcon that is displayed on the dialog's titlebar.
onExitfunctionundefinedIs called when the dialog's X button is pressed. It should return a truthy value for the dialog to exit. If it returns falsy, the X button doesn't close the dialog.
onBlurfunctionundefinedIs called when the dialog loses focus.
onFocusfunctionundefinedIs called when the dialog gains focus.

All the number type props are measured in pixels.

Contributing

If you find a bug or want to add a feature feel free to make a PR or open an Issue.

License

Gikoskos © MIT 2018

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago