Skip to content

Instantly share code, notes, and snippets.

View davebowker's full-sized avatar

Dave Bowker davebowker

View GitHub Profile
@davebowker
davebowker / Homebrew Install Top Google Fonts.md
Last active November 17, 2022 15:42 — forked from jcchikikomori/Homebrew Install Top Google Fonts.md
Quickly install top Google fonts via Homebrew

List of some top fonts for easy terminal install via Homebrew Fonts Cask.

brew install --cask font-open-sans \
 font-noto-sans \
 font-roboto font-roboto-mono font-roboto-slab \
 font-montserrat \
 font-lato \
 font-fira-code \
 font-source-code-pro \
//
// The Scripter environment.
//
// What's declared in there is available to scripts in their global namespace.
//
// symbolic type aliases
type int = number
type float = number
type byte = number
@davebowker
davebowker / generate-style-descriptions.ts
Created March 14, 2020 01:26 — forked from alexjlockwood/generate-style-descriptions.ts
Generates style descriptions for each color style in the current Figma file.
// Get the list of color styles in the current Figma file.
const colorStyles = figma.getLocalPaintStyles();
const updatedColorStyles = colorStyles.filter(style => {
const { paints } = style;
if (paints.length !== 1) {
// Skip styles containing multiple colors.
return false;
}
const [paint] = paints;
@davebowker
davebowker / cleanup-figma-names.ts
Created March 14, 2020 01:26 — forked from alexjlockwood/cleanup-figma-names.ts
Cleans up Figma component and style names
const components = figma.root.children.flatMap(pageNode => {
return pageNode.findAll(node => node.type === 'COMPONENT');
});
const styles = [
...figma.getLocalEffectStyles(),
...figma.getLocalGridStyles(),
...figma.getLocalPaintStyles(),
...figma.getLocalTextStyles(),
];
@davebowker
davebowker / flatten-icons.ts
Created March 14, 2020 01:26 — forked from alexjlockwood/flatten-icons.ts
Flattens all components in a Figma file. Note that this script assumes that (1) every component in the file is an icon, (2) each icon contains a single color, and (3) the icons don't use masks. The `figma.flatten` function may not work as you expect if one of these conditions aren't met.
// Create a list of all component nodes in the Figma file.
const componentNodes = figma.root.children.flatMap(pageNode => {
return pageNode.findAll(node => node.type === 'COMPONENT');
}) as readonly ComponentNode[];
// Create a list of component nodes that have more than one child node.
const unflattenedComponentNodes = componentNodes.filter(componentNode => {
const childrenNodes = componentNode.findAll(() => true);
return childrenNodes.length > 1;
});
@davebowker
davebowker / delete-unused-component.ts
Created March 14, 2020 01:25 — forked from alexjlockwood/delete-unused-component.ts
Deletes the selected component if it is private and unused in the file.
if (figma.currentPage.selection.length !== 1) {
figma.notify("🚫 Select a component");
return;
}
const [componentNode] = figma.currentPage.selection;
if (componentNode.type !== "COMPONENT") {
figma.notify("🚫 Select a component");
return;
}
@davebowker
davebowker / print-unlinked-colors.ts
Created March 14, 2020 01:24 — forked from alexjlockwood/print-unlinked-colors.ts
Prints nodes that have fill/stroke colors that aren't linked to a style.
figma.root.children
.flatMap(pageNode => pageNode.findAll(n => true))
.forEach(node => {
if ('fills' in node && 'fillStyleId' in node) {
if (node.fills !== figma.mixed && node.fills.length > 0 && node.fillStyleId !== '') {
print(`${node.name}'s fill color is not linked to a style`);
}
}
if ('strokes' in node && 'strokeStyleId' in node) {
if (node.strokes.length > 0 && node.strokeStyleId !== '') {
/*
* Set interaction class on body
*/
$(function () {
$('input, textarea').focus(function() {
// ID
var action_id = $(this).attr('id');
if (action_id) {
$('body').data('action_id', 'action-' + action_id)
.addClass($('body').data('action_id'));
/*
* Border Mixin
*/
// Set variables -- You could also set a variable for $style but, meh, it's always SOLID!
$border-width: 1px;
$border-color: #cccccc;
// Usage: @include border(); sets default values on all sides
// Usage: @include border(bottom); sets default values on the bottom
@davebowker
davebowker / jekyll-categories-loop
Created July 31, 2015 17:07
Loop through all categories in your Jekyll Site.html
{% for category in site.categories %}
<div class="catbloc" id="{{ category | first | remove:' ' }}">
<h2>{{ category | first }}</h2>
<ul>
{% for posts in category %}
{% for post in posts %}
{% if post.url %}
<li>
<a href="{{ post.url }}">