Skip to content

dialog: стилизация, сторисы, обёртки#31

Merged
AxyIX merged 16 commits into
feature/styles-debugfrom
overlay.dialog
Apr 18, 2026
Merged

dialog: стилизация, сторисы, обёртки#31
AxyIX merged 16 commits into
feature/styles-debugfrom
overlay.dialog

Conversation

@khaliulin
Copy link
Copy Markdown
Contributor

No description provided.

[showHeader]="showHeader"
[focusOnShow]="focusOnShow"
[styleClass]="sizeClass"
appendTo="body"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему решил не передавать этот пропс?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX добавление stories.ts в argTypes f8d18ec

@Input() closeOnEscape = true;
@Input() showHeader = true;
@Input() focusOnShow = false;
@Input() footerTemplate: TemplateRef<any> | null = null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а в хедер мы не планируем кастомные шаблоны вставлять?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX добавлен @input() headerTemplate ecd07ee

import { DialogNoModalComponent } from './examples/dialog-no-modal.component';
import { DialogNoHeaderComponent } from './examples/dialog-no-header.component';

const meta: Meta<DialogComponent> = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну увидел использования механизма DynamicDialog. по сути своей это тот же Dialog только вызывается динамически. хотя в целом можно попробовать пожить без него. и если будет неудобно - потом добавить

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX добавлен DynamicDialog bd0772c

import { Component, TemplateRef, ViewChild } from '@angular/core';
import { Button } from 'primeng/button';
import { DialogComponent } from '@cdek-it/angular-ui-kit';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у тебя на уровне каждого компонента для стори задается переменная template. Думаю её можно экспортировать и также использовать здесь, в source.code.

import {template as dialogBasicTemplate} from '../dialog-default.component.ts';
...
  standalone: true,
  imports: [DialogComponent, Button],
  template: \`
    ${dialogBasicTemplate}
  \`,
})
export class DialogBasicComponent {
  @ViewChild('footer') footer!: TemplateRef<any>;
  visible = false;
}
...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX фикс 25a2cbe

[styleClass]="sizeClass"
[appendTo]="appendTo"
>
@if (headerTemplate) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему хедер через if, а футер нет?
думаю стоит оба через if сделать

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX фикс b729d9e

template,
})
export class DialogDefaultComponent {
@ViewChild('footer') footer!: TemplateRef<any>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это не обязательно если мы используем блок в шаблоне. то есть когда мы делаем #footer у нас на уровне шаблона появляется переменная footer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX фикс 4421117

<p-button (onClick)="visible = true" label="Создать заявку"></p-button>

<ng-template #footer>
<p-button variant="text" label="Отмена" (onClick)="visible = false"></p-button>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут думаю должны быть наши кнопки, а не праймовские

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX фикс 0bc52f5

selector: 'app-dialog-dynamic',
standalone: true,
imports: [Button],
providers: [DialogService, UiDialogService],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на уровне стори мы ничего не должны знать про прайм. потому что стори это как будто бы наши модули, которые мы пишем. то есть наш UiDialogService должен сам уметь провайдить праймовский DialogService под капотом.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX фикс 175a7e4


@Injectable()
export class UiDialogService {
static providers() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это работает? На первый взгляд как будто не должно, ведь этот метод никем вызываться не будет.
Кажется что лучше пойти через injector
Для референса

// ui-dialog.service.ts
import { Injectable, Injector, ComponentRef } from '@angular/core';
import { DialogService } from 'primeng/dynamicdialog';

@Injectable({ providedIn: 'root' })
export class UiDialogService {
  
  // НЕ инжектим DialogService напрямую в конструктор!
  
  open(component: any, injector: Injector, config?: any) {
    // 1. Создаём дочерний инжектор, который содержит провайдер DialogService
    const childInjector = Injector.create({
      providers: [
        DialogService // 👈 Только здесь провайдим DialogService
      ],
      parent: injector
    });

    // 2. Получаем экземпляр DialogService из этого дочернего инжектора
    const dialogService = childInjector.get(DialogService);
    
    // 3. Используем его
    return dialogService.open(component, {
      header: 'Моя обёртка',
      width: '600px',
      ...config
    });
  }
}
‘

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AxyIX фикс 892dd28

@AxyIX AxyIX merged commit 35dddcd into feature/styles-debug Apr 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants