atenea-web-components
v1.4.13
Published
React component library for Atenea
Readme
Atenea Web Components – Tailwind Theme Integration
Automated Tailwind Theme Export
This project provides a design system and a set of custom Tailwind utilities (such as text-h1, text-h2, custom colors, etc.) that can be used both internally and in external projects. To ensure all custom utilities are available, the theme is defined in TypeScript and automatically exported to a CommonJS JavaScript file for Tailwind consumption.
How It Works
- The source of truth for the theme is
src/tokens/theme.ts(TypeScript). - A build script (
scripts/build-theme.js) generates a CommonJS-compatibletheme.jsin the project root. - The generated
theme.jsis imported in yourtailwind.config.jsto provide all custom utilities to Tailwind.
Usage in This Project
- Edit your theme in TypeScript:
- Make changes in
src/tokens/theme.ts.
- Make changes in
- Generate the JS theme:
- Run:
npm run build:theme - This will create/update
theme.jsin the root directory.
- Run:
- Tailwind config setup:
- Your
tailwind.config.jsshould look like this:const { theme } = require('./theme'); module.exports = { content: ['./src/**/*.{js,ts,jsx,tsx}'], theme: { extend: theme }, plugins: [], };
- Your
Usage in External Projects (Consumers)
If you want to use these custom utilities in another project:
- Install this package as a dependency.
- Import the generated theme in your Tailwind config:
const { theme } = require('atenea-web-components/theme'); module.exports = { content: [ './src/**/*.{js,ts,jsx,tsx}', './node_modules/atenea-web-components/**/*.{js,ts,jsx,tsx}' ], theme: { extend: theme }, plugins: [], }; - Ensure the theme is up to date:
- If you update the package or its theme, run:
npm run build:theme - (If you use a monorepo, you may want to automate this step in your build pipeline.)
- If you update the package or its theme, run:
Recommendations
- Always run
npm run build:themeafter changing the theme in TypeScript. - Add the build step to your CI/CD pipeline to avoid mismatches between TS and JS theme files.
- Document for consumers that they must use the generated
theme.jsfor full utility support (including custom font sizes liketext-h1). - If you publish this package, ensure
theme.jsis included in the published files (not gitignored or npmignored).
Troubleshooting
- If custom utilities like
text-h1do not work, ensure:- The consumer project is importing the correct
theme.js. - The build script has been run after any theme changes.
- The
contentarray intailwind.config.jsincludes the package source files.
- The consumer project is importing the correct
For questions or improvements, please open an issue or PR!
