Highlight any panel in your dashboard

Ойын-сауық

Build an RSC-compatible Highlight component that can style any element when a prop changes.
🔗 LINKS
Highlight code: buildui.com/recipes/highlight
Animated Number code: buildui.com/recipes/animated-...
🕐 TIMESTAMPS
0:00 - Intro
0:26 - Highlighting after a change
1:25 - Resetting after a timer
2:19 - Extracting a useHighlight hook
3:57 - Extracting a Highlight component
5:22 - Using data attributes to expose state
9:02 - Final demo

Пікірлер: 34

  • @mryechkin
    @mryechkin10 ай бұрын

    Super neat! Love that data attribute pattern. I can see it being very flexible for component libraries.

  • @tek9ine130
    @tek9ine13010 ай бұрын

    I was literally stalking your channel for new videos and you dropped this haha

  • @AliFahim92
    @AliFahim9210 ай бұрын

    your content is always so effective and really useful. thanks

  • @imperatrona
    @imperatrona10 ай бұрын

    great as always 🔥

  • @datoubi
    @datoubi10 ай бұрын

    Awesome job. As always

  • @rockNbrain
    @rockNbrain10 ай бұрын

    nice job dude! tks a lot! I will definetly look for use more data atributes!!

  • @rikudevs
    @rikudevs10 ай бұрын

    The goat. Learned a lot of useful stuff

  • @DEV_XO
    @DEV_XO10 ай бұрын

    Thanks Sam!

  • @nihil_um
    @nihil_um10 ай бұрын

    Simply awesome!

  • @gmjitendra
    @gmjitendra10 ай бұрын

    amazing. thanks Sam.

  • @ThugLifeModafocah
    @ThugLifeModafocah7 ай бұрын

    this is superb

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd6 сағат бұрын

    Thank you so much

  • @mdrifat6941
    @mdrifat694110 ай бұрын

    Loved the video sir. Your videos helped me a lot to learn framer motion. Will you please create a framer-motion video taking Imperative coding approach using useAnimate hook

  • @ArtemMavrin
    @ArtemMavrin10 ай бұрын

    Great video and design as always, Sam, inspire me with your lessons. Tell me, what app do you use to record video and screen?

  • @BritainRitten
    @BritainRitten10 ай бұрын

    That's neat, but then there's (apparently?) no intellisense or type safety between the `highlight` in the caller vs the Highlight component. If I change `highlight` to `highlighted` on one side vs the other, nothing will alert me of an issue. Btw, I love your videos, they are well explained. I think the extraction of that very general single-focused wrapping component is very clean otherwise.

  • @samselikoff

    @samselikoff

    10 ай бұрын

    Great point! I like the simplicity of data attributes (flexible in many environments) but if you wanted to lock it down I guess you could expose some props instead: - highlightEnterClassName - highlightLeaveClassName then wire those up inside the component 👍

  • @jordancutler7552

    @jordancutler7552

    10 ай бұрын

    I was wondering the same... Thanks for giving some insight into a type safe approach Sam and awesome video!

  • @Smartercow
    @Smartercow10 ай бұрын

    Why you use let instead of const?

  • @kevinpruett
    @kevinpruett10 ай бұрын

    Masterful video as always. I’m trying to wrap my head around the refactor to being server component-compliant and what benefits that produces. Am I correct in assuming that the refactor will allow it to initially render in the DOM on load versus needing JS to load and hydrate the component if it remained a client component?

  • @samselikoff

    @samselikoff

    10 ай бұрын

    Nope - Client Components are pre-rendered so you'd still have HTML for the initial response. The benefit is being able to use Highlight within a Server Component. Highlight itself is still client, so still ships React and hydrates. But the page is RSC, so it can do things only RSC can do, like read data from a database. Being able to use Highlight as a component rather than a hook means you could highlight parts of an RSC if a prop changed, for example dynamic data from a database, or data from a cookie (as in the Build UI demo). RSC is not about reducing JS or initially rendering HTML. It's about letting you write React components that do things we previously needed framework-specific APIs for, like getServerSideProps from Next.js or loader() from Remix. That's the benefit of RSC, and so the benefit of giving Highlight an interface that's easy to use from either a SC or a CC is that it's the kind of thing you'd likely want to use in both places.

  • @kevinpruett

    @kevinpruett

    10 ай бұрын

    @@samselikoff Ahh. Really great explanation. Appreciate the great work 👍

  • @samselikoff

    @samselikoff

    10 ай бұрын

    @@kevinpruettyou got it!

  • @faruksardar8829
    @faruksardar882910 ай бұрын

    Just curious about which extensions you use in your VS Code, Please mention it 🔥

  • @RegalWK
    @RegalWK10 ай бұрын

    so basically we could handle dark/light mode with that approach? It would be a lote harderd to maintain tho

  • @swarajsaxena00
    @swarajsaxena0010 ай бұрын

    loved the video, how does your naming always get converted to camel case automatically??

  • @serveshchaturvedi2034

    @serveshchaturvedi2034

    10 ай бұрын

    If I understand the question correctly, if you rename the variable using F2 or right click -> rename, all the instances within the scope automatically get the correctly renamed.

  • @samselikoff

    @samselikoff

    10 ай бұрын

    @@serveshchaturvedi2034 Yep F2 to rename, or for useState I use this snippet: gist.github.com/samselikoff/846f48370086fc502a66a7df7dd0a7cb

  • @ComputersAreRealCool
    @ComputersAreRealCool10 ай бұрын

    How did you create multiple cursors in each of the occurances of the word "visitors" (but exclude some of them) at 2:36? Blew my mind! (Looks like youre using vim, i also use vim but didnt know about that!)

  • @pheisar
    @pheisar10 ай бұрын

    Anyone feels RSCs is kinda leaky abstraction? This isnt any strong opinion or statement, but i have this feeling that with RSCs we spend a lot of time thinking about how to organize code due to the server and client boundaries instead of the domain we are tackling. I cant quite articulate why but it makes me feel uncomfortable. Thanks for video though, appreciate it as usual.

  • @neociber24

    @neociber24

    10 ай бұрын

    I feel you get that with practice, or just mark all as server component and forget about it

  • @user-ty1do3qi2z
    @user-ty1do3qi2z10 ай бұрын

    why did you set value type to unknown?

  • @oscarljimenez5717
    @oscarljimenez571710 ай бұрын

    Nice video, but those 'let' instead of 'const' is killing me!

  • @SogMosee
    @SogMosee10 ай бұрын

    Object styles with something like chakra is better than tailwind because tailwind feels like a whole new language to learn and looks like a wall of text rather just an extension of js like react is

Келесі