diff --git a/.eslintrc.js b/.eslintrc.js index d59a329..c2e29f1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,26 +1,20 @@ module.exports = { "extends": [ - "airbnb-base", - "plugin:vue/recommended" - ], + "airbnb-base" + ], "rules": { "max-len": ["error", { "code": 120, }], "import/prefer-default-export": ["never"], "indent": ["error", 4], - "vue/html-indent": ["error", 4], - "vue/html-closing-bracket-newline": ["error", { - "singleline": "never", - "multiline": "always" - }], - "vue/max-attributes-per-line": [3, { - "singleline": 3, - "multiline": { - "max": 1, - "allowFirstLine": false - } - }] + "no-use-before-define": ["error", { "functions": false, "classes": true }], + "no-param-reassign": ["error", { "props": false }], + "consistent-return": ["off"], + "arrow-body-style": ["off"], + "class-methods-use-this": ["off"], + "func-names": ["off"], + "prefer-arrow-callback": ["off"], }, "parserOptions": { "parser": "babel-eslint", diff --git a/.gitignore b/.gitignore index 14c62ae..6eccf94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.env /.idea +/.vscode /vendor .DS_Store /node_modules @@ -9,4 +10,4 @@ !/web/web.config /storage/** !/storage/.gitkeep -/config/license.key \ No newline at end of file +/config/license.key diff --git a/assets/img/.gitkeep b/assets/img/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/assets/js/components/index.js b/assets/js/components/index.js deleted file mode 100644 index 5249ea6..0000000 --- a/assets/js/components/index.js +++ /dev/null @@ -1,2 +0,0 @@ - -export const components = {}; diff --git a/assets/js/directives/index.js b/assets/js/directives/index.js deleted file mode 100644 index 094a3b2..0000000 --- a/assets/js/directives/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import ref from './ref'; - -export const directives = { - ref, -}; diff --git a/assets/js/directives/ref.js b/assets/js/directives/ref.js deleted file mode 100644 index e719b4b..0000000 --- a/assets/js/directives/ref.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - inserted: (el, { value: register }, vnode) => { - register({ el, component: vnode.componentInstance }); - }, -}; diff --git a/assets/js/main.js b/assets/js/main.js index 22325a1..e69de29 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,24 +0,0 @@ -import Vue from 'vue'; - -import { components } from './components'; -import { directives } from './directives'; - -const $app = window.$app || {}; - -if ($app.devMode === 'true') { - Vue.config.devtools = true; -} - -if ($app.devMode === 'false') { - Vue.config.devtools = false; - Vue.config.productionTip = false; -} - -Vue.prototype.$global = $app; - -window.$vue = new Vue({ - el: '#root', - delimiters: ['[[', ']]'], - components, - directives, -}); diff --git a/assets/scss/base/_all.scss b/assets/scss/base/_all.scss index a317e48..1b6e422 100644 --- a/assets/scss/base/_all.scss +++ b/assets/scss/base/_all.scss @@ -1,6 +1,4 @@ @import "typography"; @import "fonts"; @import "icons"; -@import "containers"; -@import "buttons"; @import "global"; diff --git a/assets/scss/base/buttons.scss b/assets/scss/base/buttons.scss deleted file mode 100644 index f8fcaac..0000000 --- a/assets/scss/base/buttons.scss +++ /dev/null @@ -1,23 +0,0 @@ -.btn { - appearance: none; - cursor: pointer; - text-decoration: none; - background: transparent; - margin: 0; - padding: 0; - border: none; - display: inline-block; - text-align: center; - transition: color 250ms ease-in-out, background 250ms ease-in-out, border 250ms ease-in-out; - - - &.btn-primary { - - &:hover, - &:focus { - &:not(.disabled) { - - } - } - } -} diff --git a/assets/scss/base/containers.scss b/assets/scss/base/containers.scss deleted file mode 100644 index 7bfdb74..0000000 --- a/assets/scss/base/containers.scss +++ /dev/null @@ -1,35 +0,0 @@ -.container { - position: relative; - max-width: 1188px; - width: calc(100% - 8rem); - margin: 0 auto; - - @include mq-below(x-small) { - width: calc(100% - 4rem); - } - - - @include mq-below(tiny) { - width: calc(100% - 2rem); - } - - &.container-medium { - max-width: 1075px; - } - - &.container-xsmall { - max-width: 840px; - } - - &.container-small { - max-width: 895px; - } - - &.container-mid-small { - max-width: 950px; - } - - &.container-large { - max-width: 1385px; - } -} diff --git a/assets/scss/base/global.scss b/assets/scss/base/global.scss index 15b2736..9dbdb6e 100644 --- a/assets/scss/base/global.scss +++ b/assets/scss/base/global.scss @@ -3,13 +3,15 @@ html { font-size: 62.5%; width: 100%; height: 100%; + box-sizing: border-box; } -body { - font-size: 1.6rem; +*, +*::before, +*::after { + box-sizing: inherit; } - -[v-cloak] { - display: none !important; +body { + font-size: 1.6rem; } diff --git a/assets/scss/main.scss b/assets/scss/main.scss index f790375..02ad027 100644 --- a/assets/scss/main.scss +++ b/assets/scss/main.scss @@ -4,5 +4,4 @@ @import "utils/all"; @import "base/all"; -@import "pages/all"; @import "modules/all"; diff --git a/assets/scss/modules/_all.scss b/assets/scss/modules/_all.scss index 6c489e9..1498574 100644 --- a/assets/scss/modules/_all.scss +++ b/assets/scss/modules/_all.scss @@ -1,4 +1,6 @@ @import "blocks/all"; -@import "components/all"; +@import "buttons"; +@import "blocks"; +@import "containers"; @import "navigation"; @import "footer"; diff --git a/assets/scss/modules/blocks.scss b/assets/scss/modules/blocks.scss new file mode 100644 index 0000000..e69de29 diff --git a/assets/scss/modules/blocks/_all.scss b/assets/scss/modules/blocks/_all.scss index 0096a28..e69de29 100644 --- a/assets/scss/modules/blocks/_all.scss +++ b/assets/scss/modules/blocks/_all.scss @@ -1 +0,0 @@ -@import "block"; diff --git a/assets/scss/modules/blocks/block.scss b/assets/scss/modules/blocks/block.scss deleted file mode 100644 index 827750a..0000000 --- a/assets/scss/modules/blocks/block.scss +++ /dev/null @@ -1,3 +0,0 @@ -.module-block { - -} \ No newline at end of file diff --git a/assets/scss/modules/buttons.scss b/assets/scss/modules/buttons.scss new file mode 100644 index 0000000..e69de29 diff --git a/assets/scss/modules/components/_all.scss b/assets/scss/modules/components/_all.scss deleted file mode 100644 index d554c56..0000000 --- a/assets/scss/modules/components/_all.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import "image-overlay"; -@import "cropped-img"; diff --git a/assets/scss/modules/components/cropped-img.scss b/assets/scss/modules/components/cropped-img.scss deleted file mode 100644 index d4e285b..0000000 --- a/assets/scss/modules/components/cropped-img.scss +++ /dev/null @@ -1,19 +0,0 @@ -.component-cropped-img { - position: relative; - overflow: hidden; - - .img { - z-index: 10; - position: absolute; - left: -10000%; - right: -10000%; - top: -10000%; - bottom: -10000%; - margin: auto; - transform: scale(.101); - min-width: 1000%; - min-height: 1000%; - max-width: 10000%; - max-height: 10000%; - } -} diff --git a/assets/scss/modules/components/image-overlay.scss b/assets/scss/modules/components/image-overlay.scss deleted file mode 100644 index ceda6a7..0000000 --- a/assets/scss/modules/components/image-overlay.scss +++ /dev/null @@ -1,16 +0,0 @@ -.component-image-overlay { - position: relative; - - &:before { - content: ""; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - height: 100%; - width: 100%; - background: color(grey, mid-dark); - opacity: .6; - } -} diff --git a/assets/scss/modules/containers.scss b/assets/scss/modules/containers.scss new file mode 100644 index 0000000..e69de29 diff --git a/assets/scss/modules/footer.scss b/assets/scss/modules/footer.scss index 9c1fe49..e69de29 100644 --- a/assets/scss/modules/footer.scss +++ b/assets/scss/modules/footer.scss @@ -1,3 +0,0 @@ -.module-footer { - -} \ No newline at end of file diff --git a/assets/scss/modules/navigation.scss b/assets/scss/modules/navigation.scss index b55eb82..e69de29 100644 --- a/assets/scss/modules/navigation.scss +++ b/assets/scss/modules/navigation.scss @@ -1,3 +0,0 @@ -.module-navigation { - -} \ No newline at end of file diff --git a/assets/scss/pages/_all.scss b/assets/scss/pages/_all.scss deleted file mode 100644 index c38d744..0000000 --- a/assets/scss/pages/_all.scss +++ /dev/null @@ -1 +0,0 @@ -@import "page"; diff --git a/assets/scss/pages/page.scss b/assets/scss/pages/page.scss deleted file mode 100644 index b7d69b5..0000000 --- a/assets/scss/pages/page.scss +++ /dev/null @@ -1,3 +0,0 @@ -.module-page { - -} diff --git a/assets/scss/utils/mixins.scss b/assets/scss/utils/mixins.scss index 834f0ee..644bd6a 100644 --- a/assets/scss/utils/mixins.scss +++ b/assets/scss/utils/mixins.scss @@ -88,3 +88,31 @@ font-size: $max-size; } } + +@mixin responsive-line-height($options) { + $min-size: map-get($options, min-size); + $max-size: map-get($options, max-size); + $lower-bound: map-get($options, lower-bound); + $upper-bound: map-get($options, upper-bound); + + $max-minus-min: strip-unit($max-size) - strip-unit($min-size); + + @if(index('rem', unit($min-size)) != null and index('rem', unit($max-size)) != null) { + $base-rem: 10; + $upper-minus-lower: strip-unit($upper-bound / $base-rem) - strip-unit($lower-bound / $base-rem); + $lower-bound-rems: #{strip-unit($lower-bound / $base-rem)}rem; + + line-height: calc(#{$min-size} + #{$max-minus-min} * ((100vw - #{$lower-bound-rems}) / #{$upper-minus-lower})); + } @else { + $upper-minus-lower: strip-unit($upper-bound) - strip-unit($lower-bound); + line-height: calc(#{$min-size} + #{$max-minus-min} * ((100vw - #{$lower-bound}) / #{$upper-minus-lower})); + } + + @include mq-below($lower-bound) { + line-height: $min-size; + } + + @include mq-above($upper-bound) { + line-height: $max-size; + } +} diff --git a/assets/shared-vars.json b/assets/shared-vars.json index 9f6ec61..42853d2 100644 --- a/assets/shared-vars.json +++ b/assets/shared-vars.json @@ -14,14 +14,11 @@ "default": 0 }, "breakpoints": { - "x-tiny": 350, - "tiny": 400, - "x-small": 480, - "mid-small": 600, - "small": 768, - "medium": 960, - "large": 1224, - "x-large": 1440, - "xx-large": 1525 + "phone-small": 340, + "phone-large": 600, + "tablet": 870, + "tablet-large": 1030, + "desktop-small": 1230, + "desktop-medium": 1270 } } diff --git a/assets/web/.gitkeep b/assets/web/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/composer.json b/composer.json index 7a3e4b7..b8f15b2 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,6 @@ "description": "Craft CMS", "type": "project", "require": { - "anubarak/craft-relabel": "^1.2", "craftcms/aws-s3": "^1.1", "craftcms/cms": "^3.0.0", "craftcms/redactor": "^2.3", diff --git a/composer.json.default b/composer.json.default index 13d3f41..9b78814 100644 --- a/composer.json.default +++ b/composer.json.default @@ -1,6 +1,5 @@ { "require": { - "anubarak/craft-relabel": "^1.2", "craftcms/aws-s3": "^1.1", "craftcms/cms": "^3.0.0", "craftcms/redactor": "^2.3", diff --git a/config/app.php b/config/app.php index da97795..24069b1 100644 --- a/config/app.php +++ b/config/app.php @@ -20,6 +20,12 @@ return [ 'modules' => [ 'my-module' => \modules\Module::class, + 'twighelpers' => [ + 'class' => \modules\twighelpers\TwigHelpers::class, + ], ], - //'bootstrap' => ['my-module'], +// 'bootstrap' => [ +// 'my-module', +// 'twighelpers', +// ], ]; diff --git a/config/general.php b/config/general.php index 82cdba9..4fa209d 100644 --- a/config/general.php +++ b/config/general.php @@ -8,6 +8,8 @@ * @see \craft\config\GeneralConfig */ +use craft\helpers\ConfigHelper; + return [ // Global settings '*' => [ @@ -26,12 +28,18 @@ // Whether to save the project config out to config/project.yaml // (see https://docs.craftcms.com/v3/project-config.html) 'useProjectConfigFile' => true, + + 'pageTrigger' => '?page=', + + 'maxUploadFileSize' => ConfigHelper::sizeInBytes('128M'), ], // Dev environment settings 'dev' => [ // Dev Mode (see https://craftcms.com/guides/what-dev-mode-does) 'devMode' => true, + + 'enableTemplateCaching' => false, ], // Staging environment settings diff --git a/config/redactor/Simple.json b/config/redactor/Simple.json index f0ded2c..f6d4f31 100644 --- a/config/redactor/Simple.json +++ b/config/redactor/Simple.json @@ -1,4 +1,4 @@ { - "buttons": ["bold", "italic"], - "toolbarFixed": true + "buttons": ["bold", "italic", "link", "file"], + "toolbarFixed": true } diff --git a/config/redactor/Standard.json b/config/redactor/Standard.json index d02c233..818b170 100644 --- a/config/redactor/Standard.json +++ b/config/redactor/Standard.json @@ -1,6 +1,6 @@ { - "buttons": ["formatting", "bold", "italic", "unorderedlist", "orderedlist", "link", "image", "video"], - "plugins": ["fullscreen", "video"], + "buttons": ["formatting", "bold", "italic", "unorderedlist", "orderedlist", "link", "file", "image", "video"], + "plugins": ["alignment", "fullscreen", "video"], "linkNewTab": true, "toolbarFixed": true } diff --git a/fortrabbit.yml b/fortrabbit.yml new file mode 100644 index 0000000..35cf207 --- /dev/null +++ b/fortrabbit.yml @@ -0,0 +1,7 @@ +version: 2 + +# called before Composer runs +#pre: + +# called after Composer runs +post: scripts/fortrabbit-post-install.php diff --git a/modules/twighelpers/TwigHelpers.php b/modules/twighelpers/TwigHelpers.php new file mode 100644 index 0000000..4c73ffe --- /dev/null +++ b/modules/twighelpers/TwigHelpers.php @@ -0,0 +1,47 @@ +getBasePath()); + + static::setInstance($this); + + parent::__construct($id, $parent, $config); + } + + public function init() + { + parent::init(); + self::$instance = $this; + + // Add in our Twig extensions + Craft::$app->view->registerTwigExtension(new TwigHelpersTwigExtension()); + + Craft::info('twighelpers module loaded', __METHOD__); + } + +} diff --git a/modules/twighelpers/twigextensions/TwigHelpersTwigExtension.php b/modules/twighelpers/twigextensions/TwigHelpersTwigExtension.php new file mode 100644 index 0000000..22f075b --- /dev/null +++ b/modules/twighelpers/twigextensions/TwigHelpersTwigExtension.php @@ -0,0 +1,55 @@ + $item2[$prop] ? -1 : 1; + }); + + return $items; + } + + /** + * @return string + */ + public function getUuid() + { + return StringHelper::UUID(); + } +} diff --git a/package.json b/package.json index f09ad49..9f6565b 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "eslint-config-airbnb-base": "^13.1.0", "eslint-loader": "^2.1.1", "eslint-plugin-import": "^2.14.0", - "eslint-plugin-vue": "^4.7.1", "laravel-mix": "^2.1.14", "laravel-mix-stylelint": "^0.2.0", "node-sass-json-importer": "^4.1.0", @@ -33,7 +32,6 @@ "stylelint-webpack-plugin": "^0.10.5" }, "dependencies": { - "normalize.css": "^8.0.1", - "vue": "^2.6.6" + "normalize.css": "^8.0.1" } } diff --git a/scripts/FauxTwigExtension.php b/scripts/FauxTwigExtension.php new file mode 100644 index 0000000..cfdb9a5 --- /dev/null +++ b/scripts/FauxTwigExtension.php @@ -0,0 +1,103 @@ + Include Path. + * You never call it, it's never included anywhere via PHP directly nor does it affect other + * classes or Twig in any way. But PhpStorm will index it, and think all those variables + * are in every single template and thus allows you to use Intellisense auto completion. + * + * Thanks to Robin Schambach; for context, see: + * https://github.com/Haehnchen/idea-php-symfony2-plugin/issues/1103 + * + * @link https://nystudio107.com + * @copyright Copyright (c) 2019 nystudio107 + * @license MIT + * @license https://opensource.org/licenses/MIT MIT Licensed + */ + +namespace php\craft; + +/** + * Class FauxCraftVariable extends the actual Craft Variable, but with added properties + * that reflect things that are added to the Craft Variable dynamically by + * plugins or modules. + * + * @property \craft\web\twig\variables\Cp $cp + * @property \craft\web\twig\variables\Io $io + * @property \craft\web\twig\variables\Routes $routes + * @property \craft\web\twig\variables\CategoryGroups $categoryGroups + * @property \craft\web\twig\variables\Config $config + * @property \craft\web\twig\variables\Deprecator $deprecator + * @property \craft\web\twig\variables\ElementIndexes $elementIndexes + * @property \craft\web\twig\variables\EntryRevisions $entryRevisions + * @property \craft\web\twig\variables\Feeds $feeds + * @property \craft\web\twig\variables\Fields $fields + * @property \craft\web\twig\variables\Globals $globals + * @property \craft\web\twig\variables\I18N $i18n + * @property \craft\web\twig\variables\Request $request + * @property \craft\web\twig\variables\Sections $sections + * @property \craft\web\twig\variables\SystemSettings $systemSettings + * @property \craft\web\twig\variables\UserSession $session + * @property \putyourlightson\blitz\variables\BlitzVariable $blitz + * @property \nystudio107\twigpack\variables\ManifestVariable $twigpack + * @mixin \craft\commerce\web\twig\CraftVariableBehavior + * + * @author nystudio107 + * @package nystudio107\craft + * @since 1.0.2 + */ +class FauxCraftVariable extends \craft\web\twig\variables\CraftVariable +{ +} + +/** + * Class FauxTwigExtension provides a faux Twig extension for PhpStorm to index + * so that we get Intellisense auto-complete in our Twig templates. + * + * @author nystudio107 + * @package nystudio107\craft + * @since 1.0.2 + */ +class FauxTwigExtension extends \Twig\Extension\AbstractExtension implements \Twig\Extension\GlobalsInterface +{ + public function getGlobals(): array + { + return [ + // Craft Variable + 'craft' => new FauxCraftVariable(), + // Craft Elements + 'asset' => new \craft\elements\Asset(), + 'category' => new \craft\elements\Category(), + 'entry' => new \craft\elements\Entry(), + 'tag' => new \craft\elements\Tag(), + // Craft "Constants" + 'SORT_ASC' => 4, + 'SORT_DESC' => 3, + 'SORT_REGULAR' => 0, + 'SORT_NUMERIC' => 1, + 'SORT_STRING' => 2, + 'SORT_LOCALE_STRING' => 5, + 'SORT_NATURAL' => 6, + 'SORT_FLAG_CASE' => 8, + 'POS_HEAD' => 1, + 'POS_BEGIN' => 2, + 'POS_END' => 3, + 'POS_READY' => 4, + 'POS_LOAD' => 5, + // Misc. Craft globals + 'currentUser' => new \craft\elements\User(), + 'currentSite' => new \craft\models\Site(), + 'now' => new \DateTime(), + ]; + } +} diff --git a/scripts/composer-post-install.php b/scripts/composer-post-install.php new file mode 100644 index 0000000..c9e351b --- /dev/null +++ b/scripts/composer-post-install.php @@ -0,0 +1,4 @@ + - - - - {% for block in codeBlocks %} - {% if block.position == 'headTop' %} - {{ block.code|raw }} - {% endif %} - {% endfor %} - + + + +{# {% for block in codeBlocks %}#} +{# {% if block.position == 'headTop' %}#} +{# {{ block.code|raw }}#} +{# {% endif %}#} +{# {% endfor %}#} + - {% for block in codeBlocks %} - {% if block.position == 'headBottom' %} - {{ block.code|raw }} - {% endif %} - {% endfor %} +{# {% for block in codeBlocks %}#} +{# {% if block.position == 'headBottom' %}#} +{# {{ block.code|raw }}#} +{# {% endif %}#} +{# {% endfor %}#} -{% for block in codeBlocks %} - {% if block.position == 'bodyTop' %} - {{ block.code|raw }} - {% endif %} -{% endfor %} +{# {% for block in codeBlocks %}#} +{# {% if block.position == 'bodyTop' %}#} +{# {{ block.code|raw }}#} +{# {% endif %}#} +{# {% endfor %}#} -
+ {% block navigation %}{% endblock %} + +
{% block main %}{% endblock %} -
+ + + {% block footer %}{% endblock %} -{% block outsideRoot %}{% endblock %} - - - - - + + + {% block beforeScripts %}{% endblock %} + + + + {% block afterScripts %}{% endblock %} -{% for block in codeBlocks %} - {% if block.position == 'bodyBottom' %} - {{ block.code|raw }} - {% endif %} -{% endfor %} +{# {% for block in codeBlocks %}#} +{# {% if block.position == 'bodyBottom' %}#} +{# {{ block.code|raw }}#} +{# {% endif %}#} +{# {% endfor %}#} diff --git a/templates/helpers/image.twig b/templates/helpers/image.twig index ed3efc6..e3f5e8d 100644 --- a/templates/helpers/image.twig +++ b/templates/helpers/image.twig @@ -1,89 +1,112 @@ {% macro cropped(image, options) %} - {% if options is defined %} - {% set dimensions = { - mode: 'crop', - width: options.width, - height: options.height, - quality: options.quality ?? 100, - position: 'center-center' - } %} + {% spaceless %} + {% if image %} + {% set defaults = { + quality: 100, + class: '', + attrs: '', + } %} + + {% set options = defaults|merge(options) %} - {% set attrs = '' %} + {% set dimensions = { + mode: 'crop', + width: options.width, + height: options.height, + quality: options.quality, + position: 'center-center' + } %} - {% if options.attrs is defined %} - {% set attrs = options.attrs %} - {% endif %} - {{ image.altText }} - {% else %} - {{ image.altText }} + {{ image.altText ?? image.title }} {% endif %} + {% endspaceless %} {% endmacro %} -{% macro backgroundCropped(image, options) %} - {% if options is defined %} + +{% macro fit(image, options) %} + {% spaceless %} + {% if image %} + {% set defaults = { + quality: 100, + class: '', + attrs: '', + } %} + + {% set options = defaults|merge(options) %} + + {% if options.width is defined %} {% set dimensions = { - mode: 'crop', - width: options.width, - height: options.height, - quality: options.quality ?? 100, - position: 'center-center' + mode: 'fit', + width: options.width } %} + {% elseif options.height is defined %} + {% set dimensions = { + mode: 'fit', + height: options.height + } %} + {% endif %} - {% set styles = '' %} - - {% if options.additionalStyles is defined %} - {% set styles = ' ' ~ options.additionalStyles %} - {% endif %} - style="background-image: url('{{ image.getUrl(dimensions) }}');{{ styles }}" - {% else %} - style="background-image: url('{{ image.url }}');" + {{ image.altText ?? image.title }} {% endif %} + {% endspaceless %} {% endmacro %} -{% macro backgroundFit(image, options) %} +{% macro backgroundCropped(image, options) %} + {% spaceless %} {% if image %} - {% if options is defined %} - {% set styles = '' %} - - {% if options.additionalStyles is defined %} - {% set styles = ' ' ~ options.additionalStyles %} - {% endif %} - - {% if options.width is defined %} - {% set dimensions = { - mode: 'fit', - width: options.width - } %} - {% elseif options.height is defined %} - {% set dimensions = { - mode: 'fit', - height: options.height - } %} - {% endif %} - style="background-image: url('{{ image.getUrl(dimensions) }}');{{ styles }}" - {% else %} - style="background-image: url('{{ image.url }}');" - {% endif %} + {% set defaults = { + quality: 100, + styles: '', + } %} + + {% set options = defaults|merge(options) %} + + {% set dimensions = { + mode: 'crop', + width: options.width, + height: options.height, + quality: options.quality, + position: 'center-center' + } %} + + style="background-image: url('{{ image.getUrl(dimensions) }}');{{ options.styles }}" {% endif %} + {% endspaceless %} {% endmacro %} -{% macro fit(image, options) %} +{% macro backgroundFit(image, options) %} + {% spaceless %} {% if image %} - {% if options is defined %} - {% if options.width is defined %} - {% set dimensions = { - mode: 'fit', - width: options.width - } %} - {% elseif options.height is defined %} - {% set dimensions = { - mode: 'fit', - height: options.height - } %} - {% endif %} - {{ image.altText }} - {% else %} - {{ image.altText }} - {% endif %} + {% set defaults = { + quality: 100, + styles: '', + } %} + + {% set options = defaults|merge(options) %} + + {% if options.width is defined %} + {% set dimensions = { + mode: 'fit', + width: options.width + } %} + {% elseif options.height is defined %} + {% set dimensions = { + mode: 'fit', + height: options.height + } %} + {% endif %} + + style="background-image: url('{{ image.getUrl(dimensions) }}');{{ options.styles }}" {% endif %} + {% endspaceless %} {% endmacro %} diff --git a/templates/helpers/text.twig b/templates/helpers/text.twig new file mode 100644 index 0000000..596e476 --- /dev/null +++ b/templates/helpers/text.twig @@ -0,0 +1,15 @@ +{% macro truncate(text, limit, append) %} + {% set suffix = append|default('...') %} + {% set punctuation = ['.',',','-',':',';'] %} + + {% set array = text|split(' ') %} + {% set arrayTruncated = array|slice(0, limit) %} + {% set string = arrayTruncated|join(' ') %} + {% if limit and array|length > limit %} + {% for mark in punctuation %} + {% set string = string|trim(mark) %} + {% endfor %} + {% set string = string ~ suffix %} + {% endif %} + {{ string|raw }} +{% endmacro %} diff --git a/templates/layouts/main.twig b/templates/layouts/main.twig index 0f8d105..bd7bcea 100644 --- a/templates/layouts/main.twig +++ b/templates/layouts/main.twig @@ -1,11 +1,15 @@ -{% extends 'base.html' %} +{% extends 'base' %} + +{% block navigation %} + {% include 'modules/navigation' %} +{% endblock %} {% block main %} - {% include 'modules/navigation.twig' %} -
- {% block preBlocks %}{% endblock %} - {% include 'modules/blocks/_index.twig' %} - {% block postBlocks %}{% endblock %} -
- {% include 'modules/footer.twig' %} + {% block preBlocks %}{% endblock %} + {% include 'modules/blocks/_index.twig' %} + {% block postBlocks %}{% endblock %} +{% endblock %} + +{% block footer %} + {% include 'modules/footer' %} {% endblock %} diff --git a/templates/modules/blocks/_index.twig b/templates/modules/blocks/_index.twig index f6d86a9..0998eac 100644 --- a/templates/modules/blocks/_index.twig +++ b/templates/modules/blocks/_index.twig @@ -1,3 +1,3 @@ {% for block in entry.blocks.level(1).all() %} - {% include ['modules/blocks/' ~ block.type, 'modules/blocks/noBlock.html'] with { block: block } %} + {% include ['modules/blocks/' ~ block.type, 'modules/blocks/noBlock.twig'] with { block: block } %} {% endfor %} diff --git a/templates/modules/blocks/sharedBlock.twig b/templates/modules/blocks/sharedBlock.twig index 6b2d720..597da19 100644 --- a/templates/modules/blocks/sharedBlock.twig +++ b/templates/modules/blocks/sharedBlock.twig @@ -1,4 +1,4 @@ {% set blocks = block.sharedBlock.one().blocks.level(1).all() %} {% for block in blocks %} - {% include ['modules/blocks/' ~ block.type, 'modules/blocks/noBlock.html'] with { block: block } %} + {% include ['modules/blocks/' ~ block.type, 'modules/blocks/noBlock.twig'] with { block: block } %} {% endfor %} diff --git a/templates/modules/footer.twig b/templates/modules/footer.twig index 25edd1f..0ed3a6c 100644 --- a/templates/modules/footer.twig +++ b/templates/modules/footer.twig @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/templates/modules/nav.twig b/templates/modules/nav.twig new file mode 100644 index 0000000..9bbf06e --- /dev/null +++ b/templates/modules/nav.twig @@ -0,0 +1,5 @@ +
+ +
diff --git a/templates/modules/navigation.twig b/templates/modules/navigation.twig deleted file mode 100644 index ad92872..0000000 --- a/templates/modules/navigation.twig +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/templates/pages/modular.twig b/templates/pages/modular.twig index 677070e..8dddd03 100644 --- a/templates/pages/modular.twig +++ b/templates/pages/modular.twig @@ -1 +1 @@ -{% extends 'layouts/main.html' %} +{% extends 'layouts/main.twig' %} diff --git a/webpack.mix.js b/webpack.mix.js index a9074ae..73f0c80 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -5,9 +5,7 @@ require('laravel-mix-stylelint'); mix.version() .disableNotifications() .setPublicPath('web') - .extract([ - 'vue', - ]) + // .extract([]) .js('assets/js/main.js', 'web/js') .sass('assets/scss/main.scss', 'web/css', { importer: sassJsonImporter(), @@ -15,6 +13,8 @@ mix.version() .stylelint({ context: './assets/', }) + .copyDirectory('assets/img', 'web/img') + .copyDirectory('assets/web', 'web') .sourceMaps() .webpackConfig({ output: {