Skip to content

Commit 9be4af4

Browse files
committed
doc: describe config options
1 parent 2ac3f32 commit 9be4af4

File tree

1 file changed

+124
-48
lines changed

1 file changed

+124
-48
lines changed

README.md

+124-48
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<div align="center">
32

43
# @twind/typescript-plugin
@@ -11,15 +10,16 @@ TypeScript language service plugin that adds IntelliSense for [Twind](https://tw
1110

1211
![Demo](https://raw.githubusercontent.com/tw-in-js/typescript-plugin/main/assets/demo.gif)
1312

14-
</div>
15-
1613
---
1714

18-
If you are using VS Code as your editor – you can try our new *[Twind Intellisense for VS Code](https://github.com/tw-in-js/vscode-twind-intellisense)* extension:
15+
If you are using VS Code as your editor – you can try our new _[Twind Intellisense for VS Code](https://github.com/tw-in-js/vscode-twind-intellisense)_ extension:
1916

2017
[Install via the Visual Studio Code Marketplace →](https://marketplace.visualstudio.com/items?itemName=sastan.twind-intellisense)
2118

2219
---
20+
21+
</div>
22+
2323
<!-- prettier-ignore-start -->
2424
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2525
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -37,14 +37,20 @@ If you are using VS Code as your editor – you can try our new *[Twind Intellis
3737

3838
## Features
3939

40-
Provides editor support for `tw` tagged template syntax including:
41-
42-
- Autocomplete for [twind](https://github.com/tw-in-js/twind) variants and classes
43-
- Details about the generated CSS
40+
- IntelliSense for [twind](https://github.com/tw-in-js/twind) variants and classes within
41+
- `tw` and `apply`
42+
- JSX attributes (`tw`, `class`, and `className`)
43+
- [style](https://twind.dev/docs/modules/twind_style.html) and `styled` (like [@twind/react](https://github.com/tw-in-js/twind-react/#readme) or [@twind/solid](https://github.com/tw-in-js/use-twind-with/tree/main/packages/solid#readme))
44+
- Quick Info about
45+
- generated CSS
46+
- used theme value
47+
- the `px` value for `rem` values
48+
- Color preview
4449
- Support for grouping of variants and classes
45-
- Warnings on unknown classes
46-
- Warnings on unknown theme values
47-
- Warnings on unknown variants
50+
- Warnings on
51+
- unknown classes
52+
- unknown theme values
53+
- unknown variants
4854

4955
## Installation
5056

@@ -83,11 +89,7 @@ declare module 'twind' {
8389

8490
> If no `twind.config.{ts,js,cjs,mjs}` exists and a `tailwind.config.{ts,js,cjs,mjs}` is found, the compatible values from the tailwind config will be used.
8591
86-
### With VS Code
87-
88-
Currently you must manually install the plugin along side TypeScript in your workspace.
89-
90-
Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson)
92+
Add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson)
9193

9294
```json
9395
{
@@ -101,6 +103,12 @@ Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang
101103
}
102104
```
103105

106+
See [Configuration](#configuration) below for details options.
107+
108+
### With VS Code
109+
110+
Currently you must manually install the plugin along side TypeScript in your workspace.
111+
104112
Finally, run the `Select TypeScript version` command in VS Code to switch to use the workspace version of TypeScript for VS Code's JavaScript and TypeScript language support. You can find more information about managing typescript versions [in the VS Code documentation](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript).
105113

106114
By default VS Code will not trigger completions when editing "string" content, for example within JSX attribute values. Updating the `editor.quickSuggestions` setting may improve your experience, particularly when editing Tailwind classes within JSX:
@@ -126,94 +134,162 @@ And configure Sublime to use the workspace version of TypeScript by [setting the
126134
}
127135
```
128136

129-
Finally add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson) and restart Sublime.
137+
### With Atom
138+
139+
This plugin works with the [Atom TypeScript plugin](https://atom.io/packages/atom-typescript).
140+
141+
To get sytnax highlighting for styled strings in Atom, consider installing the [language-babel](https://atom.io/packages/language-babel) extension.
142+
143+
### With Visual Studio
144+
145+
This plugin works [Visual Studio 2017](https://www.visualstudio.com) using the TypeScript 2.5+ SDK.
146+
147+
Then reload your project to make sure the plugin has been loaded properly. Note that `jsconfig.json` projects are currently not supported in VS.
148+
149+
## Configuration
150+
151+
### Tags
152+
153+
This plugin adds IntelliSense to any template literal [tagged](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) with `tw` or `apply`:
154+
155+
```js
156+
import { tw } from 'twind'
157+
158+
tw`
159+
sm:hover:(
160+
bg-black
161+
text-white
162+
)
163+
md:(bg-white hover:text-black)
164+
`
165+
```
166+
167+
You can enable IntelliSense for other tag names by configuring `"tags"`:
130168

131169
```json
132170
{
133171
"compilerOptions": {
134172
"plugins": [
135173
{
136-
"name": "@twind/typescript-plugin"
174+
"name": "@twind/typescript-plugin",
175+
"tags": ["tw", "cx"]
137176
}
138177
]
139178
}
140179
}
141180
```
142181

143-
### With Atom
182+
Now strings tagged with either `tw` and `cx` will have IntelliSense.
144183

145-
This plugin works with the [Atom TypeScript plugin](https://atom.io/packages/atom-typescript).
184+
### Attributes
146185

147-
Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or [`jsconfig.json`](https://code.visualstudio.com/Docs/languages/javascript#_javascript-project-jsconfigjson) and restart Atom.
186+
This plugin adds IntelliSense to JSX `tw`, `class`, and `className` attributes:
187+
188+
```js
189+
<span
190+
className="text-purple-400"
191+
tw={`
192+
sm:hover:(
193+
bg-black
194+
text-white
195+
)
196+
md:(bg-white hover:text-black)
197+
`}
198+
>...</span>
199+
`
200+
```
201+
202+
You can enable IntelliSense for other attributes by configuring `"attributes"`:
148203

149204
```json
150205
{
151206
"compilerOptions": {
152207
"plugins": [
153208
{
154-
"name": "@twind/typescript-plugin"
209+
"name": "@twind/typescript-plugin",
210+
"attributes": ["tw"]
155211
}
156212
]
157213
}
158214
}
159215
```
160216

161-
To get sytnax highlighting for styled strings in Atom, consider installing the [language-babel](https://atom.io/packages/language-babel) extension.
217+
Now only the `tw` attribute will have IntelliSense.
162218

163-
### With Visual Studio
219+
### Styles
164220

165-
This plugin works [Visual Studio 2017](https://www.visualstudio.com) using the TypeScript 2.5+ SDK.
221+
This plugin adds IntelliSense to [style](https://twind.dev/docs/modules/twind_style.html) and `styled` (like [@twind/react](https://github.com/tw-in-js/twind-react/#readme) or [@twind/solid](https://github.com/tw-in-js/use-twind-with/tree/main/packages/solid#readme))
222+
223+
```js
224+
// Same for style({... })
225+
const Button = styled("button", {
226+
base: `
227+
appearance-none border-none bg-transparent
228+
rounded-full px-2.5
229+
`,
230+
231+
variants: {
232+
variant: {
233+
gray: `
234+
bg-gray-500
235+
hover:bg-gray-600
236+
`,
237+
primary: `
238+
text-white bg-purple-500
239+
hover:bg-purple-600
240+
`,
241+
},
242+
243+
outlined: {
244+
true: `bg-transparent ring-1`,
245+
},
246+
},
247+
248+
matches: [
249+
{
250+
variant: "gray",
251+
outlined: true,
252+
use: `ring-gray-500`,
253+
},
254+
}
255+
})
256+
```
166257

167-
Then add a `plugins` section to your [`tsconfig.json`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
258+
You can enable IntelliSense for other `style` like functions by configuring `"styles"`:
168259

169260
```json
170261
{
171262
"compilerOptions": {
172263
"plugins": [
173264
{
174-
"name": "@twind/typescript-plugin"
265+
"name": "@twind/typescript-plugin",
266+
"styles": ["styled", "stitched"]
175267
}
176268
]
177269
}
178270
}
179271
```
180272

181-
Then reload your project to make sure the plugin has been loaded properly. Note that `jsconfig.json` projects are currently not supported in VS.
273+
Now the `styled` and `stitched` functions will have IntelliSense.
182274

183-
## Configuration
275+
### Debug
184276

185-
### Tags
186-
187-
This plugin adds IntelliSense to any template literal [tagged](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) with `tw`, `ow` or `bw`:
188-
189-
```js
190-
import { bw } from 'beamwind'
191-
192-
bw`
193-
sm:hover:(
194-
bg-black
195-
text-white
196-
)
197-
md:(bg-white hover:text-black)
198-
`
199-
```
200-
201-
You can enable IntelliSense for other tag names by configuring `"tags"`:
277+
Allows to enabling/disabling additional debug information shown in hover and completion popups (default: `false`).
202278

203279
```json
204280
{
205281
"compilerOptions": {
206282
"plugins": [
207283
{
208284
"name": "@twind/typescript-plugin",
209-
"tags": ["tw", "cx"]
285+
"debug": true
210286
}
211287
]
212288
}
213289
}
214290
```
215291

216-
Now strings tagged with either `tw` and `cx` will have IntelliSense.
292+
Now the debug information is shown.
217293

218294
## Contribute
219295

0 commit comments

Comments
 (0)