astro-better-details 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Details.astro CHANGED
@@ -1,14 +1,14 @@
1
1
  ---
2
- interface Props {
3
- open?: boolean;
4
- class?: string;
2
+ import type { HTMLAttributes } from 'astro/types';
3
+
4
+ interface Props extends HTMLAttributes<'details'> {
5
5
  title?: string;
6
6
  }
7
7
 
8
- const { open, class: cls, title } = Astro.props;
8
+ const { open, class: cls, title, ...rest } = Astro.props;
9
9
  ---
10
10
 
11
- <details class:list={['abt-details', cls]} open={open}>
11
+ <details class:list={['abt-details', cls]} open={open} {...rest}>
12
12
  <summary class="abt-details-summary">
13
13
  <span class="abt-details-title">{title}<slot name="title" /></span>
14
14
  <svg class="abt-details-chevron" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
@@ -32,8 +32,9 @@ const { open, class: cls, title } = Astro.props;
32
32
  display: flex;
33
33
  align-items: center;
34
34
  justify-content: space-between;
35
- gap: 0.75rem;
36
- padding: 0.75rem 1rem;
35
+ gap: 0.5rem;
36
+ /* about 40px tall at a 24px line height, above the 24px WCAG 2.2 target minimum */
37
+ padding: 0.5rem 0.75rem;
37
38
  cursor: pointer;
38
39
  list-style: none;
39
40
  background: var(--abt-details-summary-bg, #f9fafb);
@@ -43,6 +44,12 @@ const { open, class: cls, title } = Astro.props;
43
44
  border-bottom: 1px solid transparent;
44
45
  }
45
46
 
47
+ /* the container's overflow: hidden would clip an outside focus ring */
48
+ .abt-details-summary:focus-visible {
49
+ outline: 2px solid var(--abt-details-focus, currentColor);
50
+ outline-offset: -2px;
51
+ }
52
+
46
53
  .abt-details-summary::-webkit-details-marker { display: none; }
47
54
  .abt-details-summary::marker { display: none; }
48
55
 
@@ -68,6 +75,6 @@ const { open, class: cls, title } = Astro.props;
68
75
  }
69
76
 
70
77
  .abt-details-body {
71
- padding: 1rem;
78
+ padding: 0.5rem 0.75rem;
72
79
  }
73
80
  </style>
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 Better Static Sites
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -10,21 +10,32 @@ npm install astro-better-details
10
10
 
11
11
  ## Basic usage
12
12
 
13
+ Pass a plain string via the `title` prop:
14
+
13
15
  ```mdx
14
16
  import Details from 'astro-better-details/Details.astro';
15
17
 
18
+ <Details title="What is this?">
19
+ This is the expanded content. It can contain any Markdown or MDX.
20
+ </Details>
21
+ ```
22
+
23
+ Use the `title` slot when the header needs inline markup -- code, links, or components:
24
+
25
+ ```mdx
16
26
  <Details>
17
- <span slot="title">What is this?</span>
27
+ <span slot="title">Why use <code>astro-better-details</code>?</span>
18
28
  This is the expanded content. It can contain any Markdown or MDX.
19
29
  </Details>
20
30
  ```
21
31
 
22
- The `title` slot holds the always-visible summary label. The default slot holds the body content shown when expanded.
32
+ The `title` slot takes precedence over the `title` prop if both are provided. The default slot holds the body content shown when expanded.
23
33
 
24
34
  ## Props
25
35
 
26
36
  | Prop | Type | Default | Description |
27
37
  |------|------|---------|-------------|
38
+ | `title` | `string` | -- | Plain-text header label; use the `title` slot for inline markup |
28
39
  | `open` | `boolean` | `false` | Render the component already expanded |
29
40
  | `class` | `string` | -- | Additional CSS class(es) applied to the `<details>` element |
30
41
 
@@ -32,11 +43,9 @@ The `title` slot holds the always-visible summary label. The default slot holds
32
43
 
33
44
  | Slot | Description |
34
45
  |------|-------------|
35
- | `title` (named) | Label shown in the clickable summary bar |
46
+ | `title` (named) | Header content with inline markup; takes precedence over the `title` prop |
36
47
  | default | Body content, shown when expanded |
37
48
 
38
- The title slot accepts any inline content -- plain text, backtick code, links, or JSX components.
39
-
40
49
  ## Theming
41
50
 
42
51
  The component uses CSS custom properties for all visual values. Override them on `.abt-details` or any parent selector to match your brand:
package/package.json CHANGED
@@ -1,15 +1,31 @@
1
1
  {
2
2
  "name": "astro-better-details",
3
- "version": "0.1.2",
4
- "type": "module",
3
+ "version": "0.1.4",
5
4
  "description": "Expandable details/disclosure component for Astro",
6
- "author": "Nathan Contino <ncontino@lambdalatitudinarians.org>",
5
+ "keywords": [
6
+ "astro",
7
+ "astro-component",
8
+ "details",
9
+ "disclosure"
10
+ ],
7
11
  "license": "MIT",
8
- "keywords": ["astro", "astro-component", "details", "disclosure"],
12
+ "author": "Nathan Contino <ncontino@lambdalatitudinarians.org>",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/better-static-sites/better-static-sites.github.io.git",
16
+ "directory": "astro-better-details"
17
+ },
18
+ "homepage": "https://better-static-sites.github.io",
19
+ "bugs": {
20
+ "url": "https://github.com/better-static-sites/better-static-sites.github.io/issues"
21
+ },
22
+ "type": "module",
9
23
  "exports": {
10
24
  "./Details.astro": "./Details.astro"
11
25
  },
12
- "files": ["Details.astro"],
26
+ "files": [
27
+ "Details.astro"
28
+ ],
13
29
  "peerDependencies": {
14
30
  "astro": ">=4.0.0"
15
31
  }