This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-30
Channels
- # asami (4)
- # babashka (3)
- # beginners (21)
- # biff (22)
- # cljs-dev (6)
- # clojure (11)
- # clojure-europe (3)
- # clojure-norway (35)
- # clojure-spain (4)
- # clojurescript (14)
- # datalevin (2)
- # emacs (12)
- # exercism (2)
- # fulcro (10)
- # honeysql (4)
- # humbleui (3)
- # hyperfiddle (49)
- # instaparse (1)
- # introduce-yourself (1)
- # missionary (1)
- # off-topic (109)
- # pathom (2)
- # practicalli (21)
- # random (2)
- # rdf (2)
- # releases (2)
- # scittle (3)
- # specter (2)
Hello! I am trying to use React component in cljs+reagent. It is not hard, but I struggle with a reference to an inner react field (so to speak). In typescript it should like this:
<MDEditor value={value} onChange={setValue}/>
<MDEditor.Markdown source={value} style={{ whiteSpace: 'pre-wrap' }} />
and in cljs I try this:
[:> MDEditor {:value @value :on-change #(reset! value %)}]
[:> MDEditor.Markdown {:source @value :style "whiteSpace: 'pre-wrap'"}]
the first line is OK (it works), but when I add second - it breaks. How to use MDEditor.Markdown here?
Probably (.-Markdown MDEditor)?
Oh and make style a map not a string
I'm having issues translating '&:hover' Material-UI prop to ClojureScript. How am I supposed to do it? I want to change the color of the background of the text, when I hover over it.
(ns playground.core
(:require
["@mui/material" :refer [Typography]]))
[:> Typography {:variant "h2"
:font-size "1.3em"
:color {:color "palette.primary.secondary"}
:&:hover {:backgroundColor "primary.tertiary"} ;; <--- throws error
:background "palette.primary.main"}
"Hello typography!"])
From https://mui.com/material-ui/react-box/,
import * as React from 'react';
import Box from '@mui/material/Box';
export default function BoxSx() {
return (
<Box
sx={{
width: 300,
height: 300,
backgroundColor: 'primary.dark',
'&:hover': {
backgroundColor: 'primary.main',
opacity: [0.9, 0.8, 0.7],
},
}}
/>
);
}
The error:
Warning: Invalid attribute name: `&:hover
`Also note that those examples are not compatible.
The JSX one wraps all its style properties in the sx
property. Whereas your CLJS code passes all type properties at the top level.
Same way you used all other properties. Maybe its value needs to be wrapped in clj->js
, not sure. Try without it first.
Alright, that did it.
I mixed both: {:sx {"&:hover" {:backgroundColor ...}}}
and it works. Thanks @U2FRKM4TW