Skip to content

Commit bb210df

Browse files
committed
chore: Update react example
1 parent 81d42d6 commit bb210df

File tree

4 files changed

+97
-14
lines changed

4 files changed

+97
-14
lines changed

tools/test-builds/vite-react-17-wrapper/src/App.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import PopoverBody from "./components/dropdown/PopoverBody";
66
import SampleTrigger from "./components/dropdown/SampleTrigger";
77
import SpanExample from "./components/SpanExample";
88
import ButtonExample from "./components/ButtonExample";
9+
import LinkExample from "./components/LinkExample";
910

1011
export default function App() {
1112
return (
1213
<>
1314
<h1>Vite React</h1>
14-
<ButtonExample />
15-
<SpanExample />
16-
<hr/>
1715
<Popover>
1816
<PopoverTrigger>
1917
<SampleTrigger id="sample-trigger" title="Sample Trigger"/>
@@ -25,6 +23,10 @@ export default function App() {
2523
</div>
2624
</PopoverBody>
2725
</Popover>
26+
<hr/>
27+
<ButtonExample />
28+
<LinkExample />
29+
<SpanExample />
2830
</>
2931
);
3032
}

tools/test-builds/vite-react-17-wrapper/src/components/ButtonExample.tsx

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,59 @@ const ButtonExample = () => {
44
const [clickCount, updateClickCount] = React.useState(0);
55

66
return (
7-
<div className={"example-container"}>
8-
<h2>Buttons</h2>
9-
<div>
10-
<p><strong>Click count: { clickCount } </strong></p>
11-
<p>Button with a click event handler, added via `onclick` ={'>'}
12-
<button id="button-with-onclick" onClick={() => { updateClickCount(clickCount + 1)}}> Button </button>
7+
<>
8+
<div className={"example-container"}>
9+
<h2>Buttons</h2>
10+
<div>
11+
<p><strong>Click count: { clickCount } </strong></p>
12+
<p>Button with a click event handler, added via `onclick` ={'> '}
13+
<button id="button-with-onclick" onClick={() => { updateClickCount(clickCount + 1)}}> Button </button>
14+
</p>
15+
<p>Button with no handlers ={'> '}
16+
<button id="do-nothing-button">Do nothing</button>
17+
</p>
18+
</div>
19+
<div>
20+
<p>Button with listener + span child ={'> '}
21+
<button id="button-with-listener-and-span-child">
22+
<span id="span-inside-button-with-listener" onClick={() => { updateClickCount(clickCount + 1)}}> Button </span>
23+
</button>
24+
</p>
25+
26+
<p>Dead button + span child ={'> '}
27+
<button id="dead-button-with-span-child">
28+
<span id="span-inside-dead-button">Dead button</span>
29+
</button>
30+
</p>
31+
</div>
32+
</div>
33+
<div className={"example-container"}>
34+
<h2>Buttons and forms</h2>
35+
<p>Button with a form ancestor
36+
<form id="form-with-button-child">
37+
<input type="checkbox" id="bar1" name="foo" value="bar1" checked/>
38+
<label htmlFor="bar1">bar</label>
39+
<button id="button-with-form-ancestor">Button w/ form ancestor</button>
40+
</form>
1341
</p>
14-
<p>Button with no handlers ={'>'}
15-
<button id="do-nothing-button">Do nothing</button>
42+
43+
<p>Button with a related form
44+
<form id="form-with-related-button">
45+
<input type="checkbox" id="bar2" name="foo" value="bar2" checked/>
46+
<label htmlFor="bar2">bar</label>
47+
</form>
48+
<button id="button-with-related-form" form="form-with-related-button">Button w/ related form</button>
49+
</p>
50+
51+
<p>Button with an invalid form
52+
<form id="form-with-no-valid-button">
53+
<input type="checkbox" id="bar3" name="foo" value="bar3" checked/>
54+
<label htmlFor="bar3">bar</label>
55+
<button id="button-with-invalid-form" form="does-not-exist">Button w/ non-existent form</button>
56+
</form>
1657
</p>
1758
</div>
18-
</div>
59+
</>
1960
)
2061
}
2162

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from "react";
2+
3+
const LinkExample = () => {
4+
const [clickCount, updateClickCount] = React.useState(0);
5+
6+
return (
7+
<>
8+
<div className={"example-container"}>
9+
<h2>Links</h2>
10+
<div>
11+
<p><strong>Click count: { clickCount } </strong></p>
12+
<p>Link with a click event handler ={'> '}
13+
<a id="test-link-with-listener" onClick={() => { updateClickCount(clickCount + 1)}}>Link</a>
14+
</p>
15+
16+
<p>Link with href ={'> '}
17+
<a id="test-link-with-href" href="https://www.example.com">Go to Example.com</a>
18+
</p>
19+
20+
<p>Dead link ={'> '}
21+
<a id="dead-link">Link</a>
22+
</p>
23+
24+
<p>Link with a click event handler + span child ={'> '}
25+
<a id="link-with-listener-and-span-child">
26+
<span id="span-inside-link-with-listener" onClick={() => { updateClickCount(clickCount + 1)}}>Link</span>
27+
</a>
28+
</p>
29+
<p>Dead link + span child ={'> '}
30+
<a id="dead-link-with-span-child">
31+
<span id="span-inside-dead-link">Link</span>
32+
</a>
33+
</p>
34+
</div>
35+
</div>
36+
</>
37+
)
38+
}
39+
40+
export default LinkExample

tools/test-builds/vite-react-17-wrapper/src/components/SpanExample.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const SpanExample = () => {
1010
<span id={"dummy-span-1"}></span>
1111
<span id={"dummy-span-2"}></span>
1212
<p><strong>Click count: { clickCount } </strong></p>
13-
<p>Span with a click event handler, added via `onclick` ={'>'}
13+
<p>Span with a click event handler ={'> '}
1414
<span id="span-with-onclick" onClick={() => { updateClickCount(clickCount + 1)}} className="non-interactive-element">Span </span>
1515
</p>
16-
<p>Span with no handlers ={'>'}
16+
<p>Span with no handlers ={'> '}
1717
<span id="do-nothing-span" className="non-interactive-element">Span</span>
1818
</p>
1919
</div>

0 commit comments

Comments
 (0)