lukeed/clsxPublic

A tiny (239B) utility for constructing `className` strings conditionally.

feat: Add usage with Tailwind documentation #65

Mergededgarlrmerged 3 commits intomasterfromrefs/pull/65/head
  1. ED

    Add documentation on how to enable Tailwind IntelliSense inside `clsx` functions

    Fixes #64

  2. LU
    Hidden as resolved.
  3. LU

    No review summary.

  4. LU

    Thanks! Can you move this section between `Support` and `Related`?

  5. ED
    Author

    @lukeed Done!

  6. lukeedmentioned3 years ago on GitHub

  7. lukeedsubscribed3 years ago on GitHub

  8. LU
  9. lukeedmerged 496db1dd74413 years ago on GitHub

  10. lukeedclosed3 years ago on GitHub

  11. KA

    👋 @lukeed! Thanks for adding this regex! Can you please elaborate on your approach to building it? I was using https://github.com/shadcn/ui/blob/5e172fc34fdf015aa0d141f52cc8c082b8ae6613/.vscode/settings.json#L7-L8 before seeing your solution. There is a slight difference, so I'm curious if there are any edge cases not covered by any of the two regexps:

    ```diff shadcn/ui - ["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"] + ["cn\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"] your regex ```

    readme.md:97headce8c006
  12. KA

    No review summary.

  13. LU

    @edgarlr contributed this section so perhaps they can offer an explanation.

    By eyeballing it, the difference is that `([^']*)` will match anything up to `'`, which means that if `"` or or backticks appear in the class value, then the regexp in _our_ docs will include it as part of the value, whereas the other regexp stops there.

    clsx doc's regexp <img width="283" alt="Screen Shot 2023-07-18 at 10 43 53 AM" src="https://github.com/lukeed/clsx/assets/5855893/0a0f4e46-08bc-4d09-9552-dbd594c5b699">

    shadcn/ui regexp <img width="264" alt="Screen Shot 2023-07-18 at 10 44 16 AM" src="https://github.com/lukeed/clsx/assets/5855893/415538d8-7435-42ed-b41d-0f1740d2238b">

    Looks like they're both not ideal, tbh I don't use this extension, but perhaps something like this is better? I don't know if the extn is looking for the first matching group only, though

    <img width="218" alt="Screen Shot 2023-07-18 at 10 53 57 AM" src="https://github.com/lukeed/clsx/assets/5855893/94adef8d-a66b-41da-98ef-e64b3ed0a8ef">

    readme.md:97headce8c006
  14. LU

    No review summary.

  15. sync-by-unito[bot]botreferenced this in build(deps): bump clsx from 1.2.1 to 2.0.0 #3123 years ago on GitHub

  16. rsazreferenced this in [Snyk] Upgrade clsx from 2.0.0 to 2.1.1 #512 years ago on GitHub

  17. salgadevreferenced this in [Snyk] Upgrade clsx from 2.0.0 to 2.1.1 #172 years ago on GitHub

  18. wierzareferenced this in [Snyk] Upgrade clsx from 2.0.0 to 2.1.1 #1472 years ago on GitHub