-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(do-not-merge) Bootstrap support via Greenwich core extension #18190
Conversation
(Standard links)
|
b5f178f
to
1a0b777
Compare
Test fails look related @totten |
1a0b777
to
4085bfc
Compare
@seamuslee001 Ah, thanks. I'm pushing an update for that. @colemanw @eileenmcnaughton @seamuslee001 You should be able to check out this PR and see the APIv4 Explorer using Greenwich's BootstrapCSS on a new/clean build. This branch incorporates #17913 - and it also adds several other patches. However, within each subtopic, I think there are points of revision/discussion. But if the overall structure seems sane, then I can split it out into smaller PRs. |
@totten can you rebase when you get a chance? |
@eileenmcnaughton Well, I could, but... this is an exploratory/demonstrative branch that aims to give broad sense of the cumulative result of multiple PRs. It's not supposed to be merged as-is, and it's quite prone to staleness. Maybe it makes more sense to put the effort into filing a few of smaller PRs? |
@totten yeah - it was mostly that I thought about pulling it down to look & then saw it was stale so I didn't - but maybe it's better if we have that call that was scheduled earlier & discuss / demo |
Agree, we should do a little discuss/demo. |
@colemanw @eileenmcnaughton @seamuslee001 - I've taken out the parts which deal with just "Resource Collections" / "Resource Bundles" and put that in #18247. That's somewhat smaller (e.g. doesn't touch on the Greenwhich/Bootstrap stuff). It's also rebased to match some incidental changes, and I've added a few updates/fixes as well as notes+suggestions on QA. |
@totten please rebase |
4085bfc
to
fc93f7e
Compare
Right, all the "Resource collections" stuff has been merged in its own PR. That still leaves the "Bootstrap3 bundle" and "Greenwich extension". Note that the approach to the Greenwich's compilation step is changing (discussed more in https://lab.civicrm.org/dev/user-interface/-/issues/27), so this shouldn't be merged. But it's still useful for seeing the parts put together. |
The Api4Explorer page has a neat trick - if (by any means) you manage to have Bootstrap3 active within the body of this Civi page, then it will display a warning. This patch moves the trick to be part of the `bootstrap3` bundle, which means that it will be applied to any page where `bootstrap3` is activated.
@eileenmcnaughton @colemanw - I've extracted the "Bootstrap3 bundle" parts as #18354. For a more proper rendition of the "Greenwich extension" section, that's going to depend on some |
@totten this needs another rebase |
@seamuslee001 @colemanw @eileenmcnaughton - At this point, I believe everything from the experimental PR has been extracted/polished with proper PRs, so I'm gonna close this one. The new Greenwich-specific PR is #18465. Note that it has the one major change, shifting from AssetBuilder to a composer-based pre-compilation. |
Overview
This is an exploratory branch to demonstrate a more modular and nuanced approach to loading Bootstrap3 CSS. Its aim is to provide breadth and to show the connection between different pieces. The explanation is grouped into a few subtopics, each of which would likely be its own PR and possible revisions.
See also: https://lab.civicrm.org/dev/user-interface/-/issues/27
Resource collections
How do you manipulate a list of related assets - such as a combination of CSS+JS+data that must be loaded together?
There are three places where you might add, inspect, or tap-into such a list. These three build on top of each other, and they are broadly similar, but there are several technical differences. A handful of differences are important, but many of the differences are arbitrary.
CRM_Core_Resources
hook_coreResourcesList
CRM_Core_Region
addFoo('bar')
$arr[] = 'bar'
add(['foo' =>'bar'])
The idea here is to (a) create a model which combines most of the above characteristics, (b) make the model more reusable, and (c) retrofit that model as far as we can into the existing system. The unified concept of a "resource collection" captures all the similarities between them. Of course, there are still a few differences - and so we have different types of collections:
The
CollectionTrait
andCollectionInterface
are central to this:add()
,update()
, andget()
methods are interoperable withadd()
,update()
,get()
fromCRM_Core_Region
addFoo()
methods are interoperable with theaddFoo()
fromCRM_Core_Resources
. They are all thin wrappers foradd()
.CRM_Core_Resources
,CRM_Core_Region
, orhook_coreResourcesList
.CRM_Core_Resources
orCRM_Core_Region
(such asweight
,region
,name
,disabled
).hook_coreResourcesList
, but its format is different. It allows more content-types, and it provides helper methods likeget($name)
,getAll()
,filter($func)
,find($func)
, andclear()
.hook_coreResourcesList
. However, it doesn't have the full API or full content-model. The equivalent with a full API ishook_alterBundle
.string[] $types
(white-list of allowed resource-types) andarray $defaults
(list of key-values to apply to all new resources).Both
Region
andBundle
are based onCollectionTrait
, so they are very similar. The difference is that:Region
is a concrete section of the HTML document - so it can be rendered to HTML.Bundle
is an unattached list - it is not active until you add/merge into something concrete. (ex:Civi::resources()->addBundle($myBundle)
).scriptUrl
,scriptFile
,markup
, etc) is tighter in a typicalBundle
than in a typicalRegion
.Bootstrap3 bundle
If a page is written for the Bootstrap3 CSS vocabulary, then it should activate the corresponding bundle:
The bundle is a mix of different kinds of assets (e.g. CSS and JS).
Observe that different stakeholders interact with this bundle in different ways by :
civicrm-core
or extensions) activate the bundle (but the implementation is opaque to them).bootstrap.css
,bootstrap3.css
,greenwich.css
,greenwich-bootstrap.css
, orasset-builder?asdf1234
).This particular bundle is not really provided by
civicrm-core
-- core is just the middle-man who gives the namebootstrap3
. The default content is provided via the Greenwich theme/core-extension.NOTE: Why is bundle called
bootstrap3
instead of justbootstrap
? Two reasons:bootstrap6
orbootstrap7
, which will not be interoperable withbootstrap3
.Greenwich extension
Currently,
civicrm-core
has a built-in theme called "Greenwich". However, it is enmeshed with the rest of the core code. With this patchset:sequentialcreditnotes
is. So it is always available.#bootstrap-theme
(ie the same container used by Shoreditch). The compilation uses another extension,csslib
.