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

Making the PIN panel collapsable would get better experience. #1898

Open
peterzhangsnail opened this issue Mar 12, 2020 · 9 comments · May be fixed by tc39/ecmarkup#178
Open

Making the PIN panel collapsable would get better experience. #1898

peterzhangsnail opened this issue Mar 12, 2020 · 9 comments · May be fixed by tc39/ecmarkup#178

Comments

@peterzhangsnail
Copy link

First of all, the idea of providing a human-readable version is remarkable, thank you, guys! It just happens when you want to pin a lot of links to do a comparison or summarizing. The PIN panel would take over all the room of the sidebar and making it hard to handle the TOC.
2020-03-12_135438

@peterzhangsnail
Copy link
Author

After you guys clone or download this repo and run npm build to get the ouput. Here's a DIY way to add the PIN list toggle button to the spec.
It's all about modifying two files:
out/ecmarkup.js
out/ecmarkup.css
In the out/ecmarkup.js, just add these code to the end of it:

//----------------------------------------------------------------------------------
//add toggle icon to the menu
window.onload = function(){
  var MenuPins = document.getElementById('menu-pins');
  var MenuPaneHeader = MenuPins.querySelectorAll('.menu-pane-header')[0];

  var MenuPaneHeaderToggle = document.createElement('span');
  var MenuPaneHeaderToggleIcon = document.createTextNode('◢');
  MenuPaneHeaderToggle.appendChild(MenuPaneHeaderToggleIcon);
  MenuPaneHeaderToggle.setAttribute('class','MenuPinsNormal MenuPinsNormalCollpase');
  MenuPaneHeaderToggle.setAttribute('id','MenuPaneHeaderToggle');
  MenuPaneHeaderToggle.onclick = MenuPinsToggle; //add event that toggles the pin list

  MenuPaneHeader.appendChild(MenuPaneHeaderToggle);
};

//toggle the MenuPinsList 
function MenuPinsToggle(){
  var MenuPinsList = document.getElementById('menu-pins-list');
  var MenuPaneHeaderToggle = document.getElementById('MenuPaneHeaderToggle');

  if(MenuPinsList.style.display === 'none'){
    MenuPinsList.style.display = 'block';
    MenuPaneHeaderToggle.setAttribute('class','MenuPinsNormal MenuPinsNormalCollpase');
  }else{
    MenuPinsList.style.display = 'none';
    MenuPaneHeaderToggle.setAttribute('class','MenuPinsNormal');
  }
}

And in the out/ecmarkup.css, add these to the end of it:

.MenuPinsNormal {
  cursor: pointer;
  position: absolute;
  right:0px;
  display: inline-block;
  transform: rotate(45deg) translate(-15px, 10px);
}

.MenuPinsNormalCollpase {
  transform: rotate(-45deg) translate(-15px, -15px);
}

Then you will get your collapsable DIY PIN list.
2020-03-16_133638
2020-03-16_133617

@ljharb
Copy link
Member

ljharb commented Mar 16, 2020

@peterzhangsnail would you be interested in making a PR to https://github.com/bterlson/ecmarkup to add that functionality?

@ljharb ljharb reopened this Mar 16, 2020
@peterzhangsnail
Copy link
Author

It has flaws. The solution mentioned before only solves this problem on PC. How it may look on the mobile device has not been tested. So a thorough test is necessary. And to your invitation, the answer is yes, of course.

@peterzhangsnail
Copy link
Author

@ljharb I have been running a few tests and make sure that all the media rules get considered. It seems fine to me now. Then replace element.css in the ecmarkup/css/ and menu.js in the ecmarkup/js/ directory with the updated files, run npm run build after that. The ouput works well.

@ljharb
Copy link
Member

ljharb commented Mar 16, 2020

If that could be done in ecmarkup itself, rather than just in this repo, that would be ideal.

@peterzhangsnail
Copy link
Author

@ljharb It can be done, just need to add a file 'pinCollpase.js' to replace the two files with our updated files and change the build script in the package.json into "build": "node pinCollapse.js && npm run build-master"

@peterzhangsnail
Copy link
Author

peterzhangsnail commented Mar 16, 2020

@ljharb Here's the pinCollapse.js, just make it so,bro.(Of course, use it after double check)
pinCollapse.zip

@ljharb
Copy link
Member

ljharb commented Mar 17, 2020

Any chance you could make a PR to ecmarkup for that?

@ljharb ljharb reopened this Mar 17, 2020
@peterzhangsnail
Copy link
Author

peterzhangsnail commented Mar 17, 2020

@ljharb Launch a pull request there, just waiting for the owner's test and merge.

@peterzhangsnail peterzhangsnail linked a pull request Mar 18, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants