-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.js
192 lines (172 loc) · 4.2 KB
/
Tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* eslint-disable no-unused-vars */
import React from "react";
import "./Tests.css";
import { Link } from "react-router-dom";
const monsterList = ["dragon", "gryphon", "dog"];
const compiledElement = React.createElement(
"main",
{
id: "contentttttt",
},
"Monsters undiscovered: ",
monsterList.length
);
const pageHeader = (
<header className="page-header">
ghfjghjfgh{'\n'}
<Link to='/cssmoduleexample'> Other Page </Link>
</header>
);
const message = {
className: 'message',
content: "Just ate at “Les Corbeaux En Colère”. Wonderful little venue!",
published: "2024-03-14T15:09:26.000Z",
author: {
avatarSrc: "https://sandpack-bundler.vercel.app/img/avatars/009.png",
avatarDescription: "Cartoon bear",
name: "Ben Thorn",
handle: "benjaminthorn",
},
};
const messageElement = (
<article style={{ background: "#555555" }} className="messageElement">
<header>
<img
src={message.author.avatarSrc}
alt={message.author.avatarDescription}
/>
<a href={message.author.handle}>{message.author.name}</a>
</header>
<p>{message.content}</p>
<footer>
Posted <time>{message.published}</time>
</footer>
</article>
);
function ContactCard({ name, job, email }) {
return (
<li className="contact-card">
<h2 className="name-header">{name}</h2>
<dl>
<dt>Job</dt>
<dd>{job}</dd>
<dt>Email</dt>
<dd>{email}</dd>
</dl>
</li>
);
}
const contactData = [
{
id: "sunitakumar0",
name: "Sunita Kumar",
job: "Electrical Engineer",
email: "sunita.kumar@acme.co",
},
{
id: "hendersonsterling1",
name: "Henderson G. Sterling II",
job: "Receptionist",
email: "henderson-the-second@acme.co",
},
{
id: "aoikobayashi2",
name: "Aoi Kobayashi",
job: "President",
email: "kobayashi.aoi@acme.co",
},
{
id: "thesniffer3",
name: "The Sniffer",
job: "Kitty Cat",
email: "sniffsniff@acme.co",
},
];
const ContactCards = (
// <ul>
// <ContactCard
// name="Sunita Kumar"
// job="Electrical Engineer"
// email="sunita.kumar@acme.co"
// />
// <ContactCard
// name="Henderson G. Sterling II"
// job="Receptionist"
// email="henderson-the-second@acme.co"
// />
// <ContactCard
// name="Aoi Kobayashi"
// job="President"
// email="kobayashi.aoi@acme.co"
// />
// <ContactCard
// name="The Sniffer"
// job="Kitty Cat"
// email="sniffsniff@acme.co"
// />
// </ul>
<ContactListMaker />
);
// this is more efficient, it iterates through the data array and enters the info for you
// by mapping the info of each item onto the slots in a contactcard
function ContactListMaker() {
const elements = contactData.map((item) => (
<ContactCard key={item.id} name={item.name} job={item.job} email={item.email} />
));
return <ul>{elements}</ul>;
}
// you can also do this if there's a repeating string or something
// the `` and the ${} will replace the text 'item.id' with the actual id
// {data.map((item) => (
// <Avatar
// src={`/img/avatars/${item.id}.png`}
// alt={item.alt}
// />
// ))}
function ButtonMaker({ color, children }) {
return (
<button
style={{
border: "2px solid",
color: color,
borderColor: color,
background: "white",
borderRadius: 4,
padding: 16,
margin: 8,
}}
onClick={() => (window.alert("A"))}
>
{children}
</button>
);
}
const Buttons = (
<div>
<ButtonMaker color="red">Cancel</ButtonMaker>
<ButtonMaker color="black">Confirm</ButtonMaker>
</div>
);
// the return statement can only return one item
// instead of putting everything inside a div, you can use a fragment which won't mess up formatting stuff
// function FragmentExample() {
// return (
// <>
// <h1>Welcome to my homepage!</h1>
// <p>Don't forget to sign the guestbook!</p>
// </>
// );
// }
function Tests() {
return (
<div className="tests">
{pageHeader}
{compiledElement}
{messageElement}
{ContactCards}
{Buttons}
{/* <FragmentExample /> */}
</div>
);
}
export default Tests;