? Pending

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
4 Mar 2017

Before commenting here make sure you have enough knowledge about custom elements

Some resources:
[W3C] : https://www.w3.org/TR/custom-elements/
[MDN] : https://developer.mozilla.org/en-US/docs/Web/Web_Components/Custom_Elements
[Google] : https://developers.google.com/web/fundamentals/getting-started/primers/customelements

https://www.webcomponents.org

TL:DR;

Custom element is a W3C standard that is backed by all the major browsers. At the time of writing this only Chrome and Opera support them without a polyfill, but next version of Safari and Firefox will, Microsoft will follow later this year.

Summary of Changes

The objective: Use custom elements to decouple the system from Bootstrap

Benefits

  • Make Joomla more appealing for front end devs, as there won't be any coupling to a particular css framework.
  • Also make Joomla less painful for 3rd PD whenever a new css framework update is needed.
  • End user will benefit as well, as the code (at least for core) won't load jQuery and Bootstrap scripts (2 less http requests, less js to parse and execute, etc)
  • We are embracing the new technologies instead of fighting with dying ones

win-win-win-win!

B/C

This can coexist with the original bootstrap markup and javascript so there is no B/C break in any way.

Documentation Changes Required

We are introducing a new API and also a new markup, so documentation is vital!

Preview

screen shot 2017-03-04 at 21 14 51

Check the element type!

screen shot 2017-03-04 at 21 15 33

6b4c3a0 4 Mar 2017 avatar dgt41 poc
avatar dgt41 dgt41 - open - 4 Mar 2017
avatar dgt41 dgt41 - change - 4 Mar 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Mar 2017
Category Administration Templates (admin) Layout JavaScript
avatar mbabker
mbabker - comment - 4 Mar 2017

Then maybe a PR in the main repo is the wrong place for this then :)

RFC issues and PRs are perfectly valid.

avatar Bakual
Bakual - comment - 4 Mar 2017

Maybe it's me not understanding custom elements yet or me not don't sharing the "We should not use Bootstrap" mentality, but I don't see the point in this example. Maybe it's also just a bad example.
Imho it makes my life as a developer (both template and extension) only harder, not easier.

We are introducing a new API and also a new markup, so documentation is vital!

Since we are known to be very good at documenting our stuff, that will be the main point where this would either succeed or fail. Being realist it will be the latter.

It looks like we're going to cook our own soup here again instead of using some (very well documented!) "standard". I really don't like the NIH syndrome ?

From what I understand about custom elements, they make a lot of sense when you want to include custom functionality (eg a dropdown list that changes behavior based on content or expands the adds features to it). But for regular markup stuff it doesn't make much sense to me. For that we can use JLayouts just fine.

avatar dgt41
dgt41 - comment - 4 Mar 2017

@Bakual Alerts are not just some random markup, there is a script that comes with it (for the close function, it has a method and 2 events)
Documentation should be easy since there are plenty of tools out there for this, e.g. https://github.com/QingWei-Li/docsify

To make this example more interesting in your browser's console type:

tmp = document.querySelector('bs4-alert');
tmp.close();
avatar wilsonge wilsonge - change - 5 Mar 2017
The description was changed
avatar wilsonge wilsonge - edited - 5 Mar 2017
avatar wilsonge
wilsonge - comment - 5 Mar 2017

OK So I think custom elements are going to take off over the next 5 years so I'm not against this. However caveats:

  1. I am slightly nerved by the fact that custom elements are still not a approved w3c standard (and how we deal with any b/c breaks in the meantime)
  2. Documentation
  3. How templates override this markup. This is by far my biggest issue. I think having bs4 in the element name is bad (i'm assuming this is just for demo purposes) because if you are using uikit and have to replace the element bs4-alert it's going to be very confusing. But also how does that override mechanism work?
avatar dgt41
dgt41 - comment - 6 Mar 2017

Quick answers:

I hope this makes some sense

avatar laoneo
laoneo - comment - 6 Mar 2017

I really like the approach and it will make the life for me as extension developer much easier, as I don't have to care about frontend framework vendor specific markup anymore. It is the best approach I'v seen so far to become frontend framework independent.

I would also recommend not to have have bs4 in the elements names. But sounds like you are going to change that.

What for me is unclear how it would work then for a Foundation based template to load the foundation alert custom element. Would it be then trough JHTML overrides or will it be simpler with some kind of auto detection?

avatar dgt41
dgt41 - comment - 6 Mar 2017

@laoneo the call for an alert (server side/php) will be JHtml::_('customElements', $path, $options) both for bootstrap or foundation or any other css framework. For client side is just like creating a usual element:

var tempElement = document.createElement('bs4-alert');
tempElement.setAttribute('data-type', 'success');
tempElement.setAttribute('data-button', 'true');
tempElement.innerHTML = 'Wow it works!';

document.body.appendChild(tempElement);

Try to do the same (especially client side) with bootstrap...

avatar laoneo
laoneo - comment - 6 Mar 2017

So when I want to provide my own fundation custom elements, then I need to reigster my own customElements script in JHtml?

avatar C-Lodder
C-Lodder - comment - 19 Apr 2017

Maybe it's me not understanding custom elements yet or me not don't sharing the "We should not use Bootstrap" mentality, but I don't see the point in this example. Maybe it's also just a bad example.
Imho it makes my life as a developer (both template and extension) only harder, not easier.

  1. Better performance (something we all look for)
  2. Decouple from Bootstrap (something people have been moaning about for years)

This doesn't in any way remove support for Bootstrap alerts....you, template devs and extension devs are quite within you right to continue using BS/jQuery if you want to.

At the end of the day, this means that Joomla supports a web component that isn't couple to BS4....which IS a big factor for extension and template devs. Once template devs realise that we're utilising web components, they can support them, and thus alerts will then work on ANY frontend framework being used.

We all have our own extensions, we all know how bloody annoying it is whgen trying to cater for other frameworks. As it stands, on one of my own modules, I've had to resort to adding a backend parameter to select the framework you wish to use (BS2, BS3, UIKit).


Ignore the fact that this PR is loading something from a CDN....Dimitris he stated it's purely for demonstration purposes

avatar C-Lodder
C-Lodder - comment - 19 Apr 2017

Oh and what do you know? Even Google have re-built G-Earth with Web Components: https://earth.google.com/web

avatar dgt41
dgt41 - comment - 23 May 2017

For those not convinced yet about custom elements, let me point you to youtube.com. Check the source code, yup, that's right, extensive usage of custom elements:
screen shot 2017-05-23 at 14 39 53

This is how you do UI in the modern times...

avatar dgt41
dgt41 - comment - 24 May 2017

I will redo this one later on..

avatar dgt41 dgt41 - change - 24 May 2017
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2017-05-24 21:02:36
Closed_By dgt41
Labels Added: ?
avatar dgt41 dgt41 - close - 24 May 2017

Add a Comment

Login with GitHub to post a comment