Skip to content
Snippets Groups Projects
Commit 26da40b7 authored by Liam Morland's avatar Liam Morland
Browse files

Coding standards

parent 560ba639
No related branches found
No related tags found
1 merge request!10Coding standards
Showing
with 102 additions and 40 deletions
......@@ -31,4 +31,4 @@
line-height: 1;
speak: none;
text-transform: none;
}
\ No newline at end of file
}
......@@ -77,8 +77,3 @@ html:not(.js) .uw-tabcontent[role="tabpanel"][hidden]{
font-family: gesso-font-family(systemmedium);
}
}
......@@ -80,6 +80,3 @@ $tag-font-size-small: rem(gesso-font-size(-3)) !default;
}
}
}
......@@ -19,4 +19,4 @@ __Variables:__
* org-env
* org-mat
* org-sci
* org-school
\ No newline at end of file
* org-school
......@@ -28,4 +28,4 @@ __Variables: (same form card)__
* type: [string] Type of the tag, it will add class ".tag--type".
* size: [string] Size of the tag, it will add class ".tag--size"
* url: [string] URL of the tag.
* title: [string] Title of the tag.
\ No newline at end of file
* title: [string] Title of the tag.
......@@ -28,4 +28,4 @@ __Variables: (same form card)__
* type: [string] Type of the tag, it will add class ".tag--type".
* size: [string] Size of the tag, it will add class ".tag--size"
* url: [string] URL of the tag.
* title: [string] Title of the tag.
\ No newline at end of file
* title: [string] Title of the tag.
......@@ -28,4 +28,4 @@ __Variables: (same form card)__
* type: [string] Type of the tag, it will add class ".tag--type".
* size: [string] Size of the tag, it will add class ".tag--size"
* url: [string] URL of the tag.
* title: [string] Title of the tag.
\ No newline at end of file
* title: [string] Title of the tag.
......@@ -33,4 +33,4 @@ __Variables: (same form card)__
* type: [string] Type of the tag, it will add class ".tag--type".
* size: [string] Size of the tag, it will add class ".tag--size"
* url: [string] URL of the tag.
* title: [string] Title of the tag.
\ No newline at end of file
* title: [string] Title of the tag.
......@@ -5,4 +5,3 @@ title: Territorial statement
__Variables:__
* modifier_classes: Choose "black or white" to determine the background color of the statement"
......@@ -52,6 +52,3 @@
.view__filters {
margin-bottom: rem(gesso-spacing(sm));
}
<?php
/**
* @file
*/
/**
*
*/
function addCleanClassFilter(\Twig_Environment &$env, $config) {
$env->addFilter(new \Twig_SimpleFilter('clean_class', function ($string) {
$filters = [
......@@ -12,8 +20,8 @@ function addCleanClassFilter(\Twig_Environment &$env, $config) {
$string = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $string);
$string = preg_replace([
'/^[0-9]/',
'/^(-[0-9])|^(--)/'
'/^(-[0-9])|^(--)/',
], ['_', '__'], $string);
return $string;
}));
}
\ No newline at end of file
}
<?php
/**
* @file
*/
/**
*
*/
function addCleanIdFilter(\Twig_Environment &$env, $config) {
$env->addFilter(new \Twig_SimpleFilter('clean_id', function ($string) {
return $string;
}));
}
\ No newline at end of file
}
<?php
/**
* @file
*/
/**
*
*/
function addFormatDateFilter(\Twig_Environment &$env, $config) {
$env->addFilter(new \Twig_SimpleFilter('format_date', function ($string) {
return $string;
}));
}
\ No newline at end of file
}
<?php
/**
* @file
*/
/**
*
*/
function addPlaceholderFilter(\Twig_Environment &$env, $config) {
$env->addFilter(new \Twig_SimpleFilter('placeholder', function ($string) {
return $string;
}));
}
\ No newline at end of file
}
<?php
/**
* @file
*/
/**
*
*/
function addRenderFilter(\Twig_Environment &$env, $config) {
// Drupal Render filter
// Drupal Render filter.
$env->addFilter(new \Twig_SimpleFilter('render', function ($string) {
return $string;
}));
......
<?php
/**
* @file
*/
/**
*
*/
function addSafeJoinFilter(\Twig_Environment &$env, $config) {
// Drupal Safe Join filter
// Drupal Safe Join filter.
$env->addFilter(new \Twig_SimpleFilter('safe_join', function ($string) {
return $string;
}));
}
\ No newline at end of file
}
<?php
/**
* @file
*/
/**
*
*/
function addTFilter(\Twig_Environment &$env, $config) {
// Drupal translate filter
// Drupal translate filter.
$env->addFilter(new \Twig_SimpleFilter('t', function ($string) {
return $string;
}));
}
\ No newline at end of file
}
<?php
/**
* @file
*/
/**
*
*/
function addWithoutFilter(\Twig_Environment &$env, $config) {
$env->addFilter(new Twig_SimpleFilter('without', function ($string) {
return $string;
......
<?php
/**
* @file
* Creates an "add_attributes" function for Drupal that adds attributes
* with optional additions while preventing attributes from trickling down
* through includes.
* Based on https://github.com/drupal-pattern-lab/add-attributes-twig-extension
* Creates an "add_attributes" function for Drupal.
*
* Creates an "add_attributes" function for Drupal that adds attributes with
* optional additions while preventing attributes from trickling down through
* includes.
*
* @see https://github.com/drupal-pattern-lab/add-attributes-twig-extension
*/
use Drupal\Core\Template\Attribute;
......@@ -15,11 +19,11 @@ $function = new Twig_SimpleFunction('add_attributes', function ($context, $addit
$attributes = new Attribute();
$context_attribute = &$context;
foreach(explode('.', $attribute_type) as $segment) {
foreach (explode('.', $attribute_type) as $segment) {
$context_attribute = &$context_attribute[$segment];
}
// if attribute doesn't exist, create it
// If attribute doesn't exist, create it.
if (!$context_attribute) {
$context_attribute = new Attribute();
}
......@@ -58,7 +62,7 @@ $function = new Twig_SimpleFunction('add_attributes', function ($context, $addit
}
// Set all attributes.
foreach($context_attribute as $key => $value) {
foreach ($context_attribute as $key => $value) {
$attributes->setAttribute($key, $value);
// Remove this attribute from context so it doesn't filter down to child
// elements.
......@@ -68,4 +72,4 @@ $function = new Twig_SimpleFunction('add_attributes', function ($context, $addit
return $attributes;
}
}, array('needs_context' => true, 'is_safe' => array('html')));
}, ['needs_context' => TRUE, 'is_safe' => ['html']]);
<?php
/**
* @file
* Creates an "add_attributes" function for Pattern Lab.
*
* Creates an "add_attributes" function for Pattern Lab that adds attributes
* with optional additions while preventing attributes from trickling down
* through includes.
* Based on https://github.com/drupal-pattern-lab/add-attributes-twig-extension
*
* @see https://github.com/drupal-pattern-lab/add-attributes-twig-extension
*/
/**
*
*/
function addAddAttributesFunction(\Twig_Environment &$env, $config) {
$env->addFunction(new Twig_SimpleFunction('add_attributes', function ($context, $additional_attributes = [], $attribute_type = 'attributes') {
......@@ -38,7 +45,6 @@ function addAddAttributesFunction(\Twig_Environment &$env, $config) {
return implode(' ', $attributes);
}, ['needs_context' => TRUE, 'is_safe' => ['html']]));
}, array('needs_context' => true, 'is_safe' => array('html'))));
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment