kodyl / stilr

Encapsulated styling for your javascript components with all the power of javascript and CSS combined.
MIT License
236 stars 16 forks source link

export Map #14

Closed mpal9000 closed 9 years ago

mpal9000 commented 9 years ago

In my case I need this bacuase the instanceof Map checks in separate files doesn't work at the moment. Maybe there are some incompatible "babel-runtime"s somewhere in the project, but it can be useful in other ways too.

chriskjaer commented 9 years ago

The stylesheetmap should already be exposed. See https://github.com/kodyl/stilr/blob/master/lib/index.js#L117

e.g.

import Stylesheet from 'stilr'

console.log(Stylesheet.__stylesheet)     // your stylesheet map.

// ...or if you want to assing the variable to something prettier.
import Stylesheet,  {__stylesheet as StylesheetMap} from 'stilr'

one could argue that it would be better to call it stylesheetmap instead of stylesheet.

Can I ask what your use case for that is?

mpal9000 commented 9 years ago

Hi, __stylesheet is an instance but I want to import the Map class. I used StylesheetMap instead of Stylesheet, because Stylesheet is being used a a variable name for the default export in the examples.

I'm using stilr as an isomorphic js->css transformer. I have implemented handing of the transformed css and integrated that to React components. It works nice for now but it's a work in progress. On the server I create a new "stylesheet map" for each request and then pass that to context of the "tree". So I need to be able to import the same Map class that is being used internally in stilr, for instatiation and validation. Normaly I could just use the native Map class, but as I described in the previous post, I can't for some reason. This change doesn't break anything and It could be useful in other cases too.

chriskjaer commented 9 years ago

Cool! I hope you'll opensource it. I would love to see how Stilr is being used.

I've also added a small test to ensure that we export StylesheetMap.

mpal9000 commented 9 years ago

Thanks, I'll let you know when that happens

chriskjaer commented 9 years ago

:+1: Note that the export have been changed slightly because there was some problems when using normal require. See #15. The map class is now available on Stilr.Map.