-
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: activity card * feat: activity card --------- Co-authored-by: Puria Nafisi Azizi <[email protected]>
- Loading branch information
1 parent
feae57a
commit 3ed3316
Showing
10 changed files
with
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { DActivityCard } from './d-activity-card'; | ||
import { Meta, StoryObj } from '@storybook/html'; | ||
|
||
const meta = { | ||
title: 'Design System/Molecule/Activity', | ||
render: args => | ||
`<d-activity-card | ||
name="${args.name}" | ||
logo="${args.logo}" | ||
description="${args.description}" | ||
date="${args.date}" | ||
type="${args.type}" | ||
${args.message && `message="${args.message}"`}> | ||
<d-button size="small" color="accent"> | ||
action 1 | ||
</d-button> | ||
<d-button size="small" color="primary"> | ||
action 2 | ||
</d-button> | ||
</d-activity-card>`, | ||
} satisfies Meta<DActivityCard>; | ||
|
||
export default meta; | ||
type Story = StoryObj<DActivityCard>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
name: 'Proof of humanity is expired', | ||
// placeholder logo | ||
logo: 'https://via.placeholder.com/150', | ||
message: 'Proof of humanity is expired', | ||
description: 'Your proof of humanity has expired. Please renew it if you need it.', | ||
date: '1 day ago', | ||
type: 'error', | ||
}, | ||
}; |
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,38 @@ | ||
import { Component, Host, Prop, h } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'd-activity-card', | ||
styleUrl: 'd-activity-card.css', | ||
shadow: true, | ||
}) | ||
export class DActivityCard { | ||
@Prop({ reflect: true }) name: string; | ||
@Prop({ reflect: true }) logo: string; | ||
@Prop({ reflect: true }) message: string; | ||
@Prop({ reflect: true }) description: string; | ||
@Prop({ reflect: true }) date: string; | ||
@Prop({ reflect: true }) type: 'error' | 'warning' | 'success'; | ||
|
||
render() { | ||
return ( | ||
<Host> | ||
<div class="items-start border-stroke flex gap-4 border-b py-2 w-fit"> | ||
<d-avatar src={this.logo} name={this.name} shape="square" /> | ||
<div class="flex flex-col gap-2"> | ||
<h2>{this.message}</h2> | ||
<d-text size="s" class="text-on-alt"> | ||
{this.description} | ||
</d-text> | ||
<div class="flex items-center gap-2.5"> | ||
<d-info-led type={this.type} /> | ||
<d-text size="xs">{this.date}</d-text> | ||
</div> | ||
<div class="flex justify-end gap-2.5"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
</div> | ||
</Host> | ||
); | ||
} | ||
} |
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,40 @@ | ||
# d-activity-card | ||
|
||
|
||
|
||
<!-- Auto Generated Below --> | ||
|
||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| --------------- | ---------------- | ----------- | ----------------------------------- | ----------- | | ||
| `credentialSrc` | `credential-src` | | `string` | `undefined` | | ||
| `date` | `date` | | `string` | `undefined` | | ||
| `description` | `description` | | `string` | `undefined` | | ||
| `logo` | `logo` | | `string` | `undefined` | | ||
| `message` | `message` | | `string` | `undefined` | | ||
| `name` | `name` | | `string` | `undefined` | | ||
| `type` | `type` | | `"error" \| "success" \| "warning"` | `undefined` | | ||
|
||
|
||
## Dependencies | ||
|
||
### Depends on | ||
|
||
- [d-avatar](../avatar) | ||
- [d-text](../text) | ||
- [d-info-led](../info-led) | ||
|
||
### Graph | ||
```mermaid | ||
graph TD; | ||
d-activity-card --> d-avatar | ||
d-activity-card --> d-text | ||
d-activity-card --> d-info-led | ||
style d-activity-card fill:#f9f,stroke:#333,stroke-width:4px | ||
``` | ||
|
||
---------------------------------------------- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
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-activity-card', () => { | ||
it('renders', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent('<d-activity-card></d-activity-card>'); | ||
|
||
const element = await page.find('d-activity-card'); | ||
expect(element).toHaveClass('hydrated'); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
src/components/activity-card/test/d-activity-card.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,18 @@ | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { DActivityCard } from '../d-activity-card'; | ||
|
||
describe('d-activity-card', () => { | ||
it('renders', async () => { | ||
const page = await newSpecPage({ | ||
components: [DActivityCard], | ||
html: `<d-activity-card></d-activity-card>`, | ||
}); | ||
expect(page.root).toEqualHtml(` | ||
<d-activity-card> | ||
<mock:shadow-root> | ||
<slot></slot> | ||
</mock:shadow-root> | ||
</d-activity-card> | ||
`); | ||
}); | ||
}); |
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