Skip to content

Commit 2501843

Browse files
committed
description item
1 parent 2f4c4bc commit 2501843

File tree

7 files changed

+137
-1
lines changed

7 files changed

+137
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
meta:
3+
title: Description Item
4+
description:
5+
layout: component
6+
---
7+
8+
```html:preview
9+
<zn-sp divide no-gap>
10+
<zn-description-item label="Full name">
11+
Margot Foster
12+
</zn-description-item>
13+
<zn-description-item label="Full name">
14+
Margot Foster
15+
</zn-description-item>
16+
<zn-description-item label="Full name">
17+
Margot Foster
18+
</zn-description-item>
19+
<zn-description-item label="Full name">
20+
Margot Foster
21+
</zn-description-item>
22+
</zn-sp>
23+
```
24+
25+
## Examples
26+
27+
### Lots of Content
28+
29+
```html:preview
30+
<zn-description-item label="Full name">
31+
lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna
32+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
33+
</zn-description-item>
34+
```
35+
36+
### Second Example
37+
38+
TODO
39+
40+
[component-metadata:zn-description-item]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {property} from 'lit/decorators.js';
2+
import {type CSSResultGroup, html, unsafeCSS} from 'lit';
3+
import {LocalizeController} from '../../utilities/localize';
4+
import ZincElement from '../../internal/zinc-element';
5+
6+
import styles from './description-item.scss';
7+
import {classMap} from "lit/directives/class-map.js";
8+
9+
/**
10+
* @summary Short summary of the component's intended use.
11+
* @documentation https://zinc.style/components/description-item
12+
* @status experimental
13+
* @since 1.0
14+
*
15+
* @dependency zn-example
16+
*
17+
* @event zn-event-name - Emitted as an example.
18+
*
19+
* @slot - The default slot.
20+
* @slot example - An example slot.
21+
*
22+
* @csspart base - The component's base wrapper.
23+
*
24+
* @cssproperty --example - An example CSS custom property.
25+
*/
26+
export default class ZnDescriptionItem extends ZincElement {
27+
static styles: CSSResultGroup = unsafeCSS(styles);
28+
29+
// @ts-expect-error unused property
30+
private readonly localize = new LocalizeController(this);
31+
32+
@property() label: string;
33+
34+
connectedCallback() {
35+
super.connectedCallback();
36+
this.setAttribute('role', 'listitem');
37+
}
38+
39+
render() {
40+
return html`
41+
<div class=${classMap({
42+
'description-item': true,
43+
})}>
44+
<div class="description-item__label">${this.label}</div>
45+
<slot></slot>
46+
</div>
47+
`;
48+
}
49+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@use "../../wc";
2+
3+
:host {
4+
display: block;
5+
6+
--zn-description-item-label-max-width: 300px;
7+
}
8+
9+
.description-item {
10+
display: flex;
11+
flex-direction: row;
12+
padding: var(--zn-spacing-medium);
13+
14+
@include wc.container-query(null, md) {
15+
flex-direction: column;
16+
}
17+
18+
&__label {
19+
font-weight: 500;
20+
color: rgb(var(--zn-text-heading));
21+
max-width: var(--zn-description-item-label-max-width);
22+
width: 100%;
23+
}
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import '../../../dist/zn.min.js';
2+
import { expect, fixture, html } from '@open-wc/testing';
3+
4+
describe('<zn-description-item>', () => {
5+
it('should render a component', async () => {
6+
const el = await fixture(html` <zn-description-item></zn-description-item> `);
7+
8+
expect(el).to.exist;
9+
});
10+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import ZnDescriptionItem from './description-item.component';
2+
3+
export * from './description-item.component';
4+
export default ZnDescriptionItem;
5+
6+
ZnDescriptionItem.define('zn-description-item');
7+
8+
declare global {
9+
interface HTMLElementTagNameMap {
10+
'zn-description-item': ZnDescriptionItem;
11+
}
12+
}

src/components/empty-state/empty-state.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
align-items: center;
3636
justify-content: center;
3737
gap: var(--zn-spacing-x-small);
38-
padding: var(--zn-spacing-small);
38+
padding: var(--zn-spacing-3x-large) var(--zn-spacing-small);
3939
flex-grow: 1;
4040
}
4141
}

src/zinc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export {default as DragUpload} from './components/drag-upload';
7171
export {default as CheckboxGroup} from './components/checkbox-group';
7272
export {default as ConfirmContent} from './components/confirm-content';
7373
export {default as EmptyDialog} from './components/empty-dialog';
74+
export { default as DescriptionItem } from './components/description-item';
7475
/* plop:component */
7576

7677
// Utilities

0 commit comments

Comments
 (0)