Skip to content

Commit

Permalink
Add craft templates, asset rev plugin, and node dependencies for fron…
Browse files Browse the repository at this point in the history
…t-end builds
  • Loading branch information
jeremyfrank committed Mar 30, 2018
1 parent c3dc09d commit da10841
Show file tree
Hide file tree
Showing 32 changed files with 516 additions and 0 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.11.1
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"require": {
"craftcms/cms": "^3.0.0-RC1",
"vlucas/phpdotenv": "^2.4.0",
"clubstudioltd/craft-asset-rev": "^v6.0.0",
"craftcms/redactor": "^1.0.0",
"mikestecker/craft-videoembedder": "^v1.0.0",
"pennebaker/craft-architect": "^2.2.0",
Expand Down
9 changes: 9 additions & 0 deletions config/assetrev.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [

'manifestPath' => 'web/assets/rev-manifest.json',
'assetsBasePath' => 'web/assets',
'assetUrlPrefix' => '/assets/',

];
29 changes: 29 additions & 0 deletions config/path-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"src": "./src",
"dest": "./web/assets",

"javascripts": {
"src": "javascripts",
"dest": "javascripts"
},

"stylesheets": {
"src": "stylesheets",
"dest": "stylesheets"
},

"images": {
"src": "images",
"dest": "images"
},

"fonts": {
"src": "fonts",
"dest": "fonts"
},

"icons": {
"src": "icons",
"dest": "images"
}
}
41 changes: 41 additions & 0 deletions config/task-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var globImporter = require('node-sass-glob-importer')

module.exports = {
images : true,
fonts : true,
svgSprite : true,

stylesheets : {
cssnano: {
safe: true
},
sass: {
importer: globImporter()
}
},

javascripts: {
entry: {
// files paths are relative to
// javascripts.dest in path-config.json
app: ["./app.js"]
},
// This tells webpack middleware where to
// serve js files from in development:
publicPath: "/assets/javascripts"
},

browserSync: {
// Update this to match your development URL
proxy: 'craft-ssk.test',
files: ['templates/**/*']
},

production: {
rev: true
},

ghPages : false,
html : false,
static : false,
}
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "craft",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "yarn run blendid",
"build": "yarn run blendid -- build"
},
"dependencies": {
"blendid": "4.4.3",
"node-sass-glob-importer": "5.1.1"
}
}
Empty file added src/fonts/.gitkeep
Empty file.
Empty file added src/icons/.gitkeep
Empty file.
Empty file added src/images/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions src/javascripts/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './modules'

console.log(`app.js has loaded!`)
6 changes: 6 additions & 0 deletions src/javascripts/modules/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default class Example {
constructor(el) {
this.el = el
console.log(el.textContent, '- From the example module')
}
}
31 changes: 31 additions & 0 deletions src/javascripts/modules/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Automatically instantiates modules based on data-attributes
specifying module file-names.
*/

const moduleElements = document.querySelectorAll('[data-module]')

for (var i = 0; i < moduleElements.length; i++) {
const el = moduleElements[i]
const name = el.getAttribute('data-module')
const Module = require(`./${name}`).default
new Module(el)
}

/*
Usage:
======
html
----
<button data-module="disappear">disappear!</button>
js
--
// modules/disappear.js
export default class Disappear {
constructor(el) {
el.style.display = 'none'
}
}
*/
35 changes: 35 additions & 0 deletions src/stylesheets/blocks/quote.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.quote-block {
clear: both;

blockquote {
&:not([class*="float-"]) {
margin: 0;
text-align: center;
}

&[class*="float-"] {
max-width: 400px;
}

p {
font-size: 24px;
font-weight: bold;

&:first-child::before {
content: ''
}

&:last-of-type::after {
content: ''
}
}
}

cite {
color: #777;
display: block;
font-size: 16px;
font-style: normal;
margin: 0.5em 0 0;
}
}
20 changes: 20 additions & 0 deletions src/stylesheets/blocks/two-column-image-caption.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.two-column-image-caption-block {
clear: both;

.wrapper {
display: flex;
justify-content: space-between;
}

figure {
margin: 0;
width: calc(50% - 20px);
}

figcaption {
color: #777;
font-size: 16px;
font-style: normal;
margin: 0.5em 0 0;
}
}
19 changes: 19 additions & 0 deletions src/stylesheets/blocks/two-column-text.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.two-column-text-block {
clear: both;

.wrapper {
display: flex;
justify-content: space-between;
}

.text {
width: calc(50% - 20px);
}

figcaption {
color: #777;
font-size: 16px;
font-style: normal;
margin: 0.5em 0 0;
}
}
22 changes: 22 additions & 0 deletions src/stylesheets/blocks/video.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.video-block {
clear: both;
}

.video-block__inner {
position: relative;

&::before {
content: '';
display: block;
padding-top: (9/16) * 100%;
width: 100%;
}

iframe {
border: 0;
height: 100%;
position: absolute;
top: 0;
width: 100%;
}
}
67 changes: 67 additions & 0 deletions src/stylesheets/starter.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
body {
color: #444;
font-family: sans-serif;
font-size: 18px;
}

[tabindex="-1"]:focus {
outline: none;
}

img {
max-width: 100%;
vertical-align: middle;
}

*:first-child {
margin-top: 0 !important;
}

*:last-child {
margin-bottom: 0 !important;
}

.wrapper {
margin: auto;
max-width: 800px;

&.-wide {
max-width: 1000px;
}

&.-extrawide {
max-width: 1200px;
}
}

.float-left {
float: left;
margin: 0 40px 40px 0;
}

.float-right {
float: right;
margin: 0 0 40px 40px;
}

.spacing-vertical-small {
margin-bottom: 40px;
margin-top: 40px;
}

.spacing-vertical-medium {
margin-bottom: 60px;
margin-top: 60px;
}

.spacing-vertical-large {
margin-bottom: 100px;
margin-top: 100px;
}

.text {
p {
line-height: (28/18);
margin: 40px 0;
}
}
34 changes: 34 additions & 0 deletions templates/_blocks/image.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{#
Parameters
- image | asset
- display | position select | left, center, right
#}

{% set image = block.image[0] ?? null %}

{% switch block.display %}
{% case 'left' %}
{% set spacingClass = 'spacing-vertical-medium' %}
{% set wrapperClass = '-extrawide' %}
{% set displayClass = 'float-left' %}
{% case 'right' %}
{% set spacingClass = 'spacing-vertical-medium' %}
{% set wrapperClass = '-extrawide' %}
{% set displayClass = 'float-right' %}
{% default %}
{% set spacingClass = 'spacing-vertical-large' %}
{% set wrapperClass = '-wide' %}
{% set displayClass = '' %}
{% endswitch %}

{% set transformOptions = {
width: block.display != 'center' ? 560 : 1000
} %}

{% if image %}
<div class="image-block {{ spacingClass }}">
<div class="wrapper {{ wrapperClass }}">
<img src="{{ image.url(transformOptions) }}" alt="" class="{{ displayClass }}">
</div>
</div>
{% endif %}
40 changes: 40 additions & 0 deletions templates/_blocks/quote.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{#
Parameters
- quote | rich text
- attribution | plain text
- display | position select | left, center, right
#}

{%- import '_macros' as macros -%}
{{ macros.css('blocks/quote') }}

{% set displayClass = block.display != 'center' ? 'float-' ~ block.display %}

{% switch block.display %}
{% case 'left' %}
{% set spacingClass = 'spacing-vertical-small' %}
{% set wrapperClass = '-extrawide' %}
{% set displayClass = 'float-left' %}
{% case 'right' %}
{% set spacingClass = 'spacing-vertical-small' %}
{% set wrapperClass = '-extrawide' %}
{% set displayClass = 'float-right' %}
{% default %}
{% set spacingClass = 'spacing-vertical-medium' %}
{% set wrapperClass = '' %}
{% set displayClass = '' %}
{% endswitch %}

<div class="quote-block {{ spacingClass }}">
<div class="wrapper {{ wrapperClass }}">
<blockquote class="{{ displayClass }}">
{{ block.quote | raw }}

{% if block.attribution %}
<cite>
{{ block.attribution }}
</cite>
{% endif %}
</blockquote>
</div>
</div>
Loading

0 comments on commit da10841

Please sign in to comment.