Skip to content

Commit d2e8515

Browse files
committed
lexical: use tailwind
1 parent da4de09 commit d2e8515

27 files changed

+533
-25
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Tailwind CSS Integration
2+
3+
This document outlines the Tailwind CSS integration in the Jupyter Lexical package.
4+
5+
## What Was Done
6+
7+
1. **Dependencies Added:**
8+
- `tailwindcss` - Core Tailwind CSS framework
9+
- `postcss` - CSS post-processor
10+
- `autoprefixer` - CSS vendor prefixing
11+
- `@tailwindcss/forms` - Better form styling
12+
- `@tailwindcss/typography` - Typography utilities
13+
- `@tailwindcss/postcss` - PostCSS plugin for Tailwind
14+
- `postcss-loader` - Webpack loader for PostCSS
15+
16+
2. **Configuration Files:**
17+
- `tailwind.config.js` - Tailwind configuration with content paths and custom colors
18+
- `postcss.config.js` - PostCSS configuration for webpack processing
19+
- Updated `webpack.config.js` to include postcss-loader
20+
21+
3. **CSS Migration:**
22+
- Created `style/tailwind.css` with all existing styles converted to Tailwind classes
23+
- Removed individual CSS imports from TypeScript components
24+
- Maintained exact visual appearance using Tailwind utilities
25+
26+
## Files Changed
27+
28+
### Configuration
29+
- `package.json` - Added Tailwind dependencies
30+
- `webpack.config.js` - Added postcss-loader
31+
- `tailwind.config.js` - New Tailwind configuration
32+
- `postcss.config.js` - New PostCSS configuration
33+
34+
### CSS
35+
- `style/tailwind.css` - New consolidated CSS file with Tailwind
36+
- `style/index.css` - Updated to import tailwind.css
37+
38+
### TypeScript Components
39+
Removed CSS imports from all component files:
40+
- `src/components/*.tsx`
41+
- `src/plugins/*.tsx`
42+
- `src/nodes/*.tsx`
43+
- `src/themes/*.ts`
44+
45+
## Converted Styles
46+
47+
All existing styles have been converted to Tailwind classes while maintaining the same visual appearance:
48+
49+
- **Button styles** - Hover states, disabled states, sizing variants
50+
- **Modal components** - Overlay, modal box, close button
51+
- **Input components** - Wrapper, label, input field styling
52+
- **Editor components** - Content editable areas, placeholders
53+
- **Plugin components** - Toolbar, floating menus, draggable blocks
54+
- **Specialized components** - Equation editor, image nodes, comments
55+
56+
## Benefits
57+
58+
1. **Consistency** - All styling now uses a unified design system
59+
2. **Maintainability** - Easier to update and maintain styles
60+
3. **Performance** - Tailwind purges unused CSS for smaller bundles
61+
4. **Developer Experience** - Intellisense and utility-first approach
62+
5. **Responsive Design** - Built-in responsive utilities available
63+
64+
## Usage
65+
66+
The styles are automatically included when you import the main CSS:
67+
68+
```typescript
69+
import '@datalayer/jupyter-lexical/style/index.css';
70+
```
71+
72+
All existing class names continue to work, but now they're powered by Tailwind CSS under the hood.
73+
74+
## Development
75+
76+
Run the development server as usual:
77+
```bash
78+
npm start
79+
```
80+
81+
Build for production:
82+
```bash
83+
npm run build
84+
```
85+
86+
The Tailwind CSS will be processed automatically through the webpack pipeline with PostCSS.

packages/lexical/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"clean:labextension": "rimraf datalayer/labextension",
4343
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
4444
"clean:lintcache": "rimraf .eslintcache .stylelintcache",
45+
"dev": "run-p -c 'start:*'",
4546
"eslint": "jlpm eslint:check --fix",
4647
"eslint:check": "eslint . --cache --ext .ts,.tsx",
4748
"install:extension": "jlpm build",
@@ -94,6 +95,9 @@
9495
"@babel/preset-react": "^7.18.6",
9596
"@babel/preset-typescript": "^7.21.0",
9697
"@jupyterlab/builder": "^4.0.0",
98+
"@tailwindcss/forms": "^0.5.10",
99+
"@tailwindcss/postcss": "^4.1.11",
100+
"@tailwindcss/typography": "^0.5.16",
97101
"@types/codemirror": "^5.60.4",
98102
"@types/katex": "^0.14.0",
99103
"@types/lodash-es": "^4.17.6",
@@ -108,6 +112,7 @@
108112
"@types/uuid": "^8.3.0",
109113
"@typescript-eslint/eslint-plugin": "^8.29.1",
110114
"@typescript-eslint/parser": "^8.29.1",
115+
"autoprefixer": "^10.4.21",
111116
"babel-loader": "^9.1.2",
112117
"bundle-loader": "^0.5.6",
113118
"css-loader": "^7.1.2",
@@ -124,6 +129,8 @@
124129
"jest": "^29.4.3",
125130
"mkdirp": "^1.0.3",
126131
"npm-run-all": "^4.1.5",
132+
"postcss": "^8.5.6",
133+
"postcss-loader": "^8.1.1",
127134
"prettier": "^3.5.3",
128135
"process": "^0.11.10",
129136
"raw-loader": "^4.0.2",
@@ -137,6 +144,7 @@
137144
"stylelint-config-standard": "^24.0.0",
138145
"stylelint-prettier": "^2.0.0",
139146
"svg-url-loader": "^7.1.1",
147+
"tailwindcss": "^4.1.11",
140148
"typedoc": "^0.28.2",
141149
"typescript": "^5.8.3",
142150
"url-loader": "^3.0.0",

packages/lexical/postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
'@tailwindcss/postcss': {},
4+
autoprefixer: {},
5+
},
6+
}

packages/lexical/src/components/Button.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import {ReactNode} from 'react';
88
import joinClasses from '../utils/join';
99

10-
import './../../style/lexical/Button.css';
11-
1210
export const Button = ({
1311
'data-test-id': dataTestId,
1412
children,

packages/lexical/src/components/ContentEditable.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import {ContentEditable} from '@lexical/react/LexicalContentEditable';
88

9-
import './../../style/lexical/ContentEditable.css';
10-
119
export const LexicalContentEditable = ({
1210
className,
1311
}: {

packages/lexical/src/components/Dialog.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* MIT License
55
*/
66

7-
import './../../style/lexical/Dialog.css';
8-
97
import {ReactNode} from 'react';
108

119
type Props = Readonly<{

packages/lexical/src/components/EquationEditor.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* MIT License
55
*/
66

7-
import './../../style/lexical/EquationEditor.css';
87

98
import {ChangeEvent, RefObject} from 'react';
109

packages/lexical/src/components/FileInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* MIT License
55
*/
66

7-
import './../../style/lexical/Input.css';
87

98
type Props = Readonly<{
109
'data-test-id'?: string;

packages/lexical/src/components/KatexEquationAlterer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {useCallback, useState} from 'react';
88
import Button from '../components/Button';
99
import KatexRenderer from './KatexRenderer';
1010

11-
import './../../style/lexical/KatexEquationAlterer.css';
1211

1312
type Props = {
1413
initialEquation?: string;

packages/lexical/src/components/Modal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import {ReactNode, useEffect, useRef} from 'react';
88
import {createPortal} from 'react-dom';
99

10-
import './../../style/lexical/Modal.css';
11-
1210
function PortalImpl({
1311
onClose,
1412
children,

0 commit comments

Comments
 (0)