News:

Join the Facebook Fan Page.

Main Menu

[SMF 2.1]Remixed Breadcrumb

Started by TwitchisMental, January 03, 2022, 02:04:09 PM

Previous topic - Next topic

TwitchisMental

Remixed Breadcrumb Tutorial

In this tutorial we are going to take the default breadcrumb and knock it up a notch. BAM! You cannot view this attachment.

End Result - 
You cannot view this attachment.

I am just using a copy of the default theme for this tutorial.

Step 1. We will need to change some CSS. Go to the CSS folder and open the index.css in your favorite text editor. (I use Notepad++)

Step 2a. Add the following to the very top of the index.css.
:root {
  --breadcrumb_color_1: rgb(85, 126, 160); /* Main Color 1 */
  --breadcrumb_color_2: rgb(226, 233, 243); /* Main Color 2 */
  --breadcrumb_bg: rgb(255, 255, 255); /* The middle of the arrow, this needs to be the same color as the background*/
  --breadcrumb_border_color: rgb(221,211,211); /* BreadCrumb Border Color */
}


Step 2b. Find the navigate section -
/* The navigation list (i.e. linktree) */
.navigate_section {
    padding: 3px 0 0 0;
    width: 100%;
}
#main_content_section .navigate_section {
    margin: 4px 0 0 0;
    padding: 0;
}
.navigate_section ul {
    margin: 4px 0 0 0;
    padding: 0 10px;
    font-size: 0.9em;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 2px;
    box-shadow: 0 -2px 2px rgba(0, 0, 0, 0.08);
}
.navigate_section ul li {
    float: left;
    padding-bottom: 3px;
    line-height: 1.1em;
    color: #444;
    text-shadow: 1px 1px 0 #fff;
}
.navigate_section ul li a, .navigate_section ul li em {
    padding: 4px 0 4px;
    margin-top: -4px;
    display: inline-block;
}
.navigate_section ul li span {
    display: inline-block;
    margin-top: 8px;
}
.navigate_section ul li .dividers {
    color: #3f6b8c;
    font: 83.33%/150% Arial, sans-serif;
    padding: 0 2px 0 6px;
}
.navigate_section ul li .board_moderators a {
    padding: 4px 0;
}

.navigate_section a:hover span {
    text-decoration: underline;
}

Replace With

/*The Breadcrumb*/
/*Main class gives border, flexes it up, and sets width */
.navigate_section {
    padding: 0;
    float: left;
    width: 100%;
    list-style: none;
    border: 1px solid var(--breadcrumb_border_color);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    font-family: sans-serif;
}
#main_content_section .navigate_section {
    margin: 0;
    padding: 0;
}
/*Sets Font-Size*/
.navigate_section ul {
    margin: 0;
    padding: 0;
    font-size: 0.9em;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: var(--breadcrumb_bg);
    background-image: none;
}
/*We don't want the p or span tag to have a margin*/
.navigate_section p {
    margin: 0;
}
.navigate_section ul li span {
    margin-top: 0;
}
/* Fall in line li */
.navigate_section ul li {
    display: inline-flex;
}
/* Don't need these */
.navigate_section ul li .dividers {
    display: none;
}
/*Forming the arrows*/
.navigate_section ul li {
    background-color: var(--breadcrumb_color_1);
    box-sizing: border-box;
    color: var(--breadcrumb_color_2);
    display: inline-flex;
    max-height: 2em;
    padding: .5em 1em .5em 1.5em;
    position: relative;
    text-decoration: none;
    text-shadow: none;
    transition-timing-function: ease-in;
    transition: 0.5s;
    font-weight: 700;
    line-height: 1.1em;
    float: none;
}
.navigate_section ul li:before {
    border-top: 1em solid transparent;
    border-bottom: 1em solid transparent;
    border-left: 1em solid var(--breadcrumb_bg);
    content: "";
    position: absolute;
    top: 0;
    right: -1.25em;
    z-index: 1;
}
.navigate_section ul li:after {
    border-top: 1em solid transparent;
    border-bottom: 1em solid transparent;
    border-left: 1em solid var(--breadcrumb_color_1);
    content: "";
    position: absolute;
    top: 0;
    right: -0.9em;
    transition-timing-function: ease-in;
    transition: 0.5s;
    z-index: 1;
}
/* Colors */
.navigate_section strong {
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li a {
    color: var(--breadcrumb_color_2);
}
.navigate_section ul li a:hover {
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:hover a {
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:hover {
    background-color: var(--breadcrumb_color_2);
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:hover:after {
    border-left-color: var(--breadcrumb_color_2);
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:last-child  {
    background-color: var(--breadcrumb_color_2);
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:last-child a  {
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:last-child::after {
    border-left-color: var(--breadcrumb_color_2);
}

/* Lets Make This Look Better For Mobile */
@media screen and (max-width: 480px) {
.navigate_section {
    font: 1em sans-serif;
    list-style: none;
    border: none;
    display: block;
}
.navigate_section ul {
    display: block;
}
.navigate_section ul li {
    display: block;
    width: max-content;
    margin: 5px 0px 5px 0px;
}
}

Step 2c. If you would like the end to be flat, just change -

.navigate_section ul li:last-child a  {
    color: var(--white);
}
.navigate_section ul li:last-child::after {
    border-left-color: var(--breadcrumb_color_2);
}

to

.navigate_section ul li:last-child a  {   
    color: var(--breadcrumb_color_1);
}
.navigate_section ul li:last-child::after {   
    border: 1px solid transparent;
    border-left: none;
}


Step 3. We need to remove the background being set by a class a bit further down the index.css
Find -
/* If it fits I sits... */
.navigate_section .popup_content, .up_contain {
    background: #fff;
    background-image: linear-gradient(to bottom, #fff 0%, #f1f3f5 95%);
}

Replace With -

/* If it fits I sits... */
.popup_content, .up_contain {
    background: #fff;
    background-image: linear-gradient(to bottom, #fff 0%, #f1f3f5 95%);
}


Step 4. Refresh the page and you should now be seeing -

You cannot view this attachment.


Step 5. Enjoy your new breadcrumb.


Shoutout to Diego Andrés and Sesquipedalian for their help with sorting out a bug.
Original Idea Came From - https://codepen.io/thallysbezerra/embed/NAyEPB?height=316&theme-id=0&default-tab=result
My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

Diego Andrés

Very nice, might use it in the future  :P

SMF Tricks - Free & Premium Responsive Themes for SMF.

Aleksi "Lex" Kilpinen

Have to say, this looks like a cool little trick. Might have to try it out :)
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

TwitchisMental

Quote from: Diego Andrés on January 03, 2022, 02:08:19 PMVery nice, might use it in the future  :P
Thank you, I hope you do :).

Quote from: Aleksi on January 03, 2022, 02:09:48 PMHave to say, this looks like a cool little trick. Might have to try it out :)
Thank you, I hope you do too :).
My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

d3vcho

"Greeting Death as an old friend, they departed this life as equals"

Shades.

ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Mick.


TwitchisMental

My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

Wellwisher

I can see this having really good practical applications on certain themes. Nice work.

Kindred

#9
nicely done....   implemented in a new theme for 2.1 that I am working on for a site.


note for custom work beyond the Curve/Curve2 theme...
Change all instances of these for the colors to match your theme:
rgb(85, 126, 160) (this is the base background color, the border color and the hover font color)
rgb(226, 233, 243) (this is the base font color and the hover background color)

If you don't change ALL of them consistently, you may get some odd effects.

BTW: To see it  test2.turtleshellprod.com
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Nice - I'd done something similar myself recently.

If I can suggest a couple of possible improvements:

First... CSS variables, something akin to this (have not tested)

/*The Breadcrumb*/

/*Main class gives border, font size, and turns off list style*/

.breadcrumb {
  font: 1em sans-serif;
  list-style: none;
  border: 1px solid rgba(221,211,211,1);

  --main-light-color: rgb(226, 233, 243);
  --main-dark-color: rgb(85, 126, 160);
}
/*Flex it up */

.breadcrumb ul {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
/*We don't want the p tag to have a margin*/
.breadcrumb p {
  margin: 0;
}

/* Fall in line li */
.breadcrumb li {
  display: inline-flex;
}

/*Forming the arrows*/
.breadcrumb li {
  background-color: var(--main-dark-color);
  box-sizing: border-box;
  color: var(--main-light-color);
  display: inline-flex;
  max-height: 2em;
  padding: .5em 1em .5em 1.5em;
  position: relative;
  text-decoration: none;
  transition-timing-function: ease-in;
  transition: 0.5s;
  font-weight: 700;
}

.breadcrumb li:before {
  border-top: 1em solid transparent;
  border-bottom: 1em solid transparent;
  border-left: 1em solid #fff;
  content: "";
  position: absolute;
  top: 0;
  right: -1.25em;
  z-index: 1;
}

.breadcrumb li:after {
  border-top: 1em solid transparent;
  border-bottom: 1em solid transparent;
  border-left: 1em solid var(--main-dark-color);
  content: "";
  position: absolute;
  top: 0;
  right: -0.9em;
  transition-timing-function: ease-in;
  transition: 0.5s;
  z-index: 1;
}

/* Colors */

.breadcrumb strong {
    color: var(--main-dark-color);
}

.breadcrumb li a {
    color: var(--main-light-color);
}

.breadcrumb li a:hover {
    color: var(--main-dark-color);
}

.breadcrumb li:hover a {
    color: var(--main-dark-color);
}

.breadcrumb li:hover {
  background-color: var(--main-light-color);
  color: var(--main-dark-color);
}

.breadcrumb li:hover:after {
  border-left-color: var(--main-light-color);
  color: var(--main-dark-color);
}

.breadcrumb li:last-child  {
    background-color: var(--main-light-color);
    color: var(--main-dark-color);
}

.breadcrumb li:last-child a  {
    color: var(--main-dark-color);
}

.breadcrumb li:last-child::after {
    border-left-color: var(--main-light-color);
}

This way you only have to change two colour definitions to restyle the bulk of it to fit a given theme. I'm not sure about the border around the breadcrumb in general or the white fill on the left, couldn't decide if that should be a variable or not.

The other thing is a bit (lot) more fiddly around laying it out on mobile. It will normally wrap to multiple lines which is a bit annoying.

What I did (not the same markup or styling at this but food for thought) was to have the normal breadcrumb trail on desktop... I'd share a link but the site's not open yet.

You cannot view this attachment.

With it collapsing by default on mobile...

You cannot view this attachment.

And using a widget to expand it vertically when called for...

You cannot view this attachment.

Stylewise, well you can see I have Font Awesome loaded but this doesn't make that much odds in the grand scheme of things.

How the toggle is done is by way of an <input type="checkbox"> where the main styling is dropped entirely (appearance: none), then :after is populated with a glyph from Font Awesome and a different glyph is used with :checked on the input box.

The rest of the styling is basically about using :checked as a selector on the input and filtering down the .arrow items thereafter based on 1) a media query and 2) whether or not the checkbox is checked.

It's not a dropin replacement code-wise since SMF doesn't yet have a built in SCSS compiler (I added one to mine), but the relevant styling in case it is of use to anyone:

@media screen and (max-width: 767px) {
.arrowbar {
input ~ .arrow {
display: none;
}

.arrow:first-of-type {
display: block;
}

input:checked ~ .arrow {
display: block;
}

input {
position: absolute;
}

input[type="checkbox"]::after {
content: "\f0c9";
font-family: "Font Awesome 5 Free";
font-weight: 900;
}

.arrow {
padding-left: 50px;
}
}
}
@media screen and (min-width: 768px) {
.arrowbar input {
display: none;
}
}

In case it helps with the relevant placement of the input vs the other elements...

{{#if context.linktree}}
<div class="navigate_section">
<div class="arrowbar">
<input type="checkbox">
{{#each context.linktree}}
<div class="arrow{{#if @last}} active{{/if}}">
{{#if url}}
<a href="{{url}}"><span>{{#if @first}}<i class="fas fa-home fa-fw"></i> {{/if}}{{{name}}}</span></a>
{{else}}
<span>{{{name}}}</span>
{{/if}}
</div>
{{/each}}
</div>
</div>
{{/if}}

Hopefully this will make sense and can be adapted to SMF.

Diego Andrés

Neat.
I used to hide the rest in a dropdown so it's always accessible, the toggle idea is great.

SMF Tricks - Free & Premium Responsive Themes for SMF.

TwitchisMental

Quote from: Arantor on January 04, 2022, 03:20:19 PMNice - I'd done something similar myself recently.

If I can suggest a couple of possible improvements:

First... CSS variables, something akin to this (have not tested)
Yes this is one of those new things I still need to learn/force myself to use. I have noticed them being used in a few themes. Seems like everything is about saving time nowadays. Noted.

Quote from: Arantor on January 04, 2022, 03:20:19 PMThe other thing is a bit (lot) more fiddly around laying it out on mobile. It will normally wrap to multiple lines which is a bit annoying.

What I did (not the same markup or styling at this but food for thought) was to have the normal breadcrumb trail on desktop... I'd share a link but the site's not open yet.

You cannot view this attachment.

With it collapsing by default on mobile...

You cannot view this attachment.

And using a widget to expand it vertically when called for...

You cannot view this attachment.
Oh that is a fantastic idea. I love what you did for mobile view.

Quote from: Arantor on January 04, 2022, 03:20:19 PMStylewise, well you can see I have Font Awesome loaded but this doesn't make that much odds in the grand scheme of things.

How the toggle is done is by way of an <input type="checkbox"> where the main styling is dropped entirely (appearance: none), then :after is populated with a glyph from Font Awesome and a different glyph is used with :checked on the input box.

The rest of the styling is basically about using :checked as a selector on the input and filtering down the .arrow items thereafter based on 1) a media query and 2) whether or not the checkbox is checked.

It's not a dropin replacement code-wise since SMF doesn't yet have a built in SCSS compiler (I added one to mine), but the relevant styling in case it is of use to anyone:

@media screen and (max-width: 767px) {
.arrowbar {
input ~ .arrow {
display: none;
}

.arrow:first-of-type {
display: block;
}

input:checked ~ .arrow {
display: block;
}

input {
position: absolute;
}

input[type="checkbox"]::after {
content: "\f0c9";
font-family: "Font Awesome 5 Free";
font-weight: 900;
}

.arrow {
padding-left: 50px;
}
}
}
@media screen and (min-width: 768px) {
.arrowbar input {
display: none;
}
}

In case it helps with the relevant placement of the input vs the other elements...

{{#if context.linktree}}
<div class="navigate_section">
<div class="arrowbar">
<input type="checkbox">
{{#each context.linktree}}
<div class="arrow{{#if @last}} active{{/if}}">
{{#if url}}
<a href="{{url}}"><span>{{#if @first}}<i class="fas fa-home fa-fw"></i> {{/if}}{{{name}}}</span></a>
{{else}}
<span>{{{name}}}</span>
{{/if}}
</div>
{{/each}}
</div>
</div>
{{/if}}

Hopefully this will make sense and can be adapted to SMF.
I still have so much to learn. Thank you for all of your input :).
My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

Arantor

Quote from: TwitchisMental on January 04, 2022, 09:06:08 PMSeems like everything is about saving time nowadays. Noted.

Saving time isn't so much the goal here, more saving effort - instead of find/replacing the same colour in a bunch of places, you set it once and just reuse that elsewhere. For Kindred's case for example he'd only need to set the colour once.

I went further down the road and glued in an SCSS parser so I could use variables on a much more extensive basis and have my CSS minified after doing so, but this is not a small change nor for the faint of heart. (It's like an SMF 3.0 level change. But my last site had 6 themes and I wanted to make as much reuse as possible of CSS. When you have SCSS at your control you can do 'include this file' level stuff and variables are everywhere, it made maintaining those so much easier.)

Quote from: TwitchisMental on January 04, 2022, 09:06:08 PMI still have so much to learn. Thank you for all of your input :).

There's always more to learn :) I'm sure you'll be teaching me something soon enough!

Diego Andrés

I attempted mine today with Arantor's idea
I'd say it's okay for a clueless javascript guy like me

You cannot view this attachment.

SMF Tricks - Free & Premium Responsive Themes for SMF.

TwitchisMental

Quote from: Diego Andrés on January 06, 2022, 10:49:17 PMI attempted mine today with Arantor's idea
I'd say it's okay for a clueless javascript guy like me

You cannot view this attachment.
Looks pretty good :).
My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

Wellwisher

#16
Quote from: Diego Andrés on January 06, 2022, 10:49:17 PMI attempted mine today with Arantor's idea

Defo looks gorgous with the default colour scheme. I would use a location icon instead. Well done.

TwitchisMental

So I have added a small tweak for mobile view, albeit not nearly as cool as what Arantor and Diego have done with theirs XD.

Screenshot -

You cannot view this attachment.

Open up the css file again and just add this below the previously added css.  -

@media screen and (max-width: 767px) {
.breadcrumb {
  font: 1em sans-serif;
  list-style: none;
  border: none;
}

.breadcrumb ul {
  display: block;
}

.breadcrumb li {
  display: block;
  width: max-content;
  margin: 5px 0px 5px 0px;
}
}
My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

TwitchisMental

Another small tweak for those who are curious. You can make the final section end flat instead. (Similar to Arantor's example above)
 
Screenshot -

You cannot view this attachment.

Find

.breadcrumb li:last-child::after {
    border-left-color: rgb(226, 233, 243);
}

Replace with
.breadcrumb li:last-child::after {
    border: 1px solid transparent;
}
My SMF Themes - Remixed Breadcrumb Tutorial -
My SMF 2.1 Themes Demo
Need a Custom SMF Theme? Send me a message.

Diego Andrés

Uh yes, I suppose that makes a lot of sense since it's not going anywhere anymore  :laugh:

SMF Tricks - Free & Premium Responsive Themes for SMF.

Advertisement: