@calmery-chan/aleph-plugin-emotion

2.0.0 • Public • Published

@calmery-chan/aleph-plugin-emotion

@calmery-chan/aleph-plugin-emotion - npm Lint Commitizen Friendly

A plugin for using 👩‍🎤 with Aleph.js.

Features

Can only use @emotion/css.

  • [x] API
    • [x] Generate Class Names — css
    • [x] Global Styles — injectGlobal
    • [x] Animation Keyframes — keyframes
    • [x] Composing Class Names — cx
  • [ ] Custom Instances
  • [x] Server Side Rendering

Usage

$ npm i @calmery-chan/aleph-plugin-emotion
// aleph.config.ts

import type { Config } from "https://deno.land/x/aleph@v0.3.0-beta.19/types.d.ts";
import emotion from "./node_modules/@calmery-chan/aleph-plugin-emotion/plugin.ts";

export default <Config> {
  plugins: [emotion],
};

Internally, the React component is compiled using Babel, and then the CSS is extracted using the extractCritical function in @emotion/server. Therefore, if you import the npm package directly from esm.sh, etc., it will fail to compile using Babel. Use import_map.json and add the npm package using npm install.

// import_map.json

{
  "imports": {
    "@emotion/css": "https://esm.sh/@emotion/css@11.1.3",
    "react": "https://esm.sh/react@17.0.2"
  }
}
// pages/index.ts

// import { css } from "https://esm.sh/@emotion/css@11.1.3";
// import React from "https://esm.sh/react@17.0.2";
import { css } from "@emotion/css";
import React from "react";

const container = css`
  background: #000;
  color: #FFF;
`;

export default () => {
  return (
    <div className={container}>
      Hello World
    </div>
  );
};
$ npm i -D @emotion/css react
$ aleph dev

See example.

Readme

Keywords

none

Package Sidebar

Install

npm i @calmery-chan/aleph-plugin-emotion

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

9.82 kB

Total Files

9

Last publish

Collaborators

  • calmery