From b4500a5dbbd5b7e5c76d7f004c979df3297d4153 Mon Sep 17 00:00:00 2001 From: Aravind V V Date: Fri, 7 Jul 2023 17:55:40 +0530 Subject: [PATCH] Ui Updates - installed Tailwind - installed sass - added primary and secondary colors in tailwindconfig - colors in tailwindconfig can be altered to change the view - updated the ui to look better Note -------- (the app did not worked in giving results to me, so I couldnt see the Ui of modal) --- frontend/package.json | 4 + frontend/src/App.css | 0 frontend/src/{App.js => App.jsx} | 55 ++++++++------ frontend/src/App.scss | 35 +++++++++ frontend/src/components/PriceHistoryTable.jsx | 18 +++-- .../src/components/ProductDetailsPage.jsx | 2 +- frontend/src/components/SearchTextList.jsx | 12 ++- .../src/components/TrackedProductList.jsx | 43 ++++++----- frontend/src/index.css | 36 --------- frontend/src/index.js | 2 +- frontend/src/index.scss | 74 +++++++++++++++++++ frontend/tailwind.config.js | 17 +++++ 12 files changed, 209 insertions(+), 89 deletions(-) delete mode 100644 frontend/src/App.css rename frontend/src/{App.js => App.jsx} (64%) create mode 100644 frontend/src/App.scss delete mode 100644 frontend/src/index.css create mode 100644 frontend/src/index.scss create mode 100644 frontend/tailwind.config.js diff --git a/frontend/package.json b/frontend/package.json index 592be4a..5d3282e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,6 +18,7 @@ "react-modal": "^3.16.1", "react-router-dom": "^6.13.0", "react-scripts": "5.0.1", + "sass": "^1.63.6", "web-vitals": "^2.1.4" }, "scripts": { @@ -43,5 +44,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "tailwindcss": "^3.3.2" } } diff --git a/frontend/src/App.css b/frontend/src/App.css deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/App.js b/frontend/src/App.jsx similarity index 64% rename from frontend/src/App.js rename to frontend/src/App.jsx index 2b50294..e295546 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.jsx @@ -3,6 +3,7 @@ import SearchTextList from "./components/SearchTextList"; import PriceHistoryTable from "./components/PriceHistoryTable"; import axios from "axios"; import TrackedProductList from "./components/TrackedProductList"; +import "./App.scss"; const URL = "http://localhost:5000"; @@ -67,29 +68,39 @@ function App() { }; return ( -
-

Product Search Tool

-
- - +
+

Product Search Tool

+
+
+ +
+ + +
+ + + - - - - - {showPriceHistory && ( - - )} -
+ + {showPriceHistory && ( + + )} + + ); } diff --git a/frontend/src/App.scss b/frontend/src/App.scss new file mode 100644 index 0000000..feb0491 --- /dev/null +++ b/frontend/src/App.scss @@ -0,0 +1,35 @@ +.scrapper { + &__container { + @apply container p-5 m-auto; + } + &__header { + @apply flex justify-between items-center; + .title { + @apply text-primary; + } + } + + &__search { + @apply flex gap-4; + } +} +.title { + @apply text-3xl font-bold; +} + +.form__input { + @apply border-2 border-primary rounded-md p-2 relative; + label { + @apply absolute top-1/2 left-2 -translate-y-1/2 bg-white px-1 transition-all duration-200 ease-in-out pointer-events-none text-gray-500; + } + input { + @apply w-full focus:outline-none; + } + input:focus + label, + input:active + label { + @apply -translate-y-[160%] text-primary text-sm; + } +} +.product-list { + @apply flex flex-col gap-4; +} diff --git a/frontend/src/components/PriceHistoryTable.jsx b/frontend/src/components/PriceHistoryTable.jsx index 242c59b..adce76d 100644 --- a/frontend/src/components/PriceHistoryTable.jsx +++ b/frontend/src/components/PriceHistoryTable.jsx @@ -1,13 +1,13 @@ import React, { useState } from "react"; -import ModalComponent from './Modal'; +import ModalComponent from "./Modal"; import ProductDetailsPage from "./ProductDetailsPage"; function PriceHistoryTable({ priceHistory, onClose }) { const [isModalOpen, setIsModalOpen] = useState(false); - const [currentProduct, setCurrentProduct] = useState({}) + const [currentProduct, setCurrentProduct] = useState({}); const openModal = (product) => { - setCurrentProduct(product) + setCurrentProduct(product); setIsModalOpen(true); }; @@ -29,7 +29,7 @@ function PriceHistoryTable({ priceHistory, onClose }) { return (
-

Price History

+

Price History

@@ -47,10 +47,12 @@ function PriceHistoryTable({ priceHistory, onClose }) { return ( - + @@ -58,7 +60,9 @@ function PriceHistoryTable({ priceHistory, onClose }) { })}
{priceData.date} openModal(product)}>{product.name} + openModal(product)}>{product.name} + ${priceData.price} 0 ? { color: "red" } : { color: "green" }}> - {change >= 0 && "+" } + {change >= 0 && "+"} {change}%
- + { return (
-

{name}

+

{name}

Product

URL:{" "} diff --git a/frontend/src/components/SearchTextList.jsx b/frontend/src/components/SearchTextList.jsx index 6284b8d..877b9c4 100644 --- a/frontend/src/components/SearchTextList.jsx +++ b/frontend/src/components/SearchTextList.jsx @@ -1,13 +1,17 @@ -import React from 'react'; +import React from "react"; function SearchTextList({ searchTexts, onSearchTextClick }) { return (

All Products

-
    +
      {searchTexts.map((searchText, index) => ( -
    • onSearchTextClick(searchText)}> - +
    • onSearchTextClick(searchText)} + > +
    • ))}
    diff --git a/frontend/src/components/TrackedProductList.jsx b/frontend/src/components/TrackedProductList.jsx index c589998..34347eb 100644 --- a/frontend/src/components/TrackedProductList.jsx +++ b/frontend/src/components/TrackedProductList.jsx @@ -60,29 +60,36 @@ const TrackedProductList = () => { }; return ( -
    +

    Tracked Products

    -
      +
        {trackedProducts.map((product) => ( -
      • - {product.name}{" "} - handleToggleTrackedProduct(product.id)} - checked={product.tracked} - /> -
      • + ))}
      -
      -

      Add Tracked Product

      - - +
      +
      + + +
      +
      ); diff --git a/frontend/src/index.css b/frontend/src/index.css deleted file mode 100644 index 38c1ab9..0000000 --- a/frontend/src/index.css +++ /dev/null @@ -1,36 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", - "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", - monospace; -} - -.main { - padding: 5%; -} - -.row td { - align-items: center; - justify-content: center; - padding: 15px; -} - -th { - background-color: #f2f2f2; -} - -tr:nth-child(even) { - background-color: #f2f2f2; -} - -input { - margin-left: 10px; - margin-right: 10px; -} diff --git a/frontend/src/index.js b/frontend/src/index.js index 075f967..d8dcfeb 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -1,6 +1,6 @@ import React from "react"; import ReactDOM from "react-dom/client"; -import "./index.css"; +import "./index.scss"; import App from "./App"; import Modal from 'react-modal'; diff --git a/frontend/src/index.scss b/frontend/src/index.scss new file mode 100644 index 0000000..31ba084 --- /dev/null +++ b/frontend/src/index.scss @@ -0,0 +1,74 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; +@tailwind variants; + +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.main { + padding: 5%; +} + +.row td { + align-items: center; + justify-content: center; + padding: 15px; +} + +th { + background-color: #f2f2f2; +} + +tr:nth-child(even) { + background-color: #f2f2f2; +} + +h { + &1 { + //implies h1 + @apply text-3xl font-bold; + } + &2 { + //implies h2 + @apply text-xl font-bold text-primary-sublime; + } + &3 { + @apply text-base font-medium text-primary-sublime; + } +} +.btn { + @apply px-3 py-1 font-medium bg-primary text-white rounded-md hover:bg-primary-shade focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75; + &--chip { + @apply bg-secondary hover:bg-secondary-shade; + } +} +section { + @apply p-5 flex flex-col gap-6; +} +.input-button-wrapper { + @apply flex gap-4; +} +.section-wrapper { + @apply flex flex-col gap-4; +} +.tracked-products { + @apply flex flex-col gap-2; + &__item { + @apply bg-green-100 w-fit p-1 pl-3 pr-4 flex justify-between items-center gap-4 text-green-950; + & input[type="checkbox"] { + @apply accent-primary-sublime; + } + } +} diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js new file mode 100644 index 0000000..1d2d36e --- /dev/null +++ b/frontend/tailwind.config.js @@ -0,0 +1,17 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ["./src/**/*.{html,js}"], + theme: { + extend: { + colors: { + "primary": "#22c55e", + "primary-shade": "#16A34A", + "primary-sublime": "#21a03e", + "secondary": "#009688", + "secondary-shade": "#02766b" + } + }, + }, + plugins: [], +} +