netzo / fresh-netzo

Full-stack Deno Fresh meta-framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
https://netzo.io
MIT License
51 stars 3 forks source link

feat(plugins/unocss): decouple `unocss` plugin from netzo #136

Closed miguelrk closed 9 months ago

miguelrk commented 9 months ago

Closes https://github.com/netzo/netzo/issues/114. See also https://github.com/netzo/netzo/issues/85#issuecomment-1925870041.

The components module is to be dropped in favor of a standalone unocss plugin to decouple it from netzo.

Before

The components module would setup an adapted unocss fresh plugin internally and handle theming.

// netzo.ts
import { Netzo } from "netzo/mod.ts";

export const netzo = await Netzo({
  components: {
    theme: { color: "red", radius: 1.0 }
  }
});
if (import.meta.main) netzo.start();

Now

The standalone unocss fresh plugin uses a conventional uno.config.ts file and presetNetzo handles theming. Note that note that NetzoConfig extends FreshConfig so we can directly pass a fresh plugins array.

// netzo.ts
import { Netzo } from "netzo/mod.ts";
import { unocss } from "netzo/plugins/unocss/plugin.ts";

export const netzo = await Netzo({
  plugins: [unocss()], // auto-loads uno.config.ts
});
if (import.meta.main) netzo.start();
// uno.config.ts
import { defineConfig } from "netzo/plugins/unocss/plugin.ts";
import { presetNetzo } from "netzo/plugins/unocss/preset-netzo.ts";

export default defineConfig({
  presets: [
    presetNetzo({ color: "red", radius: 1.0 }),
  ],
});