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

Some thoughts (low priority) #1091

Open
kuraga opened this issue Dec 2, 2023 · 2 comments
Open

Some thoughts (low priority) #1091

kuraga opened this issue Dec 2, 2023 · 2 comments

Comments

@kuraga
Copy link

kuraga commented Dec 2, 2023

Good day!

I have some thoughts not discovered in the issues/PRs. Nobody needs to react, just thoughts.

  1. Snabbdom is written in TypeScript. So, we should describe / put an example in TypeScript. BTW, I don't know the standard way? Maybe move one of our examples to it.

  2. As @nilslindemann noticed in Add installation instructions to the README #1088 , we could describe / put an example of a totally cooked project. Bundled with Rollup, Webpack? Maybe move one of our examples to it.

  3. As I noticed in Add installation instructions to the README #1088 , we don't have the ## Installation section in README.md. (A simple one.)

  4. Did we consider which files we store in the NPM package? To store/not to store the source, the tests, etc.

  5. According the changelog is automatically contented de-facto, we should think more about commit messages and PR titles.

  6. CONTRIBUTING.md looks not full.

  7. README-in_HN.md and README-zh_CN.md will be outdated soon.

  8. Are all devDependencies needed? And: some of them is strictly fixed (without neither ^ nor ~), why?

  9. We have npm run build which builds everything. But maybe we would extract npm run build-examples, etc.

  10. Finish to label issues/PRs :).

  11. List of unfairly closed issues and pull requests (important things are there!) #1017.

  12. Add Snabbdom to https://github.com/krausest/js-framework-benchmark/.

  13. There are many of any type usages.

Thanks!

@nilslindemann
Copy link

nilslindemann commented Dec 3, 2023

I would like to repeat/extend/add to these points by @kuraga, what especially interests me to be added to the snabbdom docs:

  • How to get the examples locally running (see my linked PR).
  • What may some error messages mean, when running the tests (E.g. the missing CHROME_VERSION env var error).
  • A simple workflow how to make a website, using snabbdom as a dependency (e.g. using Parcel1/webpack/rollup).
  • Maybe a Deno workflow.

I promise a German translation of the final docs.


1 Here a working example for Parcel. Feel free to use it in the docs:

npm init -y
npm install --save-dev parcel
npm install snabbdom

Create a src/index.html:

<!doctype html>
<html>
    <head>
        <title>Snabbdom + Parcel Example</title>
        <script type="module" src="logic.ts"></script>
    </head>
    <body>
        <h1 id="heading">Unpatched</h1>
    </body>
</html>

Create a src/logic.ts (inspired by the example in the README):

import {
    init,
    classModule,
    propsModule,
    styleModule,
    eventListenersModule,
    h,
} from "snabbdom";

const patch = init([
    // Init patch function with chosen modules
    classModule, // makes it easy to toggle classes
    propsModule, // for setting properties on DOM elements
    styleModule, // handles styling on elements with support for animations
    eventListenersModule, // attaches event listeners
]);

const replaceWithLinks = () => {
    console.log("Becoming links");
    patch(greeting, link);
};

const replaceWithGreeting = () => {
    console.log("Becoming a greeting");
    patch(link, greeting);
};

const greeting = h("h1#heading.greeting", { on: { click: replaceWithLinks } }, [
    h("span", { style: { color: "blue" } }, "Hello World!"),
    " (click me)",
]);

const link = h("h1#heading.link", { on: { click: replaceWithGreeting } }, [
    "Brought to you by ",
    h("a", { props: { href: "https://github.com/snabbdom" } }, "snabbdom"),
    " and ",
    h("a", { props: { href: "https://parceljs.org/" } }, "Parcel"),
    " (click me again)",
]);

const heading = document.getElementById("heading"); if (!heading) {throw "I need a h1#heading"};

patch(heading, greeting);

Start the parcel dev server:

npx parcel src/index.html

@iambumblehead
Copy link
Contributor

@kuraga should submit a PR adding Snabbdom to the test suite at https://github.com/krausest/js-framework-benchmark/ :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants