Skip to content

Instantly share code, notes, and snippets.

@leolll
leolll / your.html
Created February 1, 2021 05:05
Radio button validation + iodine.js
<label for="password">Plan</label>
<input name="plan" type="radio" id="pro" value="pro" x-bind:class="{'invalid':plan.errorMessage}" data-rules='["requiredChoice:plan"]' data-server-errors='[]'>
<input name="plan" type="radio" id="basic" value="basic" x-bind:class="{'invalid':plan.errorMessage}" data-rules='["requiredChoice:plan"]' data-server-errors='[]'>
<p class="error-message" x-show.transition.in="plan.errorMessage" x-text="plan.errorMessage"></p>
<alignment jcr:primaryType="nt:unstructured"
name="./alignChildren"
fieldLabel="Alignment of components"
required="{Boolean}true"
selectionMode="single"
sling:resourceType="granite/ui/components/coral/foundation/form/buttongroup">
<items jcr:primaryType="nt:unstructured">
<default jcr:primaryType="nt:unstructured"
name="./default"
@wojteklu
wojteklu / clean_code.md
Last active May 5, 2024 00:17
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@vidaaudrey
vidaaudrey / ie67891011-css-hacks.txt
Created June 19, 2016 20:52 — forked from ricardozea/ie67891011-css-hacks.txt
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================
/**
* Generate image markup through WP function.
*
* Requires ACF setting of ID.
* The crop can be custom, or one of WP default ones, or leave empty.
*
* This method does not work great with Media Query Sync. However, this method
* allows you to define custom settings, and the width, height, and alt tags will
* be auto generated for you. Which is great for semantics.
*
// Markup
<img src="<?php echo $src; ?>"
alt="<?php echo $alt; ?>"
width="<?php echo $width; ?>"
height="<?php echo $height; ?>" />
// Markup Sample
<img src="<?php echo $image[0]; ?>"
width="<?php echo $image[1]; ?>"
height="<?php echo $image[2]; ?>"
alt="<?php echo $image_alt; ?>" />
// Markup Sample (Media Query Sync)
<figure>
<img class="responsive"
src="<?php echo $media_sml[0]; ?>"
@besimhu
besimhu / Sass @each loop through Sass maps.css
Last active August 29, 2015 14:17
A simple @each function to loop through a Sass map and generate styles. This is especially handy for when you have and element that reiterates with different settings.
$brand_colors: (
purple $color-purple,
maroon $color-maroon,
orange $color-orange,
yellow $color-yellow,
);
.brand-color-bg {
@each $color in $brand_colors {
&.#{nth($color, 1)} {
@besimhu
besimhu / Hamburger Menu.js
Last active August 29, 2015 14:17
A sample hamburger menu for mobile that animates into an "X" for when active.
module.exports = function() {
var $menu_trigger = $header.find('.menu-trigger');
// Trigger mobile navigation
$menu_trigger.on('click touch', function(e) {
$('body').toggleClass('nav-open');
e.preventDefault();
});