@ai-growth/nextjs
Version:
Seamlessly integrate Sanity CMS with Next.js applications for automated blog routing and rendering
184 lines • 5.73 kB
TypeScript
import { type CmsTheme } from '../components/CmsProvider';
/**
* Theme adapter configuration options
*/
export interface ThemeAdapterOptions {
/** Prefix for CSS custom properties */
cssPrefix?: string;
/** Whether to include fallback values */
includeFallbacks?: boolean;
/** Custom transformations for specific values */
transformations?: Record<string, (value: string) => string>;
}
/**
* CSS-in-JS theme object structure
*/
export interface CssInJsTheme {
colors: Record<string, string>;
typography: {
fontFamily: Record<string, string>;
fontSize: Record<string, string>;
fontWeight: Record<string, string>;
lineHeight: Record<string, string>;
};
spacing: Record<string, string>;
borderRadius: Record<string, string>;
shadows: Record<string, string>;
breakpoints: Record<string, string>;
zIndex: Record<string, number>;
}
/**
* Tailwind theme configuration structure
*/
export interface TailwindTheme {
colors: Record<string, string | Record<string, string>>;
fontFamily: Record<string, string[]>;
fontSize: Record<string, [string, string | {
lineHeight: string;
}]>;
fontWeight: Record<string, string>;
spacing: Record<string, string>;
borderRadius: Record<string, string>;
boxShadow: Record<string, string>;
screens: Record<string, string>;
zIndex: Record<string, string>;
}
/**
* CSS Variables object structure
*/
export interface CssVariables {
[key: string]: string;
}
/**
* Theme value with fallback support
*/
export interface ThemeValue {
value: string;
fallback?: string;
cssVar?: string;
}
/**
* Theme accessor utility class
*/
export declare class ThemeAccessor {
private theme;
private cssPrefix;
constructor(theme: CmsTheme, cssPrefix?: string);
/**
* Get color value with fallback
*/
color(key: string, fallback?: string): ThemeValue;
/**
* Get spacing value with fallback
*/
spacing(key: string, fallback?: string): ThemeValue;
/**
* Get typography value with fallback
*/
typography(category: string, key: string, fallback?: string): ThemeValue;
/**
* Get border radius value with fallback
*/
borderRadius(key: string, fallback?: string): ThemeValue;
/**
* Get shadow value with fallback
*/
shadow(key: string, fallback?: string): ThemeValue;
/**
* Get breakpoint value with fallback
*/
breakpoint(key: string, fallback?: string): ThemeValue;
/**
* Get CSS custom property reference
*/
cssVar(category: string, key: string): string;
/**
* Get CSS custom property reference with fallback
*/
cssVarWithFallback(category: string, key: string, fallback: string): string;
}
/**
* CSS-in-JS Theme Adapter
*/
export declare class CssInJsAdapter {
private theme;
constructor(theme: CmsTheme);
/**
* Convert CmsTheme to CSS-in-JS format
*/
toCssInJs(): CssInJsTheme;
private convertColors;
private convertTypography;
private convertSpacing;
private convertBorderRadius;
private convertShadows;
private convertBreakpoints;
private convertObject;
private applyTransformation;
private getDefaultZIndex;
}
/**
* Tailwind CSS Theme Adapter
*/
export declare class TailwindAdapter {
private theme;
constructor(theme: CmsTheme);
/**
* Convert CmsTheme to Tailwind configuration format
*/
toTailwindConfig(): TailwindTheme;
private convertColorsForTailwind;
private convertFontFamilyForTailwind;
private convertFontSizeForTailwind;
private convertFontWeightForTailwind;
private convertSpacingForTailwind;
private convertBorderRadiusForTailwind;
private convertShadowsForTailwind;
private convertBreakpointsForTailwind;
private getDefaultZIndexForTailwind;
}
/**
* CSS Variables Adapter
*/
export declare class CssVariablesAdapter {
private theme;
private options;
constructor(theme: CmsTheme, options?: ThemeAdapterOptions);
/**
* Convert CmsTheme to CSS custom properties
*/
toCssVariables(): CssVariables;
/**
* Generate CSS string from variables
*/
toCssString(selector?: string): string;
private kebabCase;
}
/**
* Factory functions for creating theme adapters
*/
export declare function createThemeAccessor(theme: CmsTheme, cssPrefix?: string): ThemeAccessor;
export declare function createCssInJsAdapter(theme: CmsTheme): CssInJsAdapter;
export declare function createTailwindAdapter(theme: CmsTheme): TailwindAdapter;
export declare function createCssVariablesAdapter(theme: CmsTheme, options?: ThemeAdapterOptions): CssVariablesAdapter;
/**
* Utility functions for common theme operations
*/
export declare function getThemeValue(theme: CmsTheme, path: string, fallback?: string): string | undefined;
export declare function hasThemeValue(theme: CmsTheme, path: string): boolean;
export declare function mergeThemeTokens(base: CmsTheme, override: Partial<CmsTheme>): CmsTheme;
declare const _default: {
ThemeAccessor: typeof ThemeAccessor;
CssInJsAdapter: typeof CssInJsAdapter;
TailwindAdapter: typeof TailwindAdapter;
CssVariablesAdapter: typeof CssVariablesAdapter;
createThemeAccessor: typeof createThemeAccessor;
createCssInJsAdapter: typeof createCssInJsAdapter;
createTailwindAdapter: typeof createTailwindAdapter;
createCssVariablesAdapter: typeof createCssVariablesAdapter;
getThemeValue: typeof getThemeValue;
hasThemeValue: typeof hasThemeValue;
mergeThemeTokens: typeof mergeThemeTokens;
};
export default _default;
//# sourceMappingURL=themeAdapters.d.ts.map