-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
Port to React #35
Comments
@hiteshsahu Thank you :D |
I think a template string helper would be nice too, similar to styled-components. /* doodle.js */
import React from 'react';
import 'css-doodle';
export default ([ rule = '' ]) => () => (
<css-doodle>{ rule }</css-doodle>
); /* example.js */
import Doodle from './doodle';
const FancyDoodle = Doodle`
:doodle {
@grid: 2 / 200px;
grid-gap: 1px;
}
background: @pick(red, pink);
`;
...
<FancyDoodle /> |
@simonmarton Nice! |
No need to wrap around. Just use it directly! import 'css-doodle';
function App() {
return (
<css-doodle>{`
:doodle {
@grid: 2 / 200px;
grid: 1px;
}
background: @pick(red, pink);
`}</css-doodle>
);
} |
Does this support tsx? |
@papan01 Nope |
I don't know the support means, but I use First, you need to extend declare namespace JSX {
interface IntrinsicElements {
'css-doodle': {}
}
} And then, you can use import React from 'react';
import 'css-doodle';
const Doodle: React.FunctionComponent = () => {
// code is referenced from https://alligator.io/css/patterns-css-doodle/
return (
<css-doodle>
{`
:doodle {
@grid: 5x8 / 100% 15rem;
}
:after {
content: "@index()"
}
background: pink;
margin: .5rem;
`}
</css-doodle>
);
};
export default Doodle; hmm. |
@Mizumaki That’s right! Thank you 🙇 |
import React from "react";
const Doodle = (rule) => () => {
React.useEffect(() => {
const script = document.createElement("script");
script.src = "https://unpkg.com/css-doodle@0.20.2/css-doodle.min.js";
document.body.appendChild(script);
}, []);
return <css-doodle>{rule}</css-doodle>;
};
export { Doodle }; use next.js and css-doodles |
For Typescript I had to add
|
anyone tried this with react-native? |
Current workaround:
It's not the best way, but if you want to use
css-doodle
inReact
you could try the following:Better way:
Just use it directly!
The text was updated successfully, but these errors were encountered: