Custom Controls

Back to Overview
00:00 --> 00:15
Now, I quickly want to talk about custom controls. So you will see that quite often on websites, and usually they are implemented in a quite cumbersome way.

00:15 --> 00:28
But they don't need to. So sometimes there's a lot behind those custom controls and sometimes there's not. And these are like a couple of simple ways.

00:28 --> 00:29
So here we have a share button.

00:30 --> 00:32
So this would be like your Facebook share button.

00:33 --> 00:35
I don't even know if they're doing this anymore.

00:35 --> 00:37
I've not been on Facebook for many, many years.

00:38 --> 00:43
But basically, this could be just a button that you submit.

00:43 --> 00:48
And, you know, JavaScript can get into the middle and do the submission through JavaScript.

00:49 --> 00:52
But it can be just that easy.

00:52 --> 00:55
And then you click it and you get like shared and the checkpoint.

00:55 --> 01:07
And that would be a nice way to have a button like this. In this case, we cross them through because it's now a disabled button, so you can't unshare this.

01:12 --> 01:30
And then the second example is a star rating. And here we have an X, which is basically zero stars, or I won't rate it. Then you have one star, two stars, three stars, four stars, five stars. And you can say three stars and boom, you have selected three stars.

01:30 --> 01:45
And here again, for color vision reasons, there is an underline under the X.

01:45 --> 01:50
And then also once you selected a star, there's also an underline underneath there.

01:50 --> 01:56
If it's focused, you see that it's with like dotted lines.

01:56 --> 02:10
And if it's going to the submission field, submission button, it basically gets solid underline.

02:11 --> 02:18
And the reason for that is, why do we have a submit rating button there at all?

02:18 --> 02:27
is because when you're using the keyboard, you can't select, in this case, a radio button

02:27 --> 02:30
and submit it at the same time.

02:31 --> 02:34
If I click here, this would be directly submitted.

02:34 --> 02:37
You can program that in JavaScript and that's totally fine.

02:38 --> 02:42
But if I'm using the keyboard, I don't want to submit, like if I'm at the start,

02:42 --> 02:47
I don't want to submit one star and then submit two stars and then submit three stars

02:47 --> 02:49
and submit four stars and then submit five stars.

02:50 --> 02:58
So you need another button and you can make that as a hidden button that you then activate when you tap to it.

03:00 --> 03:03
Yeah, and I think that's it.

03:03 --> 03:07
I mean, there are a lot of code examples in those things.

03:07 --> 03:09
So you can knock yourself out.

03:10 --> 03:16
And for this, I think, you know, that might be an interesting case study.

03:17 --> 03:24
Basically, the stars and also the X, they are these SVGs.

03:26 --> 03:30
And they get like the label, in this case, zero stars.

03:30 --> 03:33
And the SVGs are inside of the label.

03:33 --> 03:44
And then when the input becomes checked, it will then basically use styling to change the SVG inside of the label.

03:45 --> 03:45
It's very clever.

03:46 --> 04:00
And I don't say that because I did this, but because it's a really nice technique that, you know, makes sure that you don't have like a lot of different things going on.

04:00 --> 04:29
And the same goes here when I select like two stars, then basically it formats everything up to the two and including the two stars SVG. Yeah, that's all you need to know about custom controls. There's a lot of flexibility in here that we can't get into and which I don't think is like useful in this like format.

04:29 --> 04:37
If you have anything that you want to show, feel free to bring that to the tutoring sessions and we can talk about it.