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

[Dialog, Tooltip, Notification]: Sync components to match Figma designs #374

Merged
merged 19 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a3553af
DS-292: Adjust notification borders and typography
RiinaKuu May 29, 2024
2b540bc
DS-292: Change tooltip background color from ngMaterial to Fudis gray…
RiinaKuu May 30, 2024
1af1f14
DS-292: Adjust Dialog styles according to Firgma designs
RiinaKuu May 30, 2024
93ba4e1
DS-292: Rearrange Dialog stories
RiinaKuu May 31, 2024
611c03b
Merge branch 'main' into DS-292-storybook-figma-sync
RiinaKuu May 31, 2024
030bf06
Merge branch 'main' into DS-292-storybook-figma-sync
videoeero Jun 3, 2024
913ff23
Merge branch 'main' into DS-292-storybook-figma-sync
RiinaKuu Jun 4, 2024
9b91699
DS-292: Change disabled datepicker calendar icon to gray-dark
RiinaKuu Jun 4, 2024
6ac41d0
DS-292: Update Dialog Playwright base images
RiinaKuu Jun 5, 2024
9859ebd
DS-292: Update Tooltip Playwright base images
RiinaKuu Jun 5, 2024
1d9b55a
DS-292: Update disabled Datepicker Playwright base images
RiinaKuu Jun 5, 2024
ef837a0
DS-292: Update Notification Playwright base images
RiinaKuu Jun 5, 2024
e223856
DS-292: Update Section Playwright base images with Notification
RiinaKuu Jun 5, 2024
f727440
DS-292: Update Fieldset Playwright base images with Notification
RiinaKuu Jun 5, 2024
8955efa
DS-292: Update ErrorSummary Playwright base images
RiinaKuu Jun 5, 2024
c66d3e2
DS-292: Update Form Playwright base images
RiinaKuu Jun 5, 2024
ee7b4ad
DS-292: Fix dialog max-width in smallest screen sizes
RiinaKuu Jun 5, 2024
1b67361
DS-292: Update Dialog Playwright base images on mobile
RiinaKuu Jun 5, 2024
bb37ad2
Merge branch 'main' into DS-292-storybook-figma-sync
MayaMarjut Jun 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ Directives written with `kebab-case` are meant to be used as HTML element.

## Examples

<Canvas of={DialogStories.Example}></Canvas>
<Canvas of={DialogStories.ExampleWithForm}></Canvas>
<Canvas of={DialogStories.ExampleWithGrid}></Canvas>

