Skip to content

Commit b2e26ce

Browse files
update readme screenshot and examples
1 parent a4c1a17 commit b2e26ce

7 files changed

Lines changed: 56 additions & 35 deletions

File tree

README.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Intro
2+
3+
![screen example](documentation/rcv/static/screen-example.png)
4+
5+
React Component to help with development of other react components.
6+
* Just a component, no build system: works with your setup seamlessly.
7+
* See your components at once in the different states.
8+
* Zoom-in into a single component for debug.
9+
* User defined theme switching for multi brand/theme development.
10+
111
# Installation
212

313
```
@@ -6,9 +16,6 @@ npm install react-component-viewer --save-dev
616

717
# React Component Viewer
818

9-
Is a React component to preview and develop your components.
10-
Use it in your CRA created app as a demo app.
11-
1219
```typescript
1320
import * as React from 'react';
1421

@@ -25,35 +32,45 @@ widgets
2532
.registerAsGrid('Links', 300, linksDemo)
2633
.registerAsTwoColumnTable('Forms', formsDemo)
2734
.registerAsTwoColumnTable('Buttons', buttonsDemo)
28-
.registerSingle('Single Screen', profileScreenDemo)
29-
.registerAsMiniApp('Single Screen mini app', '/app', profileScreenDemo);
35+
.registerAsRows('Inputs', inputsDemo);
3036

3137
const layouts = new Registry('layouts');
32-
layouts
33-
.registerSingle('Side by Side', sideBySideDemo);
34-
35-
export function App() {
36-
return (
37-
<ComponentViewer registries={[widgets, layouts]}/>
38-
);
38+
const endToEnd = new Registry('end to end');
39+
40+
export class App extends React.Component {
41+
render() {
42+
return (
43+
<ComponentViewer
44+
registries={[widgets, layouts, endToEnd]}
45+
dropDown={{
46+
label: 'Brand',
47+
items: [
48+
{label: 'Brand-A', hotKey: 'Alt 1'},
49+
{label: 'B-Brand', hotKey: 'Alt 2'}
50+
],
51+
onSelect: this.onBrandSelect
52+
}}
53+
/>
54+
);
55+
}
56+
57+
private onBrandSelect(brand: string) {
58+
// ...
59+
}
3960
}
4061
```
4162

42-
It will work with your build system, the language of your choice and style processing.
43-
44-
![screen example](documentation/rcv/static/screen-example.png)
45-
4663
# Demo functions
4764

4865
Demo must be defined in a function that accepts `Registry`. Function should register components to display.
4966

5067
```typescript
5168
export function buttonsDemo(registry: Registry) {
5269
registry
53-
.add('enabled', () => <Button label="click me" onClick={onClick}/>,
70+
.add('primary', () => <Button primary label="click me" onClick={onClick}/>,
5471
`long description
5572
multiline markdown`)
56-
.add('disabled', () => <Button label="click me" enabled={false} onClick={onClick}/>)
73+
.add('secondary', () => <Button label="click me" onClick={onClick}/>);
5774
}
5875
```
5976

-7.05 KB
Loading

src/App.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ widgets
1616
.registerAsGrid('Links', 300, linksDemo)
1717
.registerAsTwoColumnTable('Forms', formsDemo)
1818
.registerAsTwoColumnTable('Buttons', buttonsDemo)
19-
.registerAsRows('Inputs', inputsDemo)
20-
.registerAsTabs('Long Content', longContentDemo)
21-
.registerSingle('Single Screen', profileScreenDemo)
22-
.registerAsMiniApp('Single Screen mini app', '/app', profileScreenDemo);
19+
.registerAsRows('Inputs', inputsDemo);
2320

2421
const layouts = new Registry('layouts');
2522
layouts
2623
.registerSingle('Side by Side', sideBySideDemo);
2724

25+
const endToEnd = new Registry('end to end');
26+
endToEnd.registerAsTabs('Long Content', longContentDemo)
27+
.registerSingle('Single Screen', profileScreenDemo)
28+
.registerAsMiniApp('Single Screen mini app', '/app', profileScreenDemo);
29+
2830
export class App extends React.Component {
2931
render() {
3032
return (
3133
<ComponentViewer
32-
registries={[widgets, layouts]}
34+
registries={[widgets, layouts, endToEnd]}
3335
dropDown={{
3436
label: 'Brand',
3537
items: [

src/demo-components/Button.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
.button {
22
padding: 8px;
33
border: 1px solid #ccc;
4+
border-radius: 4px;
5+
}
6+
7+
.button.primary {
8+
background-color: #618be1;
9+
color: #fafafa;
410
}

src/demo-components/Button.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import * as React from 'react';
33
import './Button.css';
44

55
export interface Props {
6+
primary?: boolean;
67
label: string;
78
onClick: () => void;
89
}
910

10-
export function Button({label, onClick}: Props) {
11+
export function Button({label, primary, onClick}: Props) {
12+
const className = 'button' + (primary ? ' primary' : '');
13+
1114
return (
12-
<div className="button" onClick={onClick}>
15+
<div className={className} onClick={onClick}>
1316
{label}
1417
</div>
1518
);

src/demos/buttons.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,8 @@ function onClick() {
99

1010
export function buttonsDemo(registry: Registry) {
1111
registry
12-
.description(`primary buttons are used to define the main action`)
13-
.add('enabled', () => <Button label="click me" onClick={onClick}/>,
12+
.add('primary', () => <Button primary label="click me" onClick={onClick}/>,
1413
`long description
1514
multiline markdown`)
16-
.add('disabled', () => <Button label="click me" onClick={onClick}/>)
17-
.description(`
18-
secondary buttons are for extra information and miscellaneous actions
19-
`)
20-
.add('enabled 2', () => <Button label="click me" onClick={onClick}/>,
21-
`long description
22-
multiline markdown`)
23-
.add('disabled 2', () => <Button label="click me" onClick={onClick}/>);
15+
.add('secondary', () => <Button label="click me" onClick={onClick}/>);
2416
}

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"jsdoc-format": true,
2222
"jsx-no-lambda": false,
2323
"jsx-no-multiline-js": false,
24+
"jsx-boolean-value": [true, "never"],
2425
"label-position": true,
2526
"max-line-length": [ true, 120 ],
2627
"member-ordering": [

0 commit comments

Comments
 (0)