How to get started with a webcomponent - Crashcourse #516
Replies: 2 comments 1 reply
-
... Additionally I don't want to use the existing bootstrap css classes, that's why I want to build the page with grid and flexbox. I want to use this project to bring fresh stuff in the app without building on top of the existing stuff with one eye on current complexity |
Beta Was this translation helpful? Give feedback.
-
You might not have to. Vanilla custom elements don't require one — only if you want to use TypeScript or possibly a runtime library. I say "possibly" because you may be able to use Lit, for example, as part of your current build. (Does it support ESM imports? Give it a try!) Worst case, you can develop your components separately — and that may even be preferable long term so you can manage them separately and reuse them elsewhere.
The nice thing about custom elements is that you can adopt them incrementally. Start with one component, swap out the old ones. Build another, swap out the old ones. I think the biggest challenge is in your setup. Does it make sense to try to build them within the existing app or outside of it as a separate package. Both approaches have advantages, but it all depends on your requirements and the existing build. |
Beta Was this translation helpful? Give feedback.
-
Hi together,
My situation:
New project:
Instead of programming Block for block with backend setup possibilities I decided to create the whole page from scratch in plain html, separate css in sass compiled by IDE to prevent wasting time on waiting the grown dinosaurs of less files are compiled
This will by my MVP - complete nice looking page in first step. Cut out CMS modules with PHP functionality will come as next step.
Now there layout elements on this page like a "quote container" or little "avatar collections with rounded images"
My thought thanks shoelace are: make my own little web components for this.
Wrapped styles secured from the rest of the page, reusable for upcoming features.
But now the question of all is: how to start?
I don't want to setup another built process in this app where other devs are working too.
I don't want any additional framework overhead if not needed.
At the end I want to write
<quote>
with some content and it should appear as defined.Where should I define
<template>
, where the JS for this?Sure, trial and error is the best way to learn and my plan is to spend the next weekend to try something out, but I need some hints from people who knows about creating own components. I love using shoelace in our other projects, but now it's time and the need to built one by myself.
There is no need to find the perfect solution in first step thanks to our company and teams agile strategies, but I would prefer a lightweight and easy to understand prototype to work on.
Sure, I'll pay the next beer for useful support.
Nice evening - greetings from Germany
Beta Was this translation helpful? Give feedback.
All reactions