Skip to content

Commit

Permalink
feat: add page description component (title and subtitle) (#99)
Browse files Browse the repository at this point in the history
* feat: add page description component (title and subtitle)

* fix: test spec
  • Loading branch information
phoebus-84 authored Jun 19, 2024
1 parent 7f041fc commit feae57a
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export namespace Components {
}
interface DLogo {
}
interface DPageDescription {
"description"?: string;
"title": string;
}
interface DSessionCard {
"date": string;
"sid": string;
Expand Down Expand Up @@ -227,6 +231,12 @@ declare global {
prototype: HTMLDLogoElement;
new (): HTMLDLogoElement;
};
interface HTMLDPageDescriptionElement extends Components.DPageDescription, HTMLStencilElement {
}
var HTMLDPageDescriptionElement: {
prototype: HTMLDPageDescriptionElement;
new (): HTMLDPageDescriptionElement;
};
interface HTMLDSessionCardElement extends Components.DSessionCard, HTMLStencilElement {
}
var HTMLDSessionCardElement: {
Expand Down Expand Up @@ -265,6 +275,7 @@ declare global {
"d-info-led": HTMLDInfoLedElement;
"d-input": HTMLDInputElement;
"d-logo": HTMLDLogoElement;
"d-page-description": HTMLDPageDescriptionElement;
"d-session-card": HTMLDSessionCardElement;
"d-tab-button": HTMLDTabButtonElement;
"d-text": HTMLDTextElement;
Expand Down Expand Up @@ -353,6 +364,10 @@ declare namespace LocalJSX {
}
interface DLogo {
}
interface DPageDescription {
"description"?: string;
"title"?: string;
}
interface DSessionCard {
"date"?: string;
"sid"?: string;
Expand Down Expand Up @@ -383,6 +398,7 @@ declare namespace LocalJSX {
"d-info-led": DInfoLed;
"d-input": DInput;
"d-logo": DLogo;
"d-page-description": DPageDescription;
"d-session-card": DSessionCard;
"d-tab-button": DTabButton;
"d-text": DText;
Expand All @@ -406,6 +422,7 @@ declare module "@stencil/core" {
"d-info-led": LocalJSX.DInfoLed & JSXBase.HTMLAttributes<HTMLDInfoLedElement>;
"d-input": LocalJSX.DInput & JSXBase.HTMLAttributes<HTMLDInputElement>;
"d-logo": LocalJSX.DLogo & JSXBase.HTMLAttributes<HTMLDLogoElement>;
"d-page-description": LocalJSX.DPageDescription & JSXBase.HTMLAttributes<HTMLDPageDescriptionElement>;
"d-session-card": LocalJSX.DSessionCard & JSXBase.HTMLAttributes<HTMLDSessionCardElement>;
"d-tab-button": LocalJSX.DTabButton & JSXBase.HTMLAttributes<HTMLDTabButtonElement>;
"d-text": LocalJSX.DText & JSXBase.HTMLAttributes<HTMLDTextElement>;
Expand Down
2 changes: 2 additions & 0 deletions src/components/heading/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [d-credential-card](../credential-card)
- [d-header](../header)
- [d-logo](../logo)
- [d-page-description](../page-description)
- [d-session-card](../session-card)

### Graph
Expand All @@ -28,6 +29,7 @@ graph TD;
d-credential-card --> d-heading
d-header --> d-heading
d-logo --> d-heading
d-page-description --> d-heading
d-session-card --> d-heading
style d-heading fill:#f9f,stroke:#333,stroke-width:4px
```
Expand Down
3 changes: 3 additions & 0 deletions src/components/page-description/d-page-description.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:host {
display: block;
}
23 changes: 23 additions & 0 deletions src/components/page-description/d-page-description.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, Host, Prop, h } from '@stencil/core';

@Component({
tag: 'd-page-description',
styleUrl: 'd-page-description.css',
shadow: true,
})
export class DPageDescription {
@Prop({ reflect: true }) title: string;
@Prop({ reflect: true }) description?: string;

render() {
return (
<Host>
<d-heading size="s">{this.title}</d-heading>
<d-text size="l">
<p>{this.description}</p>
</d-text>
</Host>
);
}

}
26 changes: 26 additions & 0 deletions src/components/page-description/page-description.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Meta, StoryObj } from '@storybook/html';
import type { Components } from '../../components.js';

const meta = {
title: 'Design System/Molecule/PageDescription',
render: args => `<d-page-description title='${args.title}' ${args.description?`description="${args.description}"`: ''}></d-page-description>`,
} satisfies Meta<Components.DPageDescription>;

export default meta;
type Story = StoryObj<Components.DPageDescription>;

export const Default: Story = {
args: {
title: 'Issuance services',
description: 'Request your credential from the followings:',
},
parameters: {},
};

export const NoDescription: Story = {
args: {
title: 'Issuance services',
},
parameters: {
},
};
33 changes: 33 additions & 0 deletions src/components/page-description/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# d-page-description



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | ------------- | ----------- | -------- | ----------- |
| `description` | `description` | | `string` | `undefined` |
| `title` | `title` | | `string` | `undefined` |


## Dependencies

### Depends on

- [d-heading](../heading)
- [d-text](../text)

### Graph
```mermaid
graph TD;
d-page-description --> d-heading
d-page-description --> d-text
style d-page-description fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
11 changes: 11 additions & 0 deletions src/components/page-description/test/d-page-description.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { newE2EPage } from '@stencil/core/testing';

describe('d-page-description', () => {
it('renders', async () => {
const page = await newE2EPage();
await page.setContent('<d-page-description></d-page-description>');

const element = await page.find('d-page-description');
expect(element).toHaveClass('hydrated');
});
});
21 changes: 21 additions & 0 deletions src/components/page-description/test/d-page-description.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { newSpecPage } from '@stencil/core/testing';
import { DPageDescription } from '../d-page-description';

describe('d-page-description', () => {
it('renders', async () => {
const page = await newSpecPage({
components: [DPageDescription],
html: `<d-page-description></d-page-description>`,
});
expect(page.root).toEqualHtml(`
<d-page-description>
<mock:shadow-root>
<d-heading size="s"></d-heading>
<d-text size="l">
<p></p>
</d-text>
</mock:shadow-root>
</d-page-description>
`);
});
});
2 changes: 2 additions & 0 deletions src/components/text/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [d-credential-service](../credential-service)
- [d-feedback](../feedback)
- [d-input](../input)
- [d-page-description](../page-description)
- [d-session-card](../session-card)
- [d-tab-button](../tab-button)

Expand All @@ -29,6 +30,7 @@ graph TD;
d-credential-service --> d-text
d-feedback --> d-text
d-input --> d-text
d-page-description --> d-text
d-session-card --> d-text
d-tab-button --> d-text
style d-text fill:#f9f,stroke:#333,stroke-width:4px
Expand Down

0 comments on commit feae57a

Please sign in to comment.