Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/Elastic.Documentation.Site/Assets/api-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@
}

/*
* The breadcrumbs, with Copy page at the right end of the same row. When both do not fit on one line Copy page wraps
* onto its own line under the breadcrumbs, at their left edge, as on a phone. Lined up on the last line of text, so
* the button sits level with the breadcrumbs on one line and under them when wrapped.
* The breadcrumbs, with Copy page at the right end of the same row. Below 1024px, when both do not fit on one line,
* Copy page wraps onto its own line under the breadcrumbs, at their left edge, as on a phone. Lined up on the last line
* of text, so the button sits level with the breadcrumbs on one line and under them when wrapped. From 1024px up the
* row does not wrap (see the media block below).
*/
.api-page-toolbar {
display: flex;
Expand All @@ -204,19 +205,31 @@
}

/* Beside the sidebar the breadcrumb row is centred on the first line of the API selector's name.
Its own 24px top padding and the page's pt-6 would put it about 22px lower. */
Its own 24px top padding and the page's pt-6 would put it about 22px lower.
On desktop Copy page stays at the top right and never wraps: the trail shrinks and wraps its own crumbs beside it. */
@media (width >= 1024px) {
.api-page-main .api-page-toolbar {
margin-top: calc(var(--spacing) * -2.5);
/* The breadcrumbs' 36px min-height already leaves 10px under their line, so a wrapped Copy page sits 12px under it. */
row-gap: 2px;
flex-wrap: nowrap;
Comment thread
infra-vault-gh-plugin-prod[bot] marked this conversation as resolved.
Resolved
align-items: first baseline;
}

.api-page-main .api-page-toolbar #breadcrumbs {
box-sizing: border-box;
flex: 1 1 0;
min-width: 0;
Comment thread
infra-vault-gh-plugin-prod[bot] marked this conversation as resolved.
Resolved
min-height: 36px;
padding-top: 0;
}

/* A flex item's minimum width is its longest word, so min-width: 0 on the trail alone lets a long label run under Copy page. */
.api-page-main .api-page-toolbar #breadcrumbs li {
overflow-wrap: anywhere;
}

.api-page-main .api-page-toolbar .api-page-actions {
margin-left: auto;
}
}

.api-page-actions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
namespace Elastic.Documentation.Journeys.Tests.Areas;

/// <summary>
/// The Copy page button ends the breadcrumb row, or wraps under the breadcrumbs when the two do not fit on one line.
/// The Copy page button ends the breadcrumb row. It stays there from 1024px up, and below that wraps under the
/// breadcrumbs when the two do not fit on one line.
/// Its menu is a popover placed by floating.ts, so where it opens, and whether it stays inside the row rather than over
/// the sidebar, only real layout can tell. The journey DSL cannot assert a box is inside another, hence this test.
/// </summary>
Expand All @@ -29,7 +30,7 @@
{
// A phone, where Copy page wraps under the breadcrumbs at the left; a laptop, where it can sit beside the
// sidebar; and a wide screen, where it ends the breadcrumb row at the right.
foreach (var width in new[] { 375, 1280, 1680 })

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / journeys / journeys build

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / journeys / journeys build

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 33 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)
{
await page.SetViewportAsync(width, 900, 1).ConfigureAwait(false);
await Task.Delay(500).ConfigureAwait(false);
Expand Down Expand Up @@ -139,16 +140,16 @@
}

[Test]
public async Task CopyPage_NeverMakesTheBreadcrumbTrailWrap()
public async Task CopyPage_StaysAtTheRightOfTheRowOnDesktopAndWrapsUnderTheTrailBelow()
{
var lines = new List<string>();
await WithPageAsync(async page =>
{
// When the trail and Copy page do not fit on one line, Copy page wraps under the trail rather than the trail
// wrapping to keep it beside: the trail has as many lines with Copy page as without it. And it is beside the
// trail where the article column is wide enough (900px, 1680px) and under it where it is not (375px, 1280px,
// where the rail narrows the column), so it is not always one or the other.
foreach (var width in new[] { 375, 900, 1280, 1680 })
// Below 1024px, when the trail and Copy page do not fit on one line, Copy page wraps under the trail rather
// than the trail wrapping to keep it beside: the trail has as many lines with Copy page as without it. From
// 1024px up the row does not wrap. Copy page stays beside the trail at the right end of the row, and the trail
// wraps its own crumbs to make room (1024px is the narrowest the article column gets beside the sidebar and rail).
foreach (var width in new[] { 375, 900, 1024, 1280, 1680 })

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / journeys / journeys build

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / journeys / journeys build

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 152 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)
{
await page.SetViewportAsync(width, 900, 1).ConfigureAwait(false);
await Task.Delay(500).ConfigureAwait(false);
Expand All @@ -160,18 +161,21 @@
const withCopy = trailLines();
// Beside the trail when the button starts on the trail's last line, under it when it starts below.
const trail = [...document.querySelectorAll('#breadcrumbs li')].map(li => li.getBoundingClientRect());
const beside = copy.getBoundingClientRect().top < Math.max(...trail.map(r => r.bottom));
const button = copy.getBoundingClientRect();
const beside = button.top < Math.max(...trail.map(r => r.bottom));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Assert first-line alignment at the narrow desktop widths. beside only checks that Copy page starts above the bottom of the last crumb, so the snapshot still passes if the button drops to the last line of a wrapped trail while staying at the right edge. Compare the button label’s vertical position with the first crumb line at 1024px and 1280px.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

const atTheRight = Math.abs(button.right - document.querySelector('.api-page-toolbar').getBoundingClientRect().right) <= 1;
const overlapsTheTrail = trail.some(r => r.right > button.left && r.top < button.bottom && r.bottom > button.top);
copy.style.display = 'none';
const without = trailLines();
copy.style.display = '';
return { same: withCopy === without, beside };
return { same: withCopy === without, beside, atTheRight, overlapsTheTrail };
})()
"""
).ConfigureAwait(false);
lines.Add(
string.Create(
CultureInfo.InvariantCulture,
$"{width}px: Copy page beside the trail {state.GetProperty("beside").GetBoolean()}, trail wraps the same with and without it {state.GetProperty("same").GetBoolean()}"
$"{width}px: Copy page beside the trail {state.GetProperty("beside").GetBoolean()}, at the right end of the row {state.GetProperty("atTheRight").GetBoolean()}, over the trail {state.GetProperty("overlapsTheTrail").GetBoolean()}, trail wraps the same with and without it {state.GetProperty("same").GetBoolean()}"
)
);
}
Expand All @@ -182,10 +186,50 @@
.Should()
.MatchInlineSnapshot(
"""
375px: Copy page beside the trail False, trail wraps the same with and without it True
900px: Copy page beside the trail True, trail wraps the same with and without it True
1280px: Copy page beside the trail False, trail wraps the same with and without it True
1680px: Copy page beside the trail True, trail wraps the same with and without it True
375px: Copy page beside the trail False, at the right end of the row False, over the trail False, trail wraps the same with and without it True
900px: Copy page beside the trail True, at the right end of the row True, over the trail False, trail wraps the same with and without it True
1024px: Copy page beside the trail True, at the right end of the row True, over the trail False, trail wraps the same with and without it False
1280px: Copy page beside the trail True, at the right end of the row True, over the trail False, trail wraps the same with and without it False
1680px: Copy page beside the trail True, at the right end of the row True, over the trail False, trail wraps the same with and without it True
"""
);
}

[Test]
public async Task CopyPage_KeepsALongCrumbOffTheButtonOnDesktop()
{
var lines = new List<string>();
await WithPageAsync(async page =>
{
// A crumb is a flex item whose minimum width is its longest word. Without overflow-wrap a word wider than the
// trail runs under Copy page, so the last crumb gets one that no trail on 1024px can hold.
foreach (var width in new[] { 1024, 1280 })

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / journeys / journeys build

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / journeys / journeys build

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)

Check warning on line 206 in tests/Elastic.Documentation.Journeys.Tests/Areas/ApiCopyPageMenuTests.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1861)
{
await page.SetViewportAsync(width, 900, 1).ConfigureAwait(false);
await Task.Delay(500).ConfigureAwait(false);
var clear = await page.EvaluateAsync(
"""
(() => {
const crumbs = [...document.querySelectorAll('#breadcrumbs li')];
crumbs[crumbs.length - 1].querySelector('span, a').textContent = 'Supercalifragilisticexpialidocious_operations_collection_name';
const button = document.querySelector('.api-page-toolbar .api-page-actions').getBoundingClientRect();
return crumbs.every(li => li.getBoundingClientRect().right <= button.left);
})()
"""
).ConfigureAwait(false);
lines.Add(
string.Create(CultureInfo.InvariantCulture, $"{width}px: every crumb ends before Copy page {clear.GetBoolean()}")
);
}
}).ConfigureAwait(false);

_ = string
.Join('\n', lines)
.Should()
.MatchInlineSnapshot(
"""
1024px: every crumb ends before Copy page True
1280px: every crumb ends before Copy page True
"""
);
}
Expand Down
Loading