diff --git a/docs/syntax/dropdowns.md b/docs/syntax/dropdowns.md index 2661a9c47..0c0301cd5 100644 --- a/docs/syntax/dropdowns.md +++ b/docs/syntax/dropdowns.md @@ -2,30 +2,51 @@ 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. -## Syntax +## Basic dropdown + + +:::::{tab-set} + +::::{tab-item} Output -```markdown :::{dropdown} Dropdown Title Dropdown content ::: -``` +:::: + +::::{tab-item} Markdown +```markdown :::{dropdown} Dropdown Title Dropdown content ::: +``` +:::: + +::::: -### Open by default +## Open by default 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. -```markdown +:::::{tab-set} + +::::{tab-item} Output + :::{dropdown} Dropdown Title :open: Dropdown content ::: -``` +:::: + +::::{tab-item} Markdown +```markdown :::{dropdown} Dropdown Title :open: Dropdown content ::: +``` +:::: + +::::: diff --git a/src/Elastic.Markdown/Assets/markdown/dropdown.css b/src/Elastic.Markdown/Assets/markdown/dropdown.css new file mode 100644 index 000000000..fa5592f77 --- /dev/null +++ b/src/Elastic.Markdown/Assets/markdown/dropdown.css @@ -0,0 +1,29 @@ +@layer components { + .markdown-content { + .dropdown { + @apply mt-4 border-1 border-gray-300 rounded-sm shadow-xs; + .dropdown-title { + @apply flex + justify-between + items-center + px-4 + py-2 + cursor-pointer + text-ink-dark + font-semibold + ; + } + + &[open] .dropdown-title { + @apply border-b-1 border-b-gray-300; + svg { + transform: rotate(90deg); + } + } + + .dropdown-content { + @apply px-4 pb-4; + } + } + } +} diff --git a/src/Elastic.Markdown/Assets/styles.css b/src/Elastic.Markdown/Assets/styles.css index e8d68c97d..997ac8e83 100644 --- a/src/Elastic.Markdown/Assets/styles.css +++ b/src/Elastic.Markdown/Assets/styles.css @@ -7,6 +7,7 @@ @import "./markdown/code.css"; @import "./copybutton.css"; @import "./markdown/admonition.css"; +@import "./markdown/dropdown.css"; #default-search::-webkit-search-cancel-button { padding-right: calc(var(--spacing) * 2); diff --git a/src/Elastic.Markdown/Slices/Directives/Dropdown.cshtml b/src/Elastic.Markdown/Slices/Directives/Dropdown.cshtml index 8ede998f5..5a202f3ba 100644 --- a/src/Elastic.Markdown/Slices/Directives/Dropdown.cshtml +++ b/src/Elastic.Markdown/Slices/Directives/Dropdown.cshtml @@ -1,8 +1,18 @@ @inherits RazorSlice -
- - @Model.Title
+ -