Skip to content

Instantly share code, notes, and snippets.

View mortendk's full-sized avatar
🤠
git commit -m "yolo"

mortendk mortendk

🤠
git commit -m "yolo"
View GitHub Profile
@mortendk
mortendk / themename.info
Created September 2, 2012 18:50
drupal: theme.info foad
;-------------- CSS FOAD -------------
;stylesheets[all][] = donteverloadmeagain.css
stylesheets[all][] = system.theme.css
stylesheets[all][] = system.menus.css
stylesheets[all][] = system.messages.css
stylesheets[all][] = jquery.ui.theme.css
stylesheets[all][] = user.css
stylesheets[all][] = field.css
stylesheets[all][] = node.css
stylesheets[all][] = comment.css
@mortendk
mortendk / _menu_dropdown.scss
Created October 15, 2012 10:13
dropdown css
/*
This will create a dropdown build on clean mean css
*/
/* -- Dropdown Structure ------------------------------------------------------------------ */
.dropdown { position: relative;}
.dropdown a{ display:block;}
.dropdown ul li{ float:left; position:relative; list-style:none;}
/* lvl 2 : hide the ul & bring it back on hover */
.dropdown ul li ul{ left:-99999px; position:absolute; z-index:9999; margin:0; background:transparent;}
@mortendk
mortendk / _tooltip.scss
Created October 15, 2012 10:14
tooltip forms drupal
//tooltips for forms
form.tooltip{
small,
.description{
text-align:left;
width:200px;
color: white;
background: #666;
@include border-radius(2px);
@mortendk
mortendk / classy-css.html
Created October 25, 2015 23:18
classy css selectors
Document all css class selectors that are in the classy theme.
<code>
.foo { }
.foo-bar { }
</code>
where it is filename.html.twig / filename.css
<h3>Available css selectors in the Classy theme:</h3>
<!doctype html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>mobile & drop down menu</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){
@mortendk
mortendk / field--image.html.twig
Created September 18, 2013 15:06
field image twig
{# title wtf is this called label btw #}
{% if not label_hidden %}
<h3 {{ title_attributes }}>{{ label }}:&nbsp;</h3>
{% endif %}
{% for delta, item in items %}
{% if loop.length > 1 %} {# no wrappers if theres only 1 item#}
<section class="images" {{ content_attributes }}> {# wanna do a print all attributes but no class #}
@mortendk
mortendk / twig-loop-template.html.twig
Last active April 29, 2016 09:29
twig loop template
{# loop template #}
{% for item in items %}
{# assing foo, bar or baz to the var foo then print em out #}
{%
set var = [
cycle(["foo", "bar", "baz"], loop.index),
]
%}
{% if loop.first %}
{# first #} {{ var }}
@mortendk
mortendk / template-choser.md
Last active April 29, 2016 09:32
Drupal8 concept for selecting templates form the ui

template chooser

Drupal8 is pretty awesome, but its a problem that you cant choose fromt the ui which template to use. Sure you can overwrite whats there (node--article.html.twig) but that dont give the end user a chance to later change in the site & can end up in even more templates & clutter.

template suggestions

Make it easy to provide a template suggestion for entities, blocks, pages, nodes, fields, menues, username, everything that have a template you should be able to give a suggestion.

class selector

A prepopulated list of classes that can be selected for a template.

The modules userbase is sitebuilders & themes that wants to provide variations for a site, developers dont have to provide templates after a site is build, and can rely on the theme to provide all the variations.

/**
* Implements hook_preprocess_menu().
*/
function vanilla_preprocess_menu(&$vars, $hook) {
if ($hook == 'menu_main') {
kint($hook);
$items = $vars['items'];
foreach ($items as $key => $item) {
$original_title = $vars['items'][$key]['title'];
$vars['items'][$key]['title'] = array(
@mortendk
mortendk / input--submit.html.twig
Created July 16, 2016 11:54
input submit as buttons
{{ attach_library(active_theme()~'/form') }}
{# find the unique name for the button. #}
{% if element['#value'].getUntranslatedString() %}
{% set element_name = element['#value'].getUntranslatedString()|clean_class %}
{% else %}
{% set element_name = element['#value']|clean_class %}
{% endif %}
{# We dont use form-submit or button--primary for the css so lets remove it. #}