Skip to content

Issues/149 - rework of navigation component #153

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

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
02ef6fc
#144 fixed multinavigation comp dark themes
smcgrath0 Aug 11, 2020
177ada5
#144 added to hatch file
smcgrath0 Aug 11, 2020
1a8490d
#144 updated with latest version of percli hatch
smcgrath0 Aug 12, 2020
c213bb1
#149 added nested dropdowns and fixed desktop nav when scrolling
smcgrath0 Aug 12, 2020
63fe9bc
#149 added hamburger menu to mobile for nav comp
smcgrath0 Aug 13, 2020
8c0ae9a
#149 fixed root link dark styles; added dialog for toggletype
smcgrath0 Aug 13, 2020
6118944
#149 fixed colors if mobile tab is open
smcgrath0 Aug 13, 2020
0e15b6a
#149 adjusted navigation models
smcgrath0 Aug 17, 2020
b730d40
#149 updated navigation comp to use navigationnested comp
smcgrath0 Aug 17, 2020
a1337a0
#149 added navgiation nested recursive component
smcgrath0 Aug 17, 2020
9d849e3
#149 fixed save error for rootpage of navigation comp
smcgrath0 Aug 17, 2020
83356f2
#149 added hamburger alignment
smcgrath0 Aug 18, 2020
a27e09d
#149 fixed hover/active colors for links in nav
smcgrath0 Aug 18, 2020
1c02ae7
#149 removed commented code
smcgrath0 Aug 18, 2020
ad4fada
#149 links change pop out direction based on where on screen
smcgrath0 Aug 19, 2020
8aa5b4e
#149 added min width custom class
smcgrath0 Aug 21, 2020
bf4c16f
#149 added dialog to nav component for toggleType, bg transparency, m…
smcgrath0 Aug 21, 2020
8aeb233
#149 added dialog styles/conditions
smcgrath0 Aug 21, 2020
4d04be1
#149 nav component tablet styles/conditionals
smcgrath0 Aug 21, 2020
c352cd5
Merge branch 'develop' of https://github.com/headwirecom/themeclean-f…
smcgrath0 Aug 26, 2020
2902a21
#149 fixed dialog defaults
smcgrath0 Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 90 additions & 10 deletions core/src/main/java/com/themecleanflex/models/NavigationModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"x-source": "inject",
"x-form-label": "Exclude pages Excluded in Sitemap",
"x-form-type": "materialswitch",
"x-form-default": false
"x-default": false
},
"justifyitems": {
"type": "string",
Expand All @@ -60,6 +60,45 @@
}
}
},
"levels": {
"type": "string",
"x-source": "inject",
"x-form-type": "number",
"x-form-label": "Levels",
"x-default": 1,
"x-form-min": 1
},
"mobiledropdownbg": {
"type": "string",
"x-source": "inject",
"x-form-label": "Transparent mobile dropdown background",
"x-form-type": "materialswitch",
"x-default": false
},
"showmobilemenuontablet": {
"type": "string",
"x-source": "inject",
"x-form-label": "Show Mobile menu on iPad/tablets",
"x-form-type": "materialswitch",
"x-default": false
},
"toggletype": {
"type": "string",
"x-source": "inject",
"x-form-label": "Collapse Style",
"x-form-type": "materialradio",
"x-default": "accordion",
"properties": {
"toggle": {
"x-form-name": "Toggle",
"x-form-value": "toggle"
},
"accordion": {
"x-form-name": "Accordion",
"x-form-value": "accordion"
}
}
},
"bgref": {
"x-form-type": "reference",
"type": "object",
Expand Down Expand Up @@ -340,7 +379,7 @@ public class NavigationModel extends AbstractComponent {
@Inject
private String rootpage;

/* {"type":"string","x-source":"inject","x-form-label":"Exclude pages Excluded in Sitemap","x-form-type":"materialswitch","x-form-default":false} */
/* {"type":"string","x-source":"inject","x-form-label":"Exclude pages Excluded in Sitemap","x-form-type":"materialswitch","x-default":false} */
@Inject
private String excludesitemapexcludes;

Expand All @@ -349,6 +388,24 @@ public class NavigationModel extends AbstractComponent {
@Default(values ="end")
private String justifyitems;

/* {"type":"string","x-source":"inject","x-form-type":"number","x-form-label":"Levels","x-default":1,"x-form-min":1} */
@Inject
@Default(values ="1")
private String levels;

/* {"type":"string","x-source":"inject","x-form-label":"Transparent mobile dropdown background","x-form-type":"materialswitch","x-default":false} */
@Inject
private String mobiledropdownbg;

/* {"type":"string","x-source":"inject","x-form-label":"Show Mobile menu on iPad/tablets","x-form-type":"materialswitch","x-default":false} */
@Inject
private String showmobilemenuontablet;

/* {"type":"string","x-source":"inject","x-form-label":"Collapse Style","x-form-type":"materialradio","x-default":"accordion","properties":{"toggle":{"x-form-name":"Toggle","x-form-value":"toggle"},"accordion":{"x-form-name":"Accordion","x-form-value":"accordion"}}} */
@Inject
@Default(values ="accordion")
private String toggletype;

/* {"type":"string","x-source":"inject","x-form-label":"Anchor Name","x-form-type":"text"} */
@Inject
private String anchorname;
Expand Down Expand Up @@ -455,7 +512,7 @@ public String getRootpage() {
return rootpage;
}

/* {"type":"string","x-source":"inject","x-form-label":"Exclude pages Excluded in Sitemap","x-form-type":"materialswitch","x-form-default":false} */
/* {"type":"string","x-source":"inject","x-form-label":"Exclude pages Excluded in Sitemap","x-form-type":"materialswitch","x-default":false} */
public String getExcludesitemapexcludes() {
return excludesitemapexcludes;
}
Expand All @@ -465,6 +522,21 @@ public String getJustifyitems() {
return justifyitems;
}

/* {"type":"string","x-source":"inject","x-form-label":"Transparent mobile dropdown background","x-form-type":"materialswitch","x-default":false} */
public String getMobiledropdownbg() {
return mobiledropdownbg;
}

/* {"type":"string","x-source":"inject","x-form-label":"Show Mobile menu on iPad/tablets","x-form-type":"materialswitch","x-default":false} */
public String getShowmobilemenuontablet() {
return showmobilemenuontablet;
}

/* {"type":"string","x-source":"inject","x-form-label":"Collapse Style","x-form-type":"materialradio","x-default":"accordion","properties":{"toggle":{"x-form-name":"Toggle","x-form-value":"toggle"},"accordion":{"x-form-name":"Accordion","x-form-value":"accordion"}}} */
public String getToggletype() {
return toggletype;
}

/* {"type":"string","x-source":"inject","x-form-label":"Anchor Name","x-form-type":"text"} */
public String getAnchorname() {
return anchorname;
Expand Down Expand Up @@ -578,13 +650,23 @@ public String getContentname() {

/* {"type":"string","x-source":"inject","x-form-type":"number","x-form-label":"Levels","x-form-default":1,"x-form-min":1} */
public String getLevels() {
return "2";
return levels == null ? "1" : levels;
}

public String getExcludeSitemapExcludes() {
return excludesitemapexcludes == null ? "false" : excludesitemapexcludes;
}

public String getRootPage() {
if(rootpage == null) {
PerPage currentPage = getResource().adaptTo(PerPage.class);
if(currentPage != null) {
return currentPage.getPath();
}
}
return rootpage;
}

public String getRootPageTitle() {
PerPageManager ppm = getResource().getResourceResolver().adaptTo(PerPageManager.class);
PerPage page = ppm.getPage(getRootpage());
Expand All @@ -609,10 +691,9 @@ public List<Page> getChildrenPages() {
PerPage page = ppm.getPage(getRootpage());
if (page != null) {
for (PerPage child : page.listChildren()) {
if(excludeSitemap && child.getContentProperty(EXCLUDE_FROM_SITEMAP, false)) {
continue;
}
if (!child.getPath().equals(page.getPath())) {
if ( !(excludeSitemap && child.getContentProperty(EXCLUDE_FROM_SITEMAP, false))
&& (!child.getPath().equals(page.getPath()))
) {
childPages.add(new Page(child, levels, excludeSitemap));
}
}
Expand Down Expand Up @@ -651,13 +732,12 @@ public Boolean getHasChildren() {

public List<Page> getChildrenPages() {
List<Page> childPages = new ArrayList<Page>();
System.out.println();
if(page != null) {
for (PerPage child: page.listChildren()) {
if(excludeSitemap && child.getContentProperty(EXCLUDE_FROM_SITEMAP, false)) {
continue;
}
if(!child.getPath().equals(page.getPath())) {
if(levels > 0 && !child.getPath().equals(page.getPath())) {
childPages.add(new Page(child, levels-1, excludeSitemap));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.themecleanflex.models;

import com.peregrine.nodetypes.models.AbstractComponent;
import com.peregrine.nodetypes.models.IComponent;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;

/*
//GEN[:DATA
{
"definitions": {
"Navigationnested": {
"type": "object",
"x-type": "component",
"properties": {}
}
},
"name": "Navigationnested",
"componentPath": "themecleanflex/components/navigationnested",
"package": "com.themecleanflex.models",
"modelName": "Navigationnested",
"classNameParent": "AbstractComponent"
}
//GEN]
*/

//GEN[:DEF
@Model(
adaptables = Resource.class,
resourceType = "themecleanflex/components/navigationnested",
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL,
adapters = IComponent.class
)
@Exporter(
name = "jackson",
extensions = "json"
)

//GEN]
public class NavigationnestedModel extends AbstractComponent {

public NavigationnestedModel(Resource r) { super(r); }

//GEN[:INJECT

//GEN]

//GEN[:GETTERS

//GEN]

//GEN[:CUSTOMGETTERS
//GEN]

}
52 changes: 35 additions & 17 deletions fragments/navigation/hatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,50 @@ module.exports = {
f.wrap($, 'themecleanflex-components-block')
f.bindAttribute($.parent(),'model','model')

let justify = `{
let navClasses = `{
'justify-start': model.justifyitems === 'start',
'justify-center': model.justifyitems === 'center',
'justify-end': model.justifyitems === 'end'
'justify-end': model.justifyitems === 'end',
'md:flex-row': !model.showmobilemenuontablet,
'lg:flex-row': model.showmobilemenuontablet
}`

f.bindAttribute($, 'class', justify, false);
f.bindAttribute($, 'class', navClasses, false);

let rootItem = $.find('div').eq(0);
f.addFor( rootItem, 'model.childrenPages', 'child' );
f.bindAttribute($.find('ul'), 'class', `{ 'flex' : menuActive, 'hidden md:flex' : ( !menuActive && !model.showmobilemenuontablet ), 'hidden lg:flex' : ( !menuActive && model.showmobilemenuontablet ), 'md:flex-row md:flex-wrap': !model.showmobilemenuontablet, 'lg:flex-row lg:flex-wrap': model.showmobilemenuontablet}`, false);
f.bindAttribute($.find('ul'), 'style', "`list-style-type: none;padding: 0px;`", false);
f.bindAttribute($.find('ul'), 'ref', "`parent`");

let rootLink = $.find('a');
f.mapField(rootLink, 'child.title', "model.childrenPages", "title");
f.bindAttribute(rootLink, 'href', "child.childrenPages.length > 0 ? false : child.path +'.html'");
f.bindAttribute(rootLink, 'class', "model.colorscheme === 'dark' ? 'text-gray-200 hover:bg-gray-200 hover:text-black' : 'text-black hover:bg-black hover:text-gray-200'",false);

let nested = $.find('div').eq(1);
f.addIf(nested, 'child.hasChildren && child.childrenPages && child.childrenPages.length > 0')
f.addFor($.find('li.children').first(), 'model.childrenPages', 'child')
f.bindAttribute($.find('li.children').first(), 'ref', "`directChildren`");
f.bindAttribute($.find('li.children').first(),'class', "`${active[i] ? 'active' : ''}`", false)
f.bindAttribute($.find('li.children > div').first(),'class', "`${active[i] ? 'bg-secondary' : ''}`", false)
f.bindAttribute($.find('li.children a').first(),'href',f.pathToUrl('child.path'))
f.bindAttribute($.find('li.children a').first(),'class',"`${active[i] ? 'active' : ''}`", false)
f.mapField($.find('li.children a').first(),'child.title')

let nestedLink = $.find('a').eq(1);
f.addFor( nestedLink, 'child.childrenPages', 'subchild' );
f.mapField( nestedLink, 'subchild.title' );
f.bindAttribute(nestedLink, 'href', "subchild.path + '.html'");
f.bindAttribute(nestedLink, 'class', "model.colorscheme === 'dark' ? 'text-gray-200 hover:bg-gray-200 hover:text-black' : 'text-black hover:bg-black hover:text-gray-200'",false);
f.replace( $.find('ul.nested').eq(0), '<themecleanflex-components-navigationnested v-bind:model="child" v-bind:parentmodel="model" style="list-style-type: none;padding: 0px;"></themecleanflex-components-navigationnested>')
f.addIf($.find('li.children themecleanflex-components-navigationnested').first(), 'child.hasChildren && child.childrenPages && child.childrenPages.length > 0');
f.bindAttribute($.find('li.children themecleanflex-components-navigationnested').first(), 'class', "`${active[i] ? 'lg:hidden' : 'hidden'}`", false)
f.bindAttribute($.find('li.children themecleanflex-components-navigationnested').first(), 'toggleitem', "toggleItem")
f.bindAttribute($.find('li.children themecleanflex-components-navigationnested').first(), 'nestedliststyle', "nestedListStyle[i]")

let nestedArrow = $.find('svg');
f.bindAttribute(nestedArrow, "style", "`${active[i] ? 'transform:rotate(180deg);' : 'transform:rotate(0deg);'}`")
f.bindEvent(nestedArrow, 'click', "(e) => { toggleItem(i, e, active); }")
f.addIf(nestedArrow, 'child.hasChildren && child.childrenPages && child.childrenPages.length > 0');

f.addElse($);
$.parent().prepend('<div class="p-5" v-if="isEditAndEmpty">{{isEditAndEmpty}}</div>')

let hamburgerClasses = `{
'self-start': model.justifyitems === 'start',
'self-end': model.justifyitems === 'end',
'md:hidden': !model.showmobilemenuontablet,
'lg:hidden': model.showmobilemenuontablet
}`

let hamburger = `<div class="font-bold text-xl cursor-pointer block transform-rotate-90 m-3" v-bind:class="${hamburgerClasses}" style="width:24px;" v-on:click="toggleMenu">|||</div>`
$.prepend(hamburger)
}
}
41 changes: 40 additions & 1 deletion fragments/navigation/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"x-source": "inject",
"x-form-label": "Exclude pages Excluded in Sitemap",
"x-form-type": "materialswitch",
"x-form-default": false
"x-default": false
},
"justifyitems": {
"type": "string",
Expand All @@ -37,6 +37,45 @@
}
}
},
"levels": {
"type":"string",
"x-source":"inject",
"x-form-type":"number",
"x-form-label":"Levels",
"x-default":1,
"x-form-min":1
},
"mobiledropdownbg": {
"type": "string",
"x-source": "inject",
"x-form-label": "Transparent mobile dropdown background",
"x-form-type": "materialswitch",
"x-default": false
},
"showmobilemenuontablet": {
"type": "string",
"x-source": "inject",
"x-form-label": "Show Mobile menu on iPad/tablets",
"x-form-type": "materialswitch",
"x-default": false
},
"toggletype": {
"type": "string",
"x-source": "inject",
"x-form-label": "Collapse Style",
"x-form-type": "materialradio",
"x-default": "accordion",
"properties": {
"toggle": {
"x-form-name": "Toggle",
"x-form-value": "toggle"
},
"accordion": {
"x-form-name": "Accordion",
"x-form-value": "accordion"
}
}
},
"bgref": {
"x-form-type": "reference",
"$ref": "fragments/block/model.json#/definitions/Block"
Expand Down
Loading