Skip to content

Commit a5d34bf

Browse files
authored
Merge pull request #100 from amir78729/feat/banner-jsdoc
docs: add JSDoc to `banner` component
2 parents f30cbc7 + 8d9488a commit a5d34bf

File tree

4 files changed

+83
-36
lines changed

4 files changed

+83
-36
lines changed

src/banner/banner.stories.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { html, TemplateResult } from "lit";
2-
import "./index.js";
3-
import "../button/index.js";
1+
import { html, TemplateResult } from 'lit';
2+
import './index.js';
3+
import '../button/index.js';
44

55
export default {
6-
title: "Banner",
7-
component: "tap-banner",
6+
title: 'Banner',
7+
component: 'tap-banner',
88
argTypes: {},
99
};
1010

@@ -28,19 +28,19 @@ const Template: Story<ArgTypes> = ({}: ArgTypes) => html`
2828
</tap-banner>
2929
3030
<tap-banner
31-
variant="hero"
31+
variant="hero"
3232
heading="با ۱۶۳۰، تلفنی تپسی بگیر"
3333
description="درخواست خودرو بدون نیاز به اینترنت"
3434
image="https://able-media.tapsi.cab/statics/N31LNC95J6MCPIYB0D.jpg"
3535
background-color="rgb(255, 213, 194)"
3636
text-color="rgb(66, 46, 40)"
3737
>
38-
<tap-button size="small" slot="extra" >majid</tap-button>
38+
<tap-button size="small" slot="extra">majid</tap-button>
3939
<tap-button size="small">دریافت تخفیف</tap-button>
4040
</tap-banner>
41-
<br />
41+
<br />
4242
<tap-banner
43-
variant="hero"
43+
variant="hero"
4444
heading="با ۱۶۳۰، تلفنی تپسی بگیر"
4545
description="درخواست خودرو بدون نیاز به اینترنت"
4646
image="https://able-media.tapsi.cab/statics/N31LNC95J6MCPIYB0D.jpg"

src/banner/banner.style.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { css } from "lit";
1+
import { css } from 'lit';
22

33
export default css`
44
:host {
@@ -36,17 +36,16 @@ export default css`
3636
3737
.banner h4 {
3838
color: var(--tap-banner-color-content);
39-
font-family: var(--tap-sys-typography-headline-xs-font);
39+
font-family: var(--tap-sys-typography-headline-xs-font, --tap-sys-font-family);
4040
line-height: var(--tap-sys-typography-headline-xs-height);
4141
font-size: var(--tap-sys-typography-headline-xs-size);
4242
font-weight: var(--tap-sys-typography-headline-xs-weight);
43-
margin: 0;
44-
margin-bottom: var(--tap-sys-spacing-3);
43+
margin: 0 0 var(--tap-sys-spacing-3);
4544
}
4645
4746
.banner p {
4847
color: var(--tap-banner-color-content);
49-
font-family: var(--tap-sys-typography-body-xs-font);
48+
font-family: var(--tap-sys-typography-body-xs-font, --tap-sys-font-family);
5049
line-height: var(--tap-sys-typography-body-xs-height);
5150
font-size: var(--tap-sys-typography-body-xs-size);
5251
font-weight: var(--tap-sys-typography-body-xs-weight);

src/banner/banner.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import { LitElement, PropertyValues, html, nothing } from "lit";
2-
import { property } from "lit/decorators.js";
3-
import { classMap } from "lit/directives/class-map.js";
1+
import { LitElement, PropertyValues, html, nothing } from 'lit';
2+
import { property } from 'lit/decorators.js';
3+
import { classMap } from 'lit/directives/class-map.js';
44

55
export class Banner extends LitElement {
66
@property() heading?: string;
77
@property() description?: string;
88
@property() image?: string;
9-
@property({ type: Boolean, attribute: "full-width" }) fullWidth = false;
10-
@property() variant: "default" | "hero" = "default";
11-
@property({ attribute: "background-color" }) backgroundColor?: string;
12-
@property({ attribute: "text-color" }) textColor?: string;
9+
@property({ type: Boolean, attribute: 'full-width' }) fullWidth = false;
10+
@property() variant: 'default' | 'hero' = 'default';
11+
@property({ attribute: 'background-color' }) backgroundColor?: string;
12+
@property({ attribute: 'text-color' }) textColor?: string;
1313
// @property() loading?: boolean;
1414

1515
protected updated(changed: PropertyValues): void {
16-
if (changed.has("backgroundColor") && !!this.backgroundColor) {
16+
if (changed.has('backgroundColor') && !!this.backgroundColor) {
1717
this.style.setProperty(
18-
"--tap-banner-color-surface",
19-
this.backgroundColor
18+
'--tap-banner-color-surface',
19+
this.backgroundColor,
2020
);
2121
}
2222

23-
if (changed.has("textColor") && !!this.textColor) {
24-
this.style.setProperty("--tap-banner-color-content", this.textColor);
23+
if (changed.has('textColor') && !!this.textColor) {
24+
this.style.setProperty('--tap-banner-color-content', this.textColor);
2525
}
2626

27-
if (changed.has("image") && !!this.image) {
27+
if (changed.has('image') && !!this.image) {
2828
this.style.setProperty(
29-
"--tap-banner-background-image",
30-
`url(${this.image})`
29+
'--tap-banner-background-image',
30+
`url(${this.image})`,
3131
);
3232
}
3333
}
@@ -38,10 +38,10 @@ export class Banner extends LitElement {
3838
role="banner"
3939
class=${classMap({
4040
banner: true,
41-
hero: this.variant === "hero",
41+
hero: this.variant === 'hero',
4242
})}
4343
>
44-
${this.variant === "hero"
44+
${this.variant === 'hero'
4545
? html`
4646
<div class="extra">
4747
<slot name="extra"></slot>

src/banner/index.ts

+53-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,62 @@
1-
import { customElement } from "lit/decorators.js";
2-
import { Banner } from "./banner.js";
3-
import styles from "./banner.style.js";
1+
import { customElement } from 'lit/decorators.js';
2+
import { Banner } from './banner.js';
3+
import styles from './banner.style.js';
44

5-
@customElement("tap-banner")
5+
/**
6+
* ### Example
7+
*
8+
* ##### Simple
9+
*
10+
* ```html
11+
* <tap-banner heading="Welcome!" description="This is a banner."></tap-banner>
12+
* ```
13+
*
14+
* ##### Hero Variant
15+
*
16+
* ```html
17+
* <tap-banner variant="hero" heading="Hero Banner" description="This is a hero banner."></tap-banner>
18+
* ```
19+
*
20+
* @summary Display a banner with optional heading, description, and action slot.
21+
*
22+
* @prop {`string`} [`heading`] - The heading text to display in the banner.
23+
* @prop {`string`} [`description`] - The description text to display in the banner.
24+
* @prop {`string`} [`image`] - The URL of the background image to display in the banner.
25+
* @prop {`boolean`} [`full-width`=`false`] - Whether the banner should take the full width of its container.
26+
* @prop {`'default'` \| `'hero'`} [`variant`=`'default'`] - The variant style of the banner.
27+
* @prop {`string`} [`background-color`] - The background color of the banner.
28+
* @prop {`string`} [`textColor`] - The text color of the banner.
29+
*
30+
* @csspart `banner` - The main banner element.
31+
* @csspart `content` - The content container inside the banner.
32+
* @csspart `action` - The action container inside the banner.
33+
* @csspart `extra` - The extra slot container inside the hero variant.
34+
*
35+
* @cssprop [`--tap-sys-spacing-6`] - Spacing around the banner content.
36+
* @cssprop [`--tap-banner-color-surface`] - Background color of the banner.
37+
* @cssprop [`--tap-sys-radius-4`] - Border radius of the banner.
38+
* @cssprop [`--tap-banner-background-image`] - Background image of the banner.
39+
* @cssprop [`--tap-sys-spacing-4`] - Margin around the banner.
40+
* @cssprop [`--tap-banner-color-content`] - Text color of the banner.
41+
* @cssprop [`--tap-sys-typography-headline-xs-font`=`--tap-sys-font-family`] - Font family for the heading text.
42+
* @cssprop [`--tap-sys-typography-headline-xs-height`] - Line height for the heading text.
43+
* @cssprop [`--tap-sys-typography-headline-xs-size`] - Font size for the heading text.
44+
* @cssprop [`--tap-sys-typography-headline-xs-weight`] - Font weight for the heading text.
45+
* @cssprop [`--tap-sys-spacing-3`] - Margin below the heading text.
46+
* @cssprop [`--tap-sys-typography-body-xs-font`] - Font family for the description text.
47+
* @cssprop [`--tap-sys-typography-body-xs-height`] - Line height for the description text.
48+
* @cssprop [`--tap-sys-typography-body-xs-size`] - Font size for the description text.
49+
* @cssprop [`--tap-sys-typography-body-xs-weight`] - Font weight for the description text.
50+
* @cssprop [`--tap-sys-spacing-5`] - Margin above the action slot.
51+
* @cssprop [`--tap-sys-spacing-8`] - Minimum height of the extra slot in the hero variant.
52+
*/
53+
@customElement('tap-banner')
654
export class TapBanner extends Banner {
755
static readonly styles = [styles];
856
}
957

1058
declare global {
1159
interface HTMLElementTagNameMap {
12-
"tap-banner": TapBanner;
60+
'tap-banner': TapBanner;
1361
}
1462
}

0 commit comments

Comments
 (0)