This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-13
Channels
- # announcements (1)
- # babashka (2)
- # biff (10)
- # cider (11)
- # clara (17)
- # clerk (10)
- # clojure (21)
- # clojure-berlin (4)
- # clojure-brasil (1)
- # clojure-europe (32)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-uk (10)
- # cursive (2)
- # data-science (11)
- # datomic (10)
- # emacs (8)
- # events (7)
- # fulcro (29)
- # gratitude (2)
- # honeysql (21)
- # hyperfiddle (7)
- # lsp (2)
- # malli (4)
- # polylith (4)
- # reitit (8)
- # releases (1)
- # shadow-cljs (15)
- # squint (3)
- # xtdb (5)
I am curious about the relationship between front-end component design and polylith. I know the polylith team is working on bringing polylith tool to the front-end, but would like to hear more experienced developers if they granularize their front-end react or other components according to pl guidelines and if they have found this useful or not.
Nope. So far the only option out there was to have all your FE code in a separate base
or in an independent sub-dir in the workspace
(that is used as a :local/root
dependency of some project). But these thinks are just about to change.
Something like this for example:
// Component for user image
class UserImage extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
img { width: 100px; height: auto; }
</style>
<img src="${this.getAttribute('src')}" alt="User Image">
`;
}
}
// Component for user name
class UserName extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.textContent = this.getAttribute('name');
}
}
// Component for user bio
class UserBio extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.textContent = this.getAttribute('bio');
}
}
// Registering components
window.customElements.define('user-image', UserImage);
window.customElements.define('user-name', UserName);
window.customElements.define('user-bio', UserBio);
Obviously these are useless components just to serve as an example.