Skip to content

Commit

Permalink
chore: add tailwind styles support for lit components (#4862)
Browse files Browse the repository at this point in the history
This PR adds the TailwindLitElement class which can be used to use
tailwind classes in multiple Lit components with [no unnecessary CSS
duplication](#4804 (comment)).

At this time this is for Tailwind V3 but this can be made compatible
with Tailwind V4 with [minimal
changes](#4804 (comment)).

Based on #4804, without the atomic-text component and its styles. You
can refer to the comments for details on usage.

---------

Co-authored-by: GitHub Actions Bot <>
Co-authored-by: ylakhdar <[email protected]>
  • Loading branch information
fpbrault and y-lakhdar authored Jan 24, 2025
1 parent 4678a59 commit 6537c36
Show file tree
Hide file tree
Showing 11 changed files with 492 additions and 2 deletions.
307 changes: 307 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/atomic-angular/scripts/build-lit.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cem from '@coveo/atomic/custom-elements-manifest' with {type: 'json'};
import { createWriteStream, readFileSync, writeFileSync } from 'fs';

const isLitDeclaration = (declaration) => declaration?.superclass?.name === 'LitElement';
const isLitDeclaration = (declaration) => declaration?.superclass?.name === 'LitElement' || declaration?.superclass?.name === 'TailwindLitElement';

const atomicAngularModuleFilePath ='projects/atomic-angular/src/lib/stencil-generated/atomic-angular.module.ts';
const atomicAngularComponentFilePath = 'projects/atomic-angular/src/lib/stencil-generated/components.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/atomic-react/scripts/build-lit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {writeFileSync} from 'node:fs';
import * as prettier from 'prettier';

const isLitDeclaration = (declaration) =>
declaration?.superclass?.name === 'LitElement';
declaration?.superclass?.name === 'LitElement' || declaration?.superclass?.name === 'TailwindLitElement';

const entries = [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/atomic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@
"jest-cli": "29.7.0",
"jest-environment-node": "29.7.0",
"jest-localstorage-mock": "2.4.26",
"lightningcss": "1.28.2",
"lit-html": "3.2.1",
"local-web-server": "5.4.0",
"natural-orderby": "5.0.0",
"postcss-focus-visible": "10.0.1",
"postcss-import": "16.1.0",
"postcss-load-config": "6.0.1",
"postcss-map": "0.11.0",
"postcss-mixins": "11.0.3",
"postcss-nested": "7.0.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/atomic/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import autoprefixer from 'autoprefixer';
import postcssImport from 'postcss-import';
import tailwindcss from 'tailwindcss';

export default {
plugins: [postcssImport(), tailwindcss(), autoprefixer()],
};
Loading

0 comments on commit 6537c36

Please sign in to comment.