Skip to content

Instantly share code, notes, and snippets.

View mihkeleidast's full-sized avatar

Mihkel Eidast mihkeleidast

View GitHub Profile
@mihkeleidast
mihkeleidast / main-before.ts
Last active November 30, 2022 18:43
.storybook/main.ts after migration
import type { StorybookViteConfig } from '@storybook/builder-vite';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import { mergeConfig } from 'vite';
const config: StorybookViteConfig = {
stories: ['../**/*.stories.mdx'],
addons: [
'./theme-addon/preset.ts',
'@storybook/addon-actions',
'@storybook/addon-a11y',
@mihkeleidast
mihkeleidast / app.tsx
Last active January 20, 2023 05:23
vanilla-extract themes
import {
lightTheme,
darkTheme,
} from 'component-library';
// Define all themes that can be chosen.
const themes: Record<string, ThemeObject> = {
'light': {
className: lightTheme,
},
@mihkeleidast
mihkeleidast / attribute-figma.ts
Created July 18, 2022 11:27
style-dictionary to figma attribute transform
import { Named, Transform } from 'style-dictionary';
const transform: Named<Transform> = {
name: 'attribute/figma',
type: 'attribute',
matcher: (token) => {
const category = token.attributes?.category ?? '';
return ['color', 'size', 'shadow', 'fontFamily', 'fontWeight', 'font'].includes(category);
},
transformer: (token) => {
@mihkeleidast
mihkeleidast / index.js
Last active July 18, 2022 10:25
common-ui analytics
const { execSync } = require('child_process');
const scanComponents = require('./scan-components');
const scanMetadata = require('./scan-metadata');
const currentDirectory = __dirname;
const repositories = [
{
name: 'customer-web',
@mihkeleidast
mihkeleidast / tokens.json
Last active May 27, 2022 14:53
figma-tokens-test
{
"sixfold-dark": {
"color": {
"core": {
"gray": {
"base": {
"value": "#9ea6b3",
"filePath": "src/brands/sixfold/color/core.json",
"isSource": false,
"original": {
const { execSync } = require('child_process');
const scanComponents = require('./scan-components');
const scanMetadata = require('./scan-metadata');
const currentDirectory = __dirname;
const PROJECT_TO_SCAN = 'customer-web';
process.chdir(`./${PROJECT_TO_SCAN}`);
@mihkeleidast
mihkeleidast / preview.tsx
Created March 1, 2019 18:45
Fractal React preview template
import React from 'react';
export interface IPreviewEnv {
reactClass: string;
publicPath: string;
}
export interface IPreviewTargetMeta {
previewDisplay?: React.StyleHTMLAttributes<HTMLBodyElement>;
}
@mihkeleidast
mihkeleidast / preview.twig
Created March 1, 2019 18:44
Fractal twig preview
<!DOCTYPE html>
<html class="no-js" lang="{{ language }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<link rel="apple-touch-icon" sizes="180x180" href="{{ '/inc/favicon/apple-touch-icon.png'|path }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ '/inc/favicon/favicon-32x32.png'|path }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ '/inc/favicon//favicon-16x16.png'|path }}">
<link rel="manifest" href="{{ '/inc/favicon/manifest.json'|path }}">
@mihkeleidast
mihkeleidast / preview.tsx
Created May 2, 2018 13:02
React Fractal Preview component
import * as React from 'react';
export interface IPreviewEnv {
reactClass: string;
publicPath: string;
}
export interface IPreviewTargetMeta {
previewDisplay?: React.StyleHTMLAttributes<HTMLBodyElement>;
}
@mihkeleidast
mihkeleidast / index.jsx
Created April 25, 2018 14:21
react-iframe-resizer
/**
*
* inject script to facilitate iframe resizing
* https://github.com/davidjbradshaw/iframe-resizer
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { iframeResizer as iframeResizerLib } from 'iframe-resizer';