diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..183417ce --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +cd "$(dirname "$(find . -maxdepth 2 -type f -name package.json | head -1)")" && npm run lint diff --git a/content/.eslintrc b/content/.eslintrc new file mode 100644 index 00000000..2a9db03f --- /dev/null +++ b/content/.eslintrc @@ -0,0 +1,10 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ] +} diff --git a/content/.gitignore b/content/.gitignore index bbb2e9bc..1c7ff479 100644 --- a/content/.gitignore +++ b/content/.gitignore @@ -35,8 +35,10 @@ msbuild.wrn # Build artifacts -wwwroot/ +wwwroot/css +wwwroot/scripts dist/ +**/.parcel-cache/ # Dependencies diff --git a/content/.husky/pre-commit b/content/.husky/pre-commit new file mode 100644 index 00000000..31c085ad --- /dev/null +++ b/content/.husky/pre-commit @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" +cd "$(dirname "$(find . -maxdepth 2 -type f -name package.json | head -1)")" && npm run lint \ No newline at end of file diff --git a/content/.parcelrc b/content/.parcelrc new file mode 100644 index 00000000..1afd98f8 --- /dev/null +++ b/content/.parcelrc @@ -0,0 +1,7 @@ +{ + "extends": "@parcel/config-default", + "namers": [ + "parcel-namer-hashless", + "..." + ] +} \ No newline at end of file diff --git a/content/.stylelintrc b/content/.stylelintrc new file mode 100644 index 00000000..2b8ab2d3 --- /dev/null +++ b/content/.stylelintrc @@ -0,0 +1,12 @@ +{ + "extends": [ + "stylelint-config-recommended-scss", + "stylelint-config-prettier-scss" + ], + "plugins": [], + "rules": { + "at-rule-no-unknown": null, + "scss/at-rule-no-unknown": true, + "no-descending-specificity": null + } +} diff --git a/content/Assets/Content/.placeholder b/content/Assets/Content/.placeholder deleted file mode 100644 index e69de29b..00000000 diff --git a/content/Assets/Styles/index.scss b/content/Assets/Styles/index.scss index 63503eed..0be745e8 100644 --- a/content/Assets/Styles/index.scss +++ b/content/Assets/Styles/index.scss @@ -15,8 +15,8 @@ * https://necolas.github.io/normalize.css/ */ -@import '../../node_modules/normalize.css/normalize'; -@import '../../node_modules/lightgallery.js/src/sass/lightgallery'; +@import url('../../node_modules/normalize.css/normalize.css'); +@import url('../../node_modules/lightgallery.js/src/sass/lightgallery.scss'); @import 'defaults/all'; diff --git a/content/Assets/Styles/variables/_breakpoints.scss b/content/Assets/Styles/variables/_breakpoints.scss index aaef8faf..880de6bd 100644 --- a/content/Assets/Styles/variables/_breakpoints.scss +++ b/content/Assets/Styles/variables/_breakpoints.scss @@ -6,7 +6,7 @@ * Media query breakpoints used by sass-mq. */ -$mq-breakpoints: ( +$breakpoints: ( mobileSmall: 320px, mobile: 375px, mobileLarge: 425px, diff --git a/content/BuildConfigs/.stylelintrc b/content/BuildConfigs/.stylelintrc deleted file mode 100644 index ff5857bb..00000000 --- a/content/BuildConfigs/.stylelintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": ["stylelint-prettier/recommended"], - "plugins": ["stylelint-prettier"], - "rules": { - "at-rule-no-unknown": null, - "prettier/prettier": true - } -} \ No newline at end of file diff --git a/content/BuildConfigs/tsconfig.json b/content/BuildConfigs/tsconfig.json deleted file mode 100644 index 3a021c8b..00000000 --- a/content/BuildConfigs/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "outDir": "../wwwroot/js", - "sourceMap": true, - "strict": true, - "noUnusedLocals": true, - "module": "es2015", - "moduleResolution": "node", - "target": "es6", - "jsx": "react", - "noImplicitAny": true, - "noImplicitThis": true, - "typeRoots": ["types", "../node_modules/@types"] - }, - "include": ["../Assets/Scripts/**/*"] -} diff --git a/content/BuildConfigs/tslint.json b/content/BuildConfigs/tslint.json deleted file mode 100644 index b87de5fd..00000000 --- a/content/BuildConfigs/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["tslint:recommended"] -} diff --git a/content/BuildConfigs/webpack.config.js b/content/BuildConfigs/webpack.config.js deleted file mode 100644 index 7aca6b7b..00000000 --- a/content/BuildConfigs/webpack.config.js +++ /dev/null @@ -1,196 +0,0 @@ -const CopyPlugin = require('copy-webpack-plugin'); -const { extendDefaultPlugins } = require('svgo'); -const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts'); -const StylelintPlugin = require('stylelint-webpack-plugin'); -const path = require('path'); - -module.exports = [ - { - entry: { - scripts: path.join(process.cwd(), 'Assets/Scripts/index.ts'), - }, - output: { - path: path.join(process.cwd(), 'wwwroot/js'), - filename: '[name].js', - }, - module: { - rules: [ - { - enforce: 'pre', - test: /(\.ts(x?)$)/, - exclude: /node_modules/, - loader: 'tslint-loader', - options: { - configFile: path.join( - process.cwd(), - 'BuildConfigs/tslint.json' - ), - emitErrors: true, - }, - }, - { - test: /(\.ts(x?)$)/, - exclude: /node_modules/, - use: [ - { - loader: 'babel-loader', - options: { - presets: [ - [ - '@babel/preset-env', - { - corejs: { - version: 3, - proposals: true, - }, - useBuiltIns: 'entry', - }, - ], - ], - }, - }, - { - loader: 'ts-loader', - options: { - configFile: path.join( - process.cwd(), - 'BuildConfigs/tsconfig.json' - ), - }, - }, - ], - }, - { - test: /(\.js(x?)$)/, - exclude: /node_modules/, - use: ['babel-loader'], - }, - ], - }, - plugins: [ - new RemoveEmptyScriptsPlugin(), - new CopyPlugin({ - patterns: [ - { - from: path.join( - process.cwd(), - 'Assets/Content/Theme.png' - ), - to: path.join(process.cwd(), 'wwwroot/Theme.png'), - }, - { - from: path.join(process.cwd(), 'Assets/Content'), - to: path.join(process.cwd(), 'wwwroot/content'), - }, - { - from: path.join(process.cwd(), 'Assets/Fonts'), - to: path.join(process.cwd(), 'wwwroot/fonts'), - }, - { - from: path.join( - process.cwd(), - 'node_modules/lightgallery.js/dist/fonts' - ), - to: path.join(process.cwd(), 'wwwroot/fonts'), - }, - { - from: path.join( - process.cwd(), - 'node_modules/lightgallery.js/dist/img' - ), - to: path.join(process.cwd(), 'wwwroot/img'), - }, - ], - }), - new ImageMinimizerPlugin({ - minimizer: { - implementation: ImageMinimizerPlugin.imageminMinify, - options: { - plugins: [ - ['optipng', { optimizationLevel: 2 }], - ['pngquant', { quality: [0.65, 0.9], speed: 4 }], - [ - 'svgo', - { - plugins: [ - { - name: 'preset-default', - }, - { - name: 'removeUnknownsAndDefaults', - active: false, - }, - { - name: 'cleanupIDs', - active: false, - }, - { - name: 'removeViewBox', - active: false, - }, - ], - }, - ], - ], - encodeOptions: { - mozjpeg: { - quality: 75, - }, - }, - }, - }, - }), - ], - resolve: { - extensions: ['.tsx', '.ts', '.js'], - }, - }, - { - entry: { - styles: path.join(process.cwd(), 'Assets/Styles/index.scss'), - }, - output: { - path: path.join(process.cwd(), 'wwwroot/css'), - }, - module: { - rules: [ - { - test: /\.scss$/, - use: [ - MiniCssExtractPlugin.loader, - { - loader: 'css-loader', - options: { - url: false, - }, - }, - { - loader: 'postcss-loader', - options: { - postcssOptions: { - plugins: [['autoprefixer']], - }, - }, - }, - 'sass-loader', - ], - }, - ], - }, - plugins: [ - new MiniCssExtractPlugin({ - filename: '../css/styles.css', - }), - new StylelintPlugin({ - configFile: path.join( - process.cwd(), - 'BuildConfigs/.stylelintrc' - ), - fix: true, - customSyntax: 'postcss-scss', - }), - ], - }, -]; diff --git a/content/BuildConfigs/webpack.config.prod.js b/content/BuildConfigs/webpack.config.prod.js deleted file mode 100644 index cf7a3b12..00000000 --- a/content/BuildConfigs/webpack.config.prod.js +++ /dev/null @@ -1,25 +0,0 @@ -const path = require('path'); - -const config = require('./webpack.config'); - -const { CleanWebpackPlugin } = require('clean-webpack-plugin'); - -config[0].plugins.push( - new CleanWebpackPlugin({ - cleanOnceBeforeBuildPatterns: [ - path.join(process.cwd(), 'wwwroot/content'), - path.join(process.cwd(), 'wwwroot/fonts'), - path.join(process.cwd(), 'wwwroot/img'), - path.join(process.cwd(), 'wwwroot/js'), - path.join(process.cwd(), 'wwwroot/Theme.png'), - ], - }) -); - -config[1].plugins.push( - new CleanWebpackPlugin({ - cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), 'wwwroot/css')], - }) -); - -module.exports = config; diff --git a/content/Etch.OrchardCore.ThemeBoilerplate.csproj b/content/Etch.OrchardCore.ThemeBoilerplate.csproj index 506a9bbf..b173413c 100644 --- a/content/Etch.OrchardCore.ThemeBoilerplate.csproj +++ b/content/Etch.OrchardCore.ThemeBoilerplate.csproj @@ -56,10 +56,10 @@ - + - + \ No newline at end of file diff --git a/content/Views/Layout.liquid b/content/Views/Layout.liquid index 5f5b1618..1be036b9 100644 --- a/content/Views/Layout.liquid +++ b/content/Views/Layout.liquid @@ -13,21 +13,17 @@ document.createElement( "picture" ); - - - - - - - - - - - - + + + + + + + + {% style src:"/Etch.OrchardCore.ThemeBoilerplate/css/styles.css", append_version:"true" %} - {% script src:"/Etch.OrchardCore.ThemeBoilerplate/js/scripts.js", append_version:"true", async: "true" %} + {% script src:"/Etch.OrchardCore.ThemeBoilerplate/scripts/index.js", append_version:"true", async: "true" %} {% resources type: "HeadLink" %} {% resources type: "Stylesheet" %} diff --git a/content/package.json b/content/package.json index bcfe8b5b..e7bade78 100644 --- a/content/package.json +++ b/content/package.json @@ -1,63 +1,75 @@ { - "name": "etch.orchardcore.themeboilerplate", - "version": "1.5.1", - "description": "Theme boilerplate is our starting point for building Orchard Core themes.", - "license": "MIT", - "author": "Etch UK", + "private": true, + "engines": { + "node": ">=14" + }, "scripts": { - "build": "npm install --no-audit && npm run bundle:prod", - "bundle:dev": "npm install && webpack --config ./BuildConfigs/webpack.config.js --mode development", - "bundle:prod": "webpack --config ./BuildConfigs/webpack.config.prod.js --mode production", - "bundle:watch": "webpack --config ./BuildConfigs/webpack.config.js --mode development --watch", - "develop": "npm run bundle:watch", - "start": "npm install && npm run develop" + "build": "npm i --no-audit && npm run clean && parcel build --no-cache --no-content-hash", + "clean": "rimraf wwwroot/scripts wwwroot/css", + "develop": "npm run clean && parcel watch --https --no-content-hash", + "install-git-hooks": "cd .. && husky install && grep \"npm run lint\" .husky/pre-commit || husky add .husky/pre-commit \"cd \\\"$(dirname \\\"$(find . -maxdepth 2 -type f -name package.json | head -1)\\\")\\\" && npm run lint\"", + "lint": "lint-staged", + "prepare": "npm run install-git-hooks", + "start": "npm i && npm run develop" }, "devDependencies": { - "@babel/core": "^7.17.9", - "@babel/preset-env": "^7.16.11", - "@types/rellax": "^1.7.2", - "autoprefixer": "^10.4.4", - "babel-loader": "^8.2.5", - "clean-webpack-plugin": "^4.0.0", - "copy-webpack-plugin": "^10.2.4", - "copyfiles": "^2.1.0", - "core-js": "^3.22.2", - "css-loader": "^6.7.1", - "css-minimizer-webpack-plugin": "^3.4.1", - "image-minimizer-webpack-plugin": "^3.2.3", - "imagemin": "^8.0.1", - "imagemin-mozjpeg": "^10.0.0", - "imagemin-optipng": "^8.0.0", - "imagemin-pngquant": "^9.0.1", - "imagemin-svgo": "^10.0.1", - "mini-css-extract-plugin": "^2.6.0", - "npm-run-all": "^4.1.5", - "postcss": "^8.3.6", - "postcss-loader": "^6.1.1", - "postcss-scss": "^4.0.3", - "prettier": "^2.6.2", - "sass": "^1.50.1", - "sass-loader": "^12.6.0", + "@parcel/transformer-sass": "^2.7.0", + "eslint": "^8.24.0", + "eslint-config-prettier": "^8.5.0", + "husky": "^8.0.1", + "lint-staged": "^13.0.3", + "parcel": "^2.7.0", + "parcel-namer-hashless": "^1.0.3", + "prettier": "^2.7.1", + "rimraf": "^3.0.2", "sass-mq": "^6.0.0", - "stylelint": "^14.7.1", - "stylelint-config-prettier": "^9.0.3", - "stylelint-config-recommended": "^7.0.0", - "stylelint-prettier": "^2.0.0", - "stylelint-webpack-plugin": "^3.2.0", - "svgo": "^2.5.0", - "ts-loader": "^9.2.8", - "tslint": "^6.1.1", - "tslint-loader": "^3.5.4", - "typescript": "^4.6.3", - "webpack": "^5.72.0", - "webpack-cli": "^4.9.2", - "webpack-remove-empty-scripts": "^0.8.0" + "stylelint": "^14.13.0", + "stylelint-config-prettier-scss": "^0.0.1", + "stylelint-config-recommended-scss": "^7.0.0" }, "dependencies": { - "lg-video.js": "^1.0.0", - "lightgallery.js": "^1.1.3", + "lg-video.js": "^1.3.0", + "lightgallery.js": "^1.4.0", "normalize.css": "^8.0.1", "picturefill": "^3.0.3", "rellax": "^1.10.0" + }, + "scriptTarget": "wwwroot/scripts/index.js", + "styleTarget": "wwwroot/css/styles.css", + "targets": { + "scriptTarget": { + "source": "Assets/Scripts/index.ts", + "outputFormat": "esmodule", + "context": "browser", + "isLibrary": false + }, + "styleTarget": { + "source": "Assets/Styles/index.scss", + "context": "browser", + "isLibrary": false + } + }, + "@parcel/transformer-css": { + "errorRecovery": true + }, + "lint-staged": { + "*.{js,ts,tsx,jsx}": [ + "eslint --quiet --fix" + ], + "*.scss": [ + "stylelint --quiet --fix" + ], + "*.{scss,json,md,html,js,jsx,ts,tsx}": [ + "prettier --write" + ] + }, + "browserslist": [ + "> 0.5%", + "Firefox ESR", + "last 2 versions", + "not dead" + ], + "prettier": { + "editorconfig": true } } diff --git a/content/Assets/Content/Flags/de.svg b/content/wwwroot/Content/Flags/de.svg similarity index 100% rename from content/Assets/Content/Flags/de.svg rename to content/wwwroot/Content/Flags/de.svg diff --git a/content/Assets/Content/Flags/en-au.svg b/content/wwwroot/Content/Flags/en-au.svg similarity index 100% rename from content/Assets/Content/Flags/en-au.svg rename to content/wwwroot/Content/Flags/en-au.svg diff --git a/content/Assets/Content/Flags/en-gb.svg b/content/wwwroot/Content/Flags/en-gb.svg similarity index 100% rename from content/Assets/Content/Flags/en-gb.svg rename to content/wwwroot/Content/Flags/en-gb.svg diff --git a/content/Assets/Content/Flags/en-us.svg b/content/wwwroot/Content/Flags/en-us.svg similarity index 100% rename from content/Assets/Content/Flags/en-us.svg rename to content/wwwroot/Content/Flags/en-us.svg diff --git a/content/Assets/Content/Flags/es.svg b/content/wwwroot/Content/Flags/es.svg similarity index 100% rename from content/Assets/Content/Flags/es.svg rename to content/wwwroot/Content/Flags/es.svg diff --git a/content/Assets/Content/Flags/fr.svg b/content/wwwroot/Content/Flags/fr.svg similarity index 100% rename from content/Assets/Content/Flags/fr.svg rename to content/wwwroot/Content/Flags/fr.svg diff --git a/content/Assets/Content/Flags/it.svg b/content/wwwroot/Content/Flags/it.svg similarity index 100% rename from content/Assets/Content/Flags/it.svg rename to content/wwwroot/Content/Flags/it.svg diff --git a/content/Assets/Content/Flags/pl.svg b/content/wwwroot/Content/Flags/pl.svg similarity index 100% rename from content/Assets/Content/Flags/pl.svg rename to content/wwwroot/Content/Flags/pl.svg diff --git a/content/wwwroot/Content/icon-carousel-indicator.svg b/content/wwwroot/Content/icon-carousel-indicator.svg new file mode 100644 index 00000000..33d4494d --- /dev/null +++ b/content/wwwroot/Content/icon-carousel-indicator.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/content/wwwroot/Content/icon-carousel-next-prev.svg b/content/wwwroot/Content/icon-carousel-next-prev.svg new file mode 100644 index 00000000..cb73bd3b --- /dev/null +++ b/content/wwwroot/Content/icon-carousel-next-prev.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/content/wwwroot/Content/icon-chevron-inverted.svg b/content/wwwroot/Content/icon-chevron-inverted.svg new file mode 100644 index 00000000..99e948ab --- /dev/null +++ b/content/wwwroot/Content/icon-chevron-inverted.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/content/wwwroot/Content/icon-chevron.svg b/content/wwwroot/Content/icon-chevron.svg new file mode 100644 index 00000000..ef684b67 --- /dev/null +++ b/content/wwwroot/Content/icon-chevron.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/content/wwwroot/Content/icon-close-white.svg b/content/wwwroot/Content/icon-close-white.svg new file mode 100644 index 00000000..09a080a6 --- /dev/null +++ b/content/wwwroot/Content/icon-close-white.svg @@ -0,0 +1,3 @@ + + + diff --git a/content/wwwroot/Content/icon-close.svg b/content/wwwroot/Content/icon-close.svg new file mode 100644 index 00000000..8884c06c --- /dev/null +++ b/content/wwwroot/Content/icon-close.svg @@ -0,0 +1,3 @@ + + + diff --git a/content/wwwroot/Content/icon-menu-white.svg b/content/wwwroot/Content/icon-menu-white.svg new file mode 100644 index 00000000..37f97407 --- /dev/null +++ b/content/wwwroot/Content/icon-menu-white.svg @@ -0,0 +1,3 @@ + + + diff --git a/content/wwwroot/Content/icon-menu.svg b/content/wwwroot/Content/icon-menu.svg new file mode 100644 index 00000000..5f3e13ea --- /dev/null +++ b/content/wwwroot/Content/icon-menu.svg @@ -0,0 +1,3 @@ + + + diff --git a/content/wwwroot/Content/logo-play.svg b/content/wwwroot/Content/logo-play.svg new file mode 100644 index 00000000..30bc5526 --- /dev/null +++ b/content/wwwroot/Content/logo-play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/content/Assets/Content/Theme.png b/content/wwwroot/Theme.png similarity index 100% rename from content/Assets/Content/Theme.png rename to content/wwwroot/Theme.png