Skip to content
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

better isolate toolbar css from rest of the theme #128

Closed
djay opened this issue May 31, 2017 · 16 comments · Fixed by plone/documentation#1592
Closed

better isolate toolbar css from rest of the theme #128

djay opened this issue May 31, 2017 · 16 comments · Fixed by plone/documentation#1592

Comments

@djay
Copy link
Member

djay commented May 31, 2017

Not sure this is the right place, but when we take a outside theme and try to use it with plone we try to eliminate all the plone css and only use it with backend.xml.
However we still need a toolbar and few other things. However the toolbar uses css with very generic selectors such the .icon- selectors.

Everything in the toolbar should have rules that will only ever apply on the toolbar and should be in its own bundle that can be included by itself

@agitator
Copy link
Member

aren't those styles in mockup/patterns?

@rafaelbco
Copy link
Member

I'm studying how to theme Plone 5 and I think I'll have the same problem. How did you solve it @djay ?

@djay
Copy link
Member Author

djay commented Nov 30, 2022

@rafaelbco
Copy link
Member

I don't quite follow. It seems I still have to include Plone's CSS and JS for the toolbar to work in the "view mode" (i.e not in "backend mode"). Quoting from the page you've mentioned:

You will still need to include a minimal Plone bundle in your theme for rendering the toolbar correctly. It is intended in future versions of Plone that this will be available by default and be very minimal making no assumptions about the JavaScript or CSS of your frontend theme so as not to conflict with it.

I could not find out which CSS and JS resources from Plone I have to include in my theme.

@djay
Copy link
Member Author

djay commented Dec 2, 2022

@rafaelbco all you have to do is add the code it suggests.

The part of that code that includes the toolbar and css only for pages which are "backend"/CMS pages is

  <!-- Include the backend theme -->
  <xi:include href="++theme++barceloneta/backend.xml" />

The second is the part that loads your custom theme (index.html) but only when its not the backend/CMS pages

  <!-- Only theme front end pages -->
  <rules css:if-content="body.frontend#visual-portal-wrapper">

    <theme href="index.html" />

    <!-- Your diazo front end rules go here -->

    </rules>

@djay
Copy link
Member Author

djay commented Dec 2, 2022

@rafaelbco maybe it would have been clearer what is really going on if it had been impliment more like this?

<xi:include href="++theme++barceloneta/min-toolbar.xml" />
<rules css:if-content="body.backend">
    <xi:include href="++theme++barceloneta/cmsui.xml" />
</rules>
<rules css:if-content="body.frontend">
    <!-- INSERT YOUR THEME RULES HERE -->
</rules>

@Rudd-O
Copy link

Rudd-O commented Dec 2, 2022

Looks like this needs more documentation?

@yurj
Copy link
Contributor

yurj commented Dec 2, 2022

For Plone 6, what I did for a custom theme (not using barceloneta but using bootstrap 5) is to include the toolbar scss from barceloneta in the theme with an import from the npm package:
@import "@plone/plonetheme-barceloneta-base/scss/toolbar";

and to add the related variables from barceloneta:

/ plone variables (used in toolbar)
// Plone specific colors
//colors
$state-draft-color:                 #fab82a!default; // lime-yellow //draft is visible
$state-pending-color:               #e2e721!default; // orange
$state-private-color:               #c4183c!default; // red
$state-internal-color:              #fab82a!default; // is draft
$state-internally-published-color:  #883dfa!default; // is intranet
$plone-link-color:                  #007bb1!default; //plone blue made slightly darker for wcag 2.0
$spacer:                            1rem!default;


// Toolbar
$plone-toolbar-bg: rgba(0, 0, 0, 0.9);
$plone-toolbar-submenu-bg: rgba(20, 20, 20, 0.95);
$plone-toolbar-font-primary: "Roboto Condensed", sans-serif;
$plone-toolbar-font-secondary: "Roboto", sans-serif;
$plone-toolbar-separator-color: rgba(255, 255, 255, 0.17);
$plone-toolbar-link: $plone-link-color;
$plone-toolbar-text-color: rgba(255, 255, 255, 0.9);
$plone-toolbar-submenu-text-color: #fff;
$plone-toolbar-submenu-header-color: lighten(#000, 80%);

$plone-toolbar-locked-color: var(--bs-warning); // is intranet

$plone-toolbar-width: 220px;
$plone-toolbar-width-collapsed: calc($spacer * 2.25);
$plone-toolbar-top-height: calc($spacer * 2.5);

The toolbar uses the toolbar mockup:
https://github.com/plone/mockup/tree/master/src/pat/toolbar

So I think you need just the npm for mockup (but you have it already in the plone javascript) and the scss variables with import as above. Maybe @petschki or @santonelli have all the bits.

P.S: maybe it is better to move to https://community.plone.org/?

@rafaelbco
Copy link
Member

@rafaelbco maybe it would have been clearer what is really going on if it had been impliment more like this?

Yes!

@rafaelbco
Copy link
Member

The second is the part that loads your custom theme (index.html) but only when its not the backend/CMS pages

But where is the css and js for the toolbar?

@gforcada
Copy link
Member

I'm looking into this as well, hopefully some patches will be sent in the next few weeks/months. We are getting a complete design, but we need:

  • toolbar
  • control panels
  • folder_content view
  • add/edit forms

So a way to extract these 4 (probably more) parts would be great 🤞🏾 🍀

@petschki
Copy link
Member

just wondering what is needed here:

  • toolbar, controlpanels and forms are separated scss files in @plone/plonetheme-barceloneta-base/scss/ ... make sure you include the dependend scss definitions.
  • folder_contents (aka. pat-structure) gets loaded within the pattern so no need for integrating it somewhere.

@yurj
Copy link
Contributor

yurj commented Dec 11, 2023

In my custom (no barceloneta) what I do is:
@import "@plone/plonetheme-barceloneta-base/scss/toolbar";

then in my theme I copy the variables used in the toolbar:

// plone variables (used in toolbar)
// Plone specific colors
//colors
$state-draft-color:                 #fab82a!default; // lime-yellow //draft is visible
$state-pending-color:               #e2e721!default; // orange
$state-private-color:               #c4183c!default; // red
$state-internal-color:              #fab82a!default; // is draft
$state-internally-published-color:  #883dfa!default; // is intranet
$plone-link-color:                  #007bb1!default; //plone blue made slightly darker for wcag 2.0
$spacer:                            1rem!default;


// Toolbar
$plone-toolbar-bg: rgba(0, 0, 0, 0.9);
$plone-toolbar-submenu-bg: rgba(20, 20, 20, 0.95);
$plone-toolbar-font-primary: "Roboto Condensed", sans-serif;
$plone-toolbar-font-secondary: "Roboto", sans-serif;
$plone-toolbar-separator-color: rgba(255, 255, 255, 0.17);
$plone-toolbar-link: $plone-link-color;
$plone-toolbar-text-color: rgba(255, 255, 255, 0.9);
$plone-toolbar-submenu-text-color: #fff;
$plone-toolbar-submenu-header-color: lighten(#000, 80%);

$plone-toolbar-locked-color: var(--bs-warning); // is intranet

$plone-toolbar-width: 220px;
$plone-toolbar-width-collapsed: calc($spacer * 2.25);
$plone-toolbar-top-height: calc($spacer * 2.5);

and in rules.xml:

 <before css:theme-children="body" css:content="#edit-bar" css:if-not-content=".ajax_load" css:if-content=".userrole-authenticated" />
 <replace css:theme="#anonymous-actions" css:content-children="#portal-personaltools-wrapper" css:if-not-content=".ajax_load" css:if-content=".userrole-anonymous" />

@gforcada
Copy link
Member

Cool, thanks!

I'm far from a frontend developer and I even have less knowledge about the ins and outs of barceloneta theme 😅

Would it be worth mentioning it in the Classic UI theming from scratch?

At the end, even if you want to go completely on your own, it does not make much sense to re-style the toolbar, control panels and add/edit forms, so having a quick guide on how to generate a minimal bundle with only these parts (as @yurj shows on his comment) might be really helpful 🎉

@petschki
Copy link
Member

absolutely the right place for documenting this usecase 👍🏼

@gforcada
Copy link
Member

I made a PR on the documentation for it: plone/documentation#1592 feedback is more than welcome! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants