Intro to Web Components - Full Walkthrough

  Рет қаралды 23,680

Before Semicolon

Before Semicolon

2 жыл бұрын

A brief introduction of web components technologies, best practices, tricks, and guide for web app components. How to create simple custom elements, pass and consume data through attributes and properties as well as how to extend template with slot placeholders.
Join this channel to get access to perks:
/ @beforesemicolon
[Mentioned Posts]
Web Components Full Walkthrough Article: / intro-to-web-component...
10 CSS Tricks to Learn: / 10-css-tricks-you-need...
Audio Player Web Component: • Custom Audio Player wi...
Date Picker Web Component: • Custom Date-Picker wit...
Style Card Post: • Btyle blog, renting, s...
Style Text Underline: • Custom Text Underline ...
[website]
beforesemicolon.com
[Blog]
/ beforesemicolon
[Follow]
- Instagram = / before_semicolon_
- twitter = / beforesemicolon
- facebook = / beforesemicolon
- codepen = codepen.io/beforesemicolon
- reddit = / beforesemicolon
[Source Code]
github.com/beforesemicolon/BF...

Пікірлер: 106
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Do you use Web Components in your projects at all? If so, how do you build them? - from scratch - using a package (which one?)
@DarrenbyDesign
@DarrenbyDesign 4 ай бұрын
I personally use Lit because it feels easier to get started and maintain my components. I am not very well versed in advanced JS so Lit helps me build things with enough understanding quickly
@BeforeSemicolon
@BeforeSemicolon 4 ай бұрын
Hi Darren, thats good to hear. Im currently working on a Web Component simplification solution that would like to get your feedback on. www.npmjs.com/package/@beforesemicolon/web-component It has few advantages compared to Lit but would cherish your view as a Lit developer.
@DarkEternal813
@DarkEternal813 2 жыл бұрын
This single video was more helpful to me than any other resources I could find on Web Components. I read documentation, looked at code examples, took classes, and this single video is SO MUCH BETTER at explaining the how and why of using Web Components. AND you even give best practice advice!? AND give accessibility tips!? You've gone above and beyond in this video, thank you so much!
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you. Really appreciate the feedback. 😊
@Arthur-cx1cg
@Arthur-cx1cg 2 жыл бұрын
Totally agree. Read a lot, watched a lot, but this video has much more step by step guides and info, with proofs, pros and cons, and amazing examples.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you Arthur. I appreciate the feedback😊
@simobermaki
@simobermaki 2 жыл бұрын
I came here looking to learn about Web Components, and boy did i learn a TON OF NEW STUFF.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thanks so much for this. Stay tuned😊
@blessdarah1256
@blessdarah1256 2 жыл бұрын
I've been looking for something very elaborate as this. Thank you for this course.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Anytime. 😊
@MrBoiks
@MrBoiks Жыл бұрын
This content feels like a breath of fresh air... Like thankyou.
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Thank you chief 😊
@roym4457
@roym4457 2 жыл бұрын
the best web components course on youtube
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you :) Welcome to BFS
@morethanpixls
@morethanpixls 2 жыл бұрын
Dude, amazing walkthrough. Liked and Subscribed.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you and welcome to BFS 😊
@ebsector
@ebsector 2 жыл бұрын
Best explanation on web components I have seen
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you. That means a lot. Appreciated:)
@jackob_music1595
@jackob_music1595 2 жыл бұрын
Thanks for this helpful video!
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Anytime:)
@MuhammadQosim
@MuhammadQosim Жыл бұрын
Your Way to make tutorial video is helpfully amazing!
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Thank you Muhammad. Appreciated 😊
@SharpOar
@SharpOar Жыл бұрын
Nice job. Thanks
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Thanks for feedback @Raul.
@kikleine
@kikleine 2 жыл бұрын
Excellent video. Nice speed too :)
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you 😊
@DarrenbyDesign
@DarrenbyDesign Жыл бұрын
This is awesome! Thank you
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Thanks for the feedback. Appreciated
@AlexDudeOriginal
@AlexDudeOriginal 2 жыл бұрын
Highly appreciate this content bro
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Yeah, there are these gotchas that trap you for sure. Thank you and stay tuned for more
@romilsikka2572
@romilsikka2572 2 жыл бұрын
bro awesome work amazing job thanks a lot
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you. Appreciate the feedback. Welcome to BFS
@ikechukwuvalentine824
@ikechukwuvalentine824 Жыл бұрын
Thank you for this useful content. There's not much resources on web components bad the downside is that it's not supported well on all browsers.
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Im here for anything related. I still believe in the technology.
@patricknelson
@patricknelson Жыл бұрын
I'm a dinosaur and had been using jQuery still for years on a large long lived project (for various reasons, partly due to legacy code maintenance). However, one time a year or so ago I was in a pinch and needed to built something somewhat complex that needed to exist inside of another website but obviously couldn't be an . I looked into web components and, with *no build system* at all, was already immediately off and running with a solution. That's one huge advantage of custom elements and the suite of other standards (which we collectively refer to as "web components") offers: "It just works" and it works out of the box. Super fast, native and etc. That's not to say other frameworks aren't very powerful as well, it's just that it offers you so much with so little overhead that it's hard to deny the utility of web components. _Particularly_ if you're looking for ways to integrate them into a legacy codebase.
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Web Components is perfect for you then. If you truly want to remain close to vanilla and get additional help, consider cwco.io . Think about it like jQuery for web components
@josefranciscodelarosaibarr6477
@josefranciscodelarosaibarr6477 2 жыл бұрын
Great job! I'm moving to web components and this video is usefull to me. Thanks a lot. I wonder which extention are you using to format HTML code into a JS file...
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you and you’re welcome! I dont’t quite understand what you are asking here. For this video I used plain Javascript to do everything but if you are looking into small and easy way to handle all aspects of web components consider trying this tool www.npmjs.com/package/@beforesemicolon/web-component
@TheBorninmotion
@TheBorninmotion 2 жыл бұрын
OMG , thank you bro its just what i am looking for , i am currently using vue with nuxt on my projects but looking for something to get out from frameworks and its dependencies , is it time to start with web components or i should wait a little bit, what do you think about it ?
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
It is the right time to jump on Web Components. You can even go ahead and use Web Components with Vue and slowly make that transition. Web Components is not a replacement for libraries like Vue but for sure a better tool to build a UI library
@vipulkumar3066
@vipulkumar3066 2 жыл бұрын
Nice
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thanks 😊
@indratanaya5701
@indratanaya5701 Жыл бұрын
Wow, this is a very nice video, man! What extension do you use to highlight those HTML wrapped in a string?
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Thanks. Im using WebStorm which already comes with everything.
@indratanaya5701
@indratanaya5701 Жыл бұрын
@@BeforeSemicolon Oh I thought it was VS Code hahaha, thanks man!
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Yeah Im an Intellij guy
@ikechukwuvalentine824
@ikechukwuvalentine824 Жыл бұрын
The extension is comment tagged templates. Super useful.
@antheus_s
@antheus_s Жыл бұрын
You can use the es6-string-html extension by Tobermory with prettier for formatting or lit-html by Matt Bierner. Edit: This is applicable to VS Code.
@bonsayeb9620
@bonsayeb9620 Жыл бұрын
Thank you very much for this video. I noticed that while your in your JS file, your VSC is able to recognize HTML syntax, how do you get VSC to recognize HTML syntax in a JS file?
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Thank you. I dont use VSC. I use jetbrains WebStorm or Intellij for my videos.
@ikechukwuvalentine824
@ikechukwuvalentine824 Жыл бұрын
An extension called comment tagged templates
@aspiringengineer
@aspiringengineer 2 жыл бұрын
Thanks for the video! What do you think about the effect of using Web Components on web performance? Is it better than using React, Vue, etc?
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Web Components is not necessarily a replacement for those libraries and frameworks. It is rather a complementary feature. What those libraries can do is use web Components under the hood to reduce their size with more benefits. WC is already performant and there are cases it is better than those. For example, if you create a UI library with it, that library will work with any other framework. If create a UI library with react it will not work with Angular or Vue and vice-versa. I wrote a more detailed article on WC you can check link.medium.com/Nj4JIAPhYjb
@annisanadia
@annisanadia 2 жыл бұрын
​@@BeforeSemicolon Does it mean to reduce the size we use Web Components inside the app built with those libraries, or we compile the app into Web Components? And you said WC is already performant and there are cases it is better than those libraries. So does that mean benefit of WC is just the interoperability, since WC & library like React are both has the same level of performance? I'll read your article.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
What I have seen done more and more frequently is using those libraries and frameworks to build things but compiling everything to WC for the browser. Raw WC is pretty rough to work with at a scale and all these popular libraries already solved that. By compiling into WC you get the added benefits of not shipping the core system that the components need to work with the library since the browsers will have it which results in smaller bundle.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
I believe that there are cases where WC is even more performant because browses are constantly optimizing to better compile native things. Browsers dont optimize to run React, Vue or Angular in a better way and it is these libraries that often change to give browsers better things to compile. I dont have the data on that so I am just assuming here
@miklosnemeth8566
@miklosnemeth8566 2 жыл бұрын
@@BeforeSemicolon In this question I disagree, the biggest enemy of web components is React itself. React has its own component model It doesn’t need web component infra. When you start using Lit and Lit-element you never need React any more. Even Bootstrap can be used with web components.
@jackob_music1595
@jackob_music1595 2 жыл бұрын
Hello! I have a question: Is it possible to send a function to a web component from the outside of it? I'm struggeling on this for over 5 hours now. I did a modal component with a lot of attributes (description, title etc.), but I need to get some specific backend functions to the component. Do you have a way to do this?
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
You can pass anything to the component using properties on the component element like I am doing with data properly. Out of curiosity, why do you want to pass a function to the component?
@jackob_music1595
@jackob_music1595 2 жыл бұрын
@@BeforeSemicolon I want to pass a function to it to perform actions on-click to a button in the component. I could write these functions in the component, but that would make the file extremly long ig
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Use dispatch event not callback. Dont pass function to component to be called. Inside the component do: this.dispatchEvent(‘eventNameYouWant’) Then outside do: const yourComponent = document.querySelector(‘your-component-tag’); yourComponent.addEventListener(‘eventNameYouDispatched’, event => { console.log(yourComponent.propertyYouWantToRead); })
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Read this article for full details link.medium.com/V2HvVIYI0ib
@jackob_music1595
@jackob_music1595 2 жыл бұрын
@@BeforeSemicolon Thanks!
@husseinalwajedi8756
@husseinalwajedi8756 2 жыл бұрын
Great explanation, what is the name of your VS code theme?
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Thank you. That’s actually WebStorm IDE. Using material Atom Dark theme
@edalpez
@edalpez 2 жыл бұрын
@@BeforeSemicolon I like your IDE setup, how did you hide the tool window label and only show the icons?
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Some IDE have “no distractions” view mode you can remove everything. I use jetbrain IDEs but this one was what used to be FREE app to code.
@edalpez
@edalpez 2 жыл бұрын
@@BeforeSemicolon Yes, I am using Webstorm IDE also but i can't customize the tool window and keep the icon only.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Tried this? www.jetbrains.com/idea/guide/tips/distraction-free-mode/
@JacoFett99
@JacoFett99 2 жыл бұрын
I'm doing a project that uses web components at the moment and I cannot find out how to select my custom element in the DOM. My script inserts my and I try to document.querySelector('custom-element') but it returns null! If I go into the console and type the same thing in, it finds my custom tags. My Web component works as normal, I just need to select the tag to change the attribute. What is happening here? There are no posts I can find addressing this.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Jaco first of all, let me save you a lot of trouble bu suggesting something like this cwco.io Where you won’t need to query select or do any DOM manipulations. It also automatically changes things and handle data for you. No need to worry about those things
@ikechukwuvalentine824
@ikechukwuvalentine824 Жыл бұрын
It always works for me, try using Firefox dev or chrome.
@miklosnemeth8566
@miklosnemeth8566 2 жыл бұрын
I regard myself an expert in web components, still I have learned a lot from you. The biggest problem for web component is React especially since it has the hook paradigm and huge aficionado community love hooks. React needs no web components, zero benefit, just problems.
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
I would love to challenge that. I created a Web Component library (cwco.io) that can be used to enhance React in performance, data context and reusability. React components only work with React but CW components can be used with any library or framework. If I create a UI library with CWCO I only have to maintain one library and use it with any project type. I can still use react to take care of other things and together build a more powerful application. Learn more: cwco.io/documentation/getting-started#react-project
@miklosnemeth8566
@miklosnemeth8566 2 жыл бұрын
@@BeforeSemicolon It's to late to watch your movie on CWCO, but definitely it will be my top prio task for tomorrow. :) I am really curious, especially how to integrate the browser-standard event machinery with React, react doesn't support custom events.
@kibem.c
@kibem.c Жыл бұрын
Hi, just a question. How would I make a component that is similar to angulsr directives? For example, a directive that opens a modal when a button is clicked.
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
You cant create directives natively. What you can do is simply listen to a button click event and call a function that opens a modal. Do you have a angular code example that you would like to replicate with web Components?
@kibem.c
@kibem.c Жыл бұрын
​@@BeforeSemicolon Yes I have a angular code example, but your comment has given me an idea! I can use the "is" attribute that listens to click events and opens a modal You think that might work? Thanks for replying
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
I dont know about “is” attribute. If its not angular there is no way for directives so you just need to listen to click events by setting event listeners
@whatthefunction9140
@whatthefunction9140 Жыл бұрын
it would be great if you would add chapters
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
I will add. Thanks for the suggestion
@ferdygnteng4712
@ferdygnteng4712 Жыл бұрын
bro, I want to ask a simple answer, it's okay. What's the difference between using the web component and using as a font on icons?
@BeforeSemicolon
@BeforeSemicolon Жыл бұрын
Sure but i dont quite understand the question… You want to know the difference between using web components and font icons?
@adren.official
@adren.official 2 жыл бұрын
how can i highlight the HTML syntax in js?
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
I use WebStorm to code. It comes with HTML syntax highlighting by default.
@miklosnemeth8566
@miklosnemeth8566 2 жыл бұрын
VS Code supports JS template literal syntax highlight, too
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
What plugin do you use?
@miklosnemeth8566
@miklosnemeth8566 2 жыл бұрын
@@BeforeSemicolon lit-plugin by Rune Mehlsen
@devT44
@devT44 10 ай бұрын
You have shown when delegatesFocus:true is applied, entire webcomponent get focused automatically as well along with focused element. But this is not happening in my case.
@BeforeSemicolon
@BeforeSemicolon 10 ай бұрын
maybe its a browser behavior. What browser and version are you using?
@devT44
@devT44 10 ай бұрын
@@BeforeSemicolon chrome 115. Also checked on Firefox. Same result. I am using windows10. Is it working differently in my case because, I am using different os?
@BeforeSemicolon
@BeforeSemicolon 10 ай бұрын
I dont think OS matters here. Are you using my code? If not, can you share?
@none0n
@none0n 2 жыл бұрын
Any idea on how to get SCSS into web components
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Just can’t. It has to be CSS. With CWCO you can link to a stylesheet file (cwco.io/documentation/stylesheet#import-stylesheet) which can be SCSS as long as it is being handled(parsed)
@none0n
@none0n 2 жыл бұрын
@@BeforeSemicolon I am able to link and parse the scss with webpack, but I get an error when I try to use `this.shadowRoot.adoptedStyleSheets = [ButtonStyle];` buttonStyle is an imported SCSS file, which is supposed to have been transpiled by webpack
@BeforeSemicolon
@BeforeSemicolon 2 жыл бұрын
Simply add the “link” tag with the path to your parsed style inside the shadow root like a normal tag. Dont use the “adoptedstylesheet”
@none0n
@none0n 2 жыл бұрын
@@BeforeSemicolon thanks
Learn JavaScript Event Listeners In 18 Minutes
18:03
Web Dev Simplified
Рет қаралды 566 М.
Practical lessons from a year of building web components - Google I/O 2016
33:29
FOOTBALL WITH PLAY BUTTONS ▶️❤️ #roadto100million
00:20
Celine Dept
Рет қаралды 17 МЛН
Climbing to 18M Subscribers 🎉
00:32
Matt Larose
Рет қаралды 17 МЛН
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,4 МЛН
Programming a Guessing Game in Rust!
13:22
Let's Get Rusty
Рет қаралды 105 М.
Vue JS 3 Tutorial for Beginners #3 - Vue.js Basics (part 2)
34:02
The ULTIMATE guide to styling/customizing Material UI (MUI)
10:29
The Best Way to Create HTML Elements with JavaScript?
5:56
How to build your first Lit component
11:59
Lit: Simple. Fast. Web Components.
Рет қаралды 33 М.
HTML vs DOM? Let’s debug them #DevToolsTips
5:12
Chrome for Developers
Рет қаралды 30 М.
Learn GitLab in 3 Hours | GitLab Complete Tutorial For Beginners
3:26:43
The Story of Web Components
6:42
uidotdev
Рет қаралды 86 М.
FOOTBALL WITH PLAY BUTTONS ▶️❤️ #roadto100million
00:20
Celine Dept
Рет қаралды 17 МЛН