|
| 1 | +import { fontFamily as _fontFamily } from "tailwindcss/defaultTheme"; |
| 2 | +import { join } from "path"; |
| 3 | +import { readFileSync } from "fs"; |
| 4 | + |
| 5 | +const CONTENT_RATIO = 1000 / 814; |
| 6 | + |
| 7 | +/** |
| 8 | + * Returns css strings for width, height, and fontSize that will result in a |
| 9 | + * fixed aspect ratio and automaticaly expand to fill the smallest dimension. |
| 10 | + * |
| 11 | + * Based loosely on https://stackoverflow.com/a/20593342 |
| 12 | + * @type {(marginXPct: number, marginYPct: number) => {width: string, height: |
| 13 | + * string, fontSize: string}} |
| 14 | + */ |
| 15 | +function getScalingStrings(marginXPct, marginYPct) { |
| 16 | + const widthVw = 100 - marginXPct * 2; |
| 17 | + const maxWidth = `calc(${widthVw}vw - var(--safe-area-inset-right) - var(--safe-area-inset-left))`; |
| 18 | + const heightVh = 100 - marginYPct * 2; |
| 19 | + const maxHeight = `calc(${heightVh}vh - var(--safe-area-inset-bottom) - var(--safe-area-inset-top))`; |
| 20 | + const heightFromWidth = `calc(${maxWidth} / ${CONTENT_RATIO})`; |
| 21 | + const widthFromHeight = `calc(${maxHeight} * ${CONTENT_RATIO})`; |
| 22 | + |
| 23 | + return { |
| 24 | + width: `min(${maxWidth}, ${widthFromHeight})`, |
| 25 | + height: `min(${maxHeight}, ${heightFromWidth})`, |
| 26 | + fontSize: `min(calc(${maxWidth} / 100), calc(${widthFromHeight} / 100))`, |
| 27 | + }; |
| 28 | +} |
| 29 | + |
| 30 | +const { |
| 31 | + width: smallWidth, |
| 32 | + height: smallHeight, |
| 33 | + fontSize: smallFontSize, |
| 34 | +} = getScalingStrings(15.28, 10.255); |
| 35 | + |
| 36 | +/** |
| 37 | + * On screens that have very wide or very tall aspect ratios, we expand closer |
| 38 | + * to the narrow dimension, otherwise the content feels small. |
| 39 | + */ |
| 40 | +const { |
| 41 | + width: stretchedWidth, |
| 42 | + height: stretchedHeight, |
| 43 | + fontSize: stretchedFontSize, |
| 44 | +} = getScalingStrings(5, 5); |
| 45 | + |
| 46 | +const references = JSON.parse( |
| 47 | + readFileSync(join(__dirname, "tsconfig.json"), "utf-8"), |
| 48 | +).references.map((ref) => ref.path); |
| 49 | + |
| 50 | +/** @type {import('tailwindcss').Config} */ |
| 51 | +export const content = ["./src/**/*.{js,ts,jsx,tsx}"]; |
| 52 | +export const theme = { |
| 53 | + extend: { |
| 54 | + fontFamily: { |
| 55 | + mono: ["Inconsolata", ..._fontFamily.mono], |
| 56 | + monoWide: ["Inconsolata-SemiExpanded", ..._fontFamily.mono], |
| 57 | + }, |
| 58 | + width: { |
| 59 | + smBase: smallWidth, |
| 60 | + stretchedBase: stretchedWidth, |
| 61 | + }, |
| 62 | + height: { |
| 63 | + smBase: smallHeight, |
| 64 | + stretchedBase: stretchedHeight, |
| 65 | + }, |
| 66 | + fontSize: { |
| 67 | + smBase: smallFontSize, |
| 68 | + stretchedBase: stretchedFontSize, |
| 69 | + xs: "1.2em", |
| 70 | + lg: "1.8em", |
| 71 | + "2xl": "2.4em", |
| 72 | + "3xl": "3.6em", |
| 73 | + }, |
| 74 | + colors: { |
| 75 | + salmon: { |
| 76 | + 100: "#FFFAF8", |
| 77 | + 300: "#F8C9BA", |
| 78 | + 400: "#FF9273", |
| 79 | + 700: "#372e2a", |
| 80 | + 800: "#161110", |
| 81 | + 900: "#0A0707", |
| 82 | + }, |
| 83 | + teal: { |
| 84 | + 100: "#F9FFFE", |
| 85 | + 200: "#CDFFF9", |
| 86 | + 300: "#99FFF3", |
| 87 | + 400: "#00907F", |
| 88 | + 500: "#47D4C3", |
| 89 | + 600: "#0F776B", |
| 90 | + 700: "#005349", |
| 91 | + 800: "#00443C", |
| 92 | + 900: "#00110F", |
| 93 | + }, |
| 94 | + }, |
| 95 | + }, |
| 96 | +}; |
| 97 | +export const corePlugins = { |
| 98 | + preflight: false, |
| 99 | +}; |
| 100 | +export const plugins = []; |
0 commit comments