Skip to content

Commit fe23084

Browse files
authored
Using faire's loaders (#1)
* Using faire's loaders * Updating std * Updating std 2 * Updating std again * Update README
1 parent 1c0b5bf commit fe23084

File tree

5 files changed

+338
-413
lines changed

5 files changed

+338
-413
lines changed

README.md

Lines changed: 9 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,223 +1,13 @@
1-
# Fashion starter by deco.cx
1+
# Faire - POC
22

3-
A fully featured starter to help you customize and deploy an ecommerce website
4-
in minutes
3+
This repo was created from a template. More information at [deco-sites/fashion](https://github.com/deco-sites/fashion#readme).
54

6-
<div style="display: flex; justify-content: center; width: 100%">
7-
<img width="600px" height="147px"
8-
src="https://cdn.discordapp.com/attachments/1043241080679841793/1083140431556116553/image.png" />
9-
</div>
5+
## How to run
106

11-
## Features
7+
1. Install `deno` (instructions [here](https://deno.com/manual/getting_started/installation)).
8+
2. Run `git clone` on this repo.
9+
3. Run `deno task start`.
10+
4. Go to http://localhost:8000/live/previews/11810?s=shirt.
11+
5. Feel free to change the `s` to search other products and see the load time.
1212

13-
This starter brings:
14-
15-
<ul>
16-
<li>Home, product and listing pages</li>
17-
<li>Content editable via CMS</li>
18-
<li>A/B test compatible</li>
19-
<li>Analytics</li>
20-
<li>Integration with VTEX, Shopify and Oracle</li>
21-
<li>Minicart with
22-
<ul>
23-
<li>Coupons</li>
24-
<li>Total</li>
25-
<li>Subtotal</li>
26-
<li>Promotions</li>
27-
</ul>
28-
</li>
29-
<li>SKU selector</li>
30-
<li>Full text search</li>
31-
<li>Search filters</li>
32-
<li>Search pagination</li>
33-
<li>SEO optmized
34-
<ul>
35-
<li>Meta tags</li>
36-
<li>Rich results</li>
37-
<li>OpenGraph</li>
38-
</ul>
39-
</li>
40-
<li>Cookie consent</li>
41-
<li>Carousel</li>
42-
<li>Product shelf</li>
43-
<li>SKU selector</li>
44-
<li>Breadcrumb</li>
45-
<li>Search filters</li>
46-
<li>Dropdown and hamburger menus</li>
47-
<li>Minicart</li>
48-
<li>Newsletter</li>
49-
<li>Footer</li>
50-
<li>Link Tree</li>
51-
</ul>
52-
53-
## Getting started
54-
55-
To execute this website on your machine, clone it to your local machine with
56-
`git clone` and make sure [deno is installed](https://deno.land/[email protected]/getting_started/installation).
57-
58-
Then open the terminal, change the directory to where fashion was cloned and type
59-
60-
```sh
61-
deno task start
62-
```
63-
64-
You should see the following output
65-
66-
```
67-
$ deno task start
68-
Task start deno run -A --watch=static/,sections/,functions/ dev.ts
69-
Watcher Process started.
70-
Starting live middleware: siteId=538 site=std
71-
The manifest has been generated for 6 routes, 5 islands, 17 sections and 16 functions.
72-
Githooks setup successfully: pre-commit
73-
Starting live middleware: siteId=239 site=fashion
74-
Listening on http://localhost:8000/
75-
```
76-
77-
Now, open [http://localhost:8000/](http://localhost:8000/). You should see the
78-
fashion starter running on your machine!
79-
80-
To continue from here, you can [perform initial setup](#initial-setup),
81-
[understand folder structure](#understanding-folder-structure), learn how to
82-
create [common design patterns](#recipes) (components) and comply to
83-
[best practices](#best-practices)
84-
85-
## Initial setup
86-
87-
Below is a checklist for the store's initial setup. After completing these
88-
tasks, your store will be ready to go live and won't need any further changes on
89-
this repository. If, after changing the content via
90-
[deco.cx's CMS](https://deco.cx/admin), you feel the store is not ready for
91-
going live, you can learn how to [customize the code](#customize-the-store)
92-
93-
Checklist
94-
95-
- [ ] Ecommerce platform connected
96-
- [ ] Fonts added
97-
- [ ] Logo changed
98-
- [ ] favicon.ico, robots.txt changed
99-
- [ ] Design system changed
100-
101-
### Connecting your e-commerce platform
102-
103-
Products, prices and promotions are provided by an ecommerce platform (VTEX,
104-
Shopify, Oracle). To connect to a platform:
105-
106-
Open the
107-
[ecommerce's global config](https://deco.cx/admin/{your-site-id}/workbench?section=deco-sites%2Fstd%2Fsections%2FconfigVTEX.global.tsx)
108-
and set your credentials. Then, open `/components/minicart/Cart.tsx` and
109-
`/routes/api/[...catchall].tsx` and replace `bravtexfashionstore` to your
110-
account name.
111-
112-
After this, your should be using the products provenient from your ecommerce
113-
account
114-
115-
### Adding fonts
116-
117-
1. Copy & paste your font files (.woff/.woff2) to `/static/fonts` folder
118-
2. Open `/components/GlobalTags.tsx` component and replace `@font-face` tags
119-
accordingly, i.e. change font-family, font-style and font-weight. Now, change
120-
the src attribute with the right font path.
121-
3. Open tailwind.config.ts and change the `fontFamily` attribute accordingly.
122-
123-
> WARNING: Do not forget to use the `asset()` function. Not adding it will
124-
> increase the traffic on your site and lead to higher costs
125-
126-
> If your don't know the font-family, font-style and font-weight, ask your
127-
> designer for these values.
128-
129-
### Adding your logo
130-
131-
1. Make sure you have your logo in `.svg` format
132-
2. Open your logo in your text editor and copy its content
133-
3. Open /static/sprites.svg
134-
4. Replace `<symbol id="Logo" .../>` with the content of your logo's `.svg`
135-
file. Make sure all `<svg />` tags are replaced with `<symbol />` tag and add
136-
the `id="Logo"` attribute. Also, make sure to have the `xmlns` attribute.
137-
138-
### Adding default assets
139-
140-
Open `static` folder and replace `favicon.ico`, `robots.txt` and
141-
`site.webmanifest` with your own assets
142-
143-
### Changing style (CSS)
144-
145-
1. Run the store (with `deno task start`).
146-
2. Open the
147-
[design system section](http://localhost:8000/_live/workbench/sections/DesignSystem.story.tsx?key=.%2Fsections%2FDesignSystem.story.tsx)
148-
3. Now, on your text editor, open `tailwind.config.ts`
149-
4. Change the default, header, badge, etc colors, text colors and border colors
150-
to better fit your desired design and check how the
151-
[design system section](http://localhost:8000/_live/workbench/sections/DesignSystem.story.tsx?key=.%2Fsections%2FDesignSystem.story.tsx)
152-
changes.
153-
154-
## Customize the store
155-
156-
If you are missing a functionality or the changes in the design system were not
157-
enough for accomplishing your project, you can fully customize all HTML/CSS/JS
158-
generated on your store by changing the code.
159-
160-
### Understanding project structure
161-
162-
This code uses:
163-
164-
1. [Deno](https://deno.land/) as runtime
165-
2. [Preact](https://preactjs.com/) as rendering engine
166-
3. [Fresh](https://fresh.deno.dev/) as meta framework.
167-
4. [Deco.cx](https://www.deco.cx/) as CMS, A/B Tester and Analytics
168-
169-
To better encapsulate the store's code and separate it from framework specific
170-
code, all HTML generator code was placed into `components` folder, whereas all
171-
logic related code was placed under `sdk`. This means that UI elements, like
172-
product shelves, footer, header, product galleries etc are all placed into
173-
`components` whereas code for computing the prices, adding to cart etc are
174-
placed under `sdk`. Other folders are framework-specific glue code, and serve
175-
for:
176-
177-
1. `islands`: Fresh based folder for adding JavaScript to the frontend. More
178-
info at [Fresh's docs](https://fresh.deno.dev/docs/concepts/islands)
179-
1. `routes`: Fresh based folder for responding custom routes to the store. More
180-
info at [Fresh's docs](https://fresh.deno.dev/docs/concepts/routes)
181-
1. `static`: Fresh based folder for serving static content (assets). Check out
182-
[Fresh's docs](https://fresh.deno.dev/docs/concepts/static-files)
183-
1. `import_map.json`: File containing your dependencies. Check out
184-
[Deno's docs](https://deno.land/[email protected]/basics/import_maps)
185-
1. `tailwind.config.ts`: tailwindcss configuration file. [tailwind docs](https://tailwindcss.com/)
186-
1. `sections`: deco.cx folder for making components both editable and composable
187-
on the CMS. Check out [deco.cx's docs](https://www.deco.cx/docs/en)
188-
1. `functions`: deco.cx folder for adding dynamic data to sections provenient
189-
from third party APIs, like ecommerce platforms, ERPs, contentful, wordpress
190-
etc
191-
192-
### Recipes
193-
194-
Deco.cx's commitment to outstanding UX requires minimal work by user's devices.
195-
This usually means shipping zero or almost to no JavaScript to browsers. This
196-
starter uses state of the art design patterns to create rich UX with HTML and
197-
CSS only.
198-
199-
Sometimes, it may be difficult to understand everything that's going on a
200-
production-ready code like this starter's components. To learn how to create
201-
common UI patterns with HTML and CSS only in a simpler context, take a look at
202-
[deco.cx's recipes](https://www.deco.cx/docs/en/recipes/customizable-sections)
203-
204-
### Best practices
205-
206-
The best practices for managing the project on the long run rely around
207-
respecting folder structure. This means:
208-
209-
1. Add `.tsx` files on `components` folder only
210-
1. Add preact hooks on `sdk` folder.
211-
1. To make a component editable, create it on the `components` folder and add an
212-
`export { default }` on the `sections` folder
213-
1. To add JavaScript to the browser, create a component on the `components`
214-
folder and add an `export { default }` on the islands folder
215-
216-
Check performance best practices on
217-
[deco.cx's docs](https://www.deco.cx/docs).
218-
219-
# Thanks to all contributors!
220-
221-
<a href="https://github.com/deco-sites/fashion/graphs/contributors">
222-
<img src="https://contributors-img.web.app/image?repo=deco-sites/fashion" />
223-
</a>
13+
More info on how it was done here: https://github.com/deco-sites/std/pull/52

components/product/ProductCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function ProductCard({ product, preload, itemListName }: Props) {
5858
<div class="absolute top-0 right-0">
5959
<WishlistIcon productGroupID={productGroupID} productID={productID} />
6060
</div>
61-
<a href={url} aria-label="view product" class="contents">
61+
<a href={url} aria-label="view product" class="contents" target="_blank">
6262
<Image
6363
src={front.url!}
6464
alt={front.alternateName}

import_map.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"imports": {
3+
"deco-sites/faire/": "./",
34
"deco-sites/fashion/": "./",
4-
"deco-sites/std/": "https://denopkg.com/deco-sites/std@1.0.2/",
5+
"deco-sites/std/": "https://denopkg.com/deco-sites/std@4796f34afb58d0becc0d1a5a8f06f5836d3bfc0e/",
56
"$live/": "https://denopkg.com/deco-cx/[email protected]/",
67
"$fresh/": "https://deno.land/x/[email protected]/",
78
"preact": "https://esm.sh/[email protected]",
@@ -12,4 +13,4 @@
1213
"std/": "https://deno.land/[email protected]/",
1314
"partytown/": "https://deno.land/x/[email protected]/"
1415
}
15-
}
16+
}

live.gen.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ import * as i2$$1 from "deco-sites/std/accounts/shopify.ts";
8383
import * as i2$$2 from "deco-sites/std/accounts/vnda.ts";
8484
import * as i2$$3 from "deco-sites/std/accounts/vtex.ts";
8585
import * as i2$$4 from "deco-sites/std/accounts/yourViews.ts";
86-
import * as i2$$$0 from "deco-sites/std/loaders/vtexLegacyProductDetailsPage.ts";
87-
import * as i2$$$1 from "deco-sites/std/loaders/vtexLegacyRelatedProductsLoader.ts";
86+
import * as i2$$$0 from "deco-sites/std/loaders/faireSearch.ts";
87+
import * as i2$$$1 from "deco-sites/std/loaders/faireSearchPage.ts";
88+
import * as i2$$$2 from "deco-sites/std/loaders/vtexLegacyProductDetailsPage.ts";
89+
import * as i2$$$3 from "deco-sites/std/loaders/vtexLegacyRelatedProductsLoader.ts";
8890
import * as i2$$$$3 from "deco-sites/std/sections/Analytics.tsx";
8991
import * as i2$$$$4 from "deco-sites/std/sections/configOCC.global.tsx";
9092
import * as i2$$$$5 from "deco-sites/std/sections/configShopify.global.tsx";
@@ -204,8 +206,10 @@ const manifest = {
204206
"deco-sites/std/accounts/yourViews.ts": i2$$4,
205207
},
206208
"loaders": {
207-
"deco-sites/std/loaders/vtexLegacyProductDetailsPage.ts": i2$$$0,
208-
"deco-sites/std/loaders/vtexLegacyRelatedProductsLoader.ts": i2$$$1,
209+
"deco-sites/std/loaders/faireSearch.ts": i2$$$0,
210+
"deco-sites/std/loaders/faireSearchPage.ts": i2$$$1,
211+
"deco-sites/std/loaders/vtexLegacyProductDetailsPage.ts": i2$$$2,
212+
"deco-sites/std/loaders/vtexLegacyRelatedProductsLoader.ts": i2$$$3,
209213
},
210214
"config": config,
211215
"baseUrl": import.meta.url,

0 commit comments

Comments
 (0)