1.0.2 • Published 3 years ago

react-win-grid v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-win-grid

A lightweight and customisable Windows 10 Grid Component for ReactJS to give a native windows look to your web apps.

GitHub license GitHub forks GitHub stars GitHub issues

Demo

Table of contents

Changelog

  • @1.0.* - First stable version

Installation

npm install react-win-grid

Getting Started

import { WinGrid, WinItem } from 'react-win-grid';

OR

const { WinGrid, WinItem } = require('react-win-grid');

WinItem

This is a button component. Use this for individual clickable/hoverable items in your layout. This can be used inside of WinGrid or as a standalone component. Below is a list of props (optional) you can pass to the component.

propsdescriptiontypeacceptable values
backgroundColorsColors that will be applied as gradient on background on mouse hoverArray of stringsAll color values supported by CSS
borderColorsColors that will applied as gradient on borders on mouse hoverArray of stringsAll color values supported by CSS
borderWidthBorder thickness in pixelsNumberAny positive number
classNameHTML class attribute equivalentString-
contentIsImageThis prop is recommended when the child is any image element.Booleantrue \| false
disabledDisable the WinItemBooleantrue \| false
eventHandlersEvent Handlers for the componentObjectkey should be valid React event names and value will be the event handler function
onlyBackgroundDon't apply hover effect on bordersBooleantrue \| false
onlyBordersDon't apply hover effect on backgroundBooleantrue \| false
styleCSS styles for the componentObjectValid css properties (camelCased)

Note: Adding the contentIsImage prop to WinItem will not allow events to pass down to its children elements as this adds a layer on top of the image for hover effect to be visible. However, you can still set event handlers on the component itself by adding the eventHandlers prop. You can instead put image and non image in seperate WinItems

//The button will not receive click event
<WinItem contentIsImage>
	<img
		src='https://picsum.photos/1920/1080/'
		alt='imagesc'
		style={{ maxWidth: `100%` }}
	/>
	<button onClick={() => console.log('click')}> I am unclickable</button>
</WinItem>

WinGrid

This is a CSS grid component with the Windows10 grid hover effect. Use this layout to arrange and all the items inside this component should be either WinItem or HTML elements. If you want to pass your react component to this, wrap it inside WinItem. All the props mentioned below are optional

propsdescriptiontypeacceptable values
borderColorsColors that will applied as gradient on borders on mouse hoverArray of stringsAll color values supported by CSS
borderWidthBorder thickness in pixelsNumberAny positive number
classNameHTML class attribute equivalentString-
directionsdirections parameter specified in cursor-nearby-elements packageNumberPositive integers
eventHandlersEvent Handlers for the componentObjectkey should be valid React event names and value will be the event handler function
highlightRadiusThis value is like factor which multiplies with the original spotlight radius aka offset resulting in smaller or bigger radiusObjectValid css properties (camelCased)
offsetPointsoffsetPoints parameter specified in cursor-nearby-elements packageArray of floatsPositive float values (Refer the package for default value)
shouldSkipAngleshouldSkipAngle parameter specified in cursor-nearby-elements packageNumberPositive integers
styleCSS styles for the componentObjectValid css properties (camelCased)

💡 Tip: Use the offsetPoints and directions props to fine tune the performance of the WinGrid based on your layout

DEMO

Edit react-wingrid DEMO