lilactown / helix

A simple, easy to use library for React development in ClojureScript.
Eclipse Public License 2.0
627 stars 52 forks source link

defnc- to create private component definitions #82

Closed lilactown closed 2 years ago

emmanueljohn1 commented 3 years ago

@lilactown I'm thinking of taking this on. I'm new to the code base. Do you have any tips on how I can tackle this?

lilactown commented 3 years ago

@emmanueljohn1 code-wise, the idea would be to introduce a new macro defnc- which adds :private true to the metadata of the display-name symbol and passes it to defnc.

I should take the time to create contributing docs, but as of now the best way to develop this would be to:

  1. start the dev server via shadow-cljs watch dev
  2. Navigate to http://localhost:8700
  3. Write new macro in helix.core
  4. Test by using defnc- in a new namespace and try and refer to it workshop.core. you should see a compiler warning saying that it's not public

I think you could also add a test for this in helix.core-test:

(defnc- private-comp
  []
  "can't see me outside of this namespace!")

(t/deftest private-component-definition
  (let [metadata (meta #'private-comp)]
    (t/is (:private metadata))))

Not 💯 on that but that's how I would try and tackle it first!

lilactown commented 3 years ago

Tests can be run via shadow-cljs watch test and navigating to http://localhost:8021