Download the PHP package fromholdio/silverstripe-csshelpers without Composer
On this page you can find all versions of the php package fromholdio/silverstripe-csshelpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fromholdio/silverstripe-csshelpers
More information about fromholdio/silverstripe-csshelpers
Files in fromholdio/silverstripe-csshelpers
Package silverstripe-csshelpers
Short Description Provides css hooks to add to your template BODY element, generated from user state and current page meta information.
License BSD-3-Clause
Homepage https://github.com/fromholdio/silverstripe-csshelpers
Informations about the package silverstripe-csshelpers
silverstripe-csshelpers
Applies an extension to SiteTree
that provides css hooks for your template, based on user state (logged in/out/etc) and current page meta information (class, class hierarchy, url-segment/route).
Intended as a cheap and easy method of adding sometimes-useful css hooks to your <body>
element.
Two variables are made available to templates:
$BodyCSSClass
$BodyCSSID
FWIW, the classes generated are based on an aged version of my own blend of BEM ... so, there's that. I'm definitely open to standardising them at some point, or allowing them to be set via static config (somehow?) at some stage.
Requirements
SilverStripe 4
Installation
composer require fromholdio/silverstripe-csshelpers
Details
$BodyCSSID
is generated using the prefix page-
and the full url-segment of the current page (i.e. it includes the route hierarchy / urlsegment's of parent pages too).
$BodyCSSClass
is generated using:
Body
is added as initial part of return string- The page's parents are looped, adding
Body--<urlsegment>
for each (allowing css-targeting of specific area of site) - The class hierarchy of the page is looped, adding
class-<classname>
for each, stopping atclass-page
- Current controller action is added:
action-<actionname>
- Logged in status is added:
logged-[in|out]
Disclaimer
Yep. Sometimes this kind of targeting with CSS hooks based on URL segments that the user can update in the CMS on a whim (through your fault or theirs 😉), is a hideous and terrible mistake.
But sometimes it's just the right tool for the job in front of you.
All versions of silverstripe-csshelpers with dependencies
silverstripe/vendor-plugin Version ^1.0
silverstripe/framework Version ^4.0