login-signup-google 1.0.0 → 1.0.1

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.
@@ -0,0 +1,31 @@
1
+ import React, { useEffect } from "react";
2
+ export default function GoogleLogin({
3
+ clientId,
4
+ onSuccess
5
+ }) {
6
+ useEffect(() => {
7
+ if (!clientId) {
8
+ console.error("Google Client ID missing");
9
+ return;
10
+ }
11
+ const script = document.createElement("script");
12
+ script.src = "https://accounts.google.com/gsi/client";
13
+ script.async = true;
14
+ script.defer = true;
15
+ document.body.appendChild(script);
16
+ script.onload = () => {
17
+ window.google.accounts.id.initialize({
18
+ client_id: clientId,
19
+ callback: onSuccess
20
+ });
21
+ window.google.accounts.id.renderButton(document.getElementById("googleBtn"), {
22
+ theme: "outline",
23
+ size: "large",
24
+ width: 300
25
+ });
26
+ };
27
+ }, [clientId, onSuccess]);
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ id: "googleBtn"
30
+ });
31
+ }
package/dist/Login.js ADDED
@@ -0,0 +1,59 @@
1
+ import React, { useState } from "react";
2
+ export default function Login({
3
+ onLogin
4
+ }) {
5
+ const [email, setEmail] = useState("");
6
+ const [password, setPassword] = useState("");
7
+ const handleSubmit = e => {
8
+ e.preventDefault();
9
+ if (!email || !password) {
10
+ alert("Please enter email and password");
11
+ return;
12
+ }
13
+
14
+ // send data to parent app
15
+ onLogin && onLogin({
16
+ email,
17
+ password
18
+ });
19
+ };
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ style: styles.box
22
+ }, /*#__PURE__*/React.createElement("h2", null, "Login"), /*#__PURE__*/React.createElement("form", {
23
+ onSubmit: handleSubmit
24
+ }, /*#__PURE__*/React.createElement("input", {
25
+ style: styles.input,
26
+ type: "email",
27
+ placeholder: "Email",
28
+ value: email,
29
+ onChange: e => setEmail(e.target.value)
30
+ }), /*#__PURE__*/React.createElement("input", {
31
+ style: styles.input,
32
+ type: "password",
33
+ placeholder: "Password",
34
+ value: password,
35
+ onChange: e => setPassword(e.target.value)
36
+ }), /*#__PURE__*/React.createElement("button", {
37
+ style: styles.button,
38
+ type: "submit"
39
+ }, "Login")));
40
+ }
41
+ const styles = {
42
+ box: {
43
+ width: 300,
44
+ padding: 20,
45
+ border: "1px solid #ddd",
46
+ borderRadius: 8,
47
+ marginBottom: 20
48
+ },
49
+ input: {
50
+ width: "100%",
51
+ padding: 8,
52
+ marginBottom: 10
53
+ },
54
+ button: {
55
+ width: "100%",
56
+ padding: 10,
57
+ cursor: "pointer"
58
+ }
59
+ };
package/dist/Signup.js ADDED
@@ -0,0 +1,57 @@
1
+ import React, { useState } from "react";
2
+ export default function Signup({
3
+ onSignup
4
+ }) {
5
+ const [email, setEmail] = useState("");
6
+ const [password, setPassword] = useState("");
7
+ const handleSubmit = e => {
8
+ e.preventDefault();
9
+ if (!email || !password) {
10
+ alert("Please enter email and password");
11
+ return;
12
+ }
13
+ onSignup && onSignup({
14
+ email,
15
+ password
16
+ });
17
+ };
18
+ return /*#__PURE__*/React.createElement("div", {
19
+ style: styles.box
20
+ }, /*#__PURE__*/React.createElement("h2", null, "Signup"), /*#__PURE__*/React.createElement("form", {
21
+ onSubmit: handleSubmit
22
+ }, /*#__PURE__*/React.createElement("input", {
23
+ style: styles.input,
24
+ type: "email",
25
+ placeholder: "Email",
26
+ value: email,
27
+ onChange: e => setEmail(e.target.value)
28
+ }), /*#__PURE__*/React.createElement("input", {
29
+ style: styles.input,
30
+ type: "password",
31
+ placeholder: "Password",
32
+ value: password,
33
+ onChange: e => setPassword(e.target.value)
34
+ }), /*#__PURE__*/React.createElement("button", {
35
+ style: styles.button,
36
+ type: "submit"
37
+ }, "Signup")));
38
+ }
39
+ const styles = {
40
+ box: {
41
+ width: 300,
42
+ padding: 20,
43
+ border: "1px solid #ddd",
44
+ borderRadius: 8,
45
+ marginBottom: 20
46
+ },
47
+ input: {
48
+ width: "100%",
49
+ padding: 8,
50
+ marginBottom: 10
51
+ },
52
+ button: {
53
+ width: "100%",
54
+ padding: 10,
55
+ cursor: "pointer"
56
+ }
57
+ };
@@ -1,4 +1,3 @@
1
- // src/index.js
2
- export { default as Login } from "./Login";
3
- export { default as Signup } from "./Signup";
4
- export { default as GoogleLogin } from "./GoogleLogin";
1
+ export { default as Login } from "./Login";
2
+ export { default as Signup } from "./Signup";
3
+ export { default as GoogleLogin } from "./GoogleLogin";
package/package.json CHANGED
@@ -1,13 +1,32 @@
1
1
  {
2
2
  "name": "login-signup-google",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Reusable React Login, Signup and Google Login components",
5
- "main": "src/index.js",
6
- "keywords": ["react", "login", "signup", "google-auth"],
7
- "author": "Your Name",
5
+ "main": "dist/index.js",
6
+
7
+ "keywords": [
8
+ "react",
9
+ "login",
10
+ "signup",
11
+ "google-auth"
12
+ ],
13
+
14
+ "author": "sowjanya",
8
15
  "license": "MIT",
9
16
 
10
17
  "peerDependencies": {
11
18
  "react": ">=18"
19
+ },
20
+
21
+ "scripts": {
22
+ "build": "babel src --out-dir dist --extensions .js,.jsx"
23
+ },
24
+
25
+ "files": ["dist"],
26
+
27
+ "devDependencies": {
28
+ "@babel/cli": "^7.28.6",
29
+ "@babel/core": "^7.28.6",
30
+ "@babel/preset-react": "^7.28.5"
12
31
  }
13
32
  }
@@ -1,26 +0,0 @@
1
- // src/GoogleLogin.jsx
2
- import { useEffect } from "react";
3
-
4
- export default function GoogleLogin({ clientId, onSuccess }) {
5
- useEffect(() => {
6
- const script = document.createElement("script");
7
- script.src = "https://accounts.google.com/gsi/client";
8
- script.async = true;
9
- script.defer = true;
10
- document.body.appendChild(script);
11
-
12
- script.onload = () => {
13
- window.google.accounts.id.initialize({
14
- client_id: clientId,
15
- callback: onSuccess,
16
- });
17
-
18
- window.google.accounts.id.renderButton(
19
- document.getElementById("googleBtn"),
20
- { theme: "outline", size: "large" }
21
- );
22
- };
23
- }, [clientId, onSuccess]);
24
-
25
- return <div id="googleBtn"></div>;
26
- }
package/src/Login.jsx DELETED
@@ -1,12 +0,0 @@
1
- // src/Login.jsx
2
- export default function Login({ onLogin }) {
3
- return (
4
- <div>
5
- <h3>Login</h3>
6
- <input placeholder="Email" />
7
- <input type="password" placeholder="Password" />
8
- <button onClick={onLogin}>Login</button>
9
- </div>
10
- );
11
- }
12
-
package/src/Signup.jsx DELETED
@@ -1,12 +0,0 @@
1
- // src/Signup.jsx
2
- export default function Signup({ onSignup }) {
3
- return (
4
- <div>
5
- <h3>Signup</h3>
6
- <input placeholder="Email" />
7
- <input type="password" placeholder="Password" />
8
- <button onClick={onSignup}>Signup</button>
9
- </div>
10
- );
11
- }
12
-