### Full code example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, Inject, Input, TemplateRef } from '@angular/core';
import { StoryFn, Meta, moduleMetadata } from '@storybook/angular';
import { FormControl, FormGroup, ReactiveFormsModule, FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { ComponentType } from '@angular/cdk/portal';
import { FudisDialogService } from '../../services/dialog/dialog.service';
import docs from './dialog.docs.mdx';
Expand All @@ -15,10 +14,54 @@ type TestForm = {
powerAnimal: FormControl<string | null>;
};

@Component({
selector: 'fudis-dialog-laucher',
template: ` <fudis-button
(handleClick)="openDialogComponent()"
[label]="'Open dialog with form'"
></fudis-button>

<ng-container *ngIf="this._chosenPowerAnimal">
<fudis-body-text
>Great choise, your power animal is {{ this._chosenPowerAnimal }}.</fudis-body-text
>
</ng-container>`,
})
class DialogLaucherComponent {
constructor(private _dialogService: FudisDialogService) {}

@Input() size: FudisDialogSize = 'md';

protected _chosenPowerAnimal: string | null;

exampleDialogFormGroup = new FormGroup<TestForm>({
powerAnimal: new FormControl(
null,
FudisValidators.required('You need to choose your power animal'),
),
});

openDialogComponent() {
this._dialogService
.open(DialogWithFormComponent, {
data: {
greeting: 'This is greeting sent from the component, which opened up this dialog!',
size: this.size,
},
})
.afterClosed()
.subscribe((result: string) => {
if (result) {
this._chosenPowerAnimal = result;
}
});
}
}

@Component({
selector: 'fudis-dialog-with-form',
template: `
<fudis-dialog [size]="size">
<fudis-dialog [size]="_size">
<fudis-dialog-content>
<fudis-form
[title]="'Dialog with fudis-form'"
Expand All @@ -41,7 +84,7 @@ type TestForm = {
</ng-template>
</fudis-fieldset>
</ng-template>
<ng-template fudisActions type="form">
<ng-template fudisActions [type]="'form'">
<fudis-button
fudisFormSubmit
[formValid]="exampleDialogFormGroup.valid"
Expand All @@ -55,17 +98,18 @@ type TestForm = {
</fudis-dialog>
`,
})
class DialogExampleWithFormComponent {
class DialogWithFormComponent {
constructor(
@Inject(MAT_DIALOG_DATA) private data: { greeting: string },
@Inject(MAT_DIALOG_DATA) private data: { greeting: string; size: FudisDialogSize },
private _dialogService: FudisDialogService,
) {
this._greetingFromOpeningComponent = this.data.greeting;
this._size = this.data.size;
}

protected _greetingFromOpeningComponent: string;
protected _size: FudisDialogSize;

@Input() size: FudisDialogSize = 'md';
protected _greetingFromOpeningComponent: string;

exampleDialogFormGroup = new FormGroup<TestForm>({
powerAnimal: new FormControl(
Expand All @@ -85,24 +129,13 @@ class DialogExampleWithFormComponent {
}

@Component({
selector: 'fudis-dialog-example-laucher',
selector: 'fudis-dialog-with-grid',
template: `
<fudis-grid [columns]="'1fr 1fr'" [width]="'xs'" [align]="'start'">
<fudis-button
(handleClick)="openDialogComponent()"
[label]="'Open dialog with form'"
></fudis-button>
<fudis-button
(handleClick)="openDialogTemplate(dialogWithGrid)"
[label]="'Open dialog with grid'"
></fudis-button>
</fudis-grid>
<fudis-button
(handleClick)="openDialogTemplate(dialogWithGrid)"
[label]="'Open dialog with grid'"
></fudis-button>

<ng-container *ngIf="this._chosenPowerAnimal">
<fudis-body-text
>Great choise, your power animal is {{ this._chosenPowerAnimal }}.</fudis-body-text
>
</ng-container>
<ng-template #dialogWithGrid>
<fudis-dialog [size]="size">
<fudis-heading fudisDialogTitle [level]="2"
Expand Down Expand Up @@ -193,35 +226,11 @@ class DialogExampleWithFormComponent {
</ng-template>
`,
})
class DialogExampleLauncherComponent {
class DialogWithGridComponent {
constructor(private _dialogService: FudisDialogService) {}

@Input() size: FudisDialogSize = 'md';

protected _chosenPowerAnimal: string | null;

exampleDialogFormGroup = new FormGroup<TestForm>({
powerAnimal: new FormControl(
null,
FudisValidators.required('You need to choose your power animal'),
),
});

openDialogComponent() {
this._dialogService
.open(DialogExampleWithFormComponent, {
data: {
greeting: 'This is greeting sent from the component, which opened up this dialog!',
},
})
.afterClosed()
.subscribe((result: string) => {
if (result) {
this._chosenPowerAnimal = result;
}
});
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
openDialogTemplate<T = any>(dialogToOpen: ComponentType<T> | TemplateRef<T>) {
this._dialogService.open(dialogToOpen);
Expand All @@ -233,9 +242,9 @@ export default {
component: DialogComponent,
decorators: [
moduleMetadata({
imports: [ReactiveFormsModule, FormsModule, RouterTestingModule],
imports: [ReactiveFormsModule, FormsModule],
providers: [],
declarations: [DialogExampleLauncherComponent, DialogExampleWithFormComponent],
declarations: [DialogWithGridComponent, DialogWithFormComponent, DialogLaucherComponent],
}),
],
parameters: {
Expand All @@ -256,12 +265,22 @@ export default {

const html = String.raw;

const Template: StoryFn<DialogComponent> = (args: DialogComponent) => ({
const TemplateGrid: StoryFn<DialogComponent> = (args: DialogComponent) => ({
props: args,
template: html` <fudis-dialog-with-grid [size]="size"></fudis-dialog-with-grid> `,
});

const TemplateFrom: StoryFn<DialogComponent> = (args: DialogComponent) => ({
props: args,
template: html` <fudis-dialog-example-laucher [size]="size"></fudis-dialog-example-laucher> `,
template: html` <fudis-dialog-laucher [size]="size"></fudis-dialog-laucher> `,
});

export const Example = Template.bind({});
Example.args = {
export const ExampleWithForm = TemplateFrom.bind({});
ExampleWithForm.args = {
size: 'md',
};

export const ExampleWithGrid = TemplateGrid.bind({});
ExampleWithForm.args = {
size: 'md',
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/* stylelint-disable selector-max-compound-selectors */
/* stylelint-disable declaration-no-important */
/* stylelint-disable declaration-property-value-disallowed-list */
/* stylelint-disable max-nesting-depth */
/* stylelint-disable unit-disallowed-list */
/* stylelint-disable selector-max-class */
/* stylelint-disable selector-class-pattern */
/* stylelint-disable selector-no-qualifying-type */
/* stylelint-disable scss/selector-no-redundant-nesting-selector */

@use "../../foundations/colors/tokens.scss" as colors;
@use "../../foundations/colors/mixins.scss" as colorMixins;
@use "../../foundations/borders/mixins.scss" as borders;
@use "../../foundations/focus/mixins.scss" as focus;
@use "../../foundations/breakpoints/mixins.scss" as breakpoints;
Expand All @@ -21,67 +23,79 @@
}

.fudis-dialog-panel {
border-top: 2px solid colors.$color-gray-dark;
border-top: 1px solid colors.$color-gray-dark;
border-right: none;
border-bottom: 2px solid colors.$color-gray-dark;
border-bottom: 1px solid colors.$color-gray-dark;
border-left: none;
max-width: 100vw !important;

& mat-dialog-container.mat-mdc-dialog-container {
padding: 0;

& .mat-mdc-dialog-title {
margin: spacing.$spacing-xxs 0 spacing.$spacing-sm 0;
padding: 0;
pointer-events: none;
& .mat-mdc-dialog-surface {
border-radius: 0;
box-shadow: none;

&::before {
display: none;
}
& .mat-mdc-dialog-title {
margin: spacing.$spacing-xxs 0 spacing.$spacing-sm 0;
padding: 0;
pointer-events: none;

&:focus-visible {
@include focus.focus-generic;
}
&::before {
display: none;
}

&:focus-visible {
@include focus.focus-generic;
}

&:focus-visible.fudis-form__header__title__dialog {
outline-offset: -2px;
&:focus-visible.fudis-form__header__title__dialog {
outline-offset: -2px;
}
}
}

& .mat-mdc-dialog-content {
@include utilities.box-reset;
& .mat-mdc-dialog-content {
@include utilities.box-reset;

&:focus-visible,
&:focus {
@include focus.focus-generic;
}
&:focus-visible,
&:focus {
@include focus.focus-generic;
}

// Checkbox and radio-button elements need small padding if form is inside dialog
// Otherwise focus and invalid styles won't show properly as dialog padding is overlapping them
& fudis-checkbox,
& fudis-radio-button {
padding-left: spacing.$spacing-xxs;
// Checkbox and radio-button elements need small padding if form is inside dialog
// Otherwise focus and invalid styles won't show properly as dialog padding is overlapping them
& fudis-checkbox,
& fudis-radio-button {
padding-left: spacing.$spacing-xxs;
}
}
}

& .mat-mdc-dialog-actions {
align-items: flex-end;
margin-top: spacing.$spacing-xs;
margin-bottom: 0;
padding: 0;
min-height: initial;

& fudis-button {
&:not(:first-of-type) {
margin-top: spacing.$spacing-xs;
margin-left: spacing.$spacing-xs;
& .mat-mdc-dialog-actions {
align-items: flex-end;
margin-top: spacing.$spacing-xs;
margin-bottom: 0;
padding: 0;
min-height: initial;

& fudis-button {
&:not(:first-of-type) {
margin-top: spacing.$spacing-xs;
margin-left: spacing.$spacing-xs;
}
}
}
}
}

/* Keep dialog borders visible and as wide as possible until sm breakpoint */
@include breakpoints.breakpoint-max("sm") {
@include borders.border("1px", "solid", "gray-dark");

max-width: 98vw !important;
}

@include breakpoints.breakpoint("sm") {
@include borders.border("2px", "solid", "gray-dark");
@include borders.border("1px", "solid", "gray-dark");

max-width: 90vw !important;

Expand All @@ -98,3 +112,11 @@
}
}
}

.fudis-dialog-backdrop {
@include colorMixins.bg-color("white");

&.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {
opacity: 0.95 !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
[disableRipple]="true"
>
<mat-icon matDatepickerToggleIcon>
<fudis-icon [icon]="'calendar'" [color]="'primary'"></fudis-icon>
<fudis-icon
[icon]="'calendar'"
[color]="control.disabled || disabled ? 'gray-dark' : 'primary'"
></fudis-icon>
</mat-icon>
</mat-datepicker-toggle>
<mat-datepicker
Expand Down
Loading
Loading