Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

css overload type purpose? #372

Open
datner opened this issue Jan 23, 2025 · 1 comment
Open

css overload type purpose? #372

datner opened this issue Jan 23, 2025 · 1 comment
Assignees
Labels
customization: css Design CSS customizability status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@datner
Copy link

datner commented Jan 23, 2025

Steps to reproduce

use css

Current behavior

N/A

Expected behavior

N/A

Context

The css function has the following overload:

/* -- snip -- */
type CssArg$1 = ((themeArgs: ThemeArgs) => CSSObjectNoCallback) | CSSObjectNoCallback;
type CssFn$1 = (themeArgs: ThemeArgs) => string | number;

interface Css {
  /**
   * @returns {string} The generated css class name to be referenced.
   */
  (arg: TemplateStringsArray, ...templateArgs: (Primitve$1 | CssFn$1)[]): string;
  /**
   * @returns {string} The generated css class name to be referenced.
   */
  (...arg: CssArg$1[]): string; // <-- focus on this one
}
/* -- snip -- */

I cannot imagine a use-case utilizing the n-ary case for css

css(
  { color: 'red' },
  { border: '1px solid black' },
  { background: 'blue' },
  ({ theme }) => ({ padding: theme.spacing(4) })
)

There is no value gain over the unary case 🤔
If anything, I would argue that this support is harmful, promoting creation of silly patterns like this:

import { redText, border, blueBg, padding } from './my-first-design-system'

css(redText,border,blueBg,padding) // -> 'aaaa0001'

promoting a classname explosion instead of composition.
I would expect that the n-ary case would function like this:

const redText = css({ color: 'red' }) // -> 'aaaa0001'
/// and the rest...

const foo = css(redText,border,blueBg,padding, { .. }) // -> 'aaaa0001 aaaa0002 aaaa0003 aaaa0004 aaaa0005'

similar to clsx basically but that would accept everything.

What is the rational behind the n-ary css function?

Your environment

N/A

Search keywords: css method types overload arguments

@datner datner added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 23, 2025
@zannager zannager added the customization: css Design CSS customizability label Jan 24, 2025
@datner
Copy link
Author

datner commented Feb 12, 2025

bump?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: css Design CSS customizability status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants