• Stars
    star
    407
  • Rank 106,183 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔲 Pop new windows in React, using `window.open`.

React New Window - Pop new windows in React, using window.open API.

Inspired by David Gilbertson's article.

Features

  • Only 3.68KB (gzipped!).
  • Support the full window.open api.
  • Built for React 16 (uses ReactDOM.createPortal).
  • Handler for blocked popups (via onBlock prop).
  • Center popups according to the parent window or screen.

Installation

npm i react-new-window --save

Usage

import React from 'react'
import NewWindow from 'react-new-window'

const Demo = () => (
  <NewWindow>
    <h1>Hi 👋</h1>
  </NewWindow>
)

When <NewWindow /> is mounted a popup window will be opened. When unmounted then the popup will be closed.

The children contents is what will be rendered into the new popup window. In that case Hi 👋 will be the content. The content can include any react-stateful code.

Documentation

Properties Type Default Description
url String The URL to open, if specified any children will be overriden (more details on url).
name String The name of the window (more details on windowName).
title String The title of the new window document.
features Object {} The set of window features (more details on windowFeatures).
onUnload Function undefined A function to be triggered before the new window unload.
onBlock Function undefined A function to be triggered when the new window could not be opened.
onOpen Function(w: Window) undefined A function to be triggered when window open by library.
center String parent Indicate how to center the new window. Valid values are: parent or screen. parent will center the new window according to its parent window. screen will center the new window according to the screen.
copyStyles Boolean true If specified, copy styles from parent window's document.
closeOnUnmount Boolean true If specified, close the new window on unmount.

Tests

Tests are manually done using Storybook. It can be run locally with: yarn storybook.

Development

To start contributing to this project, please do:

  1. Fork and clone this repo.
  2. Do your work.
  3. Create a PR.

Releases

The release process consists of two operations:

  1. Create new version using: npm version
  2. This GitHub action will publish the new version to NPM.

Prior work


Made with ❤️ by Rubens Mariuzzo.

MIT License

More Repositories

1

Laravel-JS-Localization

🌐 Convert your Laravel messages and consume them in the front-end!
PHP
594
star
2

Lang.js

🎭 Laravel Translator class in JavaScript!
JavaScript
259
star
3

checkboxes.js

☑️ A jQuery plugin that gives you nice powers over your checkboxes.
JavaScript
130
star
4

laravel-localization-loader

Laravel Localization loader for webpack. Convert Laravel Translation strings to JavaScript Objects.
JavaScript
68
star
5

dom-navigator

⚓️ JS library that allow keyboard navigation through DOM elements (←↑→↓).
JavaScript
40
star
6

react-chronos

⛓ React chronology component providing dual chronological timelines.
JavaScript
39
star
7

github-banner

⚡️ Generate a GitHub banner for your repo!
JavaScript
35
star
8

cloud9-emmet-ext

A Cloud9IDE extension for emmet.io (aka ZenCoding) integration.
JavaScript
26
star
9

lowdb-api

⚡️ lowdb-api - Express middleware that serve a virtual RESTful API.
JavaScript
25
star
10

spotlight-never-index

Exclude some folders from Spotlight.app
JavaScript
21
star
11

Laravel-Translator

Laravel command that interactively helps you translate missing keys.
PHP
19
star
12

config-webpack-plugin

💫 Merge one or more configuration files together with environment variables too.
JavaScript
18
star
13

react-input-handler

⚡️ Utility function to handle input changes in React.
JavaScript
15
star
14

ruty

📦 Ruty is a simple URL route builder, that support typing route params and queries string with TypeScript.
TypeScript
15
star
15

shorted-theme

Shorted theme references for Styled Components.
TypeScript
14
star
16

php-array-to-json

✨ Convert PHP configuration array files to JSON files. Useful to convert Laravel's PHP localization files into JSON files.
JavaScript
10
star
17

mkdir-date

A tool to create directories for each days in a period of time.
JavaScript
10
star
18

jQuery-Ajax-Latency-Simulator-Plugin

A jQuery plugin that simulate latency for any AJAX request via jQuery plugin
JavaScript
9
star
19

grunt-fb-flo

Starts a fb-flo server
JavaScript
8
star
20

Rachel

🚀 Quickly create a RESTful client!
JavaScript
7
star
21

rmariuzzo

Rubens' professional information that appears in GitHub.
JavaScript
6
star
22

fuf-cli

🔍 fuf – Find Unused Files in a directory with a single command.
JavaScript
6
star
23

react-scrollie

Scroll listener React component that provide scrolling info
JavaScript
6
star
24

fotch

Fotch – In browser fake REST API for creative development purposes!
TypeScript
5
star
25

react-grille

Make a grille pattern! AKA grid pattern or mesh!
JavaScript
5
star
26

markdown-exec

Execute commands in your Markdown and keep the output.
JavaScript
5
star
27

fuf

🔍 fuf – Find Unused Files in a directory.
JavaScript
5
star
28

chalk-printer

NodeJS library to print colored message in the console.
JavaScript
5
star
29

inspirabbble

Inspire yourself with fresh shots from Dribbble!
JavaScript
4
star
30

php-array-loader

PHP array loader module for webpack
JavaScript
4
star
31

php-array-parser

✨ Parse a PHP array
JavaScript
4
star
32

Mariuzzo.Web.Mvc.Extras

Extra missing components for ASP.NET MVC.
C#
4
star
33

entrify

📦 Library to convert package.json to index.js.
JavaScript
3
star
34

google-images-url

🔗 URL generator for Google Images
JavaScript
3
star
35

node-typescript-template

A template repo for Node and Typescript.
TypeScript
3
star
36

untoken

A token replacement tool.
TypeScript
3
star
37

calendar

A calendar widget.
TypeScript
3
star
38

untoken-cli

A token replacement CLI tool for text.
TypeScript
3
star
39

Gistie

Gist plugin for October CMS. Provides a simple way to share snippets and pastes with others using Github's gist.
PHP
3
star
40

easy-peasy-thunk-stages

Thunk stages in your model is easy-peasy!
TypeScript
2
star
41

knowledge

List of stuff I have learnt ...
2
star
42

xml-comment-api

Parse XML comment that provide an API
JavaScript
2
star
43

jQuery-Annotation-Plugin

jQuery Annotation Plugin
JavaScript
2
star
44

fixture-middleware

Use fixture data in your express app!
JavaScript
2
star
45

mishell

Mishell: collection of shell utilities.
TypeScript
2
star
46

directory-tree

Generate a tree of directories.
TypeScript
2
star
47

githood

Run commands in a group of git repos.
TypeScript
2
star
48

re-ducks

Library to reduce common tasks for React apps based on re-ducks (https://github.com/alexnm/re-ducks)
JavaScript
2
star
49

restful-api-course

The RESTful API course
JavaScript
2
star
50

attention-jquery-plugin

A jQuery plugin to call attention to any HTML element.
1
star
51

JavaScript-Prototype-Programming-Talk

Code used for the talk "JavaScript Prototype Programming" by @rmariuzzo
JavaScript
1
star
52

jQuery-Lockable-Plugin

A jQuery plugin that locks / unlocks any Textbox.
1
star
53

commons-css

A set of commons CSS to be reused, instead of writing it over & over.
1
star
54

grunt-talk

Introductory talk about Grunt (in spanish) — Automatizando el desarrollo front-end con Grunt.
1
star
55

entrify-cli

📦 CLI tool to convert package.json to index.js.
JavaScript
1
star
56

chronometer

Experiment: Chronometer desktop app using Go and Fyne.
Go
1
star