MCPcopy Create free account
hub / github.com/PageAI-Pro/page-ui / ThemeCodeEditor

Function ThemeCodeEditor

components/bricks/theme/copy-theme-code.tsx:50–189  ·  view source on GitHub ↗
({
  fonts,
  themeObject,
  copyType,
  className = '',
}: {
  fonts: {
    default: FontDefinition;
    display: FontDefinition;
  };
  themeObject: ColorThemeObject;
  copyType: CopyType;
  className?: string;
})

Source from the content-addressed store, hash-verified

48type CopyType = (typeof COPY_TYPES)[keyof typeof COPY_TYPES];
49
50const ThemeCodeEditor = ({
51 fonts,
52 themeObject,
53 copyType,
54 className = '',
55}: {
56 fonts: {
57 default: FontDefinition;
58 display: FontDefinition;
59 };
60 themeObject: ColorThemeObject;
61 copyType: CopyType;
62 className?: string;
63}) => {
64 let formattedCodeStrings: {
65 formattedCodeString: string;
66 fileName: string;
67 language?: string;
68 }[] = [];
69
70 const theme = {
71 primary: {
72 lighter: themeObject.colors.primary[3],
73 light: themeObject.colors.primary[4],
74 main: themeObject.colors.primary[5],
75 dark: themeObject.colors.primary[6],
76 darker: themeObject.colors.primary[7],
77 },
78 secondary: {
79 lighter: themeObject.colors.secondary[3],
80 light: themeObject.colors.secondary[4],
81 main: themeObject.colors.secondary[5],
82 dark: themeObject.colors.secondary[6],
83 darker: themeObject.colors.secondary[7],
84 },
85 primaryTailwindName: themeObject.tailwindNames.primary,
86 secondaryTailwindName: themeObject.tailwindNames.secondary,
87 };
88
89 switch (copyType) {
90 case COPY_TYPES.NEXTJS:
91 formattedCodeStrings = [
92 {
93 formattedCodeString: `${getNextjsFontImportString(
94 fonts,
95 )}\n\n${getNextjsFontString(fonts)}\n\n${getNextjsHtmlFontString()}`,
96 fileName: 'app/layout.tsx',
97 },
98 {
99 formattedCodeString: getShipixenThemeJs(theme),
100 fileName: 'data/config/colors.js',
101 },
102 {
103 formattedCodeString: getHtmlTheme(theme),
104 fileName:
105 'globals.css (optional if you are NOT using Shipixen, add css variables)',
106 language: 'css',
107 },

Callers

nothing calls this directly

Calls 9

getNextjsFontStringFunction · 0.90
getNextjsHtmlFontStringFunction · 0.90
getShipixenThemeJsFunction · 0.90
getHtmlThemeFunction · 0.90
getHtmlFontPageStringFunction · 0.90
getShadcnThemeFunction · 0.90
getHtmlFontStyleStringFunction · 0.90
cnFunction · 0.90

Tested by

no test coverage detected