Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept props without css or className #18

Open
jvliwanag opened this issue Mar 31, 2021 · 1 comment · May be fixed by #21
Open

Accept props without css or className #18

jvliwanag opened this issue Mar 31, 2021 · 1 comment · May be fixed by #21

Comments

@jvliwanag
Copy link

jvliwanag commented Mar 31, 2021

I wish to be able to create an alternate React.Basic.DOM with emotion Style type as additional input. To make this more ergonomic though, I'm hoping element didn't always require className and css.

I have a draft here which works nicely.

element ::
  forall input base.
  StyledInput input base =>
  ReactComponent {|base} ->
  {|input} ->
  JSX
element = runFn2 _jsx

button ::
  forall input base base_.
  StyledInput input base =>
  Row.Union base base_ R.Props_button =>
  {|input} ->
  JSX
button = element ReactDOM.button'

class StyledInput (input :: Row Type) (base :: Row Type) | input -> base
instance styledInputI ::
  ( RowToList input inputRl
  , StyledInputRl inputRl baseRl
  , ListToRow baseRl base1
  , Row.Cons "className" String base1 base2
  , Row.Nub base2 base
  ) => StyledInput input base

class StyledInputRl (inputRl :: RowList Type) (baseRl :: RowList Type) | inputRl -> baseRl

instance styledInputRlNil :: StyledInputRl Nil Nil
else instance styledInputRlConsCss ::
  StyledInputRl inputTl base =>
  StyledInputRl (Cons "css" Style inputTl) base
else instance styledInputRlConsOther ::
  StyledInputRl inputTl baseTl =>
  StyledInputRl (Cons name v inputTl) (Cons name v baseTl)

Wondering if this is a welcome addition. Perhaps a separate issue is if the React.Basic.DOM alternate with css can also reside here.

@i-am-the-slime
Copy link
Member

@jvliwanag I like this idea, I found myself passing "" as the class name a lot. Are you running your own fork with this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants