Skip to content

Instantly share code, notes, and snippets.

View maecapozzi's full-sized avatar

Mae Capozzi maecapozzi

View GitHub Profile
@maecapozzi
maecapozzi / gist:b47951c1325f3f1ae602d7f8981d1154
Created August 30, 2021 00:09
design tokens - third layer of abstraction
import { baseTheme } from './theme.ts'
export const buttonTokens = {
primary: {
backgroundColor: theme.colors.primary;
color: theme.colors.secondary;
}
}
@maecapozzi
maecapozzi / gist:31fd3a036449a9bd6d178e9df7f8f380
Created August 30, 2021 00:04
design tokens - second layer of abstraction
import colors from './colors.ts';
const baseTheme = {
colors: {
// primary is a semantic name.
primary: colors.blue100,
secondary: colors.gray:100,
}
}
@maecapozzi
maecapozzi / design-tokens-layer-1
Created August 29, 2021 23:58
design tokens - the lowest layer of abstraction
// colors.ts
const blue100 = '#18253f'
const blue200 = '#1d3158'
const blue300 = '#224177'
const gray100 = '#000000'
const gray200 = '#1e2024'
const red100 = '#7f1218'
@maecapozzi
maecapozzi / package.json
Created July 27, 2020 11:21
Sample package.json
{
"name": "@constellation-components/button",
"author": "maecapozzi <maecapozzi@gmail.com>",
"version": "1.0.3-alpha.0",
"description": "A button component",
"main": "./dist/button.js",
"types": "./dist/button.d.ts",
"scripts": {
"build": "tsc -p ./tsconfig.json"
},
@maecapozzi
maecapozzi / generatePackage.js
Created April 5, 2020 14:02
Script for a cli tool that lets users generate a new package from an example package
const fs = require('fs');
const path = require('path');
const inquirer = require('inquirer');
const { exec } = require('child_process');
// Pull the arguments off of the command
let args = process.argv.slice(2);
// Write your own custom questions that the script will ask
@maecapozzi
maecapozzi / PrivateRoute.tsx
Last active March 22, 2019 17:43
TypeScript example for passing a React component as a prop
// Sometimes you want to be able to pass a React component as a prop. One reason you might want to do this is routing.
// Imagine you want to create a special kind of route that can't be reached unless a user is logged in.
// A `<PrivateRoute />` component might be used like this:
// This component lets you see your user profile, but only after you have logged in.
// App.tsx
const App = () => (
<Router>
// Import Suspense and lazy from React
import React, { Component, Suspense, lazy } from 'react'
import axios from 'axios'
import styled from 'styled-components'
import { Container, Row, Col } from 'react-grid-system'
import { SearchBar } from './components/SearchBar'
import { SearchInput } from './components/SearchInput'
// Dynamically import the file
import React, { Suspense, lazy } from "react";
import axios from "axios";
// Thumbnails now lives in a different file (as it should)
// We dynamically import it when it's needed
const Videos = lazy(() => import("./Thumbnails"));
const Videos = ({ items }) => (
<Thumbnails>
{items.map(primeVideos => (
// This file is pseudocode! Don't try to run this, it probably won't work :)
import React from "react";
import axios from "axios";
import Thumbnails from "./Thumbnails";
const Videos = ({ items }) => (
<Thumbnails>
{items.map(primeVideos => (
<Thumbnail primeVides={primeVideos} />;
))}
// Imagine your application code looks like this
const Button = styled.button`
color: ${props => props.theme.main};
`
const theme = {
main: 'mediumseagreen',
}