Skip to content

Commit

Permalink
feat: init commit for dialog component
Browse files Browse the repository at this point in the history
  • Loading branch information
Rares Herta committed Mar 14, 2023
1 parent db9d813 commit e83cfc2
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/bee-q/src/components/dialog/__tests__/bq-dialog.e2e.ts
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 packages/bee-q/src/components/dialog/_storybook/bq-dialog.mdx
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" />
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);
59 changes: 59 additions & 0 deletions packages/bee-q/src/components/dialog/bq-dialog.tsx
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>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* -------------------------------------------------------------------------- */
/* Dialog custom properties */
/* -------------------------------------------------------------------------- */

:host {
--bq-dialog--margin: 1px;
}
9 changes: 9 additions & 0 deletions packages/bee-q/src/components/dialog/scss/bq-dialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* -------------------------------------------------------------------------- */
/* Dialog styles */
/* -------------------------------------------------------------------------- */

@import './bq-dialog-variables';

:host {
@apply block;
}

0 comments on commit e83cfc2

Please sign in to comment.