Browse Source

Merge pull request #26307 from abpframework/issue-#1803

Truncate long "In this document" headings in docs with an ellipsis
pull/26341/head
Yağmur Çelik 4 weeks ago
committed by GitHub
parent
commit
ebfaebb564
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs
  2. 4
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/TableOfContents.cshtml
  3. 1
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js
  4. 14
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/Styles/vs.css
  5. 18
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/Styles/vs.scss

8
modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Localization;
@ -24,7 +25,7 @@ namespace Volo.Docs.Areas.Documents.TagHelpers
private const string LiItemTemplateWithLink = @"<li class='{0}'><span class='plus-icon'><i class='fa fa-{1}'></i></span>{2}{3}</li>";
private const string ListItemAnchor = @"<a href='{0}' {1} class='{2}'>{3}</a>";
private const string ListItemAnchor = @"<a href='{0}' {1} class='{2}' title='{4}'>{3}</a>";
private const string ListItemSpan = @"<span class='{0}'>{1}</span>";
@ -157,10 +158,11 @@ namespace Volo.Docs.Areas.Documents.TagHelpers
sb.Clear();
var additionalAttributes = node.Keywords.IsNullOrEmpty() ? "" : "data-keywords=\"" + node.Keywords.JoinAsString(",") + "\"";
listInnerItem = string.Format(ListItemAnchor, NormalizePath(node.Path), additionalAttributes ,textCss,
listInnerItem = string.Format(ListItemAnchor, NormalizePath(node.Path), additionalAttributes, textCss,
node.Text.IsNullOrEmpty()
? "?"
: sb.Append(node.Text).Append(badgeStringBuilder.ToString()).ToString());
: sb.Append(node.Text).Append(badgeStringBuilder.ToString()).ToString(),
WebUtility.HtmlEncode(node.Text));
}
sb.Clear();

4
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/TableOfContents.cshtml

@ -11,7 +11,7 @@
@foreach (var item in Model)
{
<li class="nav-item @(item.Children.Any() ? "toc-item-has-children" : "")">
<a class="nav-link" href="#@item.Heading.Id">@item.Heading.Text</a>
<a class="nav-link" href="#@item.Heading.Id" title="@item.Heading.Text">@item.Heading.Text</a>
@if (item.Children.Any())
{
@ -28,7 +28,7 @@
@foreach (var child in children)
{
<li class="nav-item @(child.Children.Any() ? "toc-item-has-children" : "")">
<a class="nav-link" href="#@child.Heading.Id">@child.Heading.Text</a>
<a class="nav-link" href="#@child.Heading.Id" title="@child.Heading.Text">@child.Heading.Text</a>
@if (child.Children.Any())
{

1
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js

@ -31,6 +31,7 @@ var doc = doc || {};
var dataKeywords = node.keywords ? `data-keywords="${node.keywords}"` : "";
$li.append(`<span class="plus-icon"> <i class="fa fa-${node.hasChildItems ? 'chevron-right' : node.path === "javascript:;" ? 'has-link' : 'no-link'}"></i></span><a href="${node.path}" ${dataKeywords} class="${textCss}">${node.text}</a>`)
$li.children("a").attr("title", node.text);
if(node.isLazyExpandable){
$li.addClass("lazy-expand");

14
modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/Styles/vs.css

@ -356,6 +356,9 @@ body.scrolledMore:has(#abp-chatbot-container) .alert-criteria .options-header .t
padding: 4px 0;
display: block;
border-bottom: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.docs-page .docs-sidebar .docs-tree-list ul li a:hover {
color: #fff;
@ -696,6 +699,7 @@ body.scrolledMore:has(#abp-chatbot-container) .alert-criteria .options-header .t
font-size: 0.92em;
margin-left: 15px;
border-left: 1px solid #eee;
flex-wrap: nowrap;
}
.docs-page .docs-page-index .docs-inner-anchors .navbar .nav-pills .nav-link {
padding: 3px 14px 4px;
@ -709,6 +713,10 @@ body.scrolledMore:has(#abp-chatbot-container) .alert-criteria .options-header .t
margin-bottom: 1px;
transition: 0.2s;
font-weight: normal;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.docs-page .docs-page-index .docs-inner-anchors .navbar .nav-pills .nav-link.active {
border-left: 1px solid #E83090;
@ -724,9 +732,15 @@ body.scrolledMore:has(#abp-chatbot-container) .alert-criteria .options-header .t
}
.docs-page .docs-page-index .docs-inner-anchors .index-scroll {
margin-left: -30px;
flex-wrap: nowrap;
}
.docs-page .docs-page-index .docs-inner-anchors .index-scroll > .nav-pills {
flex: 1 1 0;
min-width: 0;
}
.docs-page .docs-page-index #scroll-index {
max-height: 38vh;
overflow-x: hidden;
overflow-y: auto;
scrollbar-width: thin;
}

18
modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/Styles/vs.scss

@ -437,6 +437,10 @@ body {
padding: 4px 0;
display: block;
border-bottom: 0;
// Truncate long titles visually; the full text stays in the HTML.
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:hover {
color: #fff;
@ -861,6 +865,8 @@ body {
font-size: 0.92em;
margin-left: 15px;
border-left: 1px solid #eee;
// Without nowrap, items size to their longest heading instead of the panel width.
flex-wrap: nowrap;
.nav-link {
padding: 3px 14px 4px;
@ -874,6 +880,11 @@ body {
margin-bottom: 1px;
transition: 0.2s;
font-weight: normal;
// Truncate long headings visually; the full text stays in the HTML.
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&.active {
border-left: 1px solid #E83090;
@ -903,11 +914,18 @@ body {
.index-scroll {
margin-left: -30px;
flex-wrap: nowrap;
> .nav-pills {
flex: 1 1 0;
min-width: 0;
}
}
}
#scroll-index {
max-height: 38vh;
overflow-x: hidden;
overflow-y: auto;
scrollbar-width: thin;
}

Loading…
Cancel
Save