From: Mark Otto Date: Tue, 16 Dec 2025 22:05:02 +0000 (-0800) Subject: More close button updates (#41937) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c21d7029bd37a75b4050e596bc99b090c844bbf;p=thirdparty%2Fbootstrap.git More close button updates (#41937) * Clean up close button more * New placeholder for docs examples * CSS lint fix --- diff --git a/scss/buttons/_close.scss b/scss/buttons/_close.scss index 9fc526e9a8..de65bd13c5 100644 --- a/scss/buttons/_close.scss +++ b/scss/buttons/_close.scss @@ -3,15 +3,11 @@ @use "../variables" as *; @use "../mixins/border-radius" as *; @use "../mixins/color-mode" as *; +@use "../mixins/focus-ring" as *; // scss-docs-start close-variables $btn-close-size: 1.25rem !default; -// $btn-close-width: 1em !default; -// $btn-close-height: $btn-close-width !default; -// $btn-close-padding-x: .25em !default; -// $btn-close-padding-y: $btn-close-padding-x !default; $btn-close-color: var(--#{$prefix}fg-body) !default; -$btn-close-focus-shadow: $focus-ring-box-shadow !default; $btn-close-opacity: .5 !default; $btn-close-hover-opacity: .75 !default; $btn-close-focus-opacity: .85 !default; @@ -30,7 +26,6 @@ $btn-close-disabled-opacity: .25 !default; --#{$prefix}btn-close-color: #{$btn-close-color}; --#{$prefix}btn-close-opacity: #{$btn-close-opacity}; --#{$prefix}btn-close-hover-opacity: #{$btn-close-hover-opacity}; - --#{$prefix}btn-close-focus-shadow: #{$btn-close-focus-shadow}; --#{$prefix}btn-close-focus-opacity: #{$btn-close-focus-opacity}; --#{$prefix}btn-close-disabled-opacity: #{$btn-close-disabled-opacity}; // scss-docs-end close-css-vars @@ -41,14 +36,14 @@ $btn-close-disabled-opacity: .25 !default; padding: 0; color: var(--#{$prefix}btn-close-color); background: transparent; - // background: transparent var(--#{$prefix}btn-close-bg) center / $btn-close-width auto no-repeat; // include transparent for button elements - // filter: var(--#{$prefix}btn-close-filter); border: 0; // for button elements + @include border-radius(var(--#{$prefix}border-radius-sm)); opacity: var(--#{$prefix}btn-close-opacity); > svg { - // width: 100%; - // height: 100% + display: block; + width: 100%; + height: 100%; fill: currentcolor; } @@ -60,8 +55,7 @@ $btn-close-disabled-opacity: .25 !default; } &:focus { - outline: 0; - box-shadow: var(--#{$prefix}btn-close-focus-shadow); + @include focus-ring(); opacity: var(--#{$prefix}btn-close-focus-opacity); } @@ -72,23 +66,4 @@ $btn-close-disabled-opacity: .25 !default; opacity: var(--#{$prefix}btn-close-disabled-opacity); } } - - // @mixin btn-close-white() { - // // --#{$prefix}btn-close-filter: #{$btn-close-filter-dark}; - // } - - // .btn-close-white { - // @include btn-close-white(); - // } - - // :root, - // [data-bs-theme="light"] { - // // --#{$prefix}btn-close-filter: #{$btn-close-filter}; - // } - - // @if $enable-dark-mode { - // @include color-mode(dark, true) { - // @include btn-close-white(); - // } - // } } diff --git a/site/src/components/shortcodes/CloseButton.astro b/site/src/components/shortcodes/CloseButton.astro new file mode 100644 index 0000000000..16e3fe61fa --- /dev/null +++ b/site/src/components/shortcodes/CloseButton.astro @@ -0,0 +1,21 @@ +--- +interface Props { + /** + * Additional CSS classes to add to the button (e.g., "me-2 m-auto"). + */ + class?: string + /** + * The component to dismiss (e.g., "dialog", "alert", "offcanvas", "toast"). + * Sets the `data-bs-dismiss` attribute. + */ + dismiss?: string +} + +const { class: className, dismiss } = Astro.props +--- + + diff --git a/site/src/content/docs/components/alerts.mdx b/site/src/content/docs/components/alerts.mdx index f226223200..b5326d33a9 100644 --- a/site/src/content/docs/components/alerts.mdx +++ b/site/src/content/docs/components/alerts.mdx @@ -111,7 +111,7 @@ You can see this in action with a live demo: Holy guacamole! You should check in on some of those fields below. - + `} /> diff --git a/site/src/content/docs/components/dialog.mdx b/site/src/content/docs/components/dialog.mdx index 486c32b21e..a7e26d2c5b 100644 --- a/site/src/content/docs/components/dialog.mdx +++ b/site/src/content/docs/components/dialog.mdx @@ -29,7 +29,7 @@ Toggle a dialog by clicking the button below. The dialog uses the native `showMo

Dialog title

- +

This is a native dialog element. It uses the browser's built-in modal behavior for accessibility and focus management.

@@ -50,7 +50,11 @@ The markup for a dialog is straightforward:

Dialog title

- +

Dialog body content goes here.

@@ -73,7 +77,7 @@ When `backdrop` is set to `static`, the dialog will not close when clicking outs

Static backdrop

- +

I will not close if you click outside of me. Use the close button or press Escape.

@@ -94,7 +98,7 @@ When dialogs have content that exceeds the viewport height, the entire dialog sc

Scrolling dialog

- +

This is some placeholder content to show the scrolling behavior for dialogs. When the content exceeds the viewport height, you can scroll the entire dialog within the window—the header, body, and footer all move together.

@@ -122,7 +126,7 @@ You can also create a scrollable dialog that scrolls the dialog body while keepi

Scrollable body

- +

This is some placeholder content to show the scrolling behavior for dialogs. We use repeated line breaks to demonstrate how content can exceed the dialog's inner height, showing scrolling within the body while the header and footer remain fixed.

@@ -149,7 +153,11 @@ You can also create a scrollable dialog that scrolls the dialog body while keepi

Scrollable body

- +
@@ -166,7 +174,7 @@ For a dialog that extends beyond the viewport and scrolls as a whole, add `.dial

Overflow dialog

- +

This dialog extends beyond the viewport height. Scroll to see more content. Notice how the entire dialog—including header and footer—shifts up and down as you scroll.

@@ -209,7 +217,7 @@ When a toggle trigger is inside an open dialog, clicking it will **swap** dialog

First dialog

- +

Click below to swap to a second dialog. Notice the backdrop stays visible—no flash!

@@ -223,7 +231,7 @@ When a toggle trigger is inside an open dialog, clicking it will **swap** dialog

Second dialog

- +

This is the second dialog. You can swap back to the first, or close this one entirely.

@@ -280,7 +288,7 @@ By default, dialogs open as modals using the native `showModal()` method. You ca

Non-modal dialog

- +

This dialog doesn't block the page. You can still interact with content behind it.

@@ -315,7 +323,7 @@ Dialogs have three optional sizes, available via modifier classes to be placed o

Extra large dialog

- +

This is an extra large dialog using the .dialog-xl class.

@@ -325,7 +333,7 @@ Dialogs have three optional sizes, available via modifier classes to be placed o

Large dialog

- +

This is a large dialog using the .dialog-lg class.

@@ -335,7 +343,7 @@ Dialogs have three optional sizes, available via modifier classes to be placed o

Small dialog

- +

This is a small dialog using the .dialog-sm class.

@@ -365,7 +373,7 @@ Use `.dialog-fullscreen` to make the dialog cover the entire viewport.

Fullscreen dialog

- +

This dialog covers the entire viewport.

@@ -393,7 +401,7 @@ Responsive fullscreen variants are also available. These make the dialog fullscr

Fullscreen below lg

- +

This dialog is fullscreen below the lg breakpoint.

diff --git a/site/src/content/docs/components/navbar.mdx b/site/src/content/docs/components/navbar.mdx index f934763321..3d4b01f82a 100644 --- a/site/src/content/docs/components/navbar.mdx +++ b/site/src/content/docs/components/navbar.mdx @@ -626,7 +626,7 @@ In the example below, to create an offcanvas navbar that is always collapsed acr
Offcanvas
- +