nicojs / typed-html

TypeSafe HTML templates using TypeScript. No need to learn a template library.
333 stars 51 forks source link

Missing summary tag #40

Open believer opened 1 year ago

believer commented 1 year ago

The summary tag seems to be missing in the intrinsic elements' definition. This is used together with details, which does exist in the definitions.

<details>
    <summary>Custom title for the details element</summary>
    Details that are shown when expanded.
</details>

I can create a PR if the issue is valid. I think there's only a summary: HtmlTag; missing, since the summary tag only includes the global attributes.

Thanks for a great library!

arthurfiorette commented 1 year ago

Hey @believer, I'm maintaining a fork (https://github.com/kitajs/html) which already has summary support.

This library seems to be unmaintained, (no license, #23, no fragment support...) I'm maintaining @kitajs/html with some extra features I wanted to add, like fragments, more performant, a pre-compiled mode, null/undefined handling, preact (h) build systems compatible and more...

I'm open to creating a PR to this repo if requested.

believer commented 1 year ago

@arthurfiorette Hey! Thanks for creating your fork, it works great. I had to adjust the getting started steps slightly to get it working (it might be because I'm using Bun?).

The steps are similar to the getting started steps in typed-html:


// tsconfig.json
{
  "compilerOptions": {
    "jsx": "react",
    "jsxFactory": "elements.createElement"
  }
}

// Use in file
import * as elements from '@kitajs/html'
arthurfiorette commented 1 year ago

@believer thanks for your heads up! Things should now be fixed at v1.3.1.

P.S: I think you should now be able to go back to the README setup, as the example above will not works with fragments :)

believer commented 1 year ago

@arthurfiorette Thanks for the quick update, but I still can't get it to work. If I only use jsx and reactNamespace in tsconfig.json from the README I get Can't find variable: React when I try to run the app. Adding the optional options makes no difference.

My entire tsconfig, which came from running bun init, looks like:

{
  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "esnext",
    "target": "esnext",
    "moduleResolution": "bundler",
    "moduleDetection": "force",
    "allowImportingTsExtensions": true,
    "strict": true,
    "downlevelIteration": true,
    "skipLibCheck": true,
    "jsx": "react",
    "reactNamespace": "html",
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "allowJs": true,
    "noEmit": true,
    "types": [
      "bun-types" // add Bun global
    ]
  }
}

Maybe there's some other option here that's conflicting?


Edit: Ok, it worked with:

// tsconfig.json
{
    "compilerOptions": {
        "jsx": "react",
        "reactNamespace": "elements",
        "jsxFactory": "elements.createElement",
        "jsxFragmentFactory": "elements.Fragment",
    }
}

// Use in file
import elements from '@kitajs/html'

But not if I call it html or remove jsxFactory/jsxFragmentFactory 😅