Is there an accessible way to utilize svg elements in purescript halogen? I'm trying to draw a dynamic, clickable, graph within an <svg>, but the only reference I can find to svg is in Halogen.Themes.Bootstrap, which seems to be more concerned with css themeing.
Halogen doesn't provide a module for SVG elements, but you can construct your own elements in the appropriate namespace. If you're using the currently tagged release version (v0.12.0), then these you can use the Element constructor from Halogen.HTML.Core: https://pursuit.purescript.org/packages/purescript-halogen/0.12.0/docs/Halogen.HTML.Core#t:HTML
Related
I'm currently looking for a way to capture only svelte components on the DOM tree during development mode. I can see that we I run npm run dev all elements and conponents have the "class='svelte-somerandomID'". Does this only happen in development mode?
Yes, it's only in during development that all elements get a scoping class -- and only with some tools. Actually it's a hack we've added in vite-plugin-svelte to enable more power CSS only HMR.
The classes you're referring to are what Svelte uses to make the CSS in a component apply only to the elements of this component. It adds a class that is unique to the component to all elements that can be affected by the component's CSS, and it also modifies your CSS rules to add the same class to them.
Normally the compiler only adds the scoping class to elements that can actually be targeted by the existing CSS rules in your component. If you really want all the elements in a component to have the scoping class, you can use the same trick that I linked to above: add the following rule to your component's CSS.
* {}
By default the generated class names are a hash of the component's CSS content. But you can also customize them with the cssHash compiler option. Note that vite-plugin-svelte also changes how the class names are generated, to be based on the file name instead of the content.
Since every element in the component would be targeted by this roule, this will cause the Svelte compiler to add the scoping class to all the elements.
If you wanted to automatically generalize this to every element of every component, you may want to do it with a preprocessor (if you need some inspiration, the code I've linked too actually implement this with a preprocessor).
I'm not sure if this is what you really want though. For one thing, only elements get a scoping class: components don't get a scoping class, because components don't have dedicated elements in the DOM (only the ones you may or may not add via the component's markup). The above trick would only give you a mean to select every element of a Svelte component. There might probably be easier or cleaner ways to achieve what you really want. For example, a simple wrapping component, or an action, that would use wrappingElement.querySelectorAll('*') or something...
I have a final-form backed grid built using ag-grid. Ag-grid takes renders which in my case are Fields wrapped with FormSpy's. Using pre-hooks version of final-form works but I had a few problems so I upgraded to the most recent and received the "[X] must be used inside of a component" error.
I used react devtools and sure enough, my custom Fields renderer / editor was being moved outside of context as leafs at the end of the tree. My question is, is there any workaround to make this work? Is there any way to subscribe to a specific context? Bit of an anti-pattern, I know, but I'm running low on ideas.
Example
This is the version with older final-form packages -- https://codesandbox.io/s/final-form-ag-grid-lbq7f
I was having problems using formik because ag-grid-react doesn't support React's context API without a prop, i.e. reactNext={true}. One other suggestion don't put gridApi in state, instead pass a ref to AgGridReact like:
const gridApi = useRef();
<AgGridReact
{...}
ref={gridApi}
/>
I am looking at https://github.com/mui-org/material-ui/blob/1052126cd08f19a04543d829a29f9c30e218a330/docs/src/pages/styles/basics/AdaptingHOC.js#L27
What I want to do is for a Gatsby project do something like this:
export default withStyles(styles)(HigherOrderLayout)
The problem I am facing is that the component needs a couple of other props.
Layout.propTypes = {
classes: PropTypes.object.isRequired,
title: PropTypes.object.isRequired,
children: PropTypes.array,
}
I am not sure how to provide those other props and I run into the following error:
Objects are not valid as a React child (found: object with keys
{title}). If you meant to render a collection of children, use an
array instead.
I am a complete React n00b so not able to make sense of the help pages. They examples are too simple and I can't find a single example that does what I want to achieve.
Any suggestions greatly appreciated.
The problem was rendering multiple elements in the render method,
instead you should wrapped it into a single.
You could also use to wrap it in
a single DOM node.
Seeing an Objects are not valid as a React child error might mean that a few different things are going wrong. For example, it could be because the items being rendered in the JSX Element are objects instead of primitives (so make sure you’re not passing an object where a primitive is expected).
I made a small library in python that can generate graphics and I'd like to be able to display its object in ipython as with %matplotlib inline.
Is there some library that I could use to make this work in a simple way?
Bonus points if the display can be made interactive.
From the docs on how to add rich display of your objects:
http://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display
So long as you control the class definitions, you can add _repr_*_ methods, e.g. _repr_png_ or _repr_html_. Note that they're surrounded by single underscores, unlike Python's own magic __repr__ method. Text data like HTML should be returned as a string, and binary data like PNG as bytes.
If you don't control the class definition, you can register formatters separately:
get_ipython().display_formatter.formatters['image/png'].for_type(MyType, func)
for_type() method docs
When using the HTMLWorker to covert HTML into PDF elements we can provide a StyleSheet instance that can be used to style the generated elements.
Unfortunately the CSS-to-PDF conversion is quite limited (it doesn't seem possible to indent a list for example) so I wondered if there is an equivalent iTextSharp "PDF Stylesheet" we can declare, which will be used when elements are written to the document?
Alternatively are there any events we can hook into in order to walk the element tree and apply our styles, before the document is written?
as documented on many places (especially on SO), HTMLWorker is deprecated in favor of XML Worker. XML Worker reads CSS from file, from the header, inline, etc... Read the documentation for more info about the Java version. For the C# version, take a look at the test apps.