Skip to content

Commit

Permalink
merge: #1264
Browse files Browse the repository at this point in the history
1264: small devx changes for css / tailwind tooling r=theoephraim a=theoephraim

did some digging into latest tooling and best practices for tailwind/css/etc.

Hopefully these small quality of life improvements will help make things easier and keep things tidy.

- main tool is https://github.com/lukeed/clsx
- secondary is using a (noop) [string template tag function](https://www.freecodecamp.org/news/a-quick-introduction-to-tagged-template-literals-2a07fd54bc1d/) with IDE settings to get autocomplete on class lists outside of the template tag


Some quick guidelines on tailwind classes:
- try to keep tailwind classes in the template _as much as possible_
- feel free to use clsx even when seems unnecessary as it will make adding more classes easier later
- break up super long lists of classes into multiple lines, grouping things as appropriate (ex: static classes, dark mode, toggles based on state, etc)
- dont copy paste classes if used multiple times in component, move to script as static var or computed (if dynamic) and use `clsx` and `tw` helpers
- its OK to also add semantic classes with BEM-ish naming if it might be helpful in debugging what html belongs to which component
- we may fall back to using css occasionally where it makes sense, but it should be very rare

Co-authored-by: Theo Ephraim <theo@systeminit.com>
  • Loading branch information
si-bors-ng[bot] and Theo Ephraim committed Sep 7, 2022
2 parents 580a72c + 7e7e245 commit c1517cd
Show file tree
Hide file tree
Showing 12 changed files with 770 additions and 312 deletions.
1 change: 1 addition & 0 deletions app/web/.eslintignore
@@ -0,0 +1 @@
*.css
16 changes: 16 additions & 0 deletions app/web/README.md
Expand Up @@ -55,3 +55,19 @@ This template should help get you started developing with Vue 3 and Typescript i
- Enable format on save (recommended)
- add `"editor.formatOnSave": true` to `.vscode/settings.json` file
- add `"[vue][typescript][javascript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" }` to `.vscode/settings.json` file

### .vscode/settings.json
```json
{
"editor.formatOnSave": true,
"[vue][typescript][javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
// enable tailwind class autocomplete / tooling outside of just "class" in templates
"tailwindCSS.experimental.classRegex": [
[
"tw`([^`]*)", // tw`...`
]
]
}
```

0 comments on commit c1517cd

Please sign in to comment.