Hey everyone, at the moment this is what our little responsive card does... kind of works, except with this text, look... sad text, doesn't work... in this video, we're going to make it do this, watch... kind of reshuffles... and also we're going to add a variant...
to say that we turn the price off... look, the text reflows... yes, I've messed up the spelling of Egyptian, that is also part of this video. One thing I do want to throw into here is that... you might be finding it confusing, some of you would be like... "Ah, that's a breeze, this is easy"...
for those of you who are finding it tricky, and tough... and going, "Do they have to be this complex?"... no, they don't, but it's good to understand this stuff... so that you can build complex things if you need to... and by kind of stretching out into this more complicated stuff... it makes the stuff that seemed hard, easy, you play comparison...
kind of beats it into our head, and you might be like me... and like the challenge of building these things... that are quite responsive and resilient... and we can send them out, and people can't break, oh, broken... don't drag it down, dragging down, but it's a future video... but for now let's get their text to reflow.
So we need that text to kind of reflow when that is in there... plus we want to make that a variable, so we can turn on and off... so there's two things we need to do... we need to make it an auto layout, this whole bottom chunk... and we need to make this text box fill the container... so at the moment if I click on enough...
inside of my main component, which is my card... I've got this just framed down the bottom here... which started as a purple box, and that I stuffed the price in there... and I threw in some text. So the first thing I need to do is the entire kind of wrapper... this frame here needs to be an auto layout...
we know the shortcut for that, 'Shift A', doing it all day... we'll worry about the layout in a second... I really want to jump in and do padding and margin... but let me show you the other thing we need to do, is this text box here... at the moment has got a fixed width... so that's why, when I resize this thing it doesn't really work...
if we say, fill the container, nothing really changes... except that when I respond it's going to fill the space provided... at the moment it goes to the edge of this... watch what happens when we resize it, look at that... it adjusts, there you go. So they've got this auto layout, inside of this auto layout...
which is now inside of this auto layout... ah, Figma inception... and before we go and fix the padding let's do the last thing... and turn it into a variable... just to get in the swing of things... does this need to be a variable?
We're going to do it anyway... so for this to have variables, variants, come on, Dan... it needs to be a component set, which is the same thing as a main component... and where can a main component not live? Inside a parent main component... you're like "I'm out, I'm turning the video off"...
ah, we started easy, we're getting harder, this is good, we'll keep practicing. So you're going to go over here... you are going to be, not a component at the moment... so I'm going to say, you, over here, you're my main component... 'Command Option K', 'Ctrl Alt K', you're a component... I want to add a property to it, what property?
A variant, not a variable... let's have two variants... let's put it somewhere else, let's grab the edge of it... and put it somewhere it's not kind of overlapping everything... and a second variant here, we need to turn this off... and because it's in an auto layout, just do it, Dan...
look at that, it's an auto layout, which means it disappears, everything reflows... and because this thing says, Fill Container, not Hug, not Fixed... it goes, all right, I'm going to fill the container... whereas on this one it's filling all the way to the edge here... because there's something in the way... but when there's nothing in the way it says, I'm still filling it...
hey, look how far I go... it's not over there, how do I get it? Let's go to our 'Assets panel', let's grab an instance of it... and put it over here... there we go, it's not in the right place let's have a look at our layers... I need to be inside this, my Card Event...
now I'm going to play around with the padding to try and make it look nice... and what I mean by that is... in the auto layout here, of the lower Nav... I'm just going to kind of try and push everything around... but I'm not going to do it in the instance... actually, I'm going to do it in the instance for now, I'm going to show you...
how is everybody? You're like, "Oh yeah, get this looking good, this is great." I'm going to look at the padding of the right hand side... yeah, I want it to be 16, perfect... I get this thing looking sweet... and then I realize I'm working on the instance, what do I do? Huh, what do I do?
You can select on the instance and say... right click and say, actually, I want to push, where are we? Here we go, 'Push changes to main component'... and then it will adjust over here, where is it? That one there... because you forget, and it's kind of weird...
just adjusting this and then keeping an eye on this one, and adjusting this one... sometimes it's easier to just adjust the instance and then push it to the main... mainly because I forget... and while we're here let's tidy the-- actually, that's over here, let's tidy the property names... so this is going to be Price... and I would like, I'm going to have this little option here to say, On and Off...
you can say, True or False, that works as well... can't think of any other ones, go Stop, nope, that doesn't work. if you know of any other ones that turn on this cool toggle switch... let me know in the comments, there we go... you notice that the bottom is changing in this one, how do I fix that? I am going to turn it off, fix it in my instance...
bump it up one more pixel... and then I'm going to say... you, 'Main Component', let's push it... before I forget, and now when I toggle it on and off, hey, there we go. Other problem is, I adjusted all my padding... when I had this on, to get it how I wanted...
then I pushed it back to the main component, the component set here... but these are actually separate now, can you see... the spacing is different on this one... so I need the spacing on this... actually, the spacing of this... 16, 5, 10, 10, to be the same as this...
I can copy it, 'Command Option C' to copy... that's 'Ctrl Alt C', and this one, so same two keys, plus 'V'... there we go, now hopefully... this one over here is, oh, not sure, which one am I doing? We got a little lost, there we go, you, my friend, need to be... you saw me do it, I didn't know how I did that...
but now I can surely go in here, toggle that on, that off... they're the same. So that was good, we brought up a good couple of points of like messing with... one of the variants, and assuming you're doing it for both... then realizing your mistake, and being able to... copy and paste the properties to both of these...
all right, accidental bonus. Let's do one last thing... actually, I just thought we've got a couple of variants going... so I can say, actually, this one here... my Card Lower, nope, my Price, actually has its own toggle switch... and weirdly, I was staring there, going...
"I thought I just made this thing work," it doesn't work... it actually does, it's just that... there, it's actually so you can see it's spreading out, but the word Egyptian... if it was smaller it would be better, there we go. So let's turn this toggle on, toggle off, now it works, it was working... do you get the idea?
Just, the line was too long to break down to the next one... all right, I'm back, I finished this video, and did the outro... and then I was like, "Yeah, look how cool I am"... this works, the variable turning on and off... so if I double click on the bottom one I can turn this on and off, it reflows... why doesn't it reflow nice and responsive though?
It's because if I click on my lower card... the constraints, I'm going to hold 'Shift'... so that I've got left and right going, we can pick it from here, now it'll work... why did that go away? Because it was working at the beginning, remember, earlier when I made this... remember, I said I need to make it a component, so let's drag it...
out of here, and I made a component, and then I put it back in... when it comes out of here it did it again, look, I dragged it out, and it goes... it didn't drag it out, it didn't lose it... but when I did all this stuff to it, it somehow lost that... and just become left aligned... there you go.
That is the mystery solved, or the problem that I created, and we fixed... I like to pretend, like sometimes I put these in as learning experiences... but man, when you're building these things when they... you know, start doing complicated things like we're doing now... you end up just having to test lots, and then go, "Huh, what happened?"... like in the next few videos we're going to have to go, "What's happening here?" ignore that for the moment, we will fix all that...
all the while becoming auto layout, component, variable... sorry, variant, and constraint masters, there we go... I'll see you in the next video.