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

[4.0] Cassiopea: allow header to be sticky if desired #27579

Merged
merged 10 commits into from
Feb 5, 2020

Conversation

infograf768
Copy link
Member

@infograf768 infograf768 commented Jan 20, 2020

Pull Request for Issue #27549

Summary of Changes

Adding css and parameter to make the Header sticky if desired.
Default to No.

FI: I had to add the css in index.php as adding it in grid scss did not work.

Testing Instructions

Patch. NPM needed.

Edit Cassiopea template style, Advanced tab.
Set Sticky Header to Yes

Screen Shot 2020-01-20 at 10 48 42

Display frontend and scroll.

Expected result

sticky

Note

Works here on Chrome, Firefox, Safari, Opera. Did not test other browsers.
I have no pre-conceived idea about adding this parameter or not, but we now have the choice to add this to Cassiopea if maintainers desire.

$stickyHeader = $this->params->get('stickyHeader') ? 'sticky-header' : '';

// Stick the header
if ($stickyHeader === 'sticky-header')
Copy link
Member

@C-Lodder C-Lodder Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this styling to the SCSS file.
You can then remove -webkit-sticky too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I wrote, I tried that in the grid scss by adding .sticky-header as a child of .container-header but it did not work.
Maybe it could be added by itself. Will test again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also -webkit-sticky is essential for safari.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe you need in another scss? global?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also -webkit-sticky is essential for safari.

The autoprefixer package hooks in when SCSS compiles to CSS and adds in vendor related things (i.e. the -webkit-sticky property) based on the browsers that it's told to support. So you don't need to manually add all the browser related stuff to the SCSS files, the build step takes care of that for you.

@@ -93,7 +111,7 @@
. $hasClass;
echo ($this->direction == 'rtl' ? ' rtl' : '');
?>">
<div class="grid-child container-header full-width">
<div class="grid-child container-header full-width <?php echo $stickyHeader; ?>">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the class to the <header>, not the page container

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not work in that case. In fact it breaks the display.
Or maybe I do not understand what you mean?
if in header class="header", I stand with my statement.

Copy link
Member

@C-Lodder C-Lodder Jan 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look at this properly tomorrow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved css, see below.

We 'may' move it to <header when the curve will be gone. See: #27566

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to <header>?

@jwaisner
Copy link
Member

Tested on the frontend using both Firefox and Chrome. Sticky function works even in the frontend editor. Default state is "No" as expected.

The only issue is that the switcher for the "Sticky" setting isnt correct for the "no" state. It should be disabled (grey) not enabled (green).
27579

@infograf768
Copy link
Member Author

@jwaisner
Switcher should now be Ok.

@infograf768
Copy link
Member Author

infograf768 commented Jan 20, 2020

@C-Lodder
Moved the new css to _layout.scss

npm needed.

@infograf768
Copy link
Member Author

Folks, if #27566 is tested and merged, this PR will be modified.

@jwaisner
Copy link
Member

I have tested this item ✅ successfully on 37bdd98


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@infograf768
Copy link
Member Author

@C-Lodder
tested here after patching with #27566
I tested applying sticky-header to <header after modiying the css by taking off margin: 0 0 20px 0 !important; as margins are now OK in .container-header header
In this case, it does not work with Chrome or Opera.
WE definitely need to apply the new class to div class="grid-child container-header full-width <?php echo $stickyHeader; ?>">
Will modify this PR as soon as #27566 is merged.

@brianteeman
Copy link
Contributor

You do not need to have the webkit line in the scss. The build script deals with that automatically as shown in the screenshots below.

But why are we even adding any css at all. This is a bootstrap template and bootstrap has its own utility class for this already called position-sticky

scss

image

css

image

@infograf768
Copy link
Member Author

You do not need to have the webkit line in the scss. The build script deals with that automatically as shown in the screenshots below.

OK. It would work indeed, but no use. I will delete that scss. See below.

But why are we even adding any css at all. This is a bootstrap template and bootstrap has its own utility class for this already called position-sticky

I had tested that. position-sticky is missing an essential part: top: 0;
Without it, it does not work.

But after also adding sticky-top in order to have the following code
$stickyHeader = $this->params->get('stickyHeader') ? 'position-sticky sticky-top' : '';

it works fine in all browsers tested.
Modifying this now as using layout scss is useless.

@ChristineWk
Copy link

I have tested this item ✅ successfully on f5c1f72


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@infograf768
Copy link
Member Author

