Skip to content

Commit 5949ca1

Browse files
authored
Merge pull request #144 from w3bdesign/development
Fix CSS bug with page title
2 parents b82609e + f63eddf commit 5949ca1

File tree

9 files changed

+45
-44
lines changed

9 files changed

+45
-44
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Start the server with ```npm run dev ```
2424
- Connect to Woocommerce GraphQL API and list name, price and display image for products
2525
- Cart handling with createContext
2626
- Algolia search (work in progress)
27-
- Vercel useSWR for caching and graphql-request for data fetching (gradually being replaced with Apollo Client)
28-
- Apollo for GraphQL
27+
- Apollo Client with GraphQL
2928
- Animations with React-Spring
3029
- Shows loading spinner created with Styled Components while loading data and error message if data can not be loaded
3130
- Default frontpage products loaded through a predefined JSON file with getStaticProps for preloading

components/Category/Categories.component.jsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { v4 as uuidv4 } from 'uuid';
22

3-
import PageTitle from 'components/Header/PageTitle.component';
4-
5-
6-
73
/**
84
* Map over the categories and display them individually.
95
* Uses uuidv4 for unique key IDs
@@ -12,25 +8,17 @@ import PageTitle from 'components/Header/PageTitle.component';
128
const Categories = ({ categories }) => {
139
return (
1410
<>
15-
16-
<br/>
1711

18-
19-
20-
21-
22-
<PageTitle title="Kategorier" />
23-
12+
<section className="container mx-auto bg-white">
2413

25-
26-
<section className="bg-white">
27-
<div className="container flex flex-wrap items-center mx-auto">
14+
<div className="flex ">
15+
2816
{categories.map(({ name }) => (
2917
<div
3018
key={uuidv4()}
31-
className="flex flex-col p-6 md:w-1/3 xl:w-1/4"
19+
className="flex flex-col justify-around p-6 xs:w-1/2 md:w-1/3 xl:w-1/4"
3220
>
33-
<div className="flex items-center justify-center p-6 text-center border border-gray-300 rounded-lg shadow hover:shadow-outline">
21+
<div className="flex items-center justify-center w-full h-16 text-center border border-gray-300 rounded-lg shadow hover:shadow-outline">
3422
<p className="text-lg">{name}</p>
3523
</div>
3624
</div>

components/Footer/Footer.component.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const Footer = () => {
55
return (
66
<>
7-
<footer className="container top-0 p-6 py-1 mx-auto mt-0 text-center bg-white border border-gray-300 rounded-lg shadow">
7+
<footer className="container px-6 mx-auto text-center bg-white border border-gray-300 rounded-lg shadow">
88
<div className="p-6">Copyright &copy; {new Date().getFullYear()} Daniel</div>
99
</footer>
1010
</>

components/Header/PageTitle.component.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
const PageTitle = ({ title }) => {
1+
const PageTitle = ({ title, marginleft }) => {
22
return (
3-
<section className="py-4 bg-white">
4-
<div className="container flex flex-wrap items-center mx-auto">
5-
<div className="container py-2 mx-auto mt-16 text-center">
6-
<span className="text-xl font-bold tracking-wide text-gray-800 no-underline uppercase hover:no-underline">
3+
<>
4+
{marginleft ? (
5+
<section className="container pl-6 mx-auto mt-24 bg-white">
6+
<span className="py-2 text-xl font-bold tracking-wide text-left text-gray-800 no-underline uppercase hover:no-underline">
77
{title}
88
</span>
9-
</div>
10-
</div>
11-
</section>
9+
</section>
10+
) : (
11+
<section className="container pl-4 mx-auto mt-24 bg-white">
12+
<span className="py-2 text-xl font-bold tracking-wide text-left text-gray-800 no-underline uppercase hover:no-underline">
13+
{title}
14+
</span>
15+
</section>
16+
)}
17+
</>
1218
);
1319
};
1420

components/Product/IndexProducts.component.jsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Link from 'next/link';
22
import { v4 as uuidv4 } from 'uuid';
33

4-
import PageTitle from 'components/Header/PageTitle.component';
5-
64
/**
75
* Displays all of the products as long as length is defined.
86
* Does a map() over the props array and utilizes uuidv4 for unique key values.
@@ -11,18 +9,15 @@ import PageTitle from 'components/Header/PageTitle.component';
119
const IndexProducts = ({ products }) => {
1210
return (
1311
<>
14-
<br/>
15-
16-
17-
<PageTitle title="Produkter" />
18-
19-
20-
21-
<section className="bg-white">
12+
13+
<section className="container mx-auto bg-white">
14+
2215
<div
2316
id="product-container"
24-
className="container flex flex-wrap items-center mx-auto overflow-hidden"
17+
className="flex flex-wrap items-center"
2518
>
19+
20+
2621
{products ? (
2722
products.map(
2823
({
@@ -46,8 +41,8 @@ const IndexProducts = ({ products }) => {
4641
<a>
4742
<img
4843
id="product-image"
49-
// className="object-cover w-full h-64 transition duration-500 ease-in-out transform hover:grow hover:shadow-lg hover:scale-105"
50-
className="w-64 transition duration-500 ease-in-out transform hover:grow hover:shadow-lg hover:scale-105"
44+
className="transition duration-500 ease-in-out transform hover:grow hover:shadow-lg hover:scale-105"
45+
//className="w-64 transition duration-500 ease-in-out transform hover:grow hover:shadow-lg hover:scale-105"
5146
src={image.sourceUrl}
5247
/>
5348
</a>

pages/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Hero from 'components/Index/Hero.component';
22
import IndexProducts from 'components/Product/IndexProducts.component';
3+
import PageTitle from 'components/Header/PageTitle.component';
4+
35
import client from 'utils/apollo/ApolloClient.js';
46

57
import { FETCH_ALL_PRODUCTS_QUERY } from 'utils/const/GQL_QUERIES';
@@ -14,6 +16,7 @@ const HomePage = ({ products }) => {
1416
<>
1517

1618
<Hero/>
19+
<PageTitle title="Produkter" />
1720
{products && <IndexProducts products={products} />}
1821
</>
1922
);

pages/kategorier.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Categories from 'components/Category/Categories.component';
22
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component';
3+
import PageTitle from 'components/Header/PageTitle.component';
4+
35
import client from 'utils/apollo/ApolloClient.js';
46

57
import { FETCH_ALL_CATEGORIES_QUERY } from 'utils/const/GQL_QUERIES';
@@ -12,6 +14,8 @@ const CategoryPage = ({ categories }) => {
1214

1315
return (
1416
<>
17+
<PageTitle title="Kategorier" />
18+
1519
{categories && <Categories categories={categories} />}
1620

1721
{!categories && !error && (

pages/produkter.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import IndexProducts from 'components/Product/IndexProducts.component';
22
import LoadingSpinner from 'components/LoadingSpinner/LoadingSpinner.component';
3+
import PageTitle from 'components/Header/PageTitle.component';
34

45
import { FETCH_ALL_PRODUCTS_QUERY } from 'utils/const/GQL_QUERIES';
6+
57
import client from 'utils/apollo/ApolloClient.js';
68

79
/**
@@ -15,7 +17,11 @@ const Produkter = ({ products }) => {
1517

1618
return (
1719
<>
18-
{products && <IndexProducts products={products} />}
20+
<PageTitle title="Produkter" marginleft="true"/>
21+
22+
{
23+
products && <IndexProducts products={products} />
24+
}
1925

2026
{!products && !error && (
2127
<div className="h-64 mt-8 text-2xl text-center">

styles/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
}
2525

2626
#product-container {
27-
max-width: 1100px;
27+
/* max-width: 1000px;*/
2828
}
2929

3030
/* Fix for annoying CSS bug with NavBar moving slightly on front page only */
3131
@media only screen and (min-width: 769px) {
3232
#navbar-div {
33-
margin-left: 350px;
33+
margin-left: 330px;
3434
}
3535
}
3636

0 commit comments

Comments
 (0)