Skip to content

Instantly share code, notes, and snippets.

View wesruv's full-sized avatar
🤔
Why can I have a status?

wesruv wesruv

🤔
Why can I have a status?
View GitHub Profile
@wesruv
wesruv / D8-and-D7-theme-files.md
Last active January 22, 2020 01:39
D8 and D7 template file syntax

D8 and D7 template file syntax

Below are examples of basic structures you need in templating shown in Twig (Drupal 8) and PHPTemplate (Drupal 7).

Code Comments

{# My code comment, won't appear in the HTML #}
<?php // My code comment, won't appear in the HTML ?>
<?php
// Code that accesses entity data for a template with lots of good examples of how to get information
/**
* Implements hook_preprocess_HOOK() for Paragraph templates.
*/
function THEMENAME_preprocess_paragraph(&$variables) {
$paragraphy_type = $variables['paragraph']->getType();
/**
* Optimized scroll handler
* @see https://developer.mozilla.org/en-US/docs/Web/Events/resize#requestAnimationFrame
*
* @example
* scroll.add(() => console.log('Resource conscious scroll callback!'));
*/
// eslint-disable-next-line no-unused-vars
export const scroll = (function() {
let callbacks = [],
// Defined globally in my project
$gutter: 18px;
/// Returns a CSS value to imitate a grid item when column widths are fluid with gutters are static
/// Is written to optimize CSS output, so Scss has to be a bit verbose
/// @require $gutter
///
/// @param {number} $column-span How many columns wide element should be
/// @param {number} $total-columns How many total columns are available
/// @param {number} $total What is the total width, will typically be 100%, but could be grid's max-width

Scss Style Guide Starter

Special thanks to Carwin Young (Github @carwin) whose docs this is based on

This is a guide for formatting Sass stylesheets, it's goals are:

  • To encourage consistency between developers in a repository.
  • Styles applying to an element should be in one place
  • Code should be easily find-able and legible by humans
  • Classes are mostly explicitly named (pointing to specific elements, not functionality)
---
layout: _includes/layout-basic.njk
title: Collapsible Box
tags:
- component
- component_medium
contentTitle: Collapsible Box
content: <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate veli esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
---
@wesruv
wesruv / .lando.yml
Last active February 17, 2020 20:01
Lando config for a Drupal 7 site with Compass Sass
name: mydrupalprojectwithcompass
recipe: drupal7
config:
webroot: docroot
php: '5.6'
database: mysql:5.7
xdebug: true
events:
post-db-import:
- appserver: cd $LANDO_WEBROOT/sites/default && drush rr
/* eslint-env node, es6 */
/* global require */
'use strict';
/**
* Configuration
*/
// Load dependencies
const {parallel, series, src, dest, task, watch,} = require('gulp'),
/home/wesruv/backdrop/core
$ lando rebuild -y -- -vvv
info: Bootstraping...
verbose: Emitting event pre-bootstrap
debug: Event pre-bootstrap has 0 listeners
debug: Config set: {"configFilename":"config.yml","configSources":["/snapshot/lando/build/cli/config.yml","/home/wesruv/.lando/config.yml"],"env":{"HOME":"/home/wesruv","LANG":"en_US.UTF-8","LOGNAME":"wesruv","MAIL":"/var/mail/wesruv","NVM_BIN":"/home/wesruv/.nvm/versions/node/v8.10.0/bin","NVM_CD_FLAGS":"","NVM_DIR":"/home/wesruv/.nvm","PATH":"/home/wesruv/.nvm/versions/node/v8.10.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games","PWD":"/home/wesruv/backdrop/core","SHELL":"/usr/bin/fish","SHLVL":"1","SSH_AGENT_PID":"4986","SSH_AUTH_SOCK":"/tmp/ssh-64FaUZiaHrYH/agent.4984","SSH_CLIENT":"192.168.1.241 5733 22","SSH_CONNECTION":"192.168.1.241 5733 192.168.1.243 22","SSH_ENV":"/home/wesruv/.ssh/environment","SSH_TTY":"/dev/pts/1","TERM":"xterm","USER":"wesruv","XDG_RUNTIME_DIR":"/run/user/1000","XDG_SESSION_ID":"
<?php
/**
* @file
* Contains \Drupal\scs_restful_events\Plugin\resource\events\Events__1_0.
*/
namespace Drupal\scs_restful_events\Plugin\resource\events;
/**
* Class Events__1_0