-
Notifications
You must be signed in to change notification settings - Fork 331
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
Spacing-function for unified spacing dimensions #515
Comments
Good points. I totally agree with you, in fact, have had others complain to me about this in chats. I think the material is very worth learning from, In our system we can try to implement it like this:
Users can use it in the following way:1. Use theme presets directly: const myMargin = `calc(2 * ${theme.layout.margin})`
return <div style={{ margin: myMargin, padding: theme.layout.padding }} /> 2. Users modify the base value by customizing the theme: const myTheme = Theme.createFromLight({
type: 'coolTheme',
layout: {
margin: '50px'
},
}) 3. Allow users to modify the value of individual components: <Spacer y={3} margin="1px" />
<Card padding="20px" /> 4. As an advanced usage, passing a // Means 2 times the base spacing
// 2 * '10px'
<Card margin={2} />
// Means '2px'
<Card margin="2px" /> The above idea is similar to your proposal. but the implementation is a bit different. I would like to use the fact that when using There are a lot of details to think about here and would like to hear your thoughts. |
This looks quite exciting! Looking at your proposal, the following thoughts come to my mind: WordingI've noticed you're using both Having said that, I really like the idea of themed space values for String/number propThis actually looks like a great developer UX! I really appreciate the proposal and think two things should be determined before going all-in on such a change:
Overall, I think your proposal is pretty much spot on regarding a first draft for a new spacing-spec. I'm looking forward on your further feedback! As you've said, the changes would be quite subsential, therefore adequate planing is required. |
@flaming-codes About unitsRight now Geist's code is making extensive use of a unit called How components work now:For example, the
There may even be other spacings that rely on Thoughts on ProportionalityAfter thinking for a while, I think this design model should have the following goals:
So, for the type Props = {
margin = 1, padding = 0.2, width, height, unit ... // add an extra unit
}
// merge settings, the actual work will use the 'cache function' instead of
const theme = useTheme()
const mergedMargin = margin || theme.layout.margin
const mergedUnit = unit || theme.layout.unit
styles = {
margin: mergedMargin * mergedUnit;
} The user has great freedom in using the components: // Double margin
<Card margin={2} />
// larger padding, smaller margin, scaling by unit
<Card padding={1.5} margin={0.5} />
// Scaling all values
// This will change all the margin values that can be changed at the same time
<Card unit="10pt" />
// Very few scenarios where the user needs to define an exact value
// If it is an exact value, the value will be out of the scaling system
<Card margin="10vw" />
// The margin will no longer follow the unit scaling, because the margin is defined with an exact value
<Card margin="10vw" unit="20pt" /> I was inspired by your
Ease to use
If everything goes very well, we can even remove all PerformanceThe current Geist code already uses a lot of dynamic styles, in fact, the performance is still very high, we just need to add some As you can see in the These are my thoughts just now, welcome to leave your own views. No need to rush to a conclusion, I think this will be a relatively large change. (also very exciting new feature) |
@unix Lit! This sounds very exciting! I agree with you that there's no need to rush things. In the meantime, what open issue do you think would be a good first one for me to start contributing to Geist? Thanks for you awesome work, looking forward to providing some of my coding foo ;) |
I'm trying to add this feature in #531, but it's still a first draft. Anyone can leave comments on the details of the implementation. |
This feature has been released in version |
Feature request 🚀
Expected
To improve consistency across a user's app, I think a well defined Design System should provide a way to set dimensions as a multiple based on a "ground truth" value. An example would be Material UI, where the
theme
provides aspacing
function that returns a number as a multiple based on the input number.The benefit would be a uniform distancing between components. This would be a "low level" enhancement for the already available
theme.layout. ...
.Examples
Others (Optional)
This is my first issue in this repo and I think it would be nice addition to an already great ui lib. If desired, I can create a PR as POC for it.
The text was updated successfully, but these errors were encountered: