DWilliames / paddy-sketch-plugin

Automated padding, spacing and alignment for your Sketch layers
MIT License
2.17k stars 61 forks source link

Set padding on multiple layers within a symbol #70

Closed stphndxn closed 6 years ago

stphndxn commented 6 years ago

Feature request / enhancement

I tend to construct button components like this:

When I use this plugin, the padding is applied to the "mask" layer—as expected given it is the layer furthest to the back—except I'd like it to be applied to both the symbol and the mask. I feel this might be a huge ask. I'd be happy to help develop this feature out, too, if that's an option!

mikeozornin commented 6 years ago

You can do it with Paddy now.

Here is how:

  1. Create BG for buttons as a symbol. If you want to override border radius too, than create two symbols: BG only and masked BG.
  2. Create symbol of button from: button BG symbol, text and icon symbol. Mark text with paddings and set correct symbol resize options for other elements.
  3. Profit! Paddy autoresize will work fine.

I attached example file. All buttons on Page 1 are instances of the same symbol. Try to change text and look at resize. Preview: screen shot 2018-03-08 at 17 35 11

Sketch-file: paddy-example.sketch.zip

Feel free to ask for help, if you need.

fancymans commented 6 years ago

Padding-right breaks when wrapping the Paddy elements with another set of padding.

screen shot 2018-03-09 at 6 21 51 pm screen shot 2018-03-09 at 6 23 13 pm

Sketch file: paddy-border-radii-example.sketch.zip

mikeozornin commented 6 years ago

I fixed you solution: I moved padding settings to mask and add - to BG symbol. You symbols must calculate padding only from the text layer (set - to other layers). Paddy will resize whole symbol to a new size. If you set sketch resize properly you will get what you need:

screen shot 2018-03-10 at 12 20 37

If you what to have several buttons with different border radius you can try to use nested symbols:

screen shot 2018-03-10 at 12 21 43

paddy-examples.zip

mikeozornin commented 6 years ago

Maybe having multiple paddings will be good, but you don't need it in simple cases.

DWilliames commented 6 years ago

Thanks heaps @mikeozornin for helping out responding to this!! :)

Yeah; right now Paddy doesn't support 'multiple' layers being the 'Padding' layer within the same group. It could cause some conflicts with how it is currently set up.

I think @mikeozornin has proceeded a great example of how you can do it currently. So for now I will close this feature request; as I'm not sure if it is actually necessary. 👍

fancymans commented 6 years ago

Was able to test and it works like a charm. Thanks for the help @mikeozornin! ;)

stphndxn commented 6 years ago

Unfortunately, I'm still unable to get the desired effect. My symbol contains the following layers:

Text layer 1
Text layer 2
Text layer 3
Text layer 4
Text layer 5
Text layer 6
Background Color (Symbol)
Mask

To give more context, this button component setup allows me to create multiple styles of button from a single component. For example, I can use Text layer 2, switch up the background color with another color (all my colors are symbols, to allow switching like this). The reason for the mask is so that I can ensure each button have corner radii.

In terms of labelling, they're as follows:

Primary Action, White
Primary Action, White, Semibold
Secondary Action, Blue, Bold
Secondary Action, Blue, Semibold
Secondary Action, Gray
Secondary Action, Red
-Background Color
Mask [8 16]

I only use one text layer at a time and then set the others to a blank space to remove the placeholder text. Instances of this button symbol don't update to the spacing ([8 16]).

mikeozornin commented 6 years ago

As for me, you have a very strange symbol organization ;–)

I tried to create your button in Sketch:

screen shot 2018-03-13 at 23 45 04

And source file: paddy-6-text-styles-example.sketch.zip

If I'm wrong, please attach sketch source file, I'll try to help you.

stphndxn commented 6 years ago

Hey, @mikeozornin! Nope, you've got it spot on there! Even then, downloading your Sketch file, the resizing doesn't work for me. 🤔

mikeozornin commented 6 years ago

🤔 I just had the same on my work desktop. The same plugin, same sketch version, same file and resize didn't work.

I enter button symbol editing, select any layer (e.g. mask) and deselect it. Paddy showed symbol instances update. screen shot 2018-03-14 at 13 11 56

After that resizing started again. Maybe the same magic trick will help to you too.