lukeed/clsxPublic

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

feat: support for using functions #87

Closedliuseen-lclosed 1 commit intomasterfromrefs/pull/87/head
  1. LL

    Sometimes we may encounter more complex scenarios, so we can support functions to deal with such scenarios ```javascript let z = 0 let className = clsx(() => { if(z === 0) { return 'foo' } else if (z === 1) { return 'baz' } else { return 'bar' } }) ```

  2. LU

    ```js clsx({ foo: z === 0, bar: z === 1, baz: z > 1 || z < 0, }) // or clsx( z === 0 ? "foo" : z === 1 ? "bar" : "baz" ); // or let z clsx( (function() { if(z === 0) { return 'foo' } else if (z === 1) { return 'baz' } else { return 'bar' } })() ) ```

  3. lukeedclosed2 years ago on GitHub