-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init commit for dialog component
- Loading branch information
Rares Herta
committed
Mar 14, 2023
1 parent
db9d813
commit e83cfc2
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/bee-q/src/components/dialog/__tests__/bq-dialog.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,30 @@ | ||
import { newE2EPage } from '@stencil/core/testing'; | ||
|
||
describe('bq-dialog', () => { | ||
it('should render', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent('<bq-dialog></bq-dialog>'); | ||
|
||
const element = await page.find('bq-dialog'); | ||
|
||
expect(element).toHaveClass('hydrated'); | ||
}); | ||
|
||
it('should have shadow root', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent('<bq-dialog></bq-dialog>'); | ||
|
||
const element = await page.find('bq-dialog'); | ||
|
||
expect(element.shadowRoot).not.toBeNull(); | ||
}); | ||
|
||
it('should display text', async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent('<bq-dialog></bq-dialog>'); | ||
|
||
const element = await page.find('bq-dialog >>> p'); | ||
|
||
expect(element).toEqualText('My name is Stencil'); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/bee-q/src/components/dialog/_storybook/bq-dialog.mdx
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,15 @@ | ||
import { ArgsTable, Canvas, Story } from '@storybook/addon-docs'; | ||
|
||
# Dialog | ||
|
||
## Variations | ||
|
||
### Default | ||
|
||
<Canvas> | ||
<Story id="components-dialog--default" /> | ||
</Canvas> | ||
|
||
## Properties | ||
|
||
<ArgsTable of="bq-dialog" /> |
24 changes: 24 additions & 0 deletions
24
packages/bee-q/src/components/dialog/_storybook/bq-dialog.stories.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,24 @@ | ||
import { html } from 'lit-html'; | ||
import mdx from './bq-dialog.mdx'; | ||
|
||
export default { | ||
title: 'Components/Dialog', | ||
component: 'bq-dialog', | ||
parameters: { | ||
docs: { | ||
page: mdx, | ||
}, | ||
}, | ||
argTypes: { | ||
text: { control: 'text', table: { disable: true } }, | ||
}, | ||
args: { | ||
text: 'text', | ||
}, | ||
}; | ||
|
||
const Template = (args) => { | ||
return html`<bq-dialog>${args.text}</bq-dialog>`; | ||
}; | ||
|
||
export const Default = (args) => Template(args); |
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,59 @@ | ||
import { h, Component } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'bq-dialog', | ||
styleUrl: './scss/bq-dialog.scss', | ||
shadow: true, | ||
}) | ||
export class BqDialog { | ||
// Own Properties | ||
// ==================== | ||
|
||
// Reference to host HTML element | ||
// =================================== | ||
|
||
// State() variables | ||
// Inlined decorator, alphabetical order | ||
// ======================================= | ||
|
||
// Public Property API | ||
// ======================== | ||
|
||
// Prop lifecycle events | ||
// ======================= | ||
|
||
// Events section | ||
// Requires JSDocs for public API documentation | ||
// ============================================== | ||
|
||
// Component lifecycle events | ||
// Ordered by their natural call order | ||
// ===================================== | ||
|
||
// Listeners | ||
// ============== | ||
|
||
// Public methods API | ||
// These methods are exposed on the host element. | ||
// Always use two lines. | ||
// Public Methods must be async. | ||
// Requires JSDocs for public API documentation. | ||
// =============================================== | ||
|
||
// Local methods | ||
// Internal business logic. | ||
// These methods cannot be called from the host element. | ||
// ======================================================= | ||
|
||
// render() function | ||
// Always the last one in the class. | ||
// =================================== | ||
|
||
render() { | ||
return ( | ||
<p class="m-[var(--bq-dialog--margin)]"> | ||
My name is Stencil <slot /> | ||
</p> | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/bee-q/src/components/dialog/scss/bq-dialog-variables.scss
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,7 @@ | ||
/* -------------------------------------------------------------------------- */ | ||
/* Dialog custom properties */ | ||
/* -------------------------------------------------------------------------- */ | ||
|
||
:host { | ||
--bq-dialog--margin: 1px; | ||
} |
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,9 @@ | ||
/* -------------------------------------------------------------------------- */ | ||
/* Dialog styles */ | ||
/* -------------------------------------------------------------------------- */ | ||
|
||
@import './bq-dialog-variables'; | ||
|
||
:host { | ||
@apply block; | ||
} |