-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add page description component (title and subtitle) (#99)
* feat: add page description component (title and subtitle) * fix: test spec
- Loading branch information
1 parent
7f041fc
commit feae57a
Showing
9 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:host { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
src/components/page-description/page-description.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
src/components/page-description/test/d-page-description.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
src/components/page-description/test/d-page-description.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters