Skip to content

Instantly share code, notes, and snippets.

@lewisnyman
lewisnyman / gist:2782134
Created May 24, 2012 15:10
Recreating the jQuery animation speed syntax for CSS animations using LESS
.animation-duration(@time) {
-webkit-animation-duration: @time;
-moz-animation-duration: @time;
-ms-animation-duration: @time;
-o-animation-duration: @time;
animation-duration: @time;
}
.animation-duration(@time) when (@time = fast) {
-webkit-animation-duration: 0.25s;
@lewisnyman
lewisnyman / Handlebars.idsafe
Last active December 14, 2015 05:49
A Handlebars helper for making a string HTML ID safe
Handlebars.registerHelper('idsafe', function(str) {
str = str.replace(/ /g , "-");
return str.toLowerCase();
});
@lewisnyman
lewisnyman / gist:5651296
Created May 26, 2013 00:22
template_preprocess_html
/**
* Prepares variables for HTML document templates.
*
* Default template: html.html.twig.
*
* @param array $variables
* An associative array containing:
* - page: A render element representing the page.
*
* @see system_elements()
@lewisnyman
lewisnyman / gist:10c756cb6f7a204485ca
Created February 6, 2015 14:23
Current CSSlint output for all CSS files in Drupalcore
[15:23:30] Using gulpfile /Library/WebServer/Documents/drupalcore-frontend-toolkit/gulpfile.js
[15:23:30] Starting 'csslint'...
[15:23:30] Finished 'csslint' after 6.32 ms
[15:23:31] 4 errors found in /Library/WebServer/Documents/core/modules/block/css/block.admin.css
[15:23:31] [L46:C1] Don't use IDs in selectors. Selectors should not contain IDs. (ids)
[15:23:31] [L49:C1] Don't use IDs in selectors. Selectors should not contain IDs. (ids)
[15:23:31] [L52:C1] Don't use IDs in selectors. Selectors should not contain IDs. (ids)
[15:23:31] [L64:C5] Using width with padding-right can sometimes make elements larger than you expect. Don't use width or height when using padding or border. (box-model)
[15:23:31] 2 errors found in /Library/WebServer/Documents/core/modules/ckeditor/css/ckeditor-iframe.css
[15:23:31] [L21:C3] Property with star prefix found. Checks for the star property hack (targets IE6/7) (star-property-hack)
@lewisnyman
lewisnyman / box.twig
Last active November 27, 2017 17:39
Patternab twig example patterns
<div class="box {{class}}">
<h2 class="box__title">{{title}}</h2>
<div class="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.</p>
</div>
<div class="box__actions">
{% include "atoms-button" with
{
"element": "a",
"text": "Find out more",
@lewisnyman
lewisnyman / example.twig
Created October 16, 2015 15:42
Loading Twig templates in Drupal 8
{# Load a template from the current active theme registry #}
{% include "table.html.twig" %}
{# Load a template relative to a module or theme's template directory #}
{% include "@module_or_theme/table.html.twig" %}
{# Load from the full path #}
{% include "themes/mytheme/table.html.twig" %}
@lewisnyman
lewisnyman / flexslider-init.js
Created November 9, 2015 13:37
A JS file to initialise flexslider.js in Drupal 8
(function ($, Drupal) {
'use strict';
/**
* Initialise the flexslider JS.
*/
Drupal.behaviors.felxsliderInit = {
attach: function (context, settings) {
var slider = $(context).find('.js-slider');
@lewisnyman
lewisnyman / halifax-online.co.uk
Created January 2, 2016 11:23
Remove the advertising and noise from Halifax's new online banking design
@-moz-document domain("secure.halifax-online.co.uk") {
.mvt_content,
.layout-default .layout-side,
.m-672-dm-sticker,
.sp-505-d-newly-upgraded-user-header,
.sp-pat-m-hf-01-bank-bar .m-01-menu-bar,
.productPromo {
display: none;
}
.secondary {
@lewisnyman
lewisnyman / widont.html
Created October 7, 2016 11:35
Prevent widows in Jekyll on Github pages
<!-- { Prevent widows without using a liquid filter } -->
{% assign split_title = page.title | split: ' ' %}
{% capture title %}
{% for word in split_title %}{% if forloop.last == true %}&nbsp;{{ word | strip }}{% else %} {{ word }}{% endif %}{% endfor %}
{% endcapture %}
@lewisnyman
lewisnyman / field.html.twig
Last active December 21, 2016 14:49
minimal field.html.twig — Drupal 8
{% for item in items %}
{{ item.content }}
{% endfor %}