Skip to content

Instantly share code, notes, and snippets.

@andymantell
andymantell / .editorconfig
Last active July 20, 2022 12:43
my prettier / eslint setup
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
import React, { useState } from 'react';
import { useFormikContext, useField } from 'formik';
import { DateInput } from 'govuk-react-jsx/govuk';
function DateField(props) {
const { values, errors } = useFormikContext();
const { namePrefix, items, ...restProps } = props;
const [field, meta, helpers] = useField(namePrefix); // eslint-disable-line no-unused-vars
const { setValue, setTouched } = helpers;
@andymantell
andymantell / machine.js
Last active December 12, 2019 15:19
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@andymantell
andymantell / gov.js
Last active July 7, 2020 14:41
Gulp task to convert govuk-frontend Nunjucks macros to Jinja2
/**
* NOTE: This script is deprecated and I no longer recommend it's use.
* Within HM Land Registry it is supereceded by https://github.com/LandRegistry/govuk-frontend-jinja
* This repository was born from the outputs of this conversion script, but has had numerous fixes since
* so if you are looking for a stable and accurate jinja implementation of govuk-frontend I would look there first.
*/
const path = require('path')
const fs = require('fs')
const es = require('event-stream')
from jinja2 import PackageLoader, PrefixLoader
...
app.jinja_loader = PrefixLoader({
'app': PackageLoader('name_of_app_folder'),
'govuk_elements_jinja_macros': PackageLoader('govuk_elements_jinja_macros')
})
setuptools.setup(name='govuk-elements-jinja-macros',
version='1.0.7',
description='GOV.UK elements Jinja macros',
packages=['govuk_elements_jinja_macros'],
package_data={'govuk_elements_jinja_macros': ['templates/*.html']}
)
@andymantell
andymantell / cloudSettings
Last active October 24, 2019 14:58
VS Code settings
{"lastUpload":"2019-10-24T14:58:38.529Z","extensionVersion":"v3.4.3"}
@andymantell
andymantell / vars.js
Last active August 29, 2015 14:15
Multiline var declaration and global leakage
// Multiline var declarations
var foo = 1,
bar = 2,
wibble = 3;
// ... are all too easily turned into this, with a one character change
var foo = 1,
bar = 2; // BOOM: Global scope leakage
wibble = 3;
@andymantell
andymantell / default.hbs
Last active August 29, 2015 14:13
Assemble 0.6 custom grunt task
{{> html }}
{{> head }}
<body class="{{#if notification}} has-notification{{/if}}">
<div class="outer-wrapper">
<div class="inner-wrapper">
<div class="main-wrapper">
<a class="skiplink visuallyhidden focusable" href="#main" tabindex="0">
<span>Skip to main content</span>
'use strict';
var lazy_load_image = require('../plugins/lazy-load-image.js');
var domready = require('detect-dom-ready');
var pubsub = require('pubsub-js');
// @TODO: This should only load images which are visible by default, not things that are inside hidden tabs etc
// @TODO: This loop probably belongs inside the plugin, not here
// @TODO: Select via data attributes instead of classes assuming IE8 supports this?
function process(element) {