Open up new possibilities with custom properties and HSL

Open up new possibilities with custom properties and HSL

Kevin Powell

2 года назад

26,157 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@nielslytzdk
@nielslytzdk - 03.07.2022 15:24

Love it!! There's definitely potential here. I can see one downside of taking this approach: If you have a color highligt-plugin installed you won't be able to reveal the color. For me it's a little annoying having to remember which value relate to what color, but I bet there's a workaround on that :)

Ответить
@daithi1966
@daithi1966 - 25.03.2022 04:20

This is great. I will be doing all my color like this going forward.

Ответить
@lapridagaspar
@lapridagaspar - 12.01.2022 05:37

Can i use calc for individual HSL parts? Like having the lightness * 1.1 on hover maybe.

Also, for text I never use grey tones. I always use a black or white (depending on the background, if its light or dark) and then reduce their opacity (not with the opacity property of course, with hslA ). This way i can have a lightgrey color on a white background, but if theres any hue, the text will pick some of it.

Do you know about any way to get a 0 lightness if certain var Is over 50, and a 100 if its under 50. I'm thinking something like the Holy albatross maybe where you do some calc and then multiply by 999 to get extremes (0 and 100). What i would like is a css only aproach to automatic black or white text depending on the background (which Is a custom property)

Ответить
@MARIUTSKI13897
@MARIUTSKI13897 - 22.11.2021 16:47

Magic? 😳🔥🔥🔥

Ответить
@flaviomauri
@flaviomauri - 20.10.2021 19:10

Question: for the first time i've used HSL to make easier create the :hover state of a button. Visually speaking, the web version is 20% darker to look like the Xd design... is there an explanation?

Ответить
@Po4to
@Po4to - 28.08.2021 14:26

Mind blown! I tried this in a bunch of scenarios where properties are inextricably bundled in one line and can't be overriden individually or apprended with another class - such as gradients or transforms - and it works like a charm. This opens up a world of possibilities, and things to research. Now, what I could use here is some benchmarking tool for code, possibly targeting individual tags - to examine what combinations would be most efficient and easy on the GPU, e.g. grouping and nesting using single transforms OR chaining transforms on individual, unconnected items. What I'm wondering is how the GPU handles them.

Ответить
@onadzen
@onadzen - 27.08.2021 12:30

what if client have predetermined color scheme in hex? how do we convert to hsl?

Ответить
@duckwave4449
@duckwave4449 - 25.08.2021 20:43

I really appreciate your videos. I’m finding them very helpful as I learn CSS. Keep up the good work man 👍

Ответить
@chhavimanichoubey9437
@chhavimanichoubey9437 - 25.08.2021 18:38

CUSTOM PROPERTIES ARE MORE DYNAMIC NOW

Ответить
@GimmeSomeChicken
@GimmeSomeChicken - 25.08.2021 16:03

I like the shirt may the CSS be with you

Ответить
@DenisovichDev
@DenisovichDev - 25.08.2021 11:03

Kevin I absolutely love the idea! However, I think breaking up hue saturation and lightness is a bit too much. I mean, it's absolutely brilliant and very clever, but I think in big projects it'll get too complicated because of it, and I don't think I would like to bother with 6 different types of hues just for the code to be neat like this. But definitely, definitely going to follow the first tip (removing the hsl wrapper)

Ответить
@subhamshaw1726
@subhamshaw1726 - 25.08.2021 09:13

so much powerful stuff. your videos had taught me some unique and new ways to work with css and frontend related stuff. Great work

Ответить
@jodorgu8640
@jodorgu8640 - 25.08.2021 08:10

Funny thing...i spent a few hours on w3 and stackoverflow looking for ways to lighten and darken colours using css and arrived at this just an hour before this video was posted...if only i had a crystal ball

Ответить
@jodorgu8640
@jodorgu8640 - 25.08.2021 08:10

Funny thing...i spent a few hours on w3 and stackoverflow looking for ways to lighten and darken colours using css and arrived at this just an hour before this video was posted...if only i had a crystal ball

Ответить
@ABI_SUBEDI
@ABI_SUBEDI - 25.08.2021 07:36

king of css

Ответить
@AbhinavKulshreshtha
@AbhinavKulshreshtha - 25.08.2021 07:14

Looks like I need a refresher on grid, I have no idea how grid-area: description; works.

Ответить
@castlemoyle
@castlemoyle - 25.08.2021 03:22

The company that wrote and maintains the shopping cart service we use has recently updated their styling to now use variables for all colors. (oops... colours, they from some place called Montreal) . I'll have to dig through it and see how complex it gets.

Ответить
@kh_raza
@kh_raza - 25.08.2021 02:50

css line 124 : vem
css line 156: Is bio-title class applied anywhere?



I was first confused seeing the 'grid-template-areas' in desktop webpage view, only to realize you followed mobiles first approach by seeing the media query

Ответить
@bobbysilver272
@bobbysilver272 - 25.08.2021 01:35

Hi Kevin, please tell me where is the link to your color scheme video that you mentioned?
Thank you.

Ответить
@momakplayz7985
@momakplayz7985 - 25.08.2021 01:21

Hey Kevin, you teaching css and html is nice. But what happened to JavaScript, with javascript you can do way more than you can with html and css. Why not teach JavaScript? I love your videos and they are great by the way.

Ответить
@i18nGuy
@i18nGuy - 25.08.2021 00:36

Nice methodology Kevin. Minor enhancement, you can still save typing by taking var one more level:

--hue: 150;
--sat: 100%;
--lightness: 40%;
--hsl-values : var(--hue), var(--sat), var(--lightness) ;
--hsl-primary: hsl( var(--hsl-values));

and then in classes using only the completed hsl:
background-color: var(--hsl-primary) ;

Ответить
@AmodeusR
@AmodeusR - 25.08.2021 00:15

I never heard of this "new color syntax". Where we can see more of it, or could you make a video talking about it?

Ответить
@KelseyThornton
@KelseyThornton - 24.08.2021 23:22

I used Custom Properties for something similar recentlly when using CSS Grid:

.container {
--num-cols: 1;
grid-template-columns: repeat(var(--num-cols), 1fr);
}

Then in a media query, I simply changed the definition of --num-cols to be the required value and voila!

Ответить
@jenstornell
@jenstornell - 24.08.2021 22:56

I've not watched it yet but great video thumbnail. It says it all. 😊

Ответить
@SebastianMares
@SebastianMares - 24.08.2021 20:35

Wow, brilliant!

Ответить
@efari
@efari - 24.08.2021 20:34

Kevin, did you know: to remove a whole line, you don't need to select it and then do CTRL-X
you simply need to have your cursor anywhere on that line (nothing selected) and press CTRL-X.
to then paste it, you don't need to add a new line yourself, just press CTRL-V and the line where your cursor is will shift down and your pasted text will be there
(i learned about this in VSCode, but i noticed it also works on CodePen)
saves you from triple clicking and selecting and entering a whole bunch. SPEEEEDDDDD

Ответить
@jitulborah_10
@jitulborah_10 - 24.08.2021 19:33

Loving your star wars t shirt by the way . 🥳

Ответить
@jaydenmoon1165
@jaydenmoon1165 - 24.08.2021 19:08

This wasan awesome video to wake to, now time to work :)

Ответить
@patriayvida4209
@patriayvida4209 - 24.08.2021 18:55

Thanks!!! Very interesting 👌!

Ответить
@TheThirdWorldCitizen
@TheThirdWorldCitizen - 24.08.2021 18:05

Genius little trick

Ответить
@sarfarajansari9181
@sarfarajansari9181 - 24.08.2021 17:47

This is really amazing , gonna use it in my next project🤩 , thank you kevin !I knew I'm gonna learn something new , whenever you post a new video !

Ответить
@GauravKumar-ue7nz
@GauravKumar-ue7nz - 24.08.2021 17:47

Thank you Kevin

Ответить
@julianstorm7722
@julianstorm7722 - 24.08.2021 17:37

Thx for the video. There is a really annoying feedback in your recording. You can hear it intermittently. You might wanna pull 800 or 1k in your EQ. Could also be a bit lower or higher frequency just try it out. Cheers

Ответить
@andrewrea2799
@andrewrea2799 - 24.08.2021 17:11

Ooh. This is from the article in your newsletter. Cool to see it demonstrated. 👍

Ответить
@domanickharper
@domanickharper - 24.08.2021 17:04

Thsi custom stuff is super cool, haven't tried it yet but I'd like to

Ответить
@spacenomoe
@spacenomoe - 24.08.2021 17:02

Hello Kevin! Watching your videos all the time. Thanks a lot! Please make a video how to add slick-slider or swiper-slider into code. There is issue when you adding slider in flex or grid containers - a huge horizontal scroll.

Ответить
@radshoot101
@radshoot101 - 24.08.2021 16:56

Would you do some js videos next?

Ответить
@manytrickpony695
@manytrickpony695 - 24.08.2021 16:32

This is great (and powerful) stuff, Kevin. Thanks, again!

Ответить
@codu
@codu - 24.08.2021 16:28

Awesome as always brother

Ответить
@-_._._-
@-_._._- - 24.08.2021 16:25

Ooh. I like this. I had thought about doing this stuff but didn't know if it would be smart or not. Like, setting a prop for an HSL lightness value for example. I would rather just do the full HSL as a prop. But if doing a prop for one value would let you swap values on the fly, that's neat.

Ответить
@barabaszek1
@barabaszek1 - 24.08.2021 16:21

Nice!

Ответить
@zachjensz
@zachjensz - 23.08.2021 04:28

Don't forget to make your corner of the internet a little more colorful!

Ответить