Hi everyone. In this video we're gonna make a slot component. What is it? Basically we've got something that we're gonna reuse over and over again, like the outside of this modal. There's a cross, there's rounder corners, there's a drop shadow. Instead of having two or a hundred different pop-up mods all sharing a lot of the same elements.
And when you have to adjust, say the cross or when you have to adjust part of it. And then when you wanna adjust part of it, you've gotta go and adjust all of them. What we can do is create something that has a placeholder slot in the middle. This one here. Then we can aside some preferred incident swaps. Okay?
So people can go through it and just change the center of it. It'll stop people going and thinking, all right, I need to change this quite a bit. So I'm going to break it apart and create another instance. Getting all messy. So we'll build one from scratch. We'll get a little bit lost together, we'll fix it again.
Then we'll have the sweet slot component where only the center part changes. Okay? Not the wrapper. Alright, let's jump in and do it. Alright, so I've got two separate modals. I've made a modal section for these guys, okay?
And what I'm gonna do is I want to get it set up first with just something in here and then I'll switch it out to the placeholder afterwards. 'cause I want some actual content that I might be using to kind of get the padding and stuff, right? So for this to work, the parent needs to be an order layout. Shift day. We'll make it a component 'cause that's what we're kind of using this for Now. It's in modals.
I'm gonna call this one popup. This cross here, I'm gonna say you are absolutely positioned where I'm gonna drag you to over here. I'm gonna make sure you're in the top right now. The padding, I'm gonna increase all the way around. Who remembers the shortcut? All you do, hover above it there and hold down the option.
Ke mac, alt keana, pc. Make sure you zoomed in far enough so you can actually get the line hold shift as well. And it will do all the sides. Uh, I'm gonna go, mine's gonna be quite big. I'm gonna go up to 40. Remember multiples of eight.
Alright, so what I'm gonna do now is I'm gonna get this stuff and pull it out. Okay? I'm gonna pull it out down here and inside of here I'm going to put a slot component. Okay? So the slot component needs to be its own main component and we know main components can't live in other main components. So I'm gonna say frame.
I'm gonna control or command. Ah, and I'm gonna call this one my slot. Now you can call it anything you like. There's no official rules to it. What most people do though is they'll give it a stroke. They'll make the stroke pink and they'll go to the advanced settings and change it from solar to dash.
You don't have to do that, but that's what everyone seems to be doing. Does it need a fill? Yeah, it can do. What size should it be? It doesn't really matter 'cause it's gonna get switched. Just something to hold our modal open when it's hugging it.
So this needs to be a component. So I'm using my shortcut command option K, CTRL Alt K on a pc. Just a reminder. And I'm gonna drag an instance of this, okay? Over to here to get into this and just make sure that this uh, pop-up modal is hugging both ways. Now we're going to make the bits that go inside of it, they don't need the um, External chrome around this modal.
Okay? These guys here just need to be components. We're gonna use the instant swap. So we need to make this a component. Command R. It's in the modal section.
So this is going to be email, sign up. This one over here. I don't need the modal. Okay, that was just there for design. Okay? 'cause I wanted to switch inside of there.
This one's called delete. Yeah, why not? You can come modals. Let's get big enough. You're gonna come in here as well. Make sure it's a component and the slot.
We probably will keep that somewhere else 'cause it's not gonna be part, you can use this in anything. We're using it for modal. You can use it. Any element. Okay? And is this going to work?
Let's give it a test. Actually no. Uh, the main component here, we need to add the property. Remember instance swap for earlier in the course. So this component here, I'm gonna say under properties. Actually no, I'm gonna do it for this slot.
So select this slot inside of it. I would just say slot. I want you to be able to be instant swap. Okay? What do I want? I want you to be able to swap with the preferred values of not everything.
Just my suite modals option. And I want just delete and sign up. Close that down. Now is it gonna work? Let's switch to my assets library option two. So have a look at our components where we've got mods.
We're gonna say I want this popup on this document here. Go into it, select on the slot and say, actually I'd like to change it from that. Pause the video, steer it for a little while, realize my preferred values aren't in there. Realize what I've done. Include it in the course 'cause it's probably gonna happen to you. Is I went and did all that whole stuff and went uh, instant swap and I did all this and I hit cross instead of create property.
Don't do that. Okay, so let's fix it up. So I'm gonna say you and you create property not cross. Now I should be able to click on my parent Moodle. Okay? And there inside of there is an instant swap, okay?
With some preferred values, okay? And I can switch this out now to whatever one I want, except that one's broken. Uh, great work Dan, you get the idea. Let's leave that there. Ignore that. Okay?
Actually let's switch this to the other one. That's the goal is that I have this full control now of the popup modal and the elements that are generic for lots of different stuff. Okay? If I come back and say, actually I need to adjust the padding, okay, I can do it to this one, okay? And they all adjust. I don't have to go and adjust the 10 different mods that I've got for popups.
You can have more than one slot. We've just done one here. Alright, let's figure out what went wrong with this one. I think I know what it is. Uh, this is not an auto layout, it is just two bits inside of a component, okay? And they get thrown into here an auto layout.
So the auto layout just smushes them together. So I'm gonna say as you are a component, but also shift a an auto layout. Now hopefully over here, if I switch this one, you need to be you. There we go. Alright. That is a slot component and how to break it a couple of different ways and fix it.
Again, the Big things that'll catch you out is that the things inside including this need to be a component and an auto layout. And because they need to be main components, they can't be inside this original one. You need to make them outside here, bring an instance of them and then when you're ready, click on the instance that you wanna swap. Okay? In our case, the slot. Do the instance swap property.
Make sure you hit create property and not cross. The other thing we might do is add a bit of text to this slot. Where is it? Okay, so we might go inside of this one. Let's grab the text tool and of course one placeholder slot just so that when people are using it kinda gives 'em a bit of a cue to what we're doing. You could add all sorts of notes in here.
I think we'll do before we go actually is let's publish it because I wanna use it back over here. Okay? So I'm in that kinda main style design file where I've got all my components, okay? So I'm gonna go option three, alt three on a pc. Let's publish all the things we've done. Okay?
And because we've already connected this design file, we should be able to option one, no, option two to go to the assets. Or you can go up here. Okay? And let's have a look, not the local components. Let's have a look at the main styles. Where's my mods?
There it is there. Let's grab the popup. Okay? And then me or somebody that's working with my design system can go through and say, actually I want to delete, actually no, I need the email sign up. It's a bit big Dan. There you go.
Alright, that is it. We made a placeholder slot component. I'll see you in the next video.