@jwaisner
Please test again.

@Quy
Copy link
Contributor

Quy commented Jan 21, 2020

Do you want to add this parameter to joomla.sql?

(0, 'cassiopeia', 'template', 'cassiopeia', '', 0, 1, 1, 0, '', '{"logoFile":"","fluidContainer":"0","sidebarLeftWidth":"3","sidebarRightWidth":"3"}', 0, NULL, 0, 0),

@ciar4n
Copy link
Contributor

ciar4n commented Jan 21, 2020

I haven't tested this but would this not also stick the banner position? Maybe an issue on small devices if anything large in there.

@brianteeman
Copy link
Contributor

yes and the search postion

@jwaisner
Copy link
Member

I have tested this item ✅ successfully on 9b669f6


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@infograf768
Copy link
Member Author

infograf768 commented Jan 22, 2020

Do you want to add this parameter to joomla.sql?

Not sure it is absolutely necessary as the absence of the parameter = No

@infograf768
Copy link
Member Author

I haven't tested this but would this not also stick the banner position?

Yep, it does. That's why we have a parameter to choose sticky or not, default being No which I would recommend in case of large banner usage..
Using a banner image wider than the mobile window size shrinks the image width (not proportionnaly) and is not recommended anyway.
Basically, as for most aspects, it depends on the site owner decisions.

yes and the search postion

Nope. Search is in the toggler as well as the menu position.

@infograf768
Copy link
Member Author

RTC.

It is now the decision of maintainers to get this feature in or not.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 22, 2020
@ciar4n
Copy link
Contributor

ciar4n commented Jan 22, 2020

That's why we have a parameter to choose sticky or not, default being No which I would recommend in case of large banner usage..

A fair point but personally I would just stick the navigation/logo. Also may be worth wrapping it in a media query so it only applies to desktops.

@infograf768
Copy link
Member Author

infograf768 commented Jan 22, 2020

A fair point but personally I would just stick the navigation/logo.

The only way I found was to separate totally the banner from the container-header <div>

Also may be worth wrapping it in a media query so it only applies to desktops.

We indeed could do that.
We would have to override bootstrap. In which scss would you do that?

In any case, if the banner is huge, we would have the same issue in mobile view. Is it worth?

@ciar4n
Copy link
Contributor

ciar4n commented Jan 22, 2020

Try this applied to the .container-header class..

@include media-breakpoint-up(sm) {
  position: relative !important;
}

@infograf768
Copy link
Member Author

Try this applied to the .container-header class..

Would rather be down instead of up, i.e.

@include media-breakpoint-down(sm) {
  position: relative !important;
}

and indeed, for smaller screens, the header would not stick.

@wilsonge @HLeithner
I still think personally that anyone wanting the header to be sticky is not going to add an enormous banner and that keeping the header sticky is also quite useful in mobile mode.
What do you think?

@wilsonge
Copy link
Contributor

Personally I find sticky headers on mobiles annoying as it reduces the screen size available for the text. So I'd kinda be ok with it tablet and up 🤷‍♂ but it's just a personal opinion - nothing more

@infograf768
Copy link
Member Author

Personally I find sticky headers on mobiles annoying as it reduces the screen size available for the text. So I'd kinda be ok with it tablet and up 🤷‍♂ but it's just a personal opinion - nothing more

OK, will do in order to get rid of that and concentrate on other matters

@infograf768
Copy link
Member Author

infograf768 commented Jan 26, 2020

Now unstuck in mobile view.
@ChristineWk @jwaisner @ciar4n
Please test again.

Needs npm

@rdeutz
Copy link
Contributor

rdeutz commented Feb 3, 2020

Removed RTC because a new round of testing is requested from the author of the PR


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Feb 3, 2020
@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on d6ae643

It works as described but I really don't like just adding more and more parameters


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@jwaisner
Copy link
Member

jwaisner commented Feb 3, 2020

I have tested this item ✅ successfully on d6ae643


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@Quy
Copy link
Contributor

Quy commented Feb 3, 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27579.

@Quy Quy added the RTC This Pull Request is Ready To Commit label Feb 3, 2020
@rdeutz rdeutz merged commit 9d7f97a into joomla:4.0-dev Feb 5, 2020
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Feb 5, 2020
@infograf768 infograf768 deleted the 4.0_sticky-header branch February 5, 2020 08:35
@infograf768 infograf768 added this to the Joomla 4.0 milestone Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet