diff --git a/src/components.d.ts b/src/components.d.ts index c4eff15..25c55c3 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -61,6 +61,12 @@ export namespace Components { "hidable": boolean; "title": string; } + interface DEmptyState { + "buttonText": string | undefined; + "heading": string; + "href": string | undefined; + "text": string; + } interface DFeedback { "feedback": string; "message": string | undefined; @@ -189,6 +195,12 @@ declare global { prototype: HTMLDDefinitionElement; new (): HTMLDDefinitionElement; }; + interface HTMLDEmptyStateElement extends Components.DEmptyState, HTMLStencilElement { + } + var HTMLDEmptyStateElement: { + prototype: HTMLDEmptyStateElement; + new (): HTMLDEmptyStateElement; + }; interface HTMLDFeedbackElementEventMap { "dClose": void; } @@ -293,6 +305,7 @@ declare global { "d-credential-detail": HTMLDCredentialDetailElement; "d-credential-service": HTMLDCredentialServiceElement; "d-definition": HTMLDDefinitionElement; + "d-empty-state": HTMLDEmptyStateElement; "d-feedback": HTMLDFeedbackElement; "d-header": HTMLDHeaderElement; "d-heading": HTMLDHeadingElement; @@ -363,6 +376,12 @@ declare namespace LocalJSX { "hidable"?: boolean; "title"?: string; } + interface DEmptyState { + "buttonText"?: string | undefined; + "heading"?: string; + "href"?: string | undefined; + "text"?: string; + } interface DFeedback { "feedback"?: string; "message"?: string | undefined; @@ -429,6 +448,7 @@ declare namespace LocalJSX { "d-credential-detail": DCredentialDetail; "d-credential-service": DCredentialService; "d-definition": DDefinition; + "d-empty-state": DEmptyState; "d-feedback": DFeedback; "d-header": DHeader; "d-heading": DHeading; @@ -455,6 +475,7 @@ declare module "@stencil/core" { "d-credential-detail": LocalJSX.DCredentialDetail & JSXBase.HTMLAttributes; "d-credential-service": LocalJSX.DCredentialService & JSXBase.HTMLAttributes; "d-definition": LocalJSX.DDefinition & JSXBase.HTMLAttributes; + "d-empty-state": LocalJSX.DEmptyState & JSXBase.HTMLAttributes; "d-feedback": LocalJSX.DFeedback & JSXBase.HTMLAttributes; "d-header": LocalJSX.DHeader & JSXBase.HTMLAttributes; "d-heading": LocalJSX.DHeading & JSXBase.HTMLAttributes; diff --git a/src/components/button/readme.md b/src/components/button/readme.md index 647bf28..0555b84 100644 --- a/src/components/button/readme.md +++ b/src/components/button/readme.md @@ -32,12 +32,14 @@ ### Used by + - [d-empty-state](../empty-state) - [d-input](../input) - [d-scan-button](../scan-button) ### Graph ```mermaid graph TD; + d-empty-state --> d-button d-input --> d-button d-scan-button --> d-button style d-button fill:#f9f,stroke:#333,stroke-width:4px diff --git a/src/components/empty-state/d-empty-state.css b/src/components/empty-state/d-empty-state.css new file mode 100644 index 0000000..5d4e87f --- /dev/null +++ b/src/components/empty-state/d-empty-state.css @@ -0,0 +1,3 @@ +:host { + display: block; +} diff --git a/src/components/empty-state/d-empty-state.tsx b/src/components/empty-state/d-empty-state.tsx new file mode 100644 index 0000000..11a0062 --- /dev/null +++ b/src/components/empty-state/d-empty-state.tsx @@ -0,0 +1,41 @@ +import { Component, Host, Prop, h } from '@stencil/core'; + +@Component({ + tag: 'd-empty-state', + styleUrl: 'd-empty-state.css', + shadow: true, +}) +export class DEmptyState { + @Prop() heading: string; + @Prop() text: string; + @Prop() buttonText: string | undefined = undefined; + @Prop() href: string | undefined = undefined; + + render() { + return ( + +
+
+ +
+
+ {this.heading} + + {this.text} + +
+ {this.buttonText && ( + + {this.buttonText}{' '} +
+ + + +
+
+ )} +
+
+ ); + } +} diff --git a/src/components/empty-state/empty-state.stories.ts b/src/components/empty-state/empty-state.stories.ts new file mode 100644 index 0000000..6cf224a --- /dev/null +++ b/src/components/empty-state/empty-state.stories.ts @@ -0,0 +1,69 @@ +import { DEmptyState } from './d-empty-state'; +import { Meta, StoryObj } from '@storybook/html'; + +const meta = { + title: 'Design System/Molecules/EmptyState', + render: args => + ` + + + + + + + + + `, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + heading: 'Nothing in your wallet', + text: 'Start getting your first credential', + buttonText: 'Go to Home', + href: '#', + }, + parameters: { + design: { + type: 'figma', + url: 'https://www.figma.com/file/Uxc5APvp9BsY9r71rF8HhQ/DIDWallet-UI-Trial?node-id=100%3A1839&mode=dev', + }, + }, +}; diff --git a/src/components/empty-state/readme.md b/src/components/empty-state/readme.md new file mode 100644 index 0000000..32ac967 --- /dev/null +++ b/src/components/empty-state/readme.md @@ -0,0 +1,37 @@ +# d-empty-state + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| ------------ | ------------- | ----------- | -------- | ----------- | +| `buttonText` | `button-text` | | `string` | `undefined` | +| `heading` | `heading` | | `string` | `undefined` | +| `href` | `href` | | `string` | `undefined` | +| `text` | `text` | | `string` | `undefined` | + + +## Dependencies + +### Depends on + +- [d-heading](../heading) +- [d-text](../text) +- [d-button](../button) + +### Graph +```mermaid +graph TD; + d-empty-state --> d-heading + d-empty-state --> d-text + d-empty-state --> d-button + style d-empty-state fill:#f9f,stroke:#333,stroke-width:4px +``` + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/src/components/empty-state/test/d-empty-state.e2e.ts b/src/components/empty-state/test/d-empty-state.e2e.ts new file mode 100644 index 0000000..fd45fe3 --- /dev/null +++ b/src/components/empty-state/test/d-empty-state.e2e.ts @@ -0,0 +1,11 @@ +import { newE2EPage } from '@stencil/core/testing'; + +describe('d-empty-state', () => { + it('renders', async () => { + const page = await newE2EPage(); + await page.setContent(''); + + const element = await page.find('d-empty-state'); + expect(element).toHaveClass('hydrated'); + }); +}); diff --git a/src/components/empty-state/test/d-empty-state.spec.tsx b/src/components/empty-state/test/d-empty-state.spec.tsx new file mode 100644 index 0000000..1366286 --- /dev/null +++ b/src/components/empty-state/test/d-empty-state.spec.tsx @@ -0,0 +1,26 @@ +import { newSpecPage } from '@stencil/core/testing'; +import { DEmptyState } from '../d-empty-state'; + +describe('d-empty-state', () => { + it('renders', async () => { + const page = await newSpecPage({ + components: [DEmptyState], + html: ``, + }); + expect(page.root).toEqualHtml(` + + +
+
+ +
+
+ + +
+
+
+
+ `); + }); +}); diff --git a/src/components/heading/readme.md b/src/components/heading/readme.md index 92b9425..e1f0f23 100644 --- a/src/components/heading/readme.md +++ b/src/components/heading/readme.md @@ -18,6 +18,8 @@ ### Used by - [d-credential-card](../credential-card) + - [d-empty-state](../empty-state) + - [d-header](../header) - [d-logo](../logo) - [d-page-description](../page-description) - [d-session-card](../session-card) @@ -26,6 +28,8 @@ ```mermaid graph TD; d-credential-card --> d-heading + d-empty-state --> d-heading + d-header --> d-heading d-logo --> d-heading d-page-description --> d-heading d-session-card --> d-heading diff --git a/src/components/text/readme.md b/src/components/text/readme.md index 2be2702..ef03662 100644 --- a/src/components/text/readme.md +++ b/src/components/text/readme.md @@ -19,6 +19,7 @@ - [d-activity-card](../activity-card) - [d-credential-service](../credential-service) + - [d-empty-state](../empty-state) - [d-feedback](../feedback) - [d-input](../input) - [d-page-description](../page-description) @@ -30,6 +31,7 @@ graph TD; d-activity-card --> d-text d-credential-service --> d-text + d-empty-state --> d-text d-feedback --> d-text d-input --> d-text d-page-description --> d-text