diff --git a/CHANGELOG.md b/CHANGELOG.md index 54894eade..82d0054c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -642,7 +642,6 @@ Theme UI is now written in TypeScript, and the emitted types differ from `color: 'primary'` resolves to `color: '#00f'`. ## v0.6.0-alpha.4 - - Extract objects with nested variant props. Issue #1357 - Add ability for MDX styling, and fix mdx table align styles. Issue #654 - Remove recursive default values from CSS custom properties. PR #1327 diff --git a/packages/preset-base/src/index.ts b/packages/preset-base/src/index.ts index 4d90b5016..81725e7b8 100644 --- a/packages/preset-base/src/index.ts +++ b/packages/preset-base/src/index.ts @@ -97,6 +97,8 @@ export const base = makeTheme({ img: { maxWidth: '100%', }, + } as const, +} }, }) diff --git a/packages/preset-base/test/index.ts b/packages/preset-base/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-base/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-bootstrap/src/index.ts b/packages/preset-bootstrap/src/index.ts index 05d03fb30..bf97ca904 100644 --- a/packages/preset-bootstrap/src/index.ts +++ b/packages/preset-bootstrap/src/index.ts @@ -210,6 +210,7 @@ export const styles = makeStyles({ maxWidth: '100%', height: 'auto', }, + }) export const bootstrap = makeTheme({ diff --git a/packages/preset-bootstrap/test/index.ts b/packages/preset-bootstrap/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-bootstrap/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-bulma/test/index.ts b/packages/preset-bulma/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-bulma/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-dark/test/index.ts b/packages/preset-dark/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-dark/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-deep/test/index.ts b/packages/preset-deep/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-deep/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-future/test/index.ts b/packages/preset-future/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-future/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-polaris/test/index.ts b/packages/preset-polaris/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-polaris/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-roboto/test/index.ts b/packages/preset-roboto/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-roboto/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-sketchy/test/index.ts b/packages/preset-sketchy/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-sketchy/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-swiss/test/index.ts b/packages/preset-swiss/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-swiss/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-system/test/index.ts b/packages/preset-system/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-system/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +}) diff --git a/packages/preset-tailwind/src/index.ts b/packages/preset-tailwind/src/index.ts index 7a1dfe622..e69de29bb 100644 --- a/packages/preset-tailwind/src/index.ts +++ b/packages/preset-tailwind/src/index.ts @@ -1,653 +0,0 @@ -// Based on https://github.com/tailwindcss/tailwindcss/blob/master/stubs/defaultConfig.stub.js -// and https://tailwindcss.com/components -import { makeTheme, makeColorsScale } from '@theme-ui/css/utils' - -export const borderWidths = { - px: '1px', - '0': '0', - '2': '2px', - '4': '4px', - '8': '8px', -} - -export const breakpoints = ['640px', '768px', '1024px', '1280px'] - -export const baseColors = makeColorsScale({ - transparent: 'transparent', - black: '#000', - white: '#fff', - gray: [ - '', - '#f7fafc', - '#edf2f7', - '#e2e8f0', - '#cbd5e0', - '#a0aec0', - '#718096', - '#4a5568', - '#2d3748', - '#1a202c', - ], - red: [ - '', - '#fff5f5', - '#fed7d7', - '#feb2b2', - '#fc8181', - '#f56565', - '#e53e3e', - '#c53030', - '#9b2c2c', - '#742a2a', - ], - orange: [ - '', - '#fffaf0', - '#feebc8', - '#fbd38d', - '#f6ad55', - '#ed8936', - '#dd6b20', - '#c05621', - '#9c4221', - '#7b341e', - ], - yellow: [ - '', - '#fffff0', - '#fefcbf', - '#faf089', - '#f6e05e', - '#ecc94b', - '#d69e2e', - '#b7791f', - '#975a16', - '#744210', - ], - green: [ - '', - '#f0fff4', - '#c6f6d5', - '#9ae6b4', - '#68d391', - '#48bb78', - '#38a169', - '#2f855a', - '#276749', - '#22543d', - ], - teal: [ - '', - '#e6fffa', - '#b2f5ea', - '#81e6d9', - '#4fd1c5', - '#38b2ac', - '#319795', - '#2c7a7b', - '#285e61', - '#234e52', - ], - blue: [ - '', - '#ebf8ff', - '#bee3f8', - '#90cdf4', - '#63b3ed', - '#4299e1', - '#3182ce', - '#2b6cb0', - '#2c5282', - '#2a4365', - ], - indigo: [ - '', - '#ebf4ff', - '#c3dafe', - '#a3bffa', - '#7f9cf5', - '#667eea', - '#5a67d8', - '#4c51bf', - '#434190', - '#3c366b', - ], - purple: [ - '', - '#faf5ff', - '#e9d8fd', - '#d6bcfa', - '#b794f4', - '#9f7aea', - '#805ad5', - '#6b46c1', - '#553c9a', - '#44337a', - ], - pink: [ - '', - '#fff5f7', - '#fed7e2', - '#fbb6ce', - '#f687b3', - '#ed64a6', - '#d53f8c', - '#b83280', - '#97266d', - '#702459', - ], -}) - -const commonButtonStyles = { - py: 2, - px: 3, - cursor: `pointer`, - fontSize: `100%`, - lineHeight: `inherit`, -} - -export const buttons = { - simple: { - ...commonButtonStyles, - backgroundColor: `primary`, - border: `none`, - color: `white`, - fontWeight: `bold`, - borderRadius: `default`, - '&:hover': { - backgroundColor: `primaryHover`, - }, - }, - pill: { - ...commonButtonStyles, - backgroundColor: `primary`, - border: `none`, - color: `white`, - fontWeight: `bold`, - borderRadius: `full`, - '&:hover': { - backgroundColor: `primaryHover`, - }, - }, - outline: { - ...commonButtonStyles, - backgroundColor: `transparent`, - borderWidth: `1px`, - borderStyle: `solid`, - borderColor: `primary`, - color: `primary`, - fontWeight: `semibold`, - borderRadius: `default`, - '&:hover': { - backgroundColor: `primary`, - color: `white`, - borderColor: `transparent`, - }, - }, - bordered: { - ...commonButtonStyles, - backgroundColor: `primary`, - borderWidth: `1px`, - borderStyle: `solid`, - borderColor: `primaryHover`, - color: `white`, - fontWeight: `bold`, - borderRadius: `default`, - '&:hover': { - backgroundColor: `primaryHover`, - }, - }, - disabled: { - ...commonButtonStyles, - backgroundColor: `primary`, - border: `none`, - opacity: 0.5, - cursor: `not-allowed`, - color: `white`, - fontWeight: `bold`, - borderRadius: `default`, - }, - '3D': { - ...commonButtonStyles, - backgroundColor: `primary`, - border: `none`, - borderBottomWidth: `4px`, - borderBottomStyle: `solid`, - borderBottomColor: `primaryHover`, - color: `white`, - fontWeight: `bold`, - borderRadius: `default`, - transition: `transform 0.3s ease-in-out`, - '&:hover': { - transform: `translateY(-1px)`, - }, - }, - elevated: { - ...commonButtonStyles, - backgroundColor: `white`, - borderWidth: `1px`, - borderStyle: `solid`, - borderColor: `gray.4`, - color: `text`, - fontWeight: `bold`, - borderRadius: `default`, - boxShadow: `default`, - '&:hover': { - backgroundColor: `gray.1`, - }, - }, -} - -export const colors = makeColorsScale({ - ...baseColors, - grayDark: baseColors.gray[8], - text: baseColors.gray[8], - background: baseColors.white, - primary: baseColors.blue[7], - primaryHover: baseColors.blue[8], - secondary: baseColors.gray[6], - muted: baseColors.gray[3], - success: baseColors.green[3], - info: baseColors.blue[4], - warning: baseColors.yellow[3], - danger: baseColors.red[3], - light: baseColors.gray[1], - dark: baseColors.gray[8], - textMuted: baseColors.gray[6], -}) - -export const baseFonts = { - sans: 'system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"', - serif: 'Georgia,Cambria,"Times New Roman",Times,serif', - mono: 'Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace', -} - -export const fonts = { - ...baseFonts, - body: baseFonts.sans, - heading: 'inherit', - monospace: baseFonts.mono, -} - -export const fontSizes = [ - '0.875rem', - '1rem', - '1.25rem', - '1.5rem', - '1.875rem', - '2.25rem', - '3rem', - '4rem', - '4.5rem', -] - -export const baseFontWeights = { - hairline: 100, - thin: 200, - light: 300, - normal: 400, - medium: 500, - semibold: 600, - bold: 700, - extrabold: 800, - black: 900, -} - -export const fontWeights = { - ...baseFontWeights, - body: baseFontWeights.normal, - heading: baseFontWeights.bold, -} - -const commonInputStyles = { - py: 2, - px: 3, - fontSize: `100%`, - borderRadius: `default`, - appearance: `none`, - lineHeight: `tight`, -} - -export const inputs = { - shadow: { - ...commonInputStyles, - border: `none`, - color: `gray.7`, - boxShadow: `default`, - '&:focus': { - outline: `none`, - boxShadow: `outline`, - }, - }, - inline: { - ...commonInputStyles, - backgroundColor: `gray.2`, - borderWidth: `2px`, - borderStyle: `solid`, - borderColor: `gray.2`, - color: `gray.7`, - '&:focus': { - outline: `none`, - borderColor: `primary`, - backgroundColor: `white`, - }, - }, - underline: { - ...commonInputStyles, - backgroundColor: `transparent`, - border: `none`, - borderBottomWidth: `2px`, - borderBottomStyle: `solid`, - borderBottomColor: `primary`, - borderRadius: `0px`, - color: `gray.7`, - '&:focus': { - outline: `none`, - borderColor: `primary`, - backgroundColor: `white`, - }, - }, -} - -export const letterSpacings = { - tighter: '-0.05em', - tight: '-0.025em', - normal: '0', - wide: '0.025em', - wider: '0.05em', - widest: '0.1em', -} - -export const baseLineHeights = { - none: '1', - tight: '1.25', - snug: '1.375', - normal: '1.5', - relaxed: '1.625', - loose: '2', -} - -export const lineHeights = { - ...baseLineHeights, - body: baseLineHeights.relaxed, - heading: baseLineHeights.tight, -} - -export const radii = { - none: '0', - sm: '0.125rem', - default: '0.25rem', - md: '0.375rem', - lg: '0.5rem', - full: '9999px', -} - -const tailwindSpacing = { - px: '1px', - '0': '0', - '1': '0.25rem', - '2': '0.5rem', - '3': '0.75rem', - '4': '1rem', - '5': '1.25rem', - '6': '1.5rem', - '8': '2rem', - '10': '2.5rem', - '12': '3rem', - '16': '4rem', - '20': '5rem', - '24': '6rem', - '32': '8rem', - '40': '10rem', - '48': '12rem', - '56': '14rem', - '64': '16rem', -} - -const tailwindMaxWidth = { - xs: '20rem', - sm: '24rem', - md: '28rem', - lg: '32rem', - xl: '36rem', - '2xl': '42rem', - '3xl': '48rem', - '4xl': '56rem', - '5xl': '64rem', - '6xl': '72rem', -} - -const tailwindWidth = { - '1/2': '50%', - '1/3': '33.333333%', - '2/3': '66.666667%', - '1/4': '25%', - '2/4': '50%', - '3/4': '75%', - '1/5': '20%', - '2/5': '40%', - '3/5': '60%', - '4/5': '80%', - '1/6': '16.666667%', - '2/6': '33.333333%', - '3/6': '50%', - '4/6': '66.666667%', - '5/6': '83.333333%', - '1/12': '8.333333%', - '2/12': '16.666667%', - '3/12': '25%', - '4/12': '33.333333%', - '5/12': '41.666667%', - '6/12': '50%', - '7/12': '58.333333%', - '8/12': '66.666667%', - '9/12': '75%', - '10/12': '83.333333%', - '11/12': '91.666667%', -} - -export const sizes = { - ...tailwindSpacing, - ...tailwindMaxWidth, - ...tailwindWidth, - full: '100%', - screenHeight: '100vh', - screenWidth: '100vw', -} - -export const shadows = { - xs: '0 0 0 1px rgba(0, 0, 0, 0.05)', - sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)', - default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)', - md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)', - lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)', - xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)', - '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)', - inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)', - outline: '0 0 0 3px rgba(66, 153, 225, 0.5)', - none: 'none', -} - -export const space = [ - '0', - '0.25rem', - '0.5rem', - '1rem', - '2rem', - '4rem', - '8rem', - '16rem', - '32rem', -] - -export const zIndices = { - auto: 'auto', - '0': 0, - '10': 10, - '20': 20, - '30': 30, - '40': 40, - '50': 50, -} as const - -const heading = { - fontFamily: 'heading', - fontWeight: 'heading', - lineHeight: 'heading', - m: 0, - mb: 1, -} - -export const styles = { - root: { - fontFamily: 'body', - lineHeight: 'body', - fontWeight: 'body', - }, - a: { - color: 'primary', - textDecoration: 'none', - ':hover': { - textDecoration: 'underline', - }, - }, - h1: { - ...heading, - fontSize: 6, - mt: 2, - }, - h2: { - ...heading, - fontSize: 5, - mt: 2, - }, - h3: { - ...heading, - fontSize: 4, - mt: 3, - }, - h4: { - ...heading, - fontSize: 3, - }, - h5: { - ...heading, - fontSize: 2, - }, - h6: { - ...heading, - fontSize: 1, - mb: 2, - }, - code: {}, - pre: {}, - hr: { - bg: 'muted', - border: 0, - height: '1px', - m: 3, - }, -} - -export const transforms = { - transformOrigin: { - center: 'center', - top: 'top', - 'top-right': 'top right', - right: 'right', - 'bottom-right': 'bottom right', - bottom: 'bottom', - 'bottom-left': 'bottom left', - left: 'left', - 'top-left': 'top left', - }, - translate: { - ...tailwindSpacing, - '-full': '-100%', - '-1/2': '-50%', - '1/2': '50%', - full: '100%', - }, - scale: { - '0': '0', - '50': '.5', - '75': '.75', - '90': '.9', - '95': '.95', - '100': '1', - '105': '1.05', - '110': '1.1', - '125': '1.25', - '150': '1.5', - }, - rotate: { - '-180': '-180deg', - '-90': '-90deg', - '-45': '-45deg', - '0': '0', - '45': '45deg', - '90': '90deg', - '180': '180deg', - }, - skew: { - '-12': '-12deg', - '-6': '-6deg', - '-3': '-3deg', - '0': '0', - '3': '3deg', - '6': '6deg', - '12': '12deg', - }, -} - -export const transitions = { - property: { - none: 'none', - all: 'all', - default: - 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform', - colors: 'background-color, border-color, color, fill, stroke', - opacity: 'opacity', - shadow: 'box-shadow', - transform: 'transform', - }, - timingFunction: { - linear: 'linear', - in: 'cubic-bezier(0.4, 0, 1, 1)', - out: 'cubic-bezier(0, 0, 0.2, 1)', - 'in-out': 'cubic-bezier(0.4, 0, 0.2, 1)', - }, - duration: { - '75': '75ms', - '100': '100ms', - '150': '150ms', - '200': '200ms', - '300': '300ms', - '500': '500ms', - '700': '700ms', - '1000': '1000ms', - }, -} - -export const tailwind = makeTheme({ - borderWidths, - breakpoints, - colors, - fonts, - fontSizes, - fontWeights, - letterSpacings, - lineHeights, - sizes, - shadows, - space, - radii, - zIndices, - styles, - buttons, - inputs, - transforms, - transitions, -}) - -export default tailwind diff --git a/packages/preset-tosh/test/index.ts b/packages/preset-tosh/test/index.ts new file mode 100644 index 000000000..9cfb9782e --- /dev/null +++ b/packages/preset-tosh/test/index.ts @@ -0,0 +1,9 @@ +import { Theme } from '@theme-ui/css' + +import theme from '../src' + +// Nothing actually executed here; just verify it typechecks. +test('assignable to Theme', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const typedTheme: Theme = theme +})