Comments (7)
@GrantCuster I follow you on the clearing values portion, that's definitely on our roadmap.
Can you say more on what you mean by default values in this context though?
from css.gui.
Yea, the default value is a weird one -- I will describe the situation more but totally leave it to you all to prioritize:
I think the main case is for color. Because our blocks come with a default background color, which is actually inherited from other CSS (so not a part of the styles we're feeding the editor), I think the color picker would ideally be set to that same color value so that when they open the color picker they start with that color selected, instead of in a black and white space where they need to change the hue...
It's possible that the more sustainable solution is for me to pass down those styles so that they are part of the editor... Part of the weirdness (or interestingness) of our current set-up is that we're using these as 'overrides', so the defaults are kind of "outside" the current styling system. It's interesting to try and sort through the strengths and confusing parts of CSS vs styles applied directly to a component...
So yea I'm not sure of the best solution, just sharing in case it sparks something.
from css.gui.
For populating defaults, I wonder if we could do some ref handling to initialize the style object from said ref. Could be a way to populated the inherited/computed styles. Could be pretty lightweight, too, only doing it on mount.
Not sure on what the API might look like, but here's a quick thought on a potential design:
import { useRef } from 'react'
import { Editor, styled, useStylesFromRef } from '@compai/css-gui'
const MyEditor = () => {
const ref = useRef()
const [styles, setStyles] = useStylesFromRef(ref)
return (
<>
<Editor styles={styles} onChange={setStyles}>
<Inputs.Color />
</Editor>
<styled.p ref={ref} styles={styles}>
Hello, world!
</styled.p>
<>
)
}
Will toss the "Future" label on this issue, so we can think about on how we can initialize styles for an element based on its computed styles - definitely seems like a use case we want to support. Just need to think about the most ergonomic and robust way.
from css.gui.
Regarding clearing values I've got a quick spike in a branch.
It does feel a little bit noisy. Almost wonder if we expose it as a context menu or dropdown from the label π€ . We could even make clearable an option at the editor or input level, too.
<Editor styles={styles} onChange={setStyles} clearable={true} />
Or
<Editor styles={styles} onChange={setStyles}>
<Inputs.Color clearable={true} />
</Editor>
from css.gui.
Yea I get how it could be more appropriate to some situations than others -- I also made my own custom ones (that just delete it from style state to clear) and that's working fine. The option at the input level would I think work well for my case, but it's not a blocker at the moment either.
from css.gui.
Right on, I think in the short term we'll write up a guide on rolling your own since it's something that's pretty straightforward with the composition-based editor. Can revisit in the near future to support it natively. But think we got some bigger fish to fry this week!
from css.gui.
This will now be handled in #53 as part of our in flux API, so will go ahead and close this one. Thanks for opening!
from css.gui.
Related Issues (20)
- Theme colors don't work in box shadow HOT 1
- HTML import HOT 1
- Use slots + types in export/codegen
- Allow for proper children slots/nesting
- Exports don't render slot data
- Component attributes should be editable when composed
- Allow for slots to target attributes
- Links that live inside a component don't get href removed (due to canvas=false being set)
- combobox clears out entry when pressing Esc
- Some transforms are broken HOT 1
- Element selector doesnβt match uppercase letters
- Attach styles to nodes in HTML import
- Selecting composed children can cause an error
- Add option to export code for current selection or full page
- Certain export formats missing CSS properties HOT 3
- Export to Enhance SFC does not produce valid component HOT 3
- File is throwing insecure warning in the browser HOT 1
- TypeError: culori__WEBPACK_IMPORTED_MODULE_17__.parse is not a function HOT 2
- Add export option for Astro
- Initializing Editor with plain CSS text string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css.gui.