Skip to content

Commit 6435ec3

Browse files
committed
release: 1.2.1
1 parent c3c09e4 commit 6435ec3

8 files changed

Lines changed: 82 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 1.2.1 - 2025-02-03
8+
### Added
9+
- Styled the scrollbars that appear on `<admin-bar>` and `<admin-bar-button>` popover elements.
10+
11+
### Changed
12+
- Split padding on `<admin-bar-button>` and `<admin-bar-text>` elements into separate CSS Custom Properties, `--admin-bar-block-padding` and `--admin-bar-inline-padding`.
13+
14+
715
## 1.2.0 - 2024-12-30
816
### Added
917
- Added definition lists and tables to `<admin-bar-text>` elements.

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,49 @@ Text in `<admin-bar-text>` elements are not allowed to wrap by default, but addi
264264
</admin-bar>
265265
```
266266

267+
### Adding Definition Lists to Admin Bar Text Elements (in Popovers)
268+
269+
The `dl-content` prop displays an array of key/value arrays in a `<dl>` element. While you otherwise can be creative with it, it’s intended to be used in popovers as part of `<admin-bar-button>` elements.
270+
271+
To add a button that displays a list of items in a popover you can start with an `<admin-bar>` with an `<admin-bar-button>` element in it. In the `<admin-bar-button>` element, add the `popover` slot:
272+
273+
```html
274+
<admin-bar>
275+
<admin-bar-text>
276+
List of items.
277+
<span slot="popover"></span>
278+
</admin-bar-text>
279+
</admin-bar>
280+
```
281+
282+
Add an `<admin-bar-text>` element with the `dl-content` prop. The value of the prop is an array of arrays. For each second-level array, 2 values are required. The first value will always render in a `<dt>` element and the second value will render in its matching `<dd>` element.
283+
284+
```html
285+
<admin-bar>
286+
<admin-bar-text>
287+
List of items.
288+
<span slot="popover">
289+
<admin-bar-text dl-content='[["Line 1 title", "Line 1 content"], ["Line 2 title", "Line 2 content"]]'></admin-bar-text>
290+
</span>
291+
</admin-bar-text>
292+
</admin-bar>
293+
```
294+
295+
Notice how above the `dl-content` prop uses single quotes (`''`) for the attribute value? The contents of the `dl-content` prop need to be a valid JSON string. You can use single quotes so you can use double quotes like above, however, if you are working in a situation where you can’t do that, you can escape double quotes by using `&quot;` instead:
296+
297+
```html
298+
<admin-bar>
299+
<admin-bar-text>
300+
List of items.
301+
<span slot="popover">
302+
<admin-bar-text dl-content="[&quot;Line 1 title&quot;, &quot;Line 1 content&quot;], [&quot;Line 2 title&quot;, &quot;Line 2 content&quot;]"></admin-bar-text>
303+
</span>
304+
</admin-bar-text>
305+
</admin-bar>
306+
```
307+
308+
309+
267310
### Admin Bar Text Public Properties
268311

269312
| Attribute Name | Type | Default | Description |
@@ -280,6 +323,8 @@ Text in `<admin-bar-text>` elements are not allowed to wrap by default, but addi
280323
281324
#### Admin Bar Text Types
282325

326+
Here are the TypeScript types that describe the formats for the props
327+
283328
```typescript
284329
type TextDlContent = [string | number, string | number][]
285330

@@ -290,11 +335,6 @@ interface TextTableContent {
290335
}
291336
```
292337

293-
| Name | TypeScript Type |
294-
|------------------|----------------------------------------------------------|
295-
| TextDlContent | `[string | number, string | number][]` |
296-
| TextTableContent | `{ footers?: string[]; headers?: string[]; rows: (string | number)[][] }` |
297-
298338
### Admin Bar Text Slots
299339

300340
| Slot Name | Description |
@@ -404,6 +444,12 @@ The `admin-bar.css` file has comments describing what each CSS Custom Property s
404444
/* The height of the bar and all of the buttons. */
405445
--admin-bar-height: 43px;
406446

447+
/* The vertical padding default for Admin Bar child elements. */
448+
--admin-bar-block-padding: 0;
449+
450+
/* The horizontal padding default for Admin Bar child elements. */
451+
--admin-bar-inline-padding: clamp(4px, 1vw, 13px);
452+
407453
/* When `show-environment` is added to an `<admin-bar>` an environment
408454
warning will appear. The default looks like yellow, striped police tape,
409455
but you can use any CSS value used in the background shorthand property. */
@@ -455,7 +501,7 @@ The `admin-bar.css` file has comments describing what each CSS Custom Property s
455501
--admin-bar-button-popover-border-radius: var(--admin-bar-border-radius);
456502

457503
/* The value of the padding property on `admin-bar-text` components. */
458-
/*--admin-bar-text-padding: 0 clamp(4px, 1vw, 13px);*/
504+
/*--admin-bar-text-padding: var(--admin-bar-block-padding) var(--admin-bar-inline-padding);*/
459505

460506
/* The background for labels in `admin-bar-text` components. */
461507
--admin-bar-text-label-color-bg: rgb(255 255 255 / 0.9);

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</admin-bar-button>
6565
</span>
6666
</admin-bar-button>
67-
<admin-bar-button>Popover Slot 4<span slot="popover"><admin-bar-text dl-content='[["Created at", "Dec 23, 2024 10:09 AM"],["Updated at", "Dec 29, 2024 5:23 PM"],["Entry ID", "5023"],["Long Text","Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut dolore hic ipsum quidem voluptate? Aspernatur eius esse impedit minus molestias, numquam odit qui quisquam veritatis vero. Animi inventore veritatis vero!"]]'></admin-bar-text></span></admin-bar-button>
67+
<admin-bar-button>Popover Slot 4<span slot="popover"><admin-bar-text dl-content="[[&quot;Line 1 title&quot;, &quot;Line 1 content&quot;], [&quot;Line 2 title&quot;, &quot;Line 2 content&quot;]]"></admin-bar-text></span></admin-bar-button>
6868
<admin-bar-button>Popover Slot 5<span slot="popover"><admin-bar-text table-content='{"footers":["Total 1","Total 2","Total 3"],"headers":["Column 1","Column 2","Column 3"],"rows":[["Item 1","Item 2","Item 3"],[1,2,3],["Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut dolore hic ipsum quidem voluptate? Aspernatur eius esse impedit minus molestias, numquam odit qui quisquam veritatis vero. Animi inventore veritatis vero!","ILorem ipsum dolor sit amet, consectetur adipisicing elit. Aut dolore hic ipsum quidem voluptate? Aspernatur eius esse impedit minus molestias, numquam odit qui quisquam veritatis vero. Animi inventore veritatis vero!","Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut dolore hic ipsum quidem voluptate? Aspernatur eius esse impedit minus molestias, numquam odit qui quisquam veritatis vero. Animi inventore veritatis vero!"]]}'></admin-bar-text></span></admin-bar-button>
6969
<admin-bar-button>Popover Slot 6<span slot="popover"><admin-bar-text
7070
multi-line
@@ -76,6 +76,9 @@
7676
<admin-bar-text label-content="25" label-position="before">Badge goes before</admin-bar-text>
7777
<admin-bar-text label-content="25">Badge goes after</admin-bar-text>
7878
<admin-bar-text text-content="Simple plain text"></admin-bar-text>
79+
<admin-bar-text style="--admin-bar-text-padding: 0;">
80+
<div style="padding-inline: var(--admin-bar-inline-padding); height: 100%; align-content: center; background-color: goldenrod;">DIV</div>
81+
</admin-bar-text>
7982
<admin-bar-text label-content="STAGING" style="--admin-bar-text-label-color-bg: var(--admin-bar-environment-bg-color);"></admin-bar-text>
8083
</admin-bar>
8184

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"test:open": "cypress open"
99
},
1010
"name": "admin-bar-component",
11-
"version": "1.2.0",
11+
"version": "1.2.1",
1212
"description": "A framework- and CMS-agnostic admin bar web component.",
1313
"type": "module",
1414
"main": "dist/admin-bar.js",

public/admin-bar.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
/* The height of the bar and all of the buttons. */
4646
--admin-bar-height: 43px;
4747

48+
/* The vertical padding default for Admin Bar child elements. */
49+
--admin-bar-block-padding: 0;
50+
51+
/* The horizontal padding default for Admin Bar child elements. */
52+
--admin-bar-inline-padding: clamp(4px, 1vw, 13px);
53+
4854
/* When `show-environment` is added to an `<admin-bar>` an environment
4955
warning will appear. The default looks like yellow, striped police tape,
5056
but you can use any CSS value used in the background shorthand property. */
@@ -96,7 +102,7 @@
96102
--admin-bar-button-popover-border-radius: var(--admin-bar-border-radius);
97103

98104
/* The value of the padding property on `admin-bar-text` components. */
99-
/*--admin-bar-text-padding: 0 clamp(4px, 1vw, 13px);*/
105+
/*--admin-bar-text-padding: var(--admin-bar-block-padding) var(--admin-bar-inline-padding);*/
100106

101107
/* The background for labels in `admin-bar-text` components. */
102108
--admin-bar-text-label-color-bg: rgb(255 255 255 / 0.9);

src/components/AdminBar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export class AdminBar extends LitElement {
3434
font-family: var(--admin-bar-font-stack);
3535
font-size: var(--admin-bar-font-size, 0.9rem);
3636
color: var(--admin-bar-color-text, rgb(255 255 255 / 0.8));
37+
scrollbar-color: color-mix(in srgb, var(--admin-bar-color-text), transparent 20%)
38+
color-mix(in srgb, var(--admin-bar-bg-color), transparent 90%);
39+
scrollbar-width: thin;
3740
3841
&.admin-bar--environment {
3942
grid-template-rows: var(--environment-height) var(--admin-bar-height, 43px);

src/components/AdminBarButton.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class AdminBarButton extends LitElement {
2525
flex-wrap: nowrap;
2626
gap: 5px;
2727
align-items: center;
28-
padding: 0 clamp(4px, 1vw, 13px);
28+
padding: var(--admin-bar-block-padding) var(--admin-bar-inline-padding);
2929
min-width: 100%;
3030
height: var(--admin-bar-height, 43px);
3131
background-color: var(--admin-bar-button-color-bg, transparent);
@@ -52,7 +52,7 @@ export class AdminBarButton extends LitElement {
5252
}
5353
5454
&.admin-bar-button--logout {
55-
padding: 0 clamp(10px, 3vw, 20px);
55+
padding: var(--admin-bar-block-padding) clamp(10px, 3vw, 20px);
5656
5757
&:hover {
5858
--admin-bar-button-color-bg: var(--admin-bar-color-highlight-logout, var(--admin-bar-color-highlight));
@@ -95,6 +95,9 @@ export class AdminBarButton extends LitElement {
9595
border-radius: var(--admin-bar-button-popover-border-radius, var(--admin-bar-border-radius));
9696
box-shadow: var(--admin-bar-shadow);
9797
color: var(--admin-bar-button-popover-color-text, rgb(255 255 255));
98+
scrollbar-color: color-mix(in srgb, var(--admin-bar-color-text), transparent 20%)
99+
color-mix(in srgb, var(--admin-bar-bg-color), transparent 90%);
100+
scrollbar-width: thin;
98101
99102
@supports (position-anchor: --popover-anchor) and (position-try-fallbacks: --popover-top) {
100103
& {

src/components/AdminBarText.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class AdminBarText extends LitElement {
2828
flex-wrap: nowrap;
2929
gap: 5px;
3030
align-items: center;
31-
padding: var(--admin-bar-text-padding, 0 clamp(4px, 1vw, 13px));
31+
padding: var(--admin-bar-text-padding, var(--admin-bar-block-padding) var(--admin-bar-inline-padding));
3232
height: var(--admin-bar-height, 43px);
3333
background-color: var(--admin-bar-text-color-bg, transparent);
3434
font-size: var(--font-size);
@@ -39,7 +39,7 @@ export class AdminBarText extends LitElement {
3939
color var(--admin-bar-transition-duration, 0.4s) ease-out;
4040
4141
&:is(.multi-line, :has(dl, table)) {
42-
padding: var(--admin-bar-text-padding, clamp(4px, 1vw, 13px));
42+
padding: var(--admin-bar-text-padding, var(--admin-bar-inline-padding));
4343
height: unset;
4444
white-space: unset;
4545

0 commit comments

Comments
 (0)