0.0.1 • Published 3 years ago

lvd-fluentui-propertysheet v0.0.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
3 years ago

LVD-FluentUi-PropertySheet

A ReactJS property sheet component built using the FluentUI library. What this basically does is display key-value data, with some additional features:

  • allow value rendering as a <code> fragment;
  • supports value rendering as a link, by providing an url property;
  • supports rendering an action icon button next to the value, by providing an action code and icon;
  • supports custom label rendering;
  • supports configurable label alignment;
  • supports custom value rendering.

Installation

npm install --save lvd-fluentui-propertysheet

Demo

The demo directory contains a compiled and ready-to-run example. Just open up the index.html file.

Basic Usage

import React from 'react';
import { PropertySheet, PropertySheetLabelAlignments } from 'lvd-fluentui-propertysheet';

class PropertySheetSamplePage extends React.Component {
	constructor(props) {
		super(props);
	}

	render() {
		return (
			<div className="lvd-property-sheet-demo-container">
				<PropertySheet 
					items={this._getSampleItems()}
					labelAlignment={PropertySheetLabelAlignments.right}
					onValueItemActionInvoked={this._handleValueItemActionInvoked}
				/>
			</div>
		);
	}

	_getSampleItems() {
		return [
			{ label: 'Test 1', value: 'Value 1' },
			{ label: 'Test 2', value: 'Value 2', formatAsCode: true },
			{ label: 'Test 3', value: 'Value 3', url: 'http://alexboia.net' },
			{ label: 'Test 4', value: 'Value 4', action: { code: 'Edit', icon: 'Edit' } },
			{ label: 'Test 5', value: 'Value 5' }
		];
	}
}

You can find a full working example here.

Styling

You can either directly include the dist/style.css into your html web page or use the @import directive inside your stylesheet if building using webpack:

@import '~lvd-fluentui-propertysheet/dist/style.css';

Also see the component itself.

Building

To build the demo application:

npm run build-app

To build the library:

npm run build-dist

To build both in one sitting:

npm run build

Customization Options

WhatProp NameTypeNotes
Set itemsitemsProperty Sheet Data Item ObjectSee below. Mandatory.
Set additional container css class nameclassNamestringDefaults to null.
Set additional inline css style propertiesstyleobjectKey-value plain javascript object. Defaults to {}.
Only show label fieldslabelOnlybooleanDefaults to false.
Change label alignmentlabelAlignmentPropertySheetLabelAlignmentsSee here for all supported values. Defaults to PropertySheetLabelAlignments.right.
Display underlines for values that are rendered as linksunderlineValueLinksbooleanDefaults to false.
Provide custom label rendereronRenderLabel(item: Property Sheet Data Item Object, itemIndex: number) => JSX.ElementDefaults to null.
Provide custom value rendereronRenderValue(item: Property Sheet Data Item Object, itemIndex: number) => JSX.ElementDefaults to null.

Property Sheet Data Item Object

Each item must be a plain javascript object with the following properties:

NameTypeNotes
labelstringDisplayable label. Mandatory.
valuestringDisplayable value. Optional.
formatAsCodebooleanRender this item as a code block. Optional. Defaults to false
urlstringRender this item as a link with this url. Optional. Defaults to null
actionProperty Sheet Data Item Action ObjectAction descriptor for when an action icon button needs to be rendered next to the raw value. See below. Optional. Defaults to null.

Property Sheet Data Item Action Object

Each item action descriptor must be a plain javascript object with the following properties:

NameTypeNotes
codestringAction code. Can be later used when listening for actions via onValueItemActionInvoked. Mandatory.
iconstringMust be a valid FluentUi icon name. Mandatory.

Events

EventProp NameArgumentsNotes
Item action invokedonValueItemActionInvoked(item: Property Sheet Data Item Object, itemIndex: number, event: React.MouseEvent)Triggered when the action button related to a value is clicked.

Changelog

Version 0.0.1

  • First tracked version.

Donate

I put some of my free time into developing and maintaining this plugin. If helped you in your projects and you are happy with it, you can...

ko-fi