dvingo / cljs-styled-components

ClojureScript wrapper for styled-components
MIT License
50 stars 4 forks source link

How does this work with "styled-components/native"? Do I use "react-native" components? #25

Open kentbull opened 12 months ago

kentbull commented 12 months ago

When trying to use a styled.View component like so then I am not sure what the (defstyled ... invocation should be:

React component:

import styled from "styled-components/native"
...
export const AuthContainer = styled.View`
  flex: 1;
  align-items: center;
  justify-content: center;
  align-self: center;
`
(ns myapp.widgets
  (:require ["react-native" :as rn]
            ["styled-components/native$default" :as scn]
            [cljs-styled-components.reagent :refer [defstyled theme-provider clj-props set-default-theme!]]))

(defstyled auth-container rn/View
           {:flex 1
            :align-items "center"                           
            :justify-content "center"                       
            :align-self "center"                            
             })

Would this work?

kentbull commented 12 months ago

Maybe this line from your Readme answers my question:

"any react component, which will invoke styled on the component"


(defn my-component [props]
  (dom/div {:className (goog.object/get props "className")}
      (goog.object/get props "children")))

(defstyled example2 my-component {:border "1px solid"}).