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

Sidebar redesign #200

Merged
merged 20 commits into from
Jun 16, 2022
Merged

Sidebar redesign #200

merged 20 commits into from
Jun 16, 2022

Conversation

TatianaFomina
Copy link
Contributor

Updates docs sidebar styles. Top level pages become collapsable, collapsed sections state is saved between page reloads.

@talyguryn
Copy link
Member

i don't like this fixed footer. a little bit annoying

image

@talyguryn
Copy link
Member

add an issue to pr please. #174?

@TatianaFomina TatianaFomina linked an issue Jun 9, 2022 that may be closed by this pull request
@talyguryn
Copy link
Member

maybe it will be better if the section with current page will be opened by default on page loading?

also i'd like to see opened section with subpages if i click on parent page.

image

@neSpecc
Copy link
Member

neSpecc commented Jun 9, 2022

These buttons should have hover-styles

image

I've updated the Figma file

image

*/
init(settings, moduleEl) {
this.nodes.sections = Array.from(moduleEl.querySelectorAll('.' + Sidebar.CSS.section));
this.nodes.sections.forEach(section => {
Copy link
Member

Choose a reason for hiding this comment

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

pls, move the handler to the separate method

handleSectionTogglerClick(sectionId, sectionEl, togglerEl, event) {
event.preventDefault();
this.collapsed[sectionId] = !this.collapsed[sectionId];
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(this.collapsed));
Copy link
Member

Choose a reason for hiding this comment

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

pls, move the methods for working with the storage to the separate utility class,

like this (rough example):

class Storage {
  constructor(prefix){
  }

  setItem(name, value){}
  
  getItem(name){}
}

class SidebarStorage extends Storage {
  constructor(){
    super('sidebar-state')

    this.keyName = 'sections-collapsed'
  }

  set(value){
    super.setItem(this.keyName, value)
  }

  get(){
    return super.getItem(this.keyName)
  }
}

* @param {HTMLElement} sectionEl - element of the section to toggle
* @param {HTMLElement} togglerEl - section's toggler button element
* @param {boolean} collapsed - new collapsed state
* @param {boolean} animated - true if state should change with animation
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {boolean} animated - true if state should change with animation
* @param {boolean} [animated] - true if state should change with animation

* @param {boolean} animated - true if state should change with animation
*/
setSectionCollapsed(sectionEl, togglerEl, collapsed, animated = true) {
togglerEl.classList.toggle(Sidebar.CSS.togglerCollapsed, collapsed);
Copy link
Member

Choose a reason for hiding this comment

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

why not use the parent collapsed class at the CSS?

.section--collapsed .toggler {}

src/frontend/js/modules/sidebar.js Show resolved Hide resolved
.docs-sidebar {
border-bottom: 1px solid var(--color-line-gray);
box-sizing: border-box;
padding: 30px 22px;
Copy link
Member

Choose a reason for hiding this comment

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

--layout-padding-vertical
--layout-padding-horizontal

Copy link
Contributor Author

@TatianaFomina TatianaFomina Jun 10, 2022

Choose a reason for hiding this comment

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

--layout-padding-horizontal is 16px now

width: 100vw;

@media (--desktop) {
width: 344px;
Copy link
Member

Choose a reason for hiding this comment

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

use variable please

margin: 0;
z-index: 1;
position: relative;
max-height: 1000px;
Copy link
Member

Choose a reason for hiding this comment

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

add will-change: max-height please

margin: 0;
z-index: 1;
position: relative;
max-height: 1000px;
Copy link
Member

Choose a reason for hiding this comment

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

why there is a 1000px hardcoded?


{% set mainClass = 'docs-sidebar' %}

<div data-module="sidebar" class="{{mainClass}}__wrapper">
Copy link
Member

Choose a reason for hiding this comment

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

Wrong usage of BEM: Element should not include its Block

<docs-sidebar__wrapper>
  <docs-sidebar/>
</docs-sidebar>

The Block should include Elements instead

<docs-sidebar>
  <docs-sidebar__toggler/>
  <docs-sidebar__body/>
</docs-sidebar>

@@ -0,0 +1,54 @@

{% set mainClass = 'docs-sidebar' %}
Copy link
Member

@neSpecc neSpecc Jun 10, 2022

Choose a reason for hiding this comment

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

why do you need this variable if it's almost unused?

{{ svg('aside-logo') }}
</div>
<div class="docs-sidebar__logo-caption">
<span>Powered by CodeX Docs</span>
Copy link
Member

Choose a reason for hiding this comment

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

span looks redundant

* Creates base properties
*/
constructor() {
this.nodes = {};
Copy link
Member

Choose a reason for hiding this comment

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

Describe in jsdoc, please

this.nodes = {};
const storedState = window.localStorage.getItem(LOCAL_STORAGE_KEY);

this.collapsed = storedState ? JSON.parse(storedState) : {};
Copy link
Member

Choose a reason for hiding this comment

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

and this

Copy link
Member

Choose a reason for hiding this comment

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

maybe we can pick up a more understandable name?

init(settings, moduleEl) {
this.nodes.sections = Array.from(moduleEl.querySelectorAll('.' + Sidebar.CSS.section));
this.nodes.sections.forEach(section => {
const id = section.getAttribute('data-id');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const id = section.getAttribute('data-id');
const id = section.dataset.id;

@@ -70,6 +72,13 @@
background: color-mod(var(--color-link-active) blackness(+10%));
}
}

--squircle {
Copy link
Member

Choose a reason for hiding this comment

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

cool

@TatianaFomina
Copy link
Contributor Author

@talyguryn

maybe it will be better if the section with current page will be opened by default on page loading?

if we implement the change you suggest there's going to be strange behaviour when you collapse current section and reload page - section will expand again. I have no idea how to resolve this, so, I suggest not doing this change now

@talyguryn
Copy link
Member

@talyguryn

maybe it will be better if the section with current page will be opened by default on page loading?

if we implement the change you suggest there's going to be strange behaviour when you collapse current section and reload page - section will expand again. I have no idea how to resolve this, so, I suggest not doing this change now

i don't know why i may need to use site with all collapsed sections. anyway it is just an idea

Copy link
Member

@nikmel2803 nikmel2803 left a comment

Choose a reason for hiding this comment

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

works cool 👍

@@ -27,10 +27,12 @@
--layout-padding-vertical: 30px;
--layout-width-aside: 300px;
Copy link
Member

Choose a reason for hiding this comment

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

is this variable still actual?

width: var(--sidebar-width);

@media (--desktop) {
--sidebar-width: 344px;
Copy link
Member

Choose a reason for hiding this comment

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

maybe it would be better to move it to the vars.pcss under the --layout-sidebar-width?

&__content {
border-bottom: 1px solid var(--color-line-gray);
box-sizing: border-box;
padding: var(--layout-padding-vertical) 22px;
Copy link
Member

Choose a reason for hiding this comment

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

use the --layout-padding-horizontal please, and update its value to 22

@TatianaFomina TatianaFomina merged commit 30d9690 into main Jun 16, 2022
@TatianaFomina TatianaFomina deleted the sidebar-update branch June 16, 2022 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui: update the sidebar styles
4 participants