Skip to content

Commit 61d0709

Browse files
committed
example & readme updated
1 parent 9590a37 commit 61d0709

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
`React Jsx Templating` will give you templating syntax like Angular `*ngIf`
88

9-
**_Live Example: https://codesandbox.io/s/j312l1m2x9_**
9+
***Live Example: [Open in Codesandbox](https://codesandbox.io/s/j312l1m2x9)***
1010

1111
## Install
1212

example/src/App.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ function App() {
66
return (
77
<div>
88
<section>
9-
<header>If else</header>
9+
<h2>If-Else Example</h2>
1010
<IfElse />
1111
</section>
1212

1313
<section>
14-
<header>Switch Case</header>
14+
<h2>Switch-Case Example</h2>
1515
<SwitchCase />
1616
</section>
1717
</div>

example/src/components/IfElse.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22

33
import { Div, P, Button, Br, Span } from 'react-jsx-templating';
4-
import MySomeComponent from './MySomeComponent';
4+
import MySomeComponent from './Helper/MySomeComponent';
55

66
function IfElse() {
77
const [show, setShow] = useState(true);
@@ -14,17 +14,15 @@ function IfElse() {
1414
<MySomeComponent $if={show} $else={() => <P>Yay! It works</P>}>
1515
Welcome here
1616
</MySomeComponent>
17-
<Button $if={showToggler} onClick={() => setShow(v => !v)}>
18-
Toogle
19-
</Button>
20-
<Div></Div>
21-
<Br $if={showToggler} />
22-
<Br $if={showToggler} />
2317
<Button onClick={() => setShowToggler(v => !v)}>
2418
<Span $if={!showToggler} $else={<Span>Hide Toggler</Span>}>
2519
Show Toggler
2620
</Span>
2721
</Button>
22+
<Br $if={showToggler} />
23+
<Button $if={showToggler} onClick={() => setShow(v => !v)}>
24+
Toogle Language
25+
</Button>
2826
</Div>
2927
);
3028
}

example/src/components/SwitchCase.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ function SwitchCase() {
1010
value={animal}
1111
onChange={e => setAnimal(e.target.value)}
1212
/>
13+
<br />
14+
<br />
1315
<Div $if={animal} $else={() => <div>Please type!! </div>}>
14-
<Div $switch={animal}>
16+
<Div $switch={animal.trim().toLowerCase()}>
1517
<div $case={'dog'}>woof-woof 🐕</div>
1618
<div $case={'cat'}>meows meows 🐈</div>
17-
<div $default>Ops!! No Match! </div>
19+
<div $default>Ops!! No Match with `{`${animal}`} ` </div>
1820
</Div>
1921
</Div>
2022
</div>

example/src/index.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
body {
2-
margin: 0;
2+
margin: 18px;
33
padding: 0;
44
font-family: sans-serif;
55
}
66

77
.App {
88
margin-top: 18px;
99
font-family: sans-serif;
10-
text-align: center;
10+
/* text-align: center; */
1111
}

0 commit comments

Comments
 (0)