@freddyfazbear1904/rnpkg 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/App.css ADDED
@@ -0,0 +1,184 @@
1
+ .counter {
2
+ font-size: 16px;
3
+ padding: 5px 10px;
4
+ border-radius: 5px;
5
+ color: var(--accent);
6
+ background: var(--accent-bg);
7
+ border: 2px solid transparent;
8
+ transition: border-color 0.3s;
9
+ margin-bottom: 24px;
10
+
11
+ &:hover {
12
+ border-color: var(--accent-border);
13
+ }
14
+ &:focus-visible {
15
+ outline: 2px solid var(--accent);
16
+ outline-offset: 2px;
17
+ }
18
+ }
19
+
20
+ .hero {
21
+ position: relative;
22
+
23
+ .base,
24
+ .framework,
25
+ .vite {
26
+ inset-inline: 0;
27
+ margin: 0 auto;
28
+ }
29
+
30
+ .base {
31
+ width: 170px;
32
+ position: relative;
33
+ z-index: 0;
34
+ }
35
+
36
+ .framework,
37
+ .vite {
38
+ position: absolute;
39
+ }
40
+
41
+ .framework {
42
+ z-index: 1;
43
+ top: 34px;
44
+ height: 28px;
45
+ transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
46
+ scale(1.4);
47
+ }
48
+
49
+ .vite {
50
+ z-index: 0;
51
+ top: 107px;
52
+ height: 26px;
53
+ width: auto;
54
+ transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
55
+ scale(0.8);
56
+ }
57
+ }
58
+
59
+ #center {
60
+ display: flex;
61
+ flex-direction: column;
62
+ gap: 25px;
63
+ place-content: center;
64
+ place-items: center;
65
+ flex-grow: 1;
66
+
67
+ @media (max-width: 1024px) {
68
+ padding: 32px 20px 24px;
69
+ gap: 18px;
70
+ }
71
+ }
72
+
73
+ #next-steps {
74
+ display: flex;
75
+ border-top: 1px solid var(--border);
76
+ text-align: left;
77
+
78
+ & > div {
79
+ flex: 1 1 0;
80
+ padding: 32px;
81
+ @media (max-width: 1024px) {
82
+ padding: 24px 20px;
83
+ }
84
+ }
85
+
86
+ .icon {
87
+ margin-bottom: 16px;
88
+ width: 22px;
89
+ height: 22px;
90
+ }
91
+
92
+ @media (max-width: 1024px) {
93
+ flex-direction: column;
94
+ text-align: center;
95
+ }
96
+ }
97
+
98
+ #docs {
99
+ border-right: 1px solid var(--border);
100
+
101
+ @media (max-width: 1024px) {
102
+ border-right: none;
103
+ border-bottom: 1px solid var(--border);
104
+ }
105
+ }
106
+
107
+ #next-steps ul {
108
+ list-style: none;
109
+ padding: 0;
110
+ display: flex;
111
+ gap: 8px;
112
+ margin: 32px 0 0;
113
+
114
+ .logo {
115
+ height: 18px;
116
+ }
117
+
118
+ a {
119
+ color: var(--text-h);
120
+ font-size: 16px;
121
+ border-radius: 6px;
122
+ background: var(--social-bg);
123
+ display: flex;
124
+ padding: 6px 12px;
125
+ align-items: center;
126
+ gap: 8px;
127
+ text-decoration: none;
128
+ transition: box-shadow 0.3s;
129
+
130
+ &:hover {
131
+ box-shadow: var(--shadow);
132
+ }
133
+ .button-icon {
134
+ height: 18px;
135
+ width: 18px;
136
+ }
137
+ }
138
+
139
+ @media (max-width: 1024px) {
140
+ margin-top: 20px;
141
+ flex-wrap: wrap;
142
+ justify-content: center;
143
+
144
+ li {
145
+ flex: 1 1 calc(50% - 8px);
146
+ }
147
+
148
+ a {
149
+ width: 100%;
150
+ justify-content: center;
151
+ box-sizing: border-box;
152
+ }
153
+ }
154
+ }
155
+
156
+ #spacer {
157
+ height: 88px;
158
+ border-top: 1px solid var(--border);
159
+ @media (max-width: 1024px) {
160
+ height: 48px;
161
+ }
162
+ }
163
+
164
+ .ticks {
165
+ position: relative;
166
+ width: 100%;
167
+
168
+ &::before,
169
+ &::after {
170
+ content: '';
171
+ position: absolute;
172
+ top: -4.5px;
173
+ border: 5px solid transparent;
174
+ }
175
+
176
+ &::before {
177
+ left: 0;
178
+ border-left-color: var(--border);
179
+ }
180
+ &::after {
181
+ right: 0;
182
+ border-right-color: var(--border);
183
+ }
184
+ }
package/App.jsx ADDED
@@ -0,0 +1,121 @@
1
+ import { useState } from 'react'
2
+ import reactLogo from './assets/react.svg'
3
+ import viteLogo from './assets/vite.svg'
4
+ import heroImg from './assets/hero.png'
5
+ import './App.css'
6
+
7
+ function App() {
8
+ const [count, setCount] = useState(0)
9
+
10
+ return (
11
+ <>
12
+ <section id="center">
13
+ <div className="hero">
14
+ <img src={heroImg} className="base" width="170" height="179" alt="" />
15
+ <img src={reactLogo} className="framework" alt="React logo" />
16
+ <img src={viteLogo} className="vite" alt="Vite logo" />
17
+ </div>
18
+ <div>
19
+ <h1>Get started</h1>
20
+ <p>
21
+ Edit <code>src/App.jsx</code> and save to test <code>HMR</code>
22
+ </p>
23
+ </div>
24
+ <button
25
+ className="counter"
26
+ onClick={() => setCount((count) => count + 1)}
27
+ >
28
+ Count is {count}
29
+ </button>
30
+ </section>
31
+
32
+ <div className="ticks"></div>
33
+
34
+ <section id="next-steps">
35
+ <div id="docs">
36
+ <svg className="icon" role="presentation" aria-hidden="true">
37
+ <use href="/icons.svg#documentation-icon"></use>
38
+ </svg>
39
+ <h2>Documentation</h2>
40
+ <p>Your questions, answered</p>
41
+ <ul>
42
+ <li>
43
+ <a href="https://vite.dev/" target="_blank">
44
+ <img className="logo" src={viteLogo} alt="" />
45
+ Explore Vite
46
+ </a>
47
+ </li>
48
+ <li>
49
+ <a href="https://react.dev/" target="_blank">
50
+ <img className="button-icon" src={reactLogo} alt="" />
51
+ Learn more
52
+ </a>
53
+ </li>
54
+ </ul>
55
+ </div>
56
+ <div id="social">
57
+ <svg className="icon" role="presentation" aria-hidden="true">
58
+ <use href="/icons.svg#social-icon"></use>
59
+ </svg>
60
+ <h2>Connect with us</h2>
61
+ <p>Join the Vite community</p>
62
+ <ul>
63
+ <li>
64
+ <a href="https://github.com/vitejs/vite" target="_blank">
65
+ <svg
66
+ className="button-icon"
67
+ role="presentation"
68
+ aria-hidden="true"
69
+ >
70
+ <use href="/icons.svg#github-icon"></use>
71
+ </svg>
72
+ GitHub
73
+ </a>
74
+ </li>
75
+ <li>
76
+ <a href="https://chat.vite.dev/" target="_blank">
77
+ <svg
78
+ className="button-icon"
79
+ role="presentation"
80
+ aria-hidden="true"
81
+ >
82
+ <use href="/icons.svg#discord-icon"></use>
83
+ </svg>
84
+ Discord
85
+ </a>
86
+ </li>
87
+ <li>
88
+ <a href="https://x.com/vite_js" target="_blank">
89
+ <svg
90
+ className="button-icon"
91
+ role="presentation"
92
+ aria-hidden="true"
93
+ >
94
+ <use href="/icons.svg#x-icon"></use>
95
+ </svg>
96
+ X.com
97
+ </a>
98
+ </li>
99
+ <li>
100
+ <a href="https://bsky.app/profile/vite.dev" target="_blank">
101
+ <svg
102
+ className="button-icon"
103
+ role="presentation"
104
+ aria-hidden="true"
105
+ >
106
+ <use href="/icons.svg#bluesky-icon"></use>
107
+ </svg>
108
+ Bluesky
109
+ </a>
110
+ </li>
111
+ </ul>
112
+ </div>
113
+ </section>
114
+
115
+ <div className="ticks"></div>
116
+ <section id="spacer"></section>
117
+ </>
118
+ )
119
+ }
120
+
121
+ export default App
package/ass1.jsx ADDED
@@ -0,0 +1,124 @@
1
+ import React, { useState } from "react";
2
+ import ReactDOM from "react-dom/client";
3
+
4
+ function App() {
5
+ // State for form fields
6
+ const [name, setName] = useState("");
7
+ const [email, setEmail] = useState("");
8
+ const [gender, setGender] = useState("");
9
+ const [hobbies, setHobbies] = useState([]);
10
+ const [department, setDepartment] = useState("");
11
+ const [file, setFile] = useState(null);
12
+
13
+ // Handle checkbox (multiple values)
14
+ const handleHobbies = (e) => {
15
+ const value = e.target.value;
16
+
17
+ if (hobbies.includes(value)) {
18
+ setHobbies(hobbies.filter((h) => h !== value));
19
+ } else {
20
+ setHobbies([...hobbies, value]);
21
+ }
22
+ };
23
+
24
+ // Form submit
25
+ const handleSubmit = (e) => {
26
+ e.preventDefault();
27
+
28
+ // Validation
29
+ if (!name || !email || !gender || hobbies.length === 0 || !department || !file) {
30
+ alert("Please fill all fields 😤");
31
+ return;
32
+ }
33
+
34
+ if (!email.includes("@")) {
35
+ alert("Invalid email");
36
+ return;
37
+ }
38
+
39
+ // Success
40
+ alert("Form submitted successfully ✅");
41
+ // Reset form
42
+ setName("");
43
+ setEmail("");
44
+ setGender("");
45
+ setHobbies([]);
46
+ setDepartment("");
47
+ setFile(null);
48
+ };
49
+
50
+ return (
51
+ <div>
52
+ <h1>Student Registration Form</h1>
53
+ <form onSubmit={handleSubmit}>
54
+ {/* Name */}
55
+ <input
56
+ type="text"
57
+ placeholder="Enter Name"
58
+ value={name}
59
+ onChange={(e) => setName(e.target.value)}
60
+ />
61
+ <br /><br />
62
+
63
+ {/* Email */}
64
+ <input
65
+ type="email"
66
+ placeholder="Enter Email"
67
+ value={email}
68
+ onChange={(e) => setEmail(e.target.value)}
69
+ />
70
+ <br /><br />
71
+
72
+ {/* Gender (Radio) */}
73
+ <label>Gender:</label><br />
74
+ <input
75
+ type="radio"
76
+ value="Male"
77
+ checked={gender === "Male"}
78
+ onChange={(e) => setGender(e.target.value)}
79
+ /> Male
80
+
81
+ <input
82
+ type="radio"
83
+ value="Female"
84
+ checked={gender === "Female"}
85
+ onChange={(e) => setGender(e.target.value)}
86
+ /> Female
87
+ <br /><br />
88
+
89
+ {/* Hobbies (Checkbox) */}
90
+ <label>Hobbies:</label><br />
91
+ <input type="checkbox" value="Sports" onChange={handleHobbies} /> Sports
92
+ <input type="checkbox" value="Music" onChange={handleHobbies} /> Music
93
+ <input type="checkbox" value="Reading" onChange={handleHobbies} /> Reading
94
+ <br /><br />
95
+
96
+ {/* Dropdown */}
97
+ <label>Department:</label><br />
98
+ <select
99
+ value={department}
100
+ onChange={(e) => setDepartment(e.target.value)}
101
+ >
102
+ <option value="">Select Department</option>
103
+ <option value="CSE">CSE</option>
104
+ <option value="ECE">ECE</option>
105
+ <option value="ME">ME</option>
106
+ </select>
107
+ <br /><br />
108
+
109
+ {/* File Upload */}
110
+ <label>ID Proof:</label><br />
111
+ <input
112
+ type="file"
113
+ onChange={(e) => setFile(e.target.files[0])}
114
+ />
115
+ <br /><br />
116
+ {/* Submit */}
117
+ <button type="submit">Register</button>
118
+ </form>
119
+ </div>
120
+ );
121
+ }
122
+ // Render
123
+ const root = ReactDOM.createRoot(document.getElementById("root3"));
124
+ root.render(<App />);
package/ass2.jsx ADDED
@@ -0,0 +1,89 @@
1
+ import React, { useState } from "react";
2
+ import ReactDOM from "react-dom/client";
3
+
4
+ function App() {
5
+ // Form state
6
+ const [name, setName] = useState("");
7
+ const [email, setEmail] = useState("");
8
+ const [department, setDepartment] = useState("");
9
+ const [workshop, setWorkshop] = useState("");
10
+
11
+ // Submitted data
12
+ const [submittedData, setSubmittedData] = useState(null);
13
+ // Handle submit
14
+ const handleSubmit = (e) => {
15
+ e.preventDefault(); // prevent page refresh
16
+ // Store submitted values
17
+ setSubmittedData({
18
+ name,
19
+ email,
20
+ department,
21
+ workshop
22
+ });
23
+ // Clear form (optional)
24
+ setName("");
25
+ setEmail("");
26
+ setDepartment("");
27
+ setWorkshop("");
28
+ };
29
+
30
+ return (
31
+ <div>
32
+ <h1>Workshop Registration</h1>
33
+ <form onSubmit={handleSubmit}>
34
+ {/* Name */}
35
+ <input
36
+ type="text"
37
+ placeholder="Enter Name"
38
+ value={name}
39
+ onChange={(e) => setName(e.target.value)}
40
+ />
41
+ <br /><br />
42
+ {/* Email */}
43
+ <input
44
+ type="email"
45
+ placeholder="Enter Email"
46
+ value={email}
47
+ onChange={(e) => setEmail(e.target.value)}
48
+ />
49
+ <br /><br />
50
+ {/* Department */}
51
+ <input
52
+ type="text"
53
+ placeholder="Enter Department"
54
+ value={department}
55
+ onChange={(e) => setDepartment(e.target.value)}
56
+ />
57
+ <br /><br />
58
+ {/* Workshop Dropdown */}
59
+ <select
60
+ value={workshop}
61
+ onChange={(e) => setWorkshop(e.target.value)}
62
+ >
63
+ <option value="">Select Workshop</option>
64
+ <option value="AI">AI</option>
65
+ <option value="Web Dev">Web Development</option>
66
+ <option value="Cybersecurity">Cybersecurity</option>
67
+ </select>
68
+ <br /><br />
69
+ {/* Submit */}
70
+ <button type="submit">Submit</button>
71
+ </form>
72
+
73
+ {/* DISPLAY DATA */}
74
+ {submittedData && (
75
+ <div>
76
+ <h2>Submitted Details</h2>
77
+ <p><b>Name:</b> {submittedData.name}</p>
78
+ <p><b>Email:</b> {submittedData.email}</p>
79
+ <p><b>Department:</b> {submittedData.department}</p>
80
+ <p><b>Workshop:</b> {submittedData.workshop}</p>
81
+ </div>
82
+ )}
83
+ </div>
84
+ );
85
+ }
86
+
87
+ // Render
88
+ const root = ReactDOM.createRoot(document.getElementById("root4"));
89
+ root.render(<App />);
package/ass3.jsx ADDED
@@ -0,0 +1,113 @@
1
+ import React, { useState } from "react";
2
+ import ReactDOM from "react-dom/client";
3
+
4
+ /* =========================
5
+ CourseItem
6
+ ========================= */
7
+ function CourseItem({ course }) {
8
+ return (
9
+ <div style={{ border: "1px solid black", margin: "10px", padding: "10px" }}>
10
+ <h3>{course.courseName}</h3>
11
+ <p><b>Instructor:</b> {course.instructor}</p>
12
+ <p><b>Credits:</b> {course.credits}</p>
13
+ </div>
14
+ );
15
+ }
16
+
17
+ /* =========================
18
+ CourseList
19
+ ========================= */
20
+ function CourseList({ courses }) {
21
+ return (
22
+ <div>
23
+ <h2>Course List</h2>
24
+
25
+ {courses.map((course) => (
26
+ <CourseItem key={course.id} course={course} />
27
+ ))}
28
+ </div>
29
+ );
30
+ }
31
+
32
+ /* =========================
33
+ App (MAIN LOGIC)
34
+ ========================= */
35
+ function App() {
36
+ // Initial courses
37
+ const [courses, setCourses] = useState([
38
+ { id: 1, courseName: "Machine Learning", instructor: "Dr. Kumar", credits: 4 },
39
+ { id: 2, courseName: "Computer Vision", instructor: "Dr. Anita", credits: 3 },
40
+ { id: 3, courseName: "Natural Language Processing", instructor: "Dr. Ravi", credits: 3 }
41
+ ]);
42
+
43
+ // Form inputs
44
+ const [courseName, setCourseName] = useState("");
45
+ const [instructor, setInstructor] = useState("");
46
+ const [credits, setCredits] = useState("");
47
+
48
+ // Add course function
49
+ const addCourse = (e) => {
50
+ e.preventDefault();
51
+
52
+ if (!courseName || !instructor || !credits) {
53
+ alert("Fill all fields 😤");
54
+ return;
55
+ }
56
+
57
+ const newCourse = {
58
+ id: courses.length + 1,
59
+ courseName,
60
+ instructor,
61
+ credits
62
+ };
63
+
64
+ // Update state
65
+ setCourses([...courses, newCourse]);
66
+
67
+ // Clear inputs
68
+ setCourseName("");
69
+ setInstructor("");
70
+ setCredits("");
71
+ };
72
+
73
+ return (
74
+ <div>
75
+ <h1>University Course Dashboard</h1>
76
+
77
+ {/* FORM TO ADD COURSE */}
78
+ <form onSubmit={addCourse}>
79
+ <input
80
+ type="text"
81
+ placeholder="Course Name"
82
+ value={courseName}
83
+ onChange={(e) => setCourseName(e.target.value)}
84
+ />
85
+
86
+ <input
87
+ type="text"
88
+ placeholder="Instructor"
89
+ value={instructor}
90
+ onChange={(e) => setInstructor(e.target.value)}
91
+ />
92
+
93
+ <input
94
+ type="number"
95
+ placeholder="Credits"
96
+ value={credits}
97
+ onChange={(e) => setCredits(e.target.value)}
98
+ />
99
+
100
+ <button type="submit">Add Course</button>
101
+ </form>
102
+
103
+ {/* DISPLAY COURSES */}
104
+ <CourseList courses={courses} />
105
+ </div>
106
+ );
107
+ }
108
+
109
+ /* =========================
110
+ RENDER
111
+ ========================= */
112
+ const root = ReactDOM.createRoot(document.getElementById("root5"));
113
+ root.render(<App />);
package/index.css ADDED
@@ -0,0 +1,111 @@
1
+ :root {
2
+ --text: #6b6375;
3
+ --text-h: #08060d;
4
+ --bg: #fff;
5
+ --border: #e5e4e7;
6
+ --code-bg: #f4f3ec;
7
+ --accent: #aa3bff;
8
+ --accent-bg: rgba(170, 59, 255, 0.1);
9
+ --accent-border: rgba(170, 59, 255, 0.5);
10
+ --social-bg: rgba(244, 243, 236, 0.5);
11
+ --shadow:
12
+ rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
13
+
14
+ --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
15
+ --heading: system-ui, 'Segoe UI', Roboto, sans-serif;
16
+ --mono: ui-monospace, Consolas, monospace;
17
+
18
+ font: 18px/145% var(--sans);
19
+ letter-spacing: 0.18px;
20
+ color-scheme: light dark;
21
+ color: var(--text);
22
+ background: var(--bg);
23
+ font-synthesis: none;
24
+ text-rendering: optimizeLegibility;
25
+ -webkit-font-smoothing: antialiased;
26
+ -moz-osx-font-smoothing: grayscale;
27
+
28
+ @media (max-width: 1024px) {
29
+ font-size: 16px;
30
+ }
31
+ }
32
+
33
+ @media (prefers-color-scheme: dark) {
34
+ :root {
35
+ --text: #9ca3af;
36
+ --text-h: #f3f4f6;
37
+ --bg: #16171d;
38
+ --border: #2e303a;
39
+ --code-bg: #1f2028;
40
+ --accent: #c084fc;
41
+ --accent-bg: rgba(192, 132, 252, 0.15);
42
+ --accent-border: rgba(192, 132, 252, 0.5);
43
+ --social-bg: rgba(47, 48, 58, 0.5);
44
+ --shadow:
45
+ rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
46
+ }
47
+
48
+ #social .button-icon {
49
+ filter: invert(1) brightness(2);
50
+ }
51
+ }
52
+
53
+ body {
54
+ margin: 0;
55
+ }
56
+
57
+ #root {
58
+ width: 1126px;
59
+ max-width: 100%;
60
+ margin: 0 auto;
61
+ text-align: center;
62
+ border-inline: 1px solid var(--border);
63
+ min-height: 100svh;
64
+ display: flex;
65
+ flex-direction: column;
66
+ box-sizing: border-box;
67
+ }
68
+
69
+ h1,
70
+ h2 {
71
+ font-family: var(--heading);
72
+ font-weight: 500;
73
+ color: var(--text-h);
74
+ }
75
+
76
+ h1 {
77
+ font-size: 56px;
78
+ letter-spacing: -1.68px;
79
+ margin: 32px 0;
80
+ @media (max-width: 1024px) {
81
+ font-size: 36px;
82
+ margin: 20px 0;
83
+ }
84
+ }
85
+ h2 {
86
+ font-size: 24px;
87
+ line-height: 118%;
88
+ letter-spacing: -0.24px;
89
+ margin: 0 0 8px;
90
+ @media (max-width: 1024px) {
91
+ font-size: 20px;
92
+ }
93
+ }
94
+ p {
95
+ margin: 0;
96
+ }
97
+
98
+ code,
99
+ .counter {
100
+ font-family: var(--mono);
101
+ display: inline-flex;
102
+ border-radius: 4px;
103
+ color: var(--text-h);
104
+ }
105
+
106
+ code {
107
+ font-size: 15px;
108
+ line-height: 135%;
109
+ padding: 4px 8px;
110
+ background: var(--code-bg);
111
+ }
package/index.html ADDED
@@ -0,0 +1,84 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>pat3prac</title>
8
+ <style>
9
+ body{
10
+ background-color: teal;
11
+ color: white;
12
+ }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <hr>
17
+ <div id="root"></div>
18
+ <hr>
19
+ <div id="root2"></div>
20
+ <hr>
21
+ <button onclick="hello('John', 'Doe')">HI!!!</button>
22
+ <script>
23
+ class Car{
24
+ constructor(name){
25
+ this.name = name;
26
+ }
27
+ }
28
+ hello = (var1, var2) => {
29
+ alert("Hello! " + var1 + " " + var2);
30
+ }
31
+ const mycar = new Car("TOYOTA");
32
+ document.write(mycar.name);
33
+ </script>
34
+ <!-- Destructuring -->
35
+ <script>
36
+ function calculate(a,b){
37
+ add = a+b;
38
+ sub = a-b;
39
+ mul = a*b;
40
+ div = a/b;
41
+ return [add, sub, mul, div];
42
+ }
43
+ const [a,b,c,d] = calculate(10,7);
44
+ document.write("<br>" + a);
45
+ document.write("<br>" + b);
46
+ document.write("<br>" + c);
47
+ document.write("<br>" + d);
48
+ </script>
49
+ <hr>
50
+ <script>
51
+ const arr1 = [1,2,3];
52
+ const arr2 = [4,5,6];
53
+ const arrcomb = [...arr1,...arr2];
54
+ const [one,two,...rest] = arrcomb;
55
+ document.write("<br>" + one+"<br>"+rest+"<br>");
56
+ document.write(arrcomb);
57
+ </script>
58
+ <hr>
59
+ <script type="module">
60
+ import per from "/src/person.js";
61
+
62
+ const { name, age } = per();
63
+ document.getElementById("root").innerHTML += name;
64
+ </script>
65
+ <h1>HELLO</h1>
66
+ <hr>
67
+ <hr>
68
+ <h1>Assignment 1</h1>
69
+ <div id="root3"></div>
70
+ <hr>
71
+ <hr>
72
+ <h1>Assignment 2</h1>
73
+ <div id="root4"></div>
74
+ <hr>
75
+ <hr>
76
+ <h1>Assignment 3</h1>
77
+ <div id="root5"></div>
78
+ <script type="module" src="/src/main.jsx"></script>
79
+ <script type="module" src="/src/test.jsx"></script>
80
+ <script type="module" src="/src/ass1.jsx"></script>
81
+ <script type="module" src="/src/ass2.jsx"></script>
82
+ <script type="module" src="/src/ass3.jsx"></script>
83
+ </body>
84
+ </html>
package/main.jsx ADDED
@@ -0,0 +1,264 @@
1
+ import React, {
2
+ useState,
3
+ useEffect,
4
+ useRef,
5
+ useReducer,
6
+ useCallback,
7
+ useMemo
8
+ } from "react";
9
+ import ReactDOM from "react-dom/client";
10
+
11
+
12
+
13
+
14
+ /* =========================
15
+ 2. CLASS COMPONENT + LIFECYCLE
16
+ ========================= */
17
+
18
+ class Car extends React.Component {
19
+ constructor(props) {
20
+ super(props);
21
+ this.state = { color: "Red" };
22
+ }
23
+
24
+ componentDidMount() {
25
+ console.log("Mounted 🚗");
26
+ }
27
+
28
+ componentDidUpdate() {
29
+ console.log("Updated 🔄");
30
+ }
31
+
32
+ componentWillUnmount() {
33
+ console.log("Removed 💀");
34
+ }
35
+
36
+ render() {
37
+ return (
38
+ <div>
39
+ <h3>{this.state.color} Car</h3>
40
+ <button onClick={() => this.setState({ color: "Blue" })}>
41
+ Change Color
42
+ </button>
43
+ </div>
44
+ );
45
+ }
46
+ }
47
+
48
+ /* =========================
49
+ 3. CHILD → PARENT (LIFTING STATE)
50
+ ========================= */
51
+
52
+ function Child({ sendData }) {
53
+ return (
54
+ <button onClick={() => sendData("Data from Child")}>
55
+ Send Data
56
+ </button>
57
+ );
58
+ }
59
+
60
+ /* =========================
61
+ 4. REDUCER
62
+ ========================= */
63
+
64
+ const reducer = (state, action) => {
65
+ switch (action.type) {
66
+ case "inc":
67
+ return state + 1;
68
+ case "dec":
69
+ return state - 1;
70
+ default:
71
+ return state;
72
+ }
73
+ };
74
+
75
+ /* =========================
76
+ 5. MAIN APP
77
+ ========================= */
78
+
79
+ function App() {
80
+ /* =========================
81
+ STATE (useState)
82
+ ========================= */
83
+ const [count, setCount] = useState(0);
84
+ const [text, setText] = useState("");
85
+ const [message, setMessage] = useState("");
86
+
87
+ /* =========================
88
+ FORM STATE (Controlled)
89
+ ========================= */
90
+ const [name, setName] = useState("");
91
+ const [age, setAge] = useState("");
92
+
93
+ /* =========================
94
+ useRef
95
+ ========================= */
96
+ const inputRef = useRef();
97
+
98
+ /* =========================
99
+ useReducer
100
+ ========================= */
101
+ const [num, dispatch] = useReducer(reducer, 0);
102
+
103
+ /* =========================
104
+ useEffect
105
+ ========================= */
106
+ useEffect(() => {
107
+ console.log("App Loaded");
108
+ }, []);
109
+
110
+ useEffect(() => {
111
+ console.log("Count changed:", count);
112
+ }, [count]);
113
+
114
+ /* =========================
115
+ EVENT HANDLING
116
+ ========================= */
117
+ const handleClick = () => {
118
+ setCount(count + 1);
119
+ };
120
+
121
+ /* =========================
122
+ HANDLING EVENTS WITH PARAMS
123
+ ========================= */
124
+ const greet = (name) => {
125
+ alert("Hello " + name);
126
+ };
127
+
128
+ /* =========================
129
+ FORM SUBMIT + VALIDATION
130
+ ========================= */
131
+ const handleSubmit = (e) => {
132
+ e.preventDefault();
133
+
134
+ if (name === "" || age === "") {
135
+ alert("Fill all fields");
136
+ return;
137
+ }
138
+
139
+ alert(`Name: ${name}, Age: ${age}`);
140
+ setName("");
141
+ setAge("");
142
+ };
143
+
144
+ /* =========================
145
+ LIFTING STATE
146
+ ========================= */
147
+ const handleData = (data) => {
148
+ setMessage(data);
149
+ };
150
+
151
+ /* =========================
152
+ useCallback
153
+ ========================= */
154
+ const memoFunc = useCallback(() => {
155
+ console.log("Callback function");
156
+ }, []);
157
+
158
+ /* =========================
159
+ useMemo
160
+ ========================= */
161
+ const squared = useMemo(() => count * count, [count]);
162
+
163
+ /* =========================
164
+ LISTS + MAP
165
+ ========================= */
166
+ const items = ["React", "JSX", "Hooks"];
167
+
168
+ const isLoggedIn = true;
169
+
170
+ /* =========================
171
+ INLINE STYLE
172
+ ========================= */
173
+ const style = {
174
+ color: "blue",
175
+ border: "1px solid black",
176
+ padding: "5px"
177
+ };
178
+
179
+ return (
180
+ <div>
181
+ <h1>React Concepts Practice 🚀</h1>
182
+
183
+
184
+ {/* JSX EXPRESSION */}
185
+ <p>2 + 2 = {2 + 2}</p>
186
+
187
+ {/* EVENT HANDLING */}
188
+ <h2>Count: {count}</h2>
189
+ <button onClick={handleClick}>Increase</button>
190
+
191
+ {/* CONDITIONAL (TERNARY) */}
192
+ {isLoggedIn ? <p>Logged In</p> : <p>Logged Out</p>}
193
+
194
+ {/* LOGICAL AND */}
195
+ {count > 5 && <p>Count is greater than 5</p>}
196
+
197
+ {/* LIST + KEYS */}
198
+ <ul>
199
+ {items.map((item, index) => (
200
+ <li key={index}>{item}</li>
201
+ ))}
202
+ </ul>
203
+
204
+ {/* CONTROLLED INPUT */}
205
+ <input
206
+ value={text}
207
+ onChange={(e) => setText(e.target.value)}
208
+ />
209
+ <p>You typed: {text}</p>
210
+
211
+ {/* useRef */}
212
+ <input ref={inputRef} placeholder="Focus me" />
213
+ <button onClick={() => inputRef.current.focus()}>
214
+ Focus
215
+ </button>
216
+
217
+ {/* FORM */}
218
+ <form onSubmit={handleSubmit}>
219
+ <input
220
+ placeholder="Name"
221
+ value={name}
222
+ onChange={(e) => setName(e.target.value)}
223
+ />
224
+ <input
225
+ placeholder="Age"
226
+ value={age}
227
+ onChange={(e) => setAge(e.target.value)}
228
+ />
229
+ <button type="submit">Submit</button>
230
+ </form>
231
+
232
+ {/* CHILD → PARENT */}
233
+ <Child sendData={handleData} />
234
+ <p>{message}</p>
235
+
236
+ {/* useReducer */}
237
+ <h2>Reducer: {num}</h2>
238
+ <button onClick={() => dispatch({ type: "inc" })}>+</button>
239
+ <button onClick={() => dispatch({ type: "dec" })}>-</button>
240
+
241
+ {/* useMemo */}
242
+ <p>Square: {squared}</p>
243
+
244
+ {/* CLASS COMPONENT */}
245
+ <Car />
246
+
247
+ {/* useCallback */}
248
+ <button onClick={memoFunc}>Run Callback</button>
249
+
250
+ {/* STYLING */}
251
+ <p style={style}>Styled Text</p>
252
+
253
+ {/* EVENT WITH PARAM */}
254
+ <button onClick={() => greet("Arin")}>Greet</button>
255
+ </div>
256
+ );
257
+ }
258
+
259
+ /* =========================
260
+ RENDER
261
+ ========================= */
262
+
263
+ const root = ReactDOM.createRoot(document.getElementById("root"));
264
+ root.render(<App />);
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+
3
+ "name": "@freddyfazbear1904/rnpkg",
4
+ "version": "1.0.0",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "freddyfzbear19",
11
+ "license": "ISC",
12
+ "description": ""
13
+ }
package/person.js ADDED
@@ -0,0 +1,6 @@
1
+ const per = () => {
2
+ const name = "Arin";
3
+ const age = 20;
4
+ return { name, age };
5
+ };
6
+ export default per;
package/test.jsx ADDED
@@ -0,0 +1,159 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ // const myArray = [1,2,3,4,5];
4
+ // const myList = myArray.map((num) => <li key={num}>{num}</li>);
5
+ // const root = ReactDOM.createRoot(document.getElementById("root2"));
6
+ // root.render(myList);
7
+
8
+
9
+ // function Car(props) {
10
+ // return <h2>I am a {props.brand}!</h2>;
11
+ // }
12
+ // function Garage(){
13
+ // return(
14
+ // <>
15
+ // <p>Hello How are you?</p><br></br>
16
+ // <Car brand = "Toyota"/>
17
+ // </>
18
+ // )
19
+ // }
20
+
21
+ // class Car extends React.Component{
22
+ // constructor(){
23
+ // super();
24
+ // this.state = "red";
25
+ // }
26
+ // render(){
27
+ // return <h2>I am a {this.state} car!</h2>;
28
+ // }
29
+ // }
30
+
31
+
32
+ // function Car(props) {
33
+ // return <h2>I am a {props.brand}!</h2>;
34
+ // }
35
+ // function Garage(){
36
+ // const cars =
37
+ // [
38
+ // {id: 1, brand: "Toyota"},
39
+ // {id: 2, brand: "Honda"},
40
+ // {id: 3, brand: "Ford"}
41
+ // ];
42
+ // return(
43
+ // <>
44
+ // <p>WHo Live in Me Garage?</p>
45
+ // {cars.map((car) => car.brand==='Ford' && <Car key={car.id} brand={car.brand}/> )}
46
+ // </>
47
+ // )
48
+ // }
49
+
50
+
51
+
52
+ // function MyForm(){
53
+ // return(
54
+ // <div>
55
+ // <form>
56
+ // <label>Enter Your name:
57
+ // <input type="text" name="name"/>
58
+ // </label>
59
+ // <br></br>
60
+ // <label>Enter Your Password
61
+ // <input type="password"/>
62
+ // </label>
63
+ // <br></br>
64
+ // <label>What yo Feedback Cuh?
65
+ // <input type="text"/>
66
+ // </label>
67
+ // <button type="submit">Submit</button>
68
+ // </form>
69
+ // </div>
70
+ // );
71
+ // }
72
+
73
+ import { useState } from "react";
74
+ // function MyForm(){
75
+ // const [name,setName] = useState("");
76
+
77
+ // const handleSubmit = (e) => {
78
+ // e.preventDefault();
79
+ // alert("Form Submitted! Name: "+name);
80
+ // }
81
+ // return(
82
+ // <div>
83
+ // <form onSubmit={handleSubmit}>
84
+ // <input type = "text" value = {name} onChange={(e)=> setName(e.target.value)}></input>
85
+ // </form>
86
+ // </div>
87
+ // )
88
+ // }
89
+
90
+
91
+ // function MyForm(){
92
+ // const [nameInput, setNameInput] = useState("");
93
+ // const [ageInput, setAgeInput] = useState("");
94
+ // const handleSubmit = (e) =>
95
+ // {
96
+ // e.preventDefault(); // prevents page reload
97
+
98
+ // if (nameInput === "" || ageInput === "") {
99
+ // alert("All fields required 😤");
100
+ // return;
101
+ // }
102
+
103
+ // alert(`Hello ${nameInput}, age ${ageInput}`);
104
+ // document.getElementById("root2").innerHTML += `<p>Hello ${nameInput}, age ${ageInput}</p>`;
105
+ // };
106
+ // return(
107
+ // <form onSubmit={handleSubmit}>
108
+ // <h3>Fill Form</h3>
109
+
110
+ // <input
111
+ // type="text"
112
+ // placeholder="Enter name"
113
+ // value={nameInput}
114
+ // onChange={(e) => setNameInput(e.target.value)}
115
+ // />
116
+
117
+ // <br />
118
+
119
+ // <input
120
+ // type="number"
121
+ // placeholder="Enter age"
122
+ // value={ageInput}
123
+ // onChange={(e) => setAgeInput(e.target.value)}
124
+ // />
125
+
126
+ // <br />
127
+
128
+ // <button type="submit">Submit</button>
129
+ // </form>)
130
+ // }
131
+ class Car extends React.Component {
132
+ constructor() {
133
+ super();
134
+ this.state = { color: "Red" };
135
+ }
136
+
137
+ componentDidMount() {
138
+ console.log("Mounted 😤");
139
+ }
140
+
141
+ componentDidUpdate() {
142
+ console.log("Updated 😤");
143
+ }
144
+
145
+ changeColor = () => {
146
+ this.setState({ color: "Blue" });
147
+ };
148
+
149
+ render() {
150
+ return (
151
+ <div>
152
+ <h2>I am a {this.state.color} Car 🚗</h2>
153
+ <button onClick={this.changeColor}>Change Color</button>
154
+ </div>
155
+ );
156
+ }
157
+ }
158
+ const root = ReactDOM.createRoot(document.getElementById("root2"));
159
+ root.render(<Car />);