## Table of Contents
* [About the Theme](#about-the-theme)
* [Online demo](#online-demo)
* [Performance](#performance)
* [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [Support table](#support-table)
* [Installation](#installation)
* [Usage](#usage)
* [Working with webpack](#working-with-webpack)
* [Working with npm/yarn](#working-with-npm/yarn)
* [Falcon CLI](#falcon-cli)
* [Smarty functions](#smarty-functions)
* [Smarty blocks](#smarty-blocks)
* [Register assets](#register-assets)
* [Preloading fonts](#preloading-fonts)
* [Javascript Components](#javascript-components)
* [PageSLider](#pageslider)
* [SwiperSlider](#swiperslider)
* [Features](#features)
* [Preloads/early hints](#preloads/early-hints)
* [Webp](#webp)
* [Webp nginx](#webp-nginx)
* [Workspace Aware Webpack](#workspace-aware-webpack)
* [Troubleshooting](#troubleshooting)
* [Sass performance issue](#sass-performance-issue)
* [Support project](#support-project)
* [Contribution](#contribution)
## About The Theme
**Falcon theme** is made with the latest tools such as Webpack 5, Webpack dev server with HMR :fire::fire:, and Bootstrap 4.6.
This theme was created to deliver a starter theme with the latest developers' tools and frameworks. You can create an enterprise-level PrestaShop theme that is easy to maintain.
Made for developers, and **if you are a merchant, you shouldn't download it.**
#### List of changes compared to classic theme:
1. Bootstrap updated to **4.6** from **4.0.0-alpha.5** - backwards compatibility included.
2. Updated Webpack to **5** from **2.2.1** with a whole new Webpack config.
3. Removed **tether** - not used anymore with Bootstrap 4.6 - **popper.js** added instead.
4. Removed **velocity-animate**, **jquery.scrollbox.js** and **jquery-touchswipe** - replaced with **Swiper**.
5. Removed **bootstrap-filestyle.js** - replaced with Bootstrap [custom file input](https://getbootstrap.com/docs/4.6/components/input-group/#custom-file-input)
6. Removed **jquery.ui** from `ps_searchbar`, a new module `is_searchbar` included.
7. Removed **jquery.ui** from `ps_facetedsearch` - replaced with **nouislider**. (`ps_facetedsearch` assets are unregistered inside `is_themecore` module that is required for the theme to work properly).
#### Main features:
1. Webpack config works properly with Webpack Dev server and HMR. Its watcher also observes changes on `.tpl` templates, and modules `.css/.js/.tpl` files and makes the page complete reload if needed. You don't need to refresh your webpage manually anymore to inspect results.
2. Module `is_themecore` adds structured data with proper `JSON-LD` format for **WebPage**, **Product**, **Organization** and **BreadcrumbList**. Also supports **OpenGraph** and **Twitter:card**. It adds missing breadcrumbs for pages: **cart**, **404**, **stores**, **sitemap**.
3. Dynamic importing of the Boostrap components. You can load `.js/.css` file dynamically with **DynamicImportHandler** class. There is no documentation yet, only an example of use available in `_dev/js/components/dynamic-bootstrap-components.js`.
4. [Lazyload](https://github.com/verlok/vanilla-lazyload) added for images that are below the fold.
5. Modified version of `ps_imageslider` included. You can upload images for mobile and desktop separately.
6. Multiple entry points for Webpack, files separated per view. There are 4 output `js/css` files **theme**, **product**, **checkout**, **listing** and you are able to add more with ease. If you need rich CMS pages with many styles, you don't have to include them everywhere with the **theme** output file. You can create another entry e.g. **cms** and modify the `assets.yml` file to include the new assets file.
7. List/grid switcher on the list. You are able to choose the default listing display type with only a few lines of `.js` code. All template changes are handled in `.tpl` file. It is also easy to add another list type.
8. Specific `.scss` file structure that helps you maintain your code over time.
9. Automatically generated preload links for theme fonts. You don't have to care about manually preloading fonts inside the template. Webpack generates `.html` file that is included inside the head. Fonts fileNames are `contentHashed` so client-side caching problems after fonts changes are resolved (especially useful for `icomoon` generated icon fonts.).
10. High DPI images support. With just a simple call of the Smarty function (`generateImageSources`), you are able to handle whole image sources logic - `srcset` for the High DPI images option enabled.
11. `SwiperSlider` wrapper class for `swiper.js` to fetch needed swiper modules lazily based on provided config.
12. WebP image format generated automatically on demand via `is_themcore` module.
13. `Early hints (103)` support via Cloudflare for css/image file.
### Online demo
Want to check it online in action before downloading? Demo available [here](https://falcon-theme.dev/) (page might not be avaliable on release date).
Demo hosted by our technical partner [Wrapnet](https://wrapnet.pl/).
### Performance
Performance results based on PageSpeed Insights:
#### Desktop
#### Mobile
## Getting started
### Prerequisites
#### Modules required
- [is_imageslider](https://github.com/Oksydan/is_imageslider)
- [is_searchbar](https://github.com/Oksydan/is_searchbar)
- [is_shoppingcart](https://github.com/Oksydan/is_shoppingcart)
- [is_themecore](https://github.com/Oksydan/is_themecore)
#### Optional modules
- [is_favoriteproducts](https://github.com/Oksydan/is_favoriteproducts)
#### System requirements:
- [Prestashop requirements](https://devdocs.prestashop.com/1.7/basics/installation/system-requirements/),
- vhost setup, to work with Falcon theme it is required to setup your shop domain with vhost e.g. `falcon.test`,
### Support table
Falcon version | PS version | node version
------------- | ----------- | -------------
v 1.X | 1.7.7.X | >= 10
v 2.X | 1.7.8.X | >= 14
v 3.0.X | 8.0.X | >= 14
v 3.1.X | 8.0.X | >= 15
#### Module requirements
`is_themecore` version | Theme version
------------- | -------------
1.X.X | 1.X.X
2.X.X | 2.X.X
3.X.X | 3.0.X
4.X.X | >= 3.1.X
`is_imageslider` version | Theme version
------------- | -------------
1.X.X | <= 2.X.X
2.X.X | 3.1.X
3.X.X | >= 3.1.X
`is_searchbar` version | Theme version
------------- | -------------
1.X.X | <= 2.X.X
2.X.X | 3.0.X
3.X.X | >= 3.1.X
`is_shoppingcart` version | Theme version
------------- | -------------
1.X.X | <= 2.X.X
2.X.X | 3.1.X
3.X.X | >= 3.1.X
`is_favoriteproducts` version | Theme version
------------- | -------------
1.X.X | >= 3.1.X
### Installation
1. Go to [releases](https://github.com/Oksydan/falcon/releases/) and download latest version `falcon.zip` file not source code.
2. Download required modules via github releases and place them into `{shop_dir}/modules/` folder. Make sure that you are downloading release package not source code of module. DON'T clone module repository. If you clone module repository, you will have to run `composer install` in root dir of downloaded module.
3. Unzip theme file and place it inside `{shop_dir}/themes/`.
4. If you want to change theme name unzip file. Change folder name e.g. `your-theme-name` then go to `config/theme.yml` and change:
```yml
name: falcon
display_name: Falcon theme
```
to:
```yml
name: your-theme-name
display_name: my theme display name
```
Name in `theme.yml` must be equal folder name.
5. Open in terminal directory `your-theme-name/_dev` and run:
- for `npm` :
```
npm install
```
- for `yarn` :
```
yarn install
```
6. Creating your `.env` file. You can setup you project by running `project-init` script.
7. If you didn't build your theme in step 6. Just run:
- for `npm` :
```
npm run build
```
- for `yarn` :
```
yarn build
```
8. Go in BO to Design->Theme & Logo and turn on theme. Now theme should be displayed correctly in FO and modules should be installed.
9. Now try to run:
- for `npm` :
```
npm run dev
```
- for `yarn` :
```
yarn dev
```
If your `.env` file is correctly setup. Your browser will open FO of your store.
## Usage
### Working with webpack
Webpack config is available in `_dev/webpack` folder. Files are structured by their functions:
file | description
------------- | -------------
`webpack.vars.js` | Webpack dev server config that comes from `.env` file and entry point, output file setup. To add new entry just run `add-entry` script.
`webpack.parts.js` | Contains loaders and plugins setup.
`webpack.commons.js` | Config that runs on both production and development.
`webpack.development.js` | Config that runs on development.
`webpack.production.js` | Config that runs on production.
`purge-safelist.js` | Falcon theme comes with support for [purgecss](https://purgecss.com/), but safelist is not included.
### Working with npm/yarn
script | description
------------- | -------------
`build` | Script run production config with assets optimization and chunks names hashing, silent console output.
`build-analyze` | Script run production config with assets optimization and chunks names hashing also display bundle-analyzer.
`build-purge` | Script run production config with assets optimization, chunks hashing also runs `purgecss` to remove not used styles. **Not recomended to use yet, create safelist before use**.
`build-ci` | Script used for github actions CI.
`watch` | good old watch option good if you struggle to setup `webpack-dev-server` . **Assets optimization not included**.
`dev` | Script that run `webpack dev server` that watch for changes in files and loading them w/o page reload. Script will open your store in browser with port in url, you have to remove it and refresh page. **Assets optimization not included**.
`scss-lint` | Script that run `stylelint`. It finds issues in code.
`scss-lint-fix` | Script that run `stylelint`. It finds issues in code and fix minor issues in code.
`js-lint` | Script that run `eslint`. It finds issues in code.
`js-lint-fix` | Script that run `eslint`. It finds issues in code and fix minor issues in code.
### Falcon CLI
Falcon CLI is simple tool to improve your development experience and speed you your work. We are lunching this tool with only two scripts.
#### Project init script
After installing your `node_modules` you are able to init you project without creating `.env` file by yourself.
You can run script `project-init` and answer few question to create `.env` file and build assets.
- for `npm` :
```
npm run project-init
```
- for `yarn` :
```
yarn project-init
```
#### Add entry script
New script `add-entry` simplify your process of adding new entry point to webpack configuration.
You can just run script and after inserting entry name, new entry point will be added to project.
Just remember to register your new entry in `/config/assets.yml` file.
- for `npm` :
```
npm run add-entry
```
- for `yarn` :
```
yarn add-entry
```
### Smarty functions
#### GenerateImagesSources
Function created to simplify adding images src with support for high DPI images.
parameter | required | description
------------- | ------------- | -------------
`image` | `true` | Parameter must be a product image array for example `$product.default_image`.
`size` | `true` | Size of image defined in `theme.yml` file for example `home_default`.
`lazyload` | `false` | Optional parameter, default value is equal `true`. If `lazyload` is set to true it replace image `src` parameter to `data-src` (or `srcset` if high DPI images are turned on). To lazyload working properly it is required to add `lazyload` class to that img.
Example of usage:
```smarty
```
It will output:
```html
```
#### generateImageSvgPlaceholder
Function created to return simple svg placeholder with given sizes.
parameter | required | description
------------- | ------------- | -------------
`width` | `true` | Width of an image.
`height` | `true` | Height of an image.
Example of usage:
```smarty
```
It will output:
```html
```
#### appendParamToUrl
Function created to append param to url.
parameter | required | description
------------- | ------------- | -------------
`url` | `true` | URL addres.
`key` | `true` | Parameter variable
`value` | `true` | Parameter value, can by string or array
`replace` | `false` | Replace param with the same key (default false)
#### Example of usage 1:
```smarty
{appendParamToUrl url='https://example.com?page=1' key='variable' value='value'}
```
It will output:
```html
https://example.com?page=1&variable=value
```
#### Example of usage 2:
```smarty
{appendParamToUrl url='https://example.com?var=value1' key='var' value='value2' replace=true}
```
It will output:
```html
https://example.com?var=value2
```
#### Example of usage 3:
```smarty
{appendParamToUrl url='https://example.com?family=font1' key='family' value=['font2', 'font3']}
```
It will output:
```html
https://example.com?family=font1&family=font2&family=font3
```
### Smarty blocks
#### images_block
Smarty block that modify `` tags inside block to picture tag with `webp` `