Skip to content

frizzant/fresh-jss

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

fresh-jss

Use Deno fresh with jss hooks.

Example

First add the registry to your project:

// utils/registry.ts

import { createRegistry } from "https://deno.land/x/fresh-jss/mod.ts";
const { registry, createUseStyles } = createRegistry();
export { registry, createUseStyles }

Then use it in your routes, islands and components:

// routes/index.tsx
/** @jsx h */

import { h } from "preact";
import { createUseStyles } from "../utils/registry.ts";

const useStyles = createUseStyles({
  "red": { color: "red" }
});

export default function Home() {
  const { classes } = useStyles();
  return (
    <p className={classes.red}>Red text here</p>
  );
}

Finally add the registry to page template to enable SSR:

// routes/_app.tsx
/** @jsx h */
/** @jsxFrag Fragment */

import { h, Fragment } from "preact";
import { registry } from "../utils/registry.ts";
import { Head } from "$fresh/runtime.ts";
import { AppProps } from "$fresh/server.ts";

export default function App(props: AppProps) {
  return (
    <>
      <Head>
        <style>{ registry.toString() }</style>
      </Head>
      <props.Component />
    </>
  );
}

See example directory for details.

About

Use eno fresh with jss hooks

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%