Skip to content

Commit e5b5ca2

Browse files
committed
adding fixed height setting and removing sample carousel addition
1 parent 8bfa39d commit e5b5ca2

File tree

6 files changed

+45
-22
lines changed

6 files changed

+45
-22
lines changed

docs/contribute/index.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,6 @@ Welcome, **contributor**!
88

99
Whether you're a technical writer or you've only edited Elastic docs once or twice, you're a valued contributor. Every word matters!
1010

11-
::::{carousel}
12-
:id: nested-carousel-example
13-
:controls: true
14-
:indicators: true
15-
:::{image} https://epr.elastic.co/package/abnormal_security/1.8.0/img/abnormal_security-mailbox_not_analyzed_overview.png
16-
:alt: First image description
17-
:title: First image title
18-
:::
19-
:::{image} https://epr.elastic.co/package/abnormal_security/1.8.0/img/abnormal_security-ai_security_mailbox_overview.png
20-
:alt: Second image description
21-
:title: Second image title
22-
:::
23-
:::{image} https://epr.elastic.co/package/abnormal_security/1.8.0/img/abnormal_security-audit_overview.png
24-
:alt: Third image description
25-
:title: Third image title
26-
:::
27-
::::
28-
2911
## Contribute to the docs [#contribute]
3012

3113
The version of the docs you want to contribute to determines the tool and syntax you must use to update the docs.

src/Elastic.Documentation.Site/Assets/markdown/image-carousel.css

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
.carousel-track {
99
width: 100%;
1010
position: relative;
11-
min-height: 200px; /* Ensure container has height even when slides are absolute */
11+
min-height: 200px;
1212
}
1313

1414
.carousel-slide {
@@ -92,6 +92,39 @@
9292
background-color: black;
9393
}
9494

95+
/* Fixed height carousel styles */
96+
.carousel-container[data-fixed-height] .carousel-track {
97+
min-height: auto;
98+
overflow: hidden;
99+
}
100+
101+
.carousel-container[data-fixed-height] .carousel-slide {
102+
height: 100%;
103+
top: 0;
104+
left: 0;
105+
}
106+
107+
.carousel-container[data-fixed-height] .carousel-slide[data-active="true"] {
108+
position: relative;
109+
height: 100%;
110+
top: auto;
111+
left: auto;
112+
}
113+
114+
.carousel-container[data-fixed-height] .carousel-image-reference {
115+
height: 100%;
116+
display: flex;
117+
align-items: center;
118+
justify-content: center;
119+
}
120+
121+
.carousel-container[data-fixed-height] .carousel-image-reference img {
122+
width: auto;
123+
height: 100%;
124+
max-width: 100%;
125+
object-fit: contain;
126+
object-position: center;
127+
}
95128
@media (max-width: 768px) {
96129
.carousel-control {
97130
width: 30px;

src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ private static void WriteImageCarousel(HtmlRenderer renderer, ImageCarouselBlock
127127
ImageUrl = img.ImageUrl
128128
}).ToList(),
129129
ShowControls = block.ShowControls,
130-
ShowIndicators = block.ShowIndicators
130+
ShowIndicators = block.ShowIndicators,
131+
FixedHeight = block.FixedHeight
131132
});
132133
RenderRazorSlice(slice, renderer);
133134
}

src/Elastic.Markdown/Myst/Directives/ImageCarouselBlock.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ImageCarouselBlock(DirectiveBlockParser parser, ParserContext conte
1616
public string? Id { get; set; }
1717
public bool? ShowControls { get; set; }
1818
public bool? ShowIndicators { get; set; }
19+
public string? FixedHeight { get; set; }
1920

2021
public override string Directive => "carousel";
2122

@@ -25,6 +26,7 @@ public override void FinalizeAndValidate(ParserContext context)
2526
Id = Prop("id");
2627
ShowControls = TryPropBool("controls");
2728
ShowIndicators = TryPropBool("indicators");
29+
FixedHeight = Prop("fixed-height");
2830

2931
// Process child image blocks directly
3032
foreach (var block in this)

src/Elastic.Markdown/Slices/Directives/ImageCarousel.cshtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@inherits RazorSlice<ImageCarouselViewModel>
2-
<div class="carousel-container" id="@Model.Id">
3-
<div class="carousel-track">
2+
@{
3+
var hasFixedHeight = !string.IsNullOrEmpty(Model.FixedHeight);
4+
var trackStyle = hasFixedHeight ? $"height: {Model.FixedHeight};" : "";
5+
}
6+
<div class="carousel-container" id="@Model.Id" @(hasFixedHeight ? "data-fixed-height" : "")>
7+
<div class="carousel-track" style="@trackStyle">
48
@for (int i = 0; i < Model.Images.Count; i++)
59
{
610
var image = Model.Images[i];

src/Elastic.Markdown/Slices/Directives/_ViewModels.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,5 @@ public class ImageCarouselViewModel : DirectiveViewModel
139139
public required string Id { get; init; }
140140
public bool? ShowControls { get; init; }
141141
public bool? ShowIndicators { get; init; }
142+
public string? FixedHeight { get; init; }
142143
}

0 commit comments

Comments
 (0)