Skip to content

Commit 2733263

Browse files
authored
Add dropdown styling (#529)
1 parent a431832 commit 2733263

File tree

4 files changed

+71
-10
lines changed

4 files changed

+71
-10
lines changed

docs/syntax/dropdowns.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,51 @@
22

33
Dropdowns allow you to hide and reveal content on user interaction. By default, dropdowns are collapsed. This hides content until a user clicks the title of the collapsible block.
44

5-
## Syntax
5+
## Basic dropdown
6+
7+
8+
:::::{tab-set}
9+
10+
::::{tab-item} Output
611

7-
```markdown
812
:::{dropdown} Dropdown Title
913
Dropdown content
1014
:::
11-
```
1215

16+
::::
17+
18+
::::{tab-item} Markdown
19+
```markdown
1320
:::{dropdown} Dropdown Title
1421
Dropdown content
1522
:::
23+
```
24+
::::
25+
26+
:::::
1627

17-
### Open by default
28+
## Open by default
1829

1930
You can specify that the dropdown content should be visible by default. Do this by specifying the `open` option. Users can collapse content by clicking on the dropdown title.
2031

21-
```markdown
32+
:::::{tab-set}
33+
34+
::::{tab-item} Output
35+
2236
:::{dropdown} Dropdown Title
2337
:open:
2438
Dropdown content
2539
:::
26-
```
2740

41+
::::
42+
43+
::::{tab-item} Markdown
44+
```markdown
2845
:::{dropdown} Dropdown Title
2946
:open:
3047
Dropdown content
3148
:::
49+
```
50+
::::
51+
52+
:::::
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@layer components {
2+
.markdown-content {
3+
.dropdown {
4+
@apply mt-4 border-1 border-gray-300 rounded-sm shadow-xs;
5+
.dropdown-title {
6+
@apply flex
7+
justify-between
8+
items-center
9+
px-4
10+
py-2
11+
cursor-pointer
12+
text-ink-dark
13+
font-semibold
14+
;
15+
}
16+
17+
&[open] .dropdown-title {
18+
@apply border-b-1 border-b-gray-300;
19+
svg {
20+
transform: rotate(90deg);
21+
}
22+
}
23+
24+
.dropdown-content {
25+
@apply px-4 pb-4;
26+
}
27+
}
28+
}
29+
}

src/Elastic.Markdown/Assets/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
@import "./markdown/code.css";
88
@import "./copybutton.css";
99
@import "./markdown/admonition.css";
10+
@import "./markdown/dropdown.css";
1011

1112
#default-search::-webkit-search-cancel-button {
1213
padding-right: calc(var(--spacing) * 2);

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
@inherits RazorSlice<AdmonitionViewModel>
2-
<details class="sd-sphinx-override sd-dropdown sd-card sd-mb-3 @Model.Classes" id="@Model.CrossReferenceName" open="@Model.Open">
3-
<summary class="sd-summary-title sd-card-header">
4-
<span class="sd-summary-text">@Model.Title</span><span class="sd-summary-state-marker sd-summary-chevron-right"><svg version="1.1" width="1.5em" height="1.5em" class="sd-octicon sd-octicon-chevron-right" viewBox="0 0 24 24" aria-hidden="true"><path d="M8.72 18.78a.75.75 0 0 1 0-1.06L14.44 12 8.72 6.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l6.25 6.25a.75.75 0 0 1 0 1.06l-6.25 6.25a.75.75 0 0 1-1.06 0Z"></path></svg></span></summary><div class="sd-summary-content sd-card-body docutils">
2+
<details class="dropdown @Model.Classes" id="@Model.CrossReferenceName" open="@Model.Open">
3+
<summary class="dropdown-title">
4+
<span class="sd-summary-text">@Model.Title</span>
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
fill="none"
8+
viewBox="0 0 24 24"
9+
stroke-width="1.5"
10+
stroke="currentColor"
11+
class="w-4 mr-1 shrink -rotate-90 group-has-checked/label:rotate-0 cursor-pointer text-ink">
12+
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5"/>
13+
</svg>
14+
</summary>
15+
<div class="dropdown-content">
516
[CONTENT]
617
</div>
718
</details>
8-

0 commit comments

Comments
 (0)