-
Notifications
You must be signed in to change notification settings - Fork 16
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
IBX-1455: Redesign Content Tree for OSS #59
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
393ec91
IBX-556: CT improvements
GrabowskiM 567aba7
cleanup
GrabowskiM 5e824c9
IBX-1455: Redesign Content Tree OSS
GrabowskiM cd8233c
code smells
GrabowskiM ca2cc2b
after cr
GrabowskiM 7202bc3
after cr
GrabowskiM 369a3f9
clean up
GrabowskiM b65d955
after cr
GrabowskiM 6bb7b6c
fix border
GrabowskiM 6da1155
indent
GrabowskiM 6ea12d2
actions popup
GrabowskiM 941e3f7
after demo
GrabowskiM e1f435a
use variables scss
GrabowskiM 24bc7db
ez to ibexa
GrabowskiM 67994bc
change func dec
GrabowskiM 395bf83
after cr
GrabowskiM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 19 additions & 91 deletions
110
src/bundle/Resources/public/js/scripts/admin.content.tree.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,26 @@ | ||
(function (global, doc, React, ReactDOM, eZ, localStorage) { | ||
const KEY_CONTENT_TREE_EXPANDED = 'ez-content-tree-expanded'; | ||
const CLASS_CONTENT_TREE_EXPANDED = 'ez-content-tree-container--expanded'; | ||
const CLASS_CONTENT_TREE_ANIMATE = 'ez-content-tree-container--animate'; | ||
const CLASS_BTN_CONTENT_TREE_EXPANDED = 'ibexa-btn--content-tree-expanded'; | ||
(function (global, doc, React, ReactDOM, eZ) { | ||
const token = doc.querySelector('meta[name="CSRF-Token"]').content; | ||
const siteaccess = doc.querySelector('meta[name="SiteAccess"]').content; | ||
const contentTreeContainer = doc.querySelector('.ez-content-tree-container'); | ||
const contentTreeWrapper = doc.querySelector('.ez-content-tree-container__wrapper'); | ||
const btn = doc.querySelector('.ibexa-btn--toggle-content-tree'); | ||
const contentTreeContainer = doc.querySelector('.ibexa-content-tree-container'); | ||
const contentTreeWrapper = doc.querySelector('.ibexa-content-tree-container__wrapper'); | ||
const { currentLocationPath, treeRootLocationId } = contentTreeContainer.dataset; | ||
const userId = window.eZ.helpers.user.getId(); | ||
let frame = null; | ||
const toggleContentTreePanel = () => { | ||
doc.activeElement.blur(); | ||
contentTreeContainer.classList.toggle(CLASS_CONTENT_TREE_EXPANDED); | ||
contentTreeContainer.classList.add(CLASS_CONTENT_TREE_ANIMATE); | ||
btn.classList.toggle(CLASS_BTN_CONTENT_TREE_EXPANDED); | ||
updateContentTreeWrapperHeight(); | ||
|
||
const isContentTreeExpanded = contentTreeContainer.classList.contains(CLASS_CONTENT_TREE_EXPANDED); | ||
|
||
saveContentTreeExpandedState(userId, isContentTreeExpanded); | ||
eZ.helpers.tooltips.hideAll(); | ||
}; | ||
const updateContentTreeWrapperHeight = () => { | ||
const height = Math.min(window.innerHeight - contentTreeContainer.getBoundingClientRect().top, window.innerHeight); | ||
|
||
contentTreeWrapper.style.height = `${height}px`; | ||
}; | ||
const handleViewportChange = () => { | ||
if (frame) { | ||
cancelAnimationFrame(frame); | ||
} | ||
|
||
frame = requestAnimationFrame(updateContentTreeWrapperHeight); | ||
}; | ||
const saveContentTreeExpandedState = (userId, isExpanded) => { | ||
let expandedState = JSON.parse(localStorage.getItem(KEY_CONTENT_TREE_EXPANDED)); | ||
|
||
if (!(expandedState instanceof Object)) { | ||
expandedState = {}; | ||
} | ||
|
||
expandedState[userId] = isExpanded; | ||
|
||
localStorage.setItem(KEY_CONTENT_TREE_EXPANDED, JSON.stringify(expandedState)); | ||
}; | ||
const isContentTreeExpanded = (userId) => { | ||
const expandedState = JSON.parse(localStorage.getItem(KEY_CONTENT_TREE_EXPANDED)); | ||
|
||
return expandedState && expandedState[userId]; | ||
}; | ||
|
||
ReactDOM.render( | ||
React.createElement(eZ.modules.ContentTree, { | ||
userId, | ||
currentLocationPath, | ||
rootLocationId: parseInt(treeRootLocationId, 10), | ||
restInfo: { token, siteaccess }, | ||
}), | ||
contentTreeWrapper | ||
); | ||
|
||
btn.addEventListener('click', toggleContentTreePanel, false); | ||
|
||
if (isContentTreeExpanded(userId)) { | ||
contentTreeContainer.classList.add(CLASS_CONTENT_TREE_EXPANDED); | ||
btn.classList.add(CLASS_BTN_CONTENT_TREE_EXPANDED); | ||
const removeContentTreeContainerWidth = () => { | ||
contentTreeContainer.style.width = null; | ||
} | ||
const renderTree = () => { | ||
ReactDOM.render( | ||
React.createElement(eZ.modules.ContentTree, { | ||
userId, | ||
currentLocationPath, | ||
rootLocationId: parseInt(treeRootLocationId, 10), | ||
restInfo: { token, siteaccess }, | ||
}), | ||
contentTreeWrapper | ||
); | ||
} | ||
|
||
updateContentTreeWrapperHeight(); | ||
|
||
let transitionCount = 0; | ||
let transitionEventIntervalId = null; | ||
const dispatchContentTreeResizeEvent = () => doc.body.dispatchEvent(new CustomEvent('ez-content-tree-resized')); | ||
const handleContainerTransitionStart = () => { | ||
if (transitionCount == 0) { | ||
transitionEventIntervalId = setInterval(dispatchContentTreeResizeEvent, 30); | ||
} | ||
|
||
transitionCount += 1; | ||
}; | ||
const handleContainerTransitionStop = () => { | ||
transitionCount -= 1; | ||
|
||
if (transitionCount == 0) { | ||
clearInterval(transitionEventIntervalId); | ||
dispatchContentTreeResizeEvent(); | ||
} | ||
}; | ||
|
||
contentTreeContainer.addEventListener('transitionstart', handleContainerTransitionStart, false); | ||
contentTreeContainer.addEventListener('transitioncancel', handleContainerTransitionStop, false); | ||
contentTreeContainer.addEventListener('transitionend', handleContainerTransitionStop, false); | ||
doc.body.addEventListener('ibexa-tb-rendered:ibexa-content-tree', removeContentTreeContainerWidth); | ||
|
||
window.addEventListener('resize', handleViewportChange, { capture: false, passive: true }); | ||
})(window, window.document, window.React, window.ReactDOM, window.eZ, window.localStorage); | ||
renderTree(); | ||
})(window, window.document, window.React, window.ReactDOM, window.eZ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/bundle/Resources/public/scss/ui/modules/_content.tree.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@import 'content-tree/list.item'; | ||
@import 'content-tree/list'; | ||
@import 'content-tree/header'; | ||
@import 'content-tree/popup.actions'; | ||
@import 'content-tree/main'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/bundle/Resources/public/scss/ui/modules/content-tree/_header.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.c-header { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: calculateRem(8px); | ||
padding: 0 calculateRem(4px) calculateRem(8px); | ||
border-bottom: calculateRem(1px) solid $ibexa-color-light-500; | ||
|
||
&__expand-btn { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
margin-left: calculateRem(-4px); | ||
padding: 0 0 0 calculateRem(8px); | ||
width: calculateRem(65px); | ||
height: calculateRem(65px); | ||
|
||
.ibexa-icon + .ibexa-icon { | ||
margin-right: calculateRem(2px); | ||
} | ||
} | ||
|
||
&__name { | ||
display: flex; | ||
align-items: center; | ||
font-size: $ibexa-text-font-size-large; | ||
font-weight: bold; | ||
line-height: calculateRem(33px); | ||
width: 100%; | ||
padding-left: calculateRem(16px); | ||
|
||
.ibexa-icon { | ||
margin-right: calculateRem(8px); | ||
} | ||
} | ||
|
||
&__options { | ||
display: flex; | ||
justify-content: flex-end; | ||
width: calculateRem(80px); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question:
Maybe we can change the name of the class because for me
wrapper
andcontainer
are interchangeable terms for HTML node that groups other nodes or some content