Skip to content

Instantly share code, notes, and snippets.

View backlineint's full-sized avatar
🐱

Brian Perry backlineint

🐱
View GitHub Profile
@backlineint
backlineint / config.js
Last active August 19, 2021 15:54
dotenv dev, test live snippet
const path = require("path");
const dotenv = require("dotenv");
// Register envars for dev, test, live or local if available
switch(process.env.BACKEND_ENV) {
case 'dev':
dotenv.config({ path: path.resolve(process.cwd(), '.env.dev') })
case 'test':
dotenv.config({ path: path.resolve(process.cwd(), '.env.test') })
case 'live':
@backlineint
backlineint / webpack.config.js
Last active November 26, 2019 21:26
Webpack Config for CSS Module and Sass Support in a Storybook for a Gatsby Project
// The require statement and the block within module.exports should be added to
// ./storybook/webpack.config.js
// Written for Gatsby v2 Storybook v5
const path = require("path");
module.exports = ({ config }) => {
// Update for SASS / CSS Modules support - minor adjustments to snippet
@backlineint
backlineint / TwigTest.stories.js
Created July 22, 2019 22:09
Twig In React Storybook
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';
import template from './TestTwig.twig';
import chip from '~../../../twig-assets/e-chip.twig';
const templateTwig = (
chip({
description: 'Description',
@backlineint
backlineint / facet-checkboxes.twig
Created April 3, 2017 21:18
Setting a Tab Index in a Twig Template
<section class="m-facet-checkboxes block-facet--checkbox">
<h2 class="block-title">{{ facet_checkboxes.block_title }}</h2>
<ul class="js-facets-checkbox-links">
{% for item in facet_checkboxes.checkboxes %}
{% set counter = ( counter | default(0) ) + 1 %}
<li class="facet-item">
<input type="checkbox" class="facets-checkbox" tabindex="{{ counter }}" id="{{ item.id }}">
<label for="{{ item.id }}">
<span class="facet-item__value">{{ item.label }}</span>
{% if item.count %}
@backlineint
backlineint / neato_refills.ui_patterns.yml
Last active February 10, 2017 21:25
UI Patterns Card Mapping
card:
label: Card
description: Display content in a card format
fields:
image:
type: text
label: Image
description: Image field.
preview: <img src="https://raw.githubusercontent.com/thoughtbot/refills/master/source/images/mountains.png" alt="Card Image">
header:
@backlineint
backlineint / node--cast--card.html.twig
Last active March 29, 2017 20:55
More Involved Use of field_target_entity
{# Force caching for entities we’re not rendering #}
{% set catch_cache = content.field_season|render %}
{% set season = content.field_season|field_target_entity %}
{# Can now access fields on the referenced practice entity like… #}
{% include "@molecules/card/card.twig"
with {
"img_src": file_url(content.field_image|field_target_entity.uri.value),
"img_alt": content.field_image|field_raw('alt'),
@backlineint
backlineint / node--cast--card.html.twig
Created February 8, 2017 19:12
Twig Field Value Version of Card Mapping
{% set catch_cache = content.field_image|render %}
{% include "@molecules/card/card.twig"
with {
"img_src": file_url(content.field_image|field_target_entity.uri.value),
"img_alt": content.field_image|field_raw('alt'),
"header": label|field_value,
"copy": content.body|field_value
}
%}
@backlineint
backlineint / _card.scss
Last active February 3, 2017 04:08
Markup for Card Component
.card {
$base-border-color: gainsboro !default;
$base-border-radius: 3px !default;
$base-background-color: white !default;
$base-spacing: 1.5em !default;
$action-color: #477DCA !default;
$dark-gray: #333 !default;
$base-font-color: $dark-gray !default;
$card-border-color: $base-border-color;
$card-border: 1px solid $card-border-color;
@backlineint
backlineint / landing.scss
Created December 14, 2016 19:38
Off-Grid Row Background Examples
@include breakpoint(large) {
.background {
padding-top: 1rem;
background: url('../images/centura/background.svg');
background-size: 60%;
background-repeat: no-repeat;
}
.o-icon-grid {
border: 0;
background-color: transparent;
@backlineint
backlineint / taxonomy-prep.twig
Created December 7, 2016 14:58
Creating a Delimited List of Referenced Taxonomy Terms
{# Prep specialties for display #}
{# TODO - Convert to field_target_entity_join custom twig filter #}
{# Get the render array for specialty taxonomy terms - this may be a single
object, or may be an array of objects #}
{% set entity = content.field_physician_specialty|field_target_entity %}
{# If we only have one value, set it #}
{% if entity.name.value is defined %}
{% set specialties = entity.name.value %}
{# If we have multiple values, iterate through and delimit #}
{% else %}