diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dccc652..0929209 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -30,6 +30,8 @@ jobs: run: npm i - name: Build + env: + NODE_ENV: "production" run: npm run build - name: Deploy diff --git a/src/App.css b/src/App.css index b7db91a..373615d 100644 --- a/src/App.css +++ b/src/App.css @@ -13,39 +13,114 @@ body { .App-logo { animation: App-logo-spin infinite 20s linear; height: 50px; - } @keyframes App-logo-spin { - from { transform: rotate(0deg); } - to { transform: rotate(360deg); } + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } .App-header { - background-color: #222; - height: 150px; - padding: 20px; - color: white; - border-bottom: 3px solid #ffffff; display: flex; align-items: center; - justify-content: center; - gap: 1em; - flex-wrap: wrap; + justify-content: space-between; + padding: 10px; + background-color: #282c34; + color: #fff; +} + +.header-content { + display: flex; + align-items: center; +} + +.header-content h1 { + font-size: 24px; + margin: 0; +} + +.logo-title { + display: flex; + align-items: center; +} + +.App-logo { + width: 40px; + height: 40px; + margin-right: 10px; } .header-selector { - margin: 20px; - color: white; - background-color: #282c34; + background-color: #61dafb; + color: #282c34; + border: none; + padding: 10px; border-radius: 5px; - padding: 10px 20px; - font-size: 18px; - cursor: pointer; - border: 2px solid #61DAFB; + font-size: 1.2em; + outline: none; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); cursor: pointer; } +/* Media query for mobile responsiveness */ +@media screen and (max-width: 600px) { + .logo-title { + flex-direction: column; + align-items: center; + } + + .header-content h1 { + font-size: 18px; + } +} + +h1 { + font-size: 36px; + font-weight: normal; + margin: 0; + margin-top: 20px; + color: #61dafb; +} + +.info-style { + font-size: 24px; + font-weight: normal; + line-height: 1.5; + color: #ffffff; + margin: 20px; + max-width: 800px; + margin-left: auto; + margin-right: auto; + padding: 10px; + padding-bottom: 10px; +} + +.border-top { + padding-top: 20px; + border-top: 5px solid #61dafb; +} + +.border-bottom { + padding-bottom: 20px; + border-bottom: 5px solid #61dafb; +} + +.info-style span { + font-weight: bold; + color: #61dafb; +} + +@media screen and (max-width: 600px) { + .info-style { + font-size: 18px; + margin: 10px; + } +} + .button-style { margin: 5px; margin-top: 20px; @@ -55,10 +130,9 @@ body { padding: 10px 20px; font-size: 18px; cursor: pointer; - border: 2px solid #61DAFB; + border: 2px solid #61dafb; } - .active-button-style { margin: 5px; margin-top: 20px; @@ -68,22 +142,5 @@ body { padding: 10px 20px; font-size: 18px; cursor: pointer; - border: 2px solid #FBDA61; -} - -.info-style { - font-size: 24px; - font-weight: normal; - line-height: 1.5; - color: #FFFFFF; - margin: 20px; - max-width: 800px; - margin-left: auto; - margin-right: auto; -} - -.info-style span { - font-weight: bold; - color: #61DAFB; -} - + border: 2px solid #fbda61; +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index e27dc5e..144b685 100644 --- a/src/App.js +++ b/src/App.js @@ -9,11 +9,14 @@ import UseReducer from "./pages/UseReducer"; import UseRef from "./pages/UseRef"; import PageNotFound from "./pages/PageNotFound"; import UseState from "./pages/UseState"; -import AppHeader from "./components/AppHeader.tsx"; +import AppHeader from "./components/AppHeader"; export default function App() { + // Determine the correct base URL based on the environment (local or GitHub Pages) + const baseUrl = process.env.NODE_ENV === "production" ? "/react-hooks" : ""; + return ( - +
diff --git a/src/components/AppHeader.tsx b/src/components/AppHeader.jsx similarity index 86% rename from src/components/AppHeader.tsx rename to src/components/AppHeader.jsx index 1daef51..24bf6d4 100644 --- a/src/components/AppHeader.tsx +++ b/src/components/AppHeader.jsx @@ -18,9 +18,12 @@ export default function AppHeader() { return (
- logo -

React Hooks

- +
+
+ logo +

React Hooks

+
+
{ {/* Display the doubled number with the dynamically applied theme */}
Double the input: {doubleNumber}
+ +

+ When updating the theme, the background colors change quickly because + the number value is taken from memory. However, when + changing the number, the component takes a bit of time to re-render. +

); }; diff --git a/src/pages/UseState.jsx b/src/pages/UseState.jsx index 88c20df..6128a58 100644 --- a/src/pages/UseState.jsx +++ b/src/pages/UseState.jsx @@ -40,7 +40,8 @@ export default () => { return ( <> -

+

useState

+

useState is a crucial React hook for managing state in functional components, enabling dynamic and interactive user interfaces through simple initialization and updates.