Hi everyone, in this video we're going to look at our Component properties... in a little bit more detail, string a few of them together... we're going to make our Text label, we're going to do it with an input field... where this easily can become loads of different variants... to make all the different options possible... but we're going to use our sweet new tricks to be able to do this...
where this is the Main component that has all of these different options... let's have a look. See the little required field, we turn that on and off... want to change the label, "Name"... do you need the Helper text on the bottom, Yes, No... change the words in it, but what if we need the red line around it?
We can go, let's just use the arrow one, look at that, super tidy... and a really good example of why Component properties are awesome... all right, let's jump in. First up I'm going to draw that Input box, I'm going to do it in speed mode... you make one similar... so there you go, the one thing when I built this...
was I kept these two separate, the asterisks... it's kind of like shorthand for required field, or mandatory... so I kept that separate so I could turn it on and off... and with this, I didn't make this an auto layout... I put the text on top of the frame, not inside of it... why?, because I want to later on, like I showed at the beginning...
make the outline change color... and color change is not one of the Component properties at the moment... but we can do instant swap, so we can switch that out... so we can switch an instance of this, out, just the background... but I don't want to switch the text, text takes time, switch to background color. Now it's a matter of making it work...
so what we'll do is, we'll say, let's do the easy ones... first of all let's select it all and make it a component... and let's give it a name it's going to be called "Input Field", cool... so let's do the easy ones, like the Boolean... so we're going to click on this, we're going to maybe go inside of it... and we're going to say, over here, look for Layer, look for that little icon...
click on that, and that's all we need to do... let's get an instance of this working, so 'Shift I'... and let's type in "Input". So Main component, this is my instance... and we're going to say, you have this cool little toggle switch... for, is it required, is it not?
Let's do the same for the Helper text... it's not needed for all of them, we want it as an option... so I've gone into my Main component... I'm going to find my Layer, there it is, there... and I'm going to say, there's already one called Show Asterisks, or Exclamation... no, asterisks, that's what it is, going to create a new property that says...
Show Helper Text, perfect, thank you. Now down here, I've got two double switches... show that one and show that one, happy days... anything else I need to turn on and off? Probably not for the moment... let's put that input text...
I might have to concede now that with three bits of text in here... maybe that text component property is better than I thought... so I am-- my instinct is, grab all three of them and see if I can make a... make a, down to Content, remember, Content is for the text... these things are everywhere, which is a little bit confusing... but look for those icons...
under Content it says, Mixed, so I click this and just click 'OK'... they all become the same thing, they're all connected. So now if I go down here and I start typing... where is it? Text, Label, instead of Label I put in "Sample Text"... or "Sample", at least, can you see, they all changed, it's not what I want...
so I'm going to undo, I'm going to do it individually, click on 'Label'... find down the Content, find the sweet icon... instead of just the word Text this one's going to be "Label?"... the value can be Label, that's fine, Sample Text here... same thing, not that one, we're going to create a new property... Sample Text is probably not a good name for it, let's call this one "Field Text"...
and this last one here is going to be... this one here, new Property, this one's going to be called... "Helper Text". So why am I-- this is actually useful, watch this one... when somebody drags out a new version of this... they can go through and say, "Oh, look" the label for this one is, say, "Name", they can tab down...
just 'Tab' on your keyboard, and then you can put in... whatever you want in there, then Helper text, well, maybe the first name... "First & Last Name"... I'll take it back, that's kind of useful then clicking all of this. One thing we're going to have to do now... it'd be nice if these were kind of together...
at the moment it says, Show Helper Text... but then the input for Helper text is down there... rearrange this, after we've created it... we need to go back to that Main component where we're doing all the main work... and only in this one those little lines are up here, can you see them there? So what we'll do is, probably the most impor-- actually, we'll do it...
label at the top, because it's at the top kind of the stack here... so it's a labeled text ... then we'll get it to, do we want it to show the asterisks or not? The Helper text probably needs to be down underneath the Helper text... actually, probably the other way around, right? Show it first and then be able to type into it, if it's shown...
let's have a look at this now, does this make more sense? So change the label, say "Email"... do I want to show that it's mandatory or not? then there's the text field... John Smith, do you want to show the Helper text? Yes...
then what do we want in it? that makes mostly sense, I need to change the name of this... because this one here, Show Asterix is probably not that great... you do the same thing when you go back to the original one... and you can edit these as well... so you can just double click them here...
so we might just put in "Required"... on or off... these make sense when it says, Show Helper Text... but we'll just make that one Required... it's over here, Required, on, off... nice, now it wasn't a really good use of an instant swap...
maybe had an icon somewhere in here... it's an arrow, or something like that, you would do that... what I'm going to use it for is a bit of a hack... because what I want to do is have an error option... basically, the red line that goes around... to show that this is a field that you've either missed...
got it wrong, or not enough characters, too many characters, that sort of thing. At the moment if I click on this, there aren't... if I go to my Properties, there are only variants... Boolean, Instant Swap, and Text... you might be watching this, and go, "Hey, there's 40 more of them, Dan"... I'm expecting that, this is reasonably new...
I can see in my head all the different ways you could do this... it'd be great to be able to switch out color styles, font styles... everything from the Styles, I reckon is going to come across... let me know in the comments if there is new stuff in here... if it's just a small thing I'll let you work it out... but if it's, you know, if it's loads of it I'll come back and re-record it.
So how is it going to do that red line around the outside? Have a think about it yourself, pause it and think, how would you do it? How am I going to do it is, I'm going to do it with this Frame here... I'm going to call it "Field"... and I'm going to actually make it an instant... so I'm just going to drag out the field here...
so it's outside of my Main component now, nothing to do with it... I'm going to make two of them, we're going to have... 'Command R', this one's going to be "Field Error"... now this one's going to be "Field Default", that's the one we've got now... let's do this one, I'm just going to change this Stroke to a big old red... cool, what I want to do is I'm going to grab this one...
what I'm going to do is I want to make them both, in two components... multiple components, separate ones... this one, I'm going to switch back into here... you can see here, it's just a frame at the moment, so I'm going to go, copy... we're going to use that sweet shortcut... 'Command Shift R', or 'Ctrl Shift R' to switch it...
now it's not just our frame, it is an instance of this... but because there's an instance I can now go to this Main component... and say, add an instant swap... how do I do it? Under 'Properties' here' I'm going to hit the little '+'... and I'm going to say, I want to switch the instance, instant swap, nope...
I want to go inside of it and pick the instance first... then we're going to go in here and say, this is the default field, I want... instant swap here, and I want to say, which ones can you pick from? Just from... Field Default and Field Error, that's it... so hopefully now you can switch that one out to 'Error'...
oh man, look how good that is. We've got just this thing here we've had to have a couple of extra main components... which we could delete now, because there is an instance hiding in there... hang on, no, you can't, I've come back from the future... you can't delete those main components, mainly because... I can restore this one, comes back, there he is, where's my Error one?
I can't find it, to get it, unless it's been used somewhere... and it wasn't used anywhere, so it's kind of like gone forever... I'm going to undo loads and go back, you wait there. All right, we're back, so let's not delete them, that's not good practice anyway... we're just going to hide them so we can't see them, there you go, be over there... still pretty tidy though, right?
Got one main component that does a lot of work... so our instances of that are really easy to both create and adjust... but even better, it's for those people who are going to be using... our amazing component... has this lovely sweet little panel here... on, off, too easy.
That is it, we have tied together a couple of component properties... we looked at instant swaps... we did that for the back of the field with the red line around the outside... we also did Text and the Boolean to turn things on and off... all right, that is it, I will see you in the next video.