Skip to content
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

feat: Add more granular spacing options #84

Merged
merged 9 commits into from
Feb 10, 2023

Conversation

DRBragg
Copy link
Collaborator

@DRBragg DRBragg commented Feb 9, 2023

Adds multiple ways to set margin and/or padding on stacks and flows:
single value:

margin: 20
#=> "margin:20px"

array of values:

margin: [1, 2, 3, 4]
#=> "margin-left:1px;margin-right:2px;margin-top:3px;margin-bottom:4px"

hash with values:

margin: { left: 1, bottom: 4 }
#=> "margin-left:1px;margin-bottom:4px"

keywords:

margin_right: 2, margin_top: 3
#=> "margin-right:2px;margin-top:3px"

@DRBragg DRBragg added the enhancement New feature or request label Feb 9, 2023
@DRBragg DRBragg self-assigned this Feb 9, 2023
when Array
DIRECTIONS.zip(values).to_h.each do |direction, value|
styles["#{attribute}-#{direction}"] = Dimensions.length(value)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: What happens here if somebody sends in an array of three elements? Should we compact after the to_h?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then only margin-left, margin-right, and margin-top will be set. We could compact here but the compact! handles all cases so probably not needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I benchmarked it real quick and the difference is fairly minor but a complex enough layout (100,000+ stacks) could see a speed boot (~100-200 ms) from compacting post to_h so I'm going to make the change. Good call!

DRBragg and others added 2 commits February 9, 2023 13:51
a complex enough layout (100,000+ stacks) could see a speed boot (~100-200 ms) from compacting post to_h
@DRBragg DRBragg merged commit 02f9d6a into scarpe-team:main Feb 10, 2023
@DRBragg DRBragg deleted the granular_spacing branch February 10, 2023 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants