CanopyTax / kremling

Embarrassingly simple css for React
https://kremling.js.org
Apache License 2.0
36 stars 4 forks source link

Brainstorming how to get css syntax highlighting #32

Closed geoctrl closed 5 years ago

geoctrl commented 5 years ago

I'm toying with some ideas on how to get syntax highlighting for css using kremling (css-in-js)

my first thought was that we could do some sort of html syntax highlighting using a webpack loader (like vue-loader) where both js & styles lived in harmony:

<script>
  import React from 'react';
  import { useCss } from 'kremling';

  export function TestComponent() {
    const scope = useCss($style);
    return (
      <div {...scope} className="thing">
        test Component
      </div>
    );
  }

  TestComponent.propTypes = {};
</script>

<style>
  .thing {
    background-color: red;
  }
</style>

pros:

cons:


Another option is that we could add a kremling tag to the css template literal:

import { kremCss } from 'kremling';

const css = kremCss`
  & .thing { }
`;

This would allow us to target kremCss with an editor plugin to get the highlighting

pros:

cons:

joeldenning commented 5 years ago

I lean towards the second, over the first. The first seems like it changes how you write all your react code in a pretty drastic way

geoctrl commented 5 years ago

implemented k tag #33

joeldenning commented 5 years ago

We should add documentation for getting syntax highlighting