Skip to content

Instantly share code, notes, and snippets.

View RainbowArray's full-sized avatar

Heather Brooke Drummond RainbowArray

View GitHub Profile
@RainbowArray
RainbowArray / composer.json
Last active June 16, 2016 19:07
Drupal 8 composer with Pantheon
{
"name": "",
"description": "Constructing Drupal 8 docroot with upstream drops-8 updates",
"type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "",
"email": ""
}
git branch -a | grep -v '8.0.x\|8.1.x\|8.2.x\| 2061377-151-reroll-wysiwyg-image-styles\|remotes' | xargs git branch -D
@RainbowArray
RainbowArray / fragment-of-page-html.html.twig
Created February 15, 2016 21:08
Need to include a node field image in the page.html.twig template with Drupal 8? This is the most straightforward way I've found to do so. (This is using the file entity module.)
{% if node.field_hero_image.entity %}
<img src="{{ file_url(node.field_hero_image.entity.uri.value) }}"
alt="{{ node.field_hero_image.alt }}"
{% if node.field_hero_image.title %}
title="{{ node.field_hero_image.title }}"
{% endif %}
/>
{% endif %}
@RainbowArray
RainbowArray / THEMENAME.theme
Created January 27, 2016 20:03
Change meta viewport tag in D8
<?php
/**
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
function THEMENAME_preprocess_html(&$variables) {
foreach ($variables['page']['#attached']['html_head'] as $key => $value) {
if ($value[1] === 'viewport') {
$value[0]['#attributes']['content'] = 'width=device-width,minimum-scale=1,initial-scale=1';
$variables['page']['#attached']['html_head'][$key] = $value;
@RainbowArray
RainbowArray / gist:67db4735d649a8efe694
Last active October 7, 2015 22:55
Prioritized theming changes to get in before RC1
RTBC
Needs Review
- Rename menu regions (https://www.drupal.org/node/2513526)
- Remove classes from C templates (https://www.drupal.org/node/2407723)
Needs Work
- Dream markup for tabs (https://www.drupal.org/node/1999182)
- Remove classes from F templates (https://www.drupal.org/node/2407727)
- Remove classes from P templates: very old patch (https://www.drupal.org/node/2407737)
@RainbowArray
RainbowArray / emtopx
Created July 30, 2014 05:22
Sass em to px conversion
@function em2px($target, $context: $base-font-size-em) {
@if $target == 0 { @return 0 }
@return ($target / 1em) * ($context / 1em) * 16 + 0px;
}
@RainbowArray
RainbowArray / gist:7660902
Last active December 29, 2015 10:59
Modernizr svg/png switching?
if (!Modernizr.svg) {
var svgs = document.querySelectorAll('img[src$=".svg"]');
for (var i = 0, j = svgs.length; i < j; i++) {
var src = svgs[i].src.replace('.svg', '.png');
}
for (var k = 0, l = svgs.length; k < l; k++) {
svgs[k].setAttribute('src', src);
}
}