Modified config files for Aceternity.

This commit is contained in:
sid
2024-10-26 20:40:04 +01:00
parent 4a10e8d42a
commit 2235ae9851
3 changed files with 56 additions and 5 deletions

12
package-lock.json generated
View File

@@ -25,7 +25,7 @@
"next": "14.2.13",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwind-merge": "^2.5.2",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
@@ -39,6 +39,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/tailwindcss": "^3.0.11",
"chai": "^4.2.0",
"eslint": "^8",
"eslint-config-next": "14.2.13",
@@ -7461,6 +7462,13 @@
"license": "MIT",
"peer": true
},
"node_modules/@types/tailwindcss": {
"version": "3.0.11",
"resolved": "https://registry.npmjs.org/@types/tailwindcss/-/tailwindcss-3.0.11.tgz",
"integrity": "sha512-PR+BOIrI+rxteHwFvkfIOty+PDJwTG4ute3alxSSXpF/xKpryO1room265m46Auyae0VwqUYs3PuVEOF9Oil3w==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/yargs": {
"version": "17.0.33",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz",
@@ -13016,7 +13024,6 @@
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz",
"integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"dependencies": {
"node-gyp-build": "^4.3.0"
@@ -13379,7 +13386,6 @@
"resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz",
"integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"dependencies": {
"node-gyp-build": "^4.3.0"

View File

@@ -29,7 +29,7 @@
"next": "14.2.13",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwind-merge": "^2.5.2",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
@@ -43,6 +43,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/tailwindcss": "^3.0.11",
"chai": "^4.2.0",
"eslint": "^8",
"eslint-config-next": "14.2.13",

View File

@@ -1,4 +1,10 @@
import type { Config } from 'tailwindcss';
import tailwindcssAnimate from 'tailwindcss-animate';
type ColorValue = string | ColorDictionary;
interface ColorDictionary {
[colorName: string]: ColorValue;
}
const config: Config = {
darkMode: ['class'],
@@ -68,6 +74,44 @@ const config: Config = {
},
},
},
plugins: [require('tailwindcss-animate')],
plugins: [tailwindcssAnimate, addVariablesForColors],
};
export default config;
// Plugin to add each Tailwind color as a CSS variable
function addVariablesForColors({
addBase,
theme,
}: {
addBase: (styles: Record<string, Record<string, string>>) => void;
theme: (path: string) => unknown;
}) {
const colors = theme('colors') as ColorDictionary;
const flattenedColors = flattenColors(colors);
const newVars = Object.fromEntries(
Object.entries(flattenedColors).map(([key, val]) => [`--${key}`, val])
);
addBase({
':root': newVars,
});
}
// Recursive function to flatten nested color objects
function flattenColors(
colors: ColorDictionary,
prefix = ''
): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of Object.entries(colors)) {
if (typeof value === 'string') {
// If the value is a string, add it to the result
result[prefix + key] = value;
} else if (typeof value === 'object' && value !== null) {
// If the value is an object, recursively flatten it
Object.assign(result, flattenColors(value, `${prefix}${key}-`));
}
}
return result;
}