From 8fefb2f03ca501363eb9e07e23579ba29f2d8c99 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Tue, 3 Mar 2020 08:37:40 -0800 Subject: [PATCH] prototyping function for sidebar --- pandas_sphinx_theme/__init__.py | 32 ++++++++++++++ pandas_sphinx_theme/docs-sidebar.html | 30 +------------- pandas_sphinx_theme/static/css/theme.css | 2 +- src/scss/theme.scss | 53 ++++++++++-------------- 4 files changed, 55 insertions(+), 62 deletions(-) diff --git a/pandas_sphinx_theme/__init__.py b/pandas_sphinx_theme/__init__.py index 4421657820..dc5303bac6 100644 --- a/pandas_sphinx_theme/__init__.py +++ b/pandas_sphinx_theme/__init__.py @@ -122,8 +122,40 @@ def get_page_toc_object(): except: return {} + def nav_to_html_list(nav, level=1, include_item_names=False): + if len(nav) == 0: + return '' + ul = [f'") + + # Now add indentation for our level + base_indent = " " * (level - 1) + ul = [base_indent + line for line in ul] + ul = '\n'.join(ul) + return ul + ctx["get_nav_object"] = get_nav_object ctx["get_page_toc_object"] = get_page_toc_object + ctx["nav_to_html_list"] = nav_to_html_list return None diff --git a/pandas_sphinx_theme/docs-sidebar.html b/pandas_sphinx_theme/docs-sidebar.html index a3315cfe97..6488727d13 100644 --- a/pandas_sphinx_theme/docs-sidebar.html +++ b/pandas_sphinx_theme/docs-sidebar.html @@ -5,34 +5,6 @@ diff --git a/pandas_sphinx_theme/static/css/theme.css b/pandas_sphinx_theme/static/css/theme.css index e9fd91829d..a7800e280b 100644 --- a/pandas_sphinx_theme/static/css/theme.css +++ b/pandas_sphinx_theme/static/css/theme.css @@ -1 +1 @@ -hr{border:1px solid #b1b4b6}body{font-family:sans-serif}a{color:#005b81;text-decoration:none}a:hover{color:#e32e00;text-decoration:underline}p.rubric{border-bottom:1px solid #c9c9c9}a.headerlink{color:#c60f0f;font-size:.8em;padding:0 4px;text-decoration:none}a.headerlink:hover{background-color:#c60f0f;color:#fff}div.deprecated p{display:inline}div.deprecated{margin-bottom:10px;margin-top:10px;padding:7px;background-color:#ffe4e4;border:1px solid #f66}div.highlight{background-color:#fff}div.topic{background-color:#eee}pre{padding:10px;background-color:#fafafa;color:#222;line-height:1.2em;border:1px solid #c9c9c9;margin:1.5em 0;-webkit-box-shadow:1px 1px 1px #d8d8d8;-moz-box-shadow:1px 1px 1px #d8d8d8}.viewcode-back{font-family:Arial,sans-serif}div.viewcode-block:target{background-color:#f4debf;border-top:1px solid #ac9;border-bottom:1px solid #ac9}table.field-list{border-collapse:separate;border-spacing:10px;margin-left:1px}table.field-list th.field-name{padding:1px 8px 1px 5px;white-space:nowrap;background-color:#eee}table.field-list td.field-body>p{font-style:italic}table.field-list td.field-body>p>strong{font-style:normal}td.field-body blockquote{border-left:none;margin:0 0 .3em;padding-left:30px}td:first-child{white-space:nowrap}div.seealso dd{margin-top:0;margin-bottom:0}.footer{width:100%;border-top:1px solid #ccc;padding-top:10px}.navbar-brand img{max-height:50px;width:auto;height:3rem}.navbar-light{background:#fff!important;box-shadow:0 .125rem .25rem 0 rgba(0,0,0,.11)}.navbar-nav li a{padding:0 15px}.navbar-nav>.active>.nav-link{font-weight:600;color:#130654!important}.navbar-header a{padding:0 15px}.bd-search{position:relative;padding:1rem 15px;margin-right:-15px;margin-left:-15px;border-bottom:1px solid rgba(0,0,0,.05)}.bd-toc{-ms-flex-order:2;order:2;padding-top:1.5rem;padding-bottom:1.5rem;height:calc(100vh - 2rem);overflow-y:auto}@supports (position:-webkit-sticky) or (position:sticky){.bd-toc{position:-webkit-sticky;position:sticky;top:4rem;height:calc(100vh - 4rem);overflow-y:auto}}.section-nav{padding-left:0;border-left:1px solid #eee;border-bottom:none}.section-nav ul{padding-left:1rem}.toc-entry,.toc-entry a{display:block}.toc-entry a{padding:.125rem 1.5rem;color:#77757a}.toc-entry a:hover{color:rgba(0,0,0,.85);text-decoration:none}.bd-sidebar{-ms-flex-order:0;order:0;border-bottom:1px solid rgba(0,0,0,.1)}@media (min-width:768px){.bd-sidebar{border-right:1px solid rgba(0,0,0,.1)}@supports (position:-webkit-sticky) or (position:sticky){.bd-sidebar{position:-webkit-sticky;position:sticky;top:5rem;z-index:1000;height:calc(100vh - 4rem)}}}@media (min-width:1200px){.bd-sidebar{-ms-flex:0 1 320px;flex:0 1 320px}}.bd-links{padding-top:1rem;padding-bottom:1rem;margin-right:-15px;margin-left:-15px}@media (min-width:768px){@supports (position:-webkit-sticky) or (position:sticky){.bd-links{max-height:calc(100vh - 9rem);overflow-y:auto}}}@media (min-width:768px){.bd-links{display:block!important}}.bd-sidenav{display:none}.bd-toc-link{display:block;padding:.25rem 1.5rem;font-weight:600;color:rgba(0,0,0,.65)}.bd-toc-link:hover{color:rgba(0,0,0,.85);text-decoration:none}.bd-toc-item.active{margin-bottom:1rem}.bd-toc-item.active:not(:first-child){margin-top:1rem}.bd-toc-item.active>.bd-toc-link{color:rgba(0,0,0,.85)}.bd-toc-item.active>.bd-toc-link:hover{background-color:transparent}.bd-toc-item.active>.bd-sidenav{display:block}.bd-sidebar .nav>li>a{display:block;padding:.25rem 1.5rem;font-size:90%;color:rgba(0,0,0,.65)}.bd-sidebar .nav>li>a:hover{color:rgba(0,0,0,.85);text-decoration:none;background-color:transparent}.bd-sidebar .nav>.active:hover>a,.bd-sidebar .nav>.active>a{font-weight:600;color:#130654}.bd-sidebar .nav>li>ul{list-style:none;padding:.25rem 1.5rem}.bd-sidebar .nav>li>ul>li>a{display:block;padding:.25rem 1.5rem;font-size:90%;color:rgba(0,0,0,.65)}.bd-sidebar .nav>li>ul>.active:hover>a,.bd-sidebar .nav>li>ul>.active>a{font-weight:600;color:#130654}h2:before,h3:before,h4:before,h5:before,h6:before{display:block;content:"";height:80px;margin:-80px 0 0}body{padding-top:80px}.toc-h2{font-size:.85rem}.toc-h3{font-size:.75rem}.toc-h4{font-size:.65rem}.toc-entry>.nav-link.active{font-weight:600;color:#130654;background-color:transparent;border-left:2px solid #563d7c}.nav-link:hover{border-style:none}#navbar-main-elements li.nav-item i{font-size:.7rem;padding-left:2px;vertical-align:middle}.bd-toc .nav .nav{display:none}.bd-toc .nav>.active>ul{display:block}div.prev-next-bottom{margin:20px 0}div.prev-next-bottom a.left-prev,div.prev-next-bottom a.right-next{padding:10px;border:1px solid rgba(0,0,0,.2);max-width:45%;overflow-x:hidden;color:rgba(0,0,0,.65)}div.prev-next-bottom a.left-prev{float:left}div.prev-next-bottom a.left-prev:before{content:"<< "}div.prev-next-bottom a.right-next{float:right}div.prev-next-bottom a.right-next:after{content:" >>"}.alert{padding-bottom:0}.alert-info a{color:#e83e8c}h1{font-size:3rem}h2{font-size:2.5rem}i.fab{vertical-align:middle;font-style:normal;font-size:1.5rem;line-height:1.25}i.fa-github-square:before{color:#333}i.fa-twitter-square:before{color:#55acee}.tocsection{border-left:1px solid #eee;padding:.3rem 1.5rem}div.tocsection i{padding-right:.5rem}div.editthispage{padding-bottom:.6rem} \ No newline at end of file +hr{border:1px solid #b1b4b6}body{font-family:sans-serif}a{color:#005b81;text-decoration:none}a:hover{color:#e32e00;text-decoration:underline}p.rubric{border-bottom:1px solid #c9c9c9}a.headerlink{color:#c60f0f;font-size:.8em;padding:0 4px;text-decoration:none}a.headerlink:hover{background-color:#c60f0f;color:#fff}div.deprecated p{display:inline}div.deprecated{margin-bottom:10px;margin-top:10px;padding:7px;background-color:#ffe4e4;border:1px solid #f66}div.highlight{background-color:#fff}div.topic{background-color:#eee}pre{padding:10px;background-color:#fafafa;color:#222;line-height:1.2em;border:1px solid #c9c9c9;margin:1.5em 0;-webkit-box-shadow:1px 1px 1px #d8d8d8;-moz-box-shadow:1px 1px 1px #d8d8d8}.viewcode-back{font-family:Arial,sans-serif}div.viewcode-block:target{background-color:#f4debf;border-top:1px solid #ac9;border-bottom:1px solid #ac9}table.field-list{border-collapse:separate;border-spacing:10px;margin-left:1px}table.field-list th.field-name{padding:1px 8px 1px 5px;white-space:nowrap;background-color:#eee}table.field-list td.field-body>p{font-style:italic}table.field-list td.field-body>p>strong{font-style:normal}td.field-body blockquote{border-left:none;margin:0 0 .3em;padding-left:30px}td:first-child{white-space:nowrap}div.seealso dd{margin-top:0;margin-bottom:0}.footer{width:100%;border-top:1px solid #ccc;padding-top:10px}.navbar-brand img{max-height:50px;width:auto;height:3rem}.navbar-light{background:#fff!important;box-shadow:0 .125rem .25rem 0 rgba(0,0,0,.11)}.navbar-nav li a{padding:0 15px}.navbar-nav>.active>.nav-link{font-weight:600;color:#130654!important}.navbar-header a{padding:0 15px}.bd-search{position:relative;padding:1rem 15px;margin-right:-15px;margin-left:-15px;border-bottom:1px solid rgba(0,0,0,.05)}.bd-toc{-ms-flex-order:2;order:2;padding-top:1.5rem;padding-bottom:1.5rem;height:calc(100vh - 2rem);overflow-y:auto}@supports (position:-webkit-sticky) or (position:sticky){.bd-toc{position:-webkit-sticky;position:sticky;top:4rem;height:calc(100vh - 4rem);overflow-y:auto}}.section-nav{padding-left:0;border-left:1px solid #eee;border-bottom:none}.section-nav ul{padding-left:1rem}.toc-entry,.toc-entry a{display:block}.toc-entry a{padding:.125rem 1.5rem;color:#77757a}.toc-entry a:hover{color:rgba(0,0,0,.85);text-decoration:none}.bd-sidebar{-ms-flex-order:0;order:0;border-bottom:1px solid rgba(0,0,0,.1)}@media (min-width:768px){.bd-sidebar{border-right:1px solid rgba(0,0,0,.1)}@supports (position:-webkit-sticky) or (position:sticky){.bd-sidebar{position:-webkit-sticky;position:sticky;top:5rem;z-index:1000;height:calc(100vh - 4rem)}}}@media (min-width:1200px){.bd-sidebar{-ms-flex:0 1 320px;flex:0 1 320px}}.bd-links{padding-top:1rem;padding-bottom:1rem;margin-right:-15px;margin-left:-15px}@media (min-width:768px){@supports (position:-webkit-sticky) or (position:sticky){.bd-links{max-height:calc(100vh - 9rem);overflow-y:auto}}}@media (min-width:768px){.bd-links{display:block!important}}.bd-sidenav{display:none}.bd-toc-link{display:block;padding:.25rem 1.5rem;font-weight:600;color:rgba(0,0,0,.65)}.bd-toc-link:hover{color:rgba(0,0,0,.85);text-decoration:none}.bd-toc-item.active{margin-bottom:1rem}.bd-toc-item.active:not(:first-child){margin-top:1rem}.bd-toc-item.active>.bd-toc-link{color:rgba(0,0,0,.85)}.bd-toc-item.active>.bd-toc-link:hover{background-color:transparent}.bd-toc-item.active>.bd-sidenav{display:block}.bd-sidebar .nav{list-style:none;padding:.25rem 1.5rem}.bd-sidebar .nav.sidenav_l1{padding:.25rem 0}.bd-sidebar .nav li{width:100%}.bd-sidebar .nav li>a{display:block;padding:.25rem 1.5rem;font-size:90%;color:rgba(0,0,0,.65)}.bd-sidebar .nav li>a:hover{color:rgba(0,0,0,.85);text-decoration:none;background-color:transparent}.bd-sidebar .nav .active:hover>a,.bd-sidebar .nav .active>a{font-weight:600;color:#130654}h2:before,h3:before,h4:before,h5:before,h6:before{display:block;content:"";height:80px;margin:-80px 0 0}body{padding-top:80px}.toc-h2{font-size:.85rem}.toc-h3{font-size:.75rem}.toc-h4{font-size:.65rem}.toc-entry>.nav-link.active{font-weight:600;color:#130654;background-color:transparent;border-left:2px solid #563d7c}.nav-link:hover{border-style:none}#navbar-main-elements li.nav-item i{font-size:.7rem;padding-left:2px;vertical-align:middle}.bd-toc .nav .nav{display:none}.bd-toc .nav>.active>ul{display:block}div.prev-next-bottom{margin:20px 0}div.prev-next-bottom a.left-prev,div.prev-next-bottom a.right-next{padding:10px;border:1px solid rgba(0,0,0,.2);max-width:45%;overflow-x:hidden;color:rgba(0,0,0,.65)}div.prev-next-bottom a.left-prev{float:left}div.prev-next-bottom a.left-prev:before{content:"<< "}div.prev-next-bottom a.right-next{float:right}div.prev-next-bottom a.right-next:after{content:" >>"}.alert{padding-bottom:0}.alert-info a{color:#e83e8c}h1{font-size:3rem}h2{font-size:2.5rem}i.fab{vertical-align:middle;font-style:normal;font-size:1.5rem;line-height:1.25}i.fa-github-square:before{color:#333}i.fa-twitter-square:before{color:#55acee}.tocsection{border-left:1px solid #eee;padding:.3rem 1.5rem}div.tocsection i{padding-right:.5rem}div.editthispage{padding-bottom:.6rem} \ No newline at end of file diff --git a/src/scss/theme.scss b/src/scss/theme.scss index 06544ab379..87b440cc20 100644 --- a/src/scss/theme.scss +++ b/src/scss/theme.scss @@ -176,17 +176,28 @@ } } -.bd-sidebar .nav > { - li > a { - display: block; - padding: 0.25rem 1.5rem; - font-size: 90%; - color: rgba(0, 0, 0, 0.65); +.bd-sidebar .nav { + list-style: none; + padding: 0.25rem 1.5rem; - &:hover { - color: rgba(0, 0, 0, 0.85); - text-decoration: none; - background-color: transparent; + &.sidenav_l1 { + padding: 0.25rem 0rem; + } + + li { + width: 100%; + + > a { + display: block; + padding: 0.25rem 1.5rem; + font-size: 90%; + color: rgba(0, 0, 0, 0.65); + + &:hover { + color: rgba(0, 0, 0, 0.85); + text-decoration: none; + background-color: transparent; + } } } @@ -201,28 +212,6 @@ background-color: transparent; */ } } - - li > ul { - list-style: none; - padding: 0.25rem 1.5rem; - - > { - li > a { - display: block; - padding: 0.25rem 1.5rem; - font-size: 90%; - color: rgba(0, 0, 0, 0.65); - } - - .active { - > a, - &:hover > a { - font-weight: 600; - color: #130654; - } - } - } - } } /* offsetting html anchor titles to adjust for fixed header, https://github.com/pandas-dev/pandas-sphinx-theme/issues/6*/