Skip to content

Commit 483af1d

Browse files
committed
refactor: Pico v2 react class-less login
1 parent 2ae36ff commit 483af1d

3 files changed

Lines changed: 18 additions & 29 deletions

File tree

v2-react-classless-login/public/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<meta name="color-scheme" content="light dark" />
77
<title>React Class-less login • Pico CSS</title>
8+
<meta
9+
name="description"
10+
content="A minimal, class-less login page in React, with a custom primary color."
11+
/>
812
</head>
913
<body>
1014
<noscript>You need to enable JavaScript to run this app.</noscript>

v2-react-classless-login/src/App.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import React from "react";
2-
import useMinHeight from "./useMinHeight";
1+
import React, { useRef, useEffect } from "react";
32
import mainStyles from "./main.scss";
43

54
const App = () => {
6-
useMinHeight();
5+
const mainRef = useRef();
6+
useEffect(() => {
7+
const setMinHeight = () => {
8+
if (!mainRef.current) return;
9+
mainRef.current.style.minHeight = `${window.innerHeight}px`;
10+
};
11+
setMinHeight();
12+
window.addEventListener("resize", setMinHeight);
13+
return () => {
14+
window.removeEventListener("resize", setMinHeight);
15+
};
16+
}, []);
717

818
return (
9-
<main>
19+
<main ref={mainRef}>
1020
<h1>Sign in</h1>
1121
<form>
1222
<input

v2-react-classless-login/src/useMinHeight.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)