Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dialog): add new <bq-dialog> component #269

Merged
merged 28 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
135ba1a
feat(dialog): init commit for dialog component
Mar 14, 2023
824baff
feat(dialog): add button for open dialog modal
Mar 14, 2023
3a77e25
feat(dialog): add sizes for storybook
Mar 15, 2023
fb449cd
feat(dialog): add variant for footer dialog
Mar 16, 2023
8182f6e
feat(dialog): add overlay and click outside functionality and styling
Mar 17, 2023
25aea80
feat(dialog): update styling
Mar 20, 2023
b1e1478
feat(dialog): refactor html layout and scss file
Mar 21, 2023
172ba74
feat(dialog): delete unnecessary variables and fix bug for click icon…
Mar 21, 2023
6e235f1
feat(dialog): delete unecessary variables
Mar 21, 2023
71c053c
feat(dialog): add cursor for close button
Mar 22, 2023
ed9af02
feat(dialog): update dialog component storybook
Mar 22, 2023
5a47509
feat(dialog): update comments
Mar 23, 2023
bcaf455
feat(dialog): change html structure and add e2e tests
Mar 31, 2023
9a58da1
feat(dialog): delete commented code
Mar 31, 2023
859863a
feat(dialog): fix eslint
endv-bogdanb Jun 14, 2023
40b9faa
feat(dialog): update spacing with tokens
endv-bogdanb Jun 16, 2023
7223551
feat(dialog): rename variant to footerApperance
endv-bogdanb Jun 16, 2023
ed6b7ef
feat(dialog): add option to hide x button
endv-bogdanb Jun 16, 2023
25980fa
fix(dialog): styling when icon is no present
endv-bogdanb Jun 16, 2023
3785216
refactor(dialog): rename closable and info
endv-bogdanb Jun 16, 2023
59c3ad0
feat(dialog): restructure JSX and add esc key support
endv-bogdanb Jun 16, 2023
124d44e
refactor(dialog): use native HTML dialog element
dgonzalezr Jun 26, 2023
c3ca5ae
fix(dialog backdrop): make CSS variable colors available
dgonzalezr Jun 26, 2023
03d090e
fix(tailwind config): wrong grey colors group
dgonzalezr Jun 26, 2023
3dcc0d1
docs(dialog): update storybook examples
dgonzalezr Jun 26, 2023
0038ea9
refactor(dialog): remove header icon slot and improve layout
dgonzalezr Jun 27, 2023
6bbb39c
feat(dialog): add `cancel` method and `bqCancel` event emitter
dgonzalezr Jun 27, 2023
443ec3b
docs(dialog): update overview documentation
dgonzalezr Jun 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions config/tailwind.primitve.colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ export const PRIMITIVE_COLORS = {
1000: 'var(--bq-green-1000)',
},
grey: {
50: 'var(--bq-neutral-50)',
100: 'var(--bq-neutral-100)',
200: 'var(--bq-neutral-200)',
300: 'var(--bq-neutral-300)',
400: 'var(--bq-neutral-400)',
500: 'var(--bq-neutral-500)',
600: 'var(--bq-neutral-600)',
700: 'var(--bq-neutral-700)',
800: 'var(--bq-neutral-800)',
900: 'var(--bq-neutral-900)',
50: 'var(--bq-grey-50)',
100: 'var(--bq-grey-100)',
200: 'var(--bq-grey-200)',
300: 'var(--bq-grey-300)',
400: 'var(--bq-grey-400)',
500: 'var(--bq-grey-500)',
600: 'var(--bq-grey-600)',
700: 'var(--bq-grey-700)',
800: 'var(--bq-grey-800)',
900: 'var(--bq-grey-900)',
},
indigo: {
100: 'var(--bq-indigo-100)',
Expand Down
91 changes: 91 additions & 0 deletions packages/bee-q/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { TAvatarShape, TAvatarSize } from "./components/avatar/bq-avatar.types";
import { TBadgeSize } from "./components/badge/bq-badge.types";
import { TButtonAppearance, TButtonSize, TButtonType, TButtonVariant } from "./components/button/bq-button.types";
import { TDialogFooterAppearance, TDialogSize } from "./components/dialog/bq-dialog.types";
import { TDividerOrientation, TDividerStrokeLinecap, TDividerTitleAlignment } from "./components/divider/bq-divider.types";
import { TIconWeight } from "./components/icon/bq-icon.types";
import { TNotificationType } from "./components/notification/bq-notification.types";
Expand All @@ -22,6 +23,7 @@ import { FloatingUIPlacement } from "./services/interfaces";
export { TAvatarShape, TAvatarSize } from "./components/avatar/bq-avatar.types";
export { TBadgeSize } from "./components/badge/bq-badge.types";
export { TButtonAppearance, TButtonSize, TButtonType, TButtonVariant } from "./components/button/bq-button.types";
export { TDialogFooterAppearance, TDialogSize } from "./components/dialog/bq-dialog.types";
export { TDividerOrientation, TDividerStrokeLinecap, TDividerTitleAlignment } from "./components/divider/bq-divider.types";
export { TIconWeight } from "./components/icon/bq-icon.types";
export { TNotificationType } from "./components/notification/bq-notification.types";
Expand Down Expand Up @@ -172,6 +174,44 @@ export namespace Components {
*/
"value": string;
}
interface BqDialog {
/**
* Dismiss or cancel the dialog
*/
"cancel": () => Promise<void>;
/**
* If true, the dialog will not close when clicking on the backdrop overlay
*/
"disableCloseClickOutside": boolean;
/**
* If true, the dialog will not close when the [Esc] key is press
*/
"disableCloseEscKeydown": boolean;
/**
* The appearance of footer
*/
"footerApperance": TDialogFooterAppearance;
/**
* Closes the dialog
*/
"hide": () => Promise<void>;
/**
* If true, it hides the close button
*/
"hideCloseButton": boolean;
/**
* If true, the dialog will be shown as open
*/
"open": boolean;
/**
* Open the dialog
*/
"show": () => Promise<void>;
/**
* The size of the dialog
*/
"size": TDialogSize;
}
interface BqDivider {
/**
* If true, the divider has a dashed pattern
Expand Down Expand Up @@ -592,6 +632,10 @@ export interface BqCheckboxCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLBqCheckboxElement;
}
export interface BqDialogCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLBqDialogElement;
}
export interface BqIconCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLBqIconElement;
Expand Down Expand Up @@ -663,6 +707,12 @@ declare global {
prototype: HTMLBqCheckboxElement;
new (): HTMLBqCheckboxElement;
};
interface HTMLBqDialogElement extends Components.BqDialog, HTMLStencilElement {
}
var HTMLBqDialogElement: {
prototype: HTMLBqDialogElement;
new (): HTMLBqDialogElement;
};
interface HTMLBqDividerElement extends Components.BqDivider, HTMLStencilElement {
}
var HTMLBqDividerElement: {
Expand Down Expand Up @@ -762,6 +812,7 @@ declare global {
"bq-badge": HTMLBqBadgeElement;
"bq-button": HTMLBqButtonElement;
"bq-checkbox": HTMLBqCheckboxElement;
"bq-dialog": HTMLBqDialogElement;
"bq-divider": HTMLBqDividerElement;
"bq-icon": HTMLBqIconElement;
"bq-notification": HTMLBqNotificationElement;
Expand Down Expand Up @@ -929,6 +980,44 @@ declare namespace LocalJSX {
*/
"value": string;
}
interface BqDialog {
/**
* If true, the dialog will not close when clicking on the backdrop overlay
*/
"disableCloseClickOutside"?: boolean;
/**
* If true, the dialog will not close when the [Esc] key is press
*/
"disableCloseEscKeydown"?: boolean;
/**
* The appearance of footer
*/
"footerApperance"?: TDialogFooterAppearance;
/**
* If true, it hides the close button
*/
"hideCloseButton"?: boolean;
/**
* Callback handler emitted when the dialog has been canceled or dismissed
*/
"onBqCancel"?: (event: BqDialogCustomEvent<void>) => void;
/**
* Callback handler emitted when the dialog will close
*/
"onBqClose"?: (event: BqDialogCustomEvent<void>) => void;
/**
* Callback handler emitted when the dialog will open
*/
"onBqOpen"?: (event: BqDialogCustomEvent<void>) => void;
/**
* If true, the dialog will be shown as open
*/
"open"?: boolean;
/**
* The size of the dialog
*/
"size"?: TDialogSize;
}
interface BqDivider {
/**
* If true, the divider has a dashed pattern
Expand Down Expand Up @@ -1377,6 +1466,7 @@ declare namespace LocalJSX {
"bq-badge": BqBadge;
"bq-button": BqButton;
"bq-checkbox": BqCheckbox;
"bq-dialog": BqDialog;
"bq-divider": BqDivider;
"bq-icon": BqIcon;
"bq-notification": BqNotification;
Expand Down Expand Up @@ -1407,6 +1497,7 @@ declare module "@stencil/core" {
*/
"bq-button": LocalJSX.BqButton & JSXBase.HTMLAttributes<HTMLBqButtonElement>;
"bq-checkbox": LocalJSX.BqCheckbox & JSXBase.HTMLAttributes<HTMLBqCheckboxElement>;
"bq-dialog": LocalJSX.BqDialog & JSXBase.HTMLAttributes<HTMLBqDialogElement>;
"bq-divider": LocalJSX.BqDivider & JSXBase.HTMLAttributes<HTMLBqDividerElement>;
/**
* Icons are simplified images that graphically explain the meaning of an object on the screen.
Expand Down
2 changes: 2 additions & 0 deletions packages/bee-q/src/components/button/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Buttons are designed for users to take action on a page or a screen.

### Used by

- [bq-dialog](../dialog)
- [bq-notification](../notification)

### Depends on
Expand All @@ -59,6 +60,7 @@ Buttons are designed for users to take action on a page or a screen.
```mermaid
graph TD;
bq-button --> bq-icon
bq-dialog --> bq-button
bq-notification --> bq-button
style bq-button fill:#f9f,stroke:#333,stroke-width:4px
```
Expand Down
41 changes: 41 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,41 @@
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 title', async () => {
const page = await newE2EPage();
await page.setContent('<bq-dialog><h3 slot="title">Dialog Title</h3></bq-dialog>');

const element = await page.find('bq-dialog');

expect(element).toEqualText('Dialog Title');
});

it('should display content', async () => {
const page = await newE2EPage();
await page.setContent(
'<bq-dialog><p slot="content">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p></bq-dialog>',
);

const element = await page.find('bq-dialog');

expect(element).toEqualText('Lorem Ipsum is simply dummy text of the printing and typesetting industry.');
});
});
24 changes: 24 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,24 @@
import { ArgTypes, Stories, Title, Subtitle } from '@storybook/addon-docs';

<Title>Dialog</Title>

Description A Dialog is a UI component used to display additional content or prompt a user for action.
It provides a way to display additional information, options, or controls in a separate, non-obstructive interface element.

<Subtitle>Usage</Subtitle>

To ensure a seamless user experience and maximize the effectiveness of the Dialog Modal component, it is recommended to follow these best practices:

- Keep it simple: Avoid overwhelming the user with excessive content within the Dialog Modal. Strive for simplicity and present only the essential information or options necessary to complete the intended action or convey the message.
- Use a clear and concise title: Provide a descriptive title that clearly communicates the purpose or content of the Dialog Modal. This helps users quickly understand the context and relevance of the dialog.
- Prioritize actions: If there are multiple actions within the Dialog Modal, make sure to present them in an order that helps users easily identify and choose the appropriate action. Consider using clear call-to-action buttons with descriptive labels to guide the user.

<Subtitle>👍 When to use</Subtitle>

- Displaying additional information, options, or controls that are relevant to a specific task or action.
- Prompting a user for confirmation or input, such as when performing a potentially destructive action or making changes to a critical setting.
- Providing a way for users to access related content or features without navigating away from the current interface.

<Title>Properties</Title>

<ArgTypes of="bq-dialog" />
Loading