Skip to content

Commit f09c957

Browse files
authored
Merge pull request #1002 from w3bdesign/1001-refactor-and-improve-code-quality
1001 refactor and improve code quality
2 parents d2cf783 + ffa8ae9 commit f09c957

File tree

97 files changed

+2449
-2020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2449
-2020
lines changed

.babelrc

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

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NEXT_PUBLIC_GRAPHQL_URL="https://wordpress.url.com/graphql"
22
NEXT_PUBLIC_ALGOLIA_INDEX_NAME= "algolia"
33
NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL="https://res.cloudinary.com/placeholder-337_utsb7h.jpg"
4-
NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL="https://res.cloudinary.com/placeholder-616-616_beecp5.jpg"
4+
NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL="https://via.placeholder.com/600"
55
NEXT_PUBLIC_ALGOLIA_APP_ID = "changeme"
66
NEXT_PUBLIC_ALGOLIA_PUBLIC_API_KEY = "changeme"
77
NODE_ENV="development"

.eslintrc.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"extends": ["next/core-web-vitals", "eslint:recommended"],
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"rules": {
6+
"@next/next/no-img-element": "off",
7+
"no-useless-escape": "off",
8+
"@typescript-eslint/no-unused-vars": 1
9+
},
10+
"globals": { "JSX": true },
11+
"env": {
12+
"browser": true,
13+
"es6": true
14+
}
315
}

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
---
1+
* * *
2+
23
name: Bug report
34
about: Create a report to help us improve
45
title: ''
56
labels: ''
67
assignees: ''
78

8-
---
9+
* * *
910

1011
**Describe the bug**
1112
A clear and concise description of what the bug is.
@@ -24,15 +25,17 @@ A clear and concise description of what you expected to happen.
2425
If applicable, add screenshots to help explain your problem.
2526

2627
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
28+
29+
- OS: [e.g. iOS]
30+
- Browser [e.g. chrome, safari]
31+
- Version [e.g. 22]
3032

3133
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
34+
35+
- Device: [e.g. iPhone6]
36+
- OS: [e.g. iOS8.1]
37+
- Browser [e.g. stock browser, safari]
38+
- Version [e.g. 22]
3639

3740
**Additional context**
3841
Add any other context about the problem here.

.github/workflows/playwright.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: windows-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 18
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npx playwright test
22+
env:
23+
CI: true
24+
NEXT_PUBLIC_GRAPHQL_URL: ${{ secrets.NEXT_PUBLIC_GRAPHQL_URL }}
25+
- uses: actions/upload-artifact@v3
26+
if: always()
27+
with:
28+
name: playwright-report
29+
path: playwright-report/
30+
retention-days: 30

.gitignore

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
1-
# See https://help.github.com/ignore-files/ for more about ignoring files.
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
44
/node_modules
5-
node_modules
6-
.next
5+
/.pnp
6+
.pnp.js
77

88
# testing
99
/coverage
1010

11+
# next.js
12+
/.next/
13+
/out/
14+
1115
# production
1216
/build
1317

1418
# misc
1519
.DS_Store
16-
.env
17-
.env.local
18-
.env.development.local
19-
.env.test.local
20-
.env.production.local
20+
*.pem
2121

22+
# debug
2223
npm-debug.log*
2324
yarn-debug.log*
2425
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
.env
31+
32+
# vercel
33+
.vercel
34+
35+
# typescript
36+
*.tsbuildinfo
37+
next-env.d.ts
38+
/test-results/
39+
/playwright-report/
40+
/playwright/.cache/

CODE_OF_CONDUCT.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

@@ -68,9 +68,9 @@ members of the project's leadership.
6868
## Attribution
6969

7070
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
71+
available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
7272

7373
[homepage]: https://www.contributor-covenant.org
7474

7575
For answers to common questions about this code of conduct, see
76-
https://www.contributor-covenant.org/faq
76+
<https://www.contributor-covenant.org/faq>

CONTRIBUTING.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Please note we have a code of conduct, please follow it in all your interactions
77

88
## Pull Request Process
99

10-
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11-
build.
12-
2. Update the README.md with details of changes to the interface, this includes new environment
13-
variables, exposed ports, useful file locations and container parameters.
14-
3. Increase the version numbers in any examples files and the README.md to the new version that this
15-
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16-
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17-
do not have permission to do that, you may request the second reviewer to merge it for you.
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, exposed ports, useful file locations and container parameters.
14+
3. Increase the version numbers in any examples files and the README.md to the new version that this
15+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17+
do not have permission to do that, you may request the second reviewer to merge it for you.
1818

1919
## Code of Conduct
2020

@@ -32,22 +32,22 @@ orientation.
3232
Examples of behavior that contributes to creating a positive environment
3333
include:
3434

35-
* Using welcoming and inclusive language
36-
* Being respectful of differing viewpoints and experiences
37-
* Gracefully accepting constructive criticism
38-
* Focusing on what is best for the community
39-
* Showing empathy towards other community members
35+
- Using welcoming and inclusive language
36+
- Being respectful of differing viewpoints and experiences
37+
- Gracefully accepting constructive criticism
38+
- Focusing on what is best for the community
39+
- Showing empathy towards other community members
4040

4141
Examples of unacceptable behavior by participants include:
4242

43-
* The use of sexualized language or imagery and unwelcome sexual attention or
44-
advances
45-
* Trolling, insulting/derogatory comments, and personal or political attacks
46-
* Public or private harassment
47-
* Publishing others' private information, such as a physical or electronic
48-
address, without explicit permission
49-
* Other conduct which could reasonably be considered inappropriate in a
50-
professional setting
43+
- The use of sexualized language or imagery and unwelcome sexual attention or
44+
advances
45+
- Trolling, insulting/derogatory comments, and personal or political attacks
46+
- Public or private harassment
47+
- Publishing others' private information, such as a physical or electronic
48+
address, without explicit permission
49+
- Other conduct which could reasonably be considered inappropriate in a
50+
professional setting
5151

5252
### Our Responsibilities
5353

@@ -89,4 +89,5 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
8989
available at [http://contributor-covenant.org/version/1/4][version]
9090

9191
[homepage]: http://contributor-covenant.org
92+
9293
[version]: http://contributor-covenant.org/version/1/4/

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ The current release has been tested and is confirmed working with the following
4848

4949
<https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm> (Chrome)
5050

51+
3. Make sure WooCommerce has some products already
5152

52-
3. Make sure WooCommerce has some products already or import some sample products
53-
54-
The WooCommerce sample products CSV file is available at `wp-content/plugins/woocommerce/sample-data/sample_products.csv` or [Sample products](sample_products/)
55-
56-
Import the products at `WP Dashboard > Tools > Import > WooCommerce products(CSV)`
5753

5854
4. Clone or fork the repo and modify `.env.example` and rename it to `.env`
5955

@@ -77,14 +73,16 @@ The current release has been tested and is confirmed working with the following
7773

7874
- Next.js version 13.1.6
7975
- React 18
76+
- Typescript
8077
- Connect to Woocommerce GraphQL API and list name, price and display image for products
8178
- Support for simple products and variable products
8279
- Cart handling and checkout with WooCommerce (Cash On Delivery only for now)
8380
- Algolia search (requires [algolia-woo-indexer](https://github.com/w3bdesign/algolia-woo-indexer))
8481
- Meets WCAG accessibility standards where possible
8582
- Placeholder for products without images
8683
- Apollo Client with GraphQL
87-
- React Hook Form with form validation and error display
84+
- React Hook Form
85+
- Native HTML5 form validation
8886
- Animations with Framer motion, Styled components and Animate.css
8987
- Loading spinner created with Styled Components
9088
- Shows page load progress with Nprogress during navigation
@@ -94,7 +92,6 @@ The current release has been tested and is confirmed working with the following
9492
- Pretty URLs with builtin Nextjs functionality
9593
- Tailwind 3 for styling
9694
- JSDoc comments
97-
- WooCommerce cart session is automatically deleted after 48 hours to prevent GraphQL session expiration errors
9895

9996
## Troubleshooting
10097

@@ -119,7 +116,6 @@ With that said, keep the following in mind:
119116
## TODO
120117

121118
- Add total to cart/checkout page
122-
- Show stock quantity on individual products
123119
- Copy billing address to shipping address
124120
- Display product variation name in cart / checkout
125121
- Hide products not in stock

0 commit comments

Comments
 (0)