Skip to content

Instantly share code, notes, and snippets.

View kilmc's full-sized avatar

Kilian McMahon kilmc

View GitHub Profile
@kilmc
kilmc / 01-basics.md
Last active February 9, 2020 19:58
Battery Docs

Battery

How Battery works

The core of Battery is the propertyConfig. These objects configure Battery to recognize valid class names from your Atomic CSS library and then convert them into full CSS classes. Here's an example of a propertyConfig for background-color.

const backgroundColor = {
  property: "background-color",
  propertyIdentifier: "bg",
@kilmc
kilmc / Component.tsx
Created August 21, 2020 14:21
Adjustable Heading Levels
import React, { createContext, useContext } from 'react';
const HeadingLevelContext = createContext<number>(0);
type HTMLTag = keyof JSX.IntrinsicElements;
interface HeadingProps {
children: React.ReactNode;
level: 1 | 2 | 3 | 4 | 5 | 6;
}
class AnnualLists {
data() {
const hasTags = (tags) => tags.flat().length > 0;
const tagsToObject = (tags) =>
Object.fromEntries(tags.map((tag) => tag.split(":")));
return {
pagination: {
data: "lists.annual",
size: 1,