fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Unknown utility "class-name"

Open nikableh opened this issue 4 years ago • 5 comments

For some reason, this...

// components/SidebarIcon.tsx

/** @jsx h */
import { h } from "preact";

export function SidebarIcon(props: {iconName: string}) {
  return (
    <div className="sidebar-icon">
      {props.iconName}
    </div>
  );
}

...gives me this error from TypeScript in VSCode:

Unknown utility "sidebar-icon" ts(-2020)

I have a feeling that might be caused by Twind because if I use one of its classes — everything is fine. Am I not allowed to create my own classes if I use Twind?

nikableh avatar Jul 05 '22 16:07 nikableh

I've just tested with twind and without twind. Both of them not gave me an error.

fdemir avatar Jul 05 '22 17:07 fdemir

I understood the source, but not the reason of the issue.

To solve the https://github.com/denoland/fresh/issues/425, I created this file:

// config/twind.config.ts

/** @jsx h */

/** @type {import('twind').Configuration} */

It solved the issue of autocomplete not working for the Twind, but at the same time introduced the above Unknown utillity error. Deleting this config/twind.config.ts file solves the issue, but breaks autocomplete.

nikableh avatar Jul 05 '22 19:07 nikableh

This seems like something you'd want to report to the twind folks.

lucacasonato avatar Jul 06 '22 10:07 lucacasonato

How was this resolved? I'm trying to embed markdown in my site, which otherwise uses tailwind/twind, but I can't figure out how to style it. I get the above error when I try wrap the markdown HTML in my own class. I've looked at a dozen intro-to-Fresh tutorials that use Markdown, and the only ones illustrating style support use gfm. I can't use gfm.

jtlapp avatar Nov 13 '22 19:11 jtlapp

Well, right after I posted the above question, I came up with the following functioning hack:

    <>
      <Head>
        <link rel="stylesheet" href={asset("post.css")} />
      </Head>
     <article ...>
        ...
        <main
          dangerouslySetInnerHTML={{
            __html: `<div class='post'>\n${props.post.html}</div>\n`,
          }}
          />
      </article>
    </>

jtlapp avatar Nov 13 '22 19:11 jtlapp