-
Notifications
You must be signed in to change notification settings - Fork 0
confirm-dialog: стилизация, сторисы, обёртки #33
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
Open
khaliulin
wants to merge
6
commits into
overlay.dialog
Choose a base branch
from
overlay.confirmdialog
base: overlay.dialog
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4032f6f
confirm-dialog: стилизация, сторисы, обёртки
8020a49
confirm-dialog: убран класс p-icon с иконки сообщения
1627b92
confirm-dialog: добавлены headerTemplate и footerTemplate для кастоми…
0480f7a
confirm-dialog: добавлен ConfirmDialogService, заменён ConfirmationSe…
b6684fd
confirm-dialog: фикс цветов иконок severity, убран severity secondary…
2c16a58
Merge branch 'overlay.dialog' into overlay.confirmdialog
khaliulin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
src/lib/components/confirm-dialog/confirm-dialog.component.ts
This file contains hidden or 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,87 @@ | ||
| import { Component, Input, TemplateRef } from '@angular/core'; | ||
| import { NgTemplateOutlet } from '@angular/common'; | ||
| import { ConfirmDialog } from 'primeng/confirmdialog'; | ||
| import { Button } from 'primeng/button'; | ||
| import { PrimeTemplate } from 'primeng/api'; | ||
|
|
||
| export type ConfirmDialogSize = 'sm' | 'default' | 'lg' | 'xlg'; | ||
| export type ConfirmDialogSeverity = 'success' | 'info' | 'warn' | 'help' | 'danger' | 'default'; | ||
|
|
||
| @Component({ | ||
| selector: 'confirm-dialog', | ||
| host: { style: 'display: contents' }, | ||
| standalone: true, | ||
| imports: [ConfirmDialog, Button, PrimeTemplate, NgTemplateOutlet], | ||
| template: ` | ||
| <p-confirmDialog [key]="key" [styleClass]="computedClass" appendTo="body"> | ||
| <ng-template pTemplate="headless" let-message let-onAccept="onAccept" let-onReject="onReject"> | ||
| @if (headerTemplate) { | ||
| <ng-container [ngTemplateOutlet]="headerTemplate" | ||
| [ngTemplateOutletContext]="{ $implicit: message, onAccept, onReject }"> | ||
| </ng-container> | ||
| } @else { | ||
| <div class="p-dialog-header"> | ||
| <div class="p-dialog-title"> | ||
| <i [class]="message.icon"></i> | ||
| <span>{{ message.header }}</span> | ||
| </div> | ||
| <button | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. кнопки должны быть наши, иначе всё сломается если прайм выпилим из под капота. |
||
| class="p-button p-component p-button-icon-only p-button-rounded p-button-text p-dialog-close-button" | ||
| type="button" | ||
| (click)="onReject()" | ||
| > | ||
| <span class="p-button-icon ti ti-x"></span> | ||
| </button> | ||
| </div> | ||
| } | ||
| <div class="p-dialog-content"> | ||
| <p>{{ message.message }}</p> | ||
| </div> | ||
| @if (footerTemplate) { | ||
| <ng-container [ngTemplateOutlet]="footerTemplate" | ||
| [ngTemplateOutletContext]="{ $implicit: message, onAccept, onReject }"> | ||
| </ng-container> | ||
| } @else { | ||
| <div class="p-dialog-footer"> | ||
| <p-button | ||
| [label]="message.rejectLabel" | ||
| variant="text" | ||
| (onClick)="onReject()" | ||
| ></p-button> | ||
| <p-button | ||
| [label]="message.acceptLabel" | ||
| [severity]="message.acceptButtonProps?.severity" | ||
| (onClick)="onAccept()" | ||
| ></p-button> | ||
| </div> | ||
| } | ||
| </ng-template> | ||
| </p-confirmDialog> | ||
| `, | ||
| }) | ||
| export class ConfirmDialogComponent { | ||
| @Input() key = ''; | ||
| @Input() size: ConfirmDialogSize = 'default'; | ||
| @Input() severity: ConfirmDialogSeverity = 'default'; | ||
| @Input() headerTemplate: TemplateRef<any> | null = null; | ||
| @Input() footerTemplate: TemplateRef<any> | null = null; | ||
|
|
||
| get computedClass(): string { | ||
| const classes: string[] = []; | ||
| if (this.size === 'sm') classes.push('p-confirmdialog-sm'); | ||
| else if (this.size === 'lg') classes.push('p-confirmdialog-lg'); | ||
| else if (this.size === 'xlg') classes.push('p-confirmdialog-xlg'); | ||
|
|
||
| const severityMap: Record<ConfirmDialogSeverity, string> = { | ||
| success: 'p-confirm-dialog-accept', | ||
| info: 'p-confirm-dialog-info', | ||
| warn: 'p-confirm-dialog-warn', | ||
| help: 'p-confirm-dialog-help', | ||
| danger: 'p-confirm-dialog-error', | ||
| default: '', | ||
| }; | ||
| if (severityMap[this.severity]) classes.push(severityMap[this.severity]); | ||
|
|
||
| return classes.join(' '); | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
src/lib/components/confirm-dialog/confirm-dialog.service.ts
This file contains hidden or 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,16 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { Confirmation, ConfirmationService } from 'primeng/api'; | ||
|
|
||
| export type ConfirmDialogOptions = Pick< | ||
| Confirmation, | ||
| 'key' | 'message' | 'header' | 'icon' | 'acceptLabel' | 'rejectLabel' | 'accept' | 'reject' | 'acceptButtonProps' | ||
| >; | ||
|
|
||
| @Injectable() | ||
| export class ConfirmDialogService { | ||
| constructor(private readonly confirmationService: ConfirmationService) {} | ||
|
|
||
| confirm(options: ConfirmDialogOptions): void { | ||
| this.confirmationService.confirm(options); | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| export const confirmDialogCss = ({ dt }: { dt: (token: string) => string }): string => ` | ||
| /* Иконка в заголовке */ | ||
| .p-confirmdialog .p-dialog-title { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: ${dt('dialog.header.gap')}; | ||
| } | ||
|
|
||
| .p-confirmdialog .p-dialog-title i { | ||
| width: ${dt('confirmdialog.icon.size')}; | ||
| height: ${dt('confirmdialog.icon.size')}; | ||
| font-size: ${dt('confirmdialog.icon.size')}; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| /* Размеры */ | ||
| .p-confirmdialog.p-dialog { | ||
| width: ${dt('overlay.width')}; | ||
| } | ||
|
|
||
| .p-confirmdialog-sm.p-dialog { | ||
| width: ${dt('sizing.80x')}; | ||
| } | ||
|
|
||
| .p-confirmdialog-lg.p-dialog { | ||
| width: ${dt('sizing.120x')}; | ||
| } | ||
|
|
||
| .p-confirmdialog-xlg.p-dialog { | ||
| width: ${dt('sizing.128x')}; | ||
| } | ||
|
|
||
| /* Цвета иконок по severity */ | ||
| .p-confirmdialog[data-pc-severity="success"] .p-dialog-title i, | ||
| .p-confirmdialog.p-confirm-dialog-accept .p-dialog-title i { | ||
| color: ${dt('confirmdialog.extend.extIcon.success')}; | ||
| } | ||
|
|
||
| .p-confirmdialog[data-pc-severity="info"] .p-dialog-title i, | ||
| .p-confirmdialog.p-confirm-dialog-info .p-dialog-title i { | ||
| color: ${dt('confirmdialog.extend.extIcon.info')}; | ||
| } | ||
|
|
||
| .p-confirmdialog[data-pc-severity="warn"] .p-dialog-title i, | ||
| .p-confirmdialog.p-confirm-dialog-warn .p-dialog-title i { | ||
| color: ${dt('confirmdialog.extend.extIcon.warn')}; | ||
| } | ||
|
|
||
| .p-confirmdialog[data-pc-severity="help"] .p-dialog-title i, | ||
| .p-confirmdialog.p-confirm-dialog-help .p-dialog-title i { | ||
| color: ${dt('confirmdialog.extend.extIcon.help')}; | ||
| } | ||
|
|
||
| .p-confirmdialog[data-pc-severity="danger"] .p-dialog-title i, | ||
| .p-confirmdialog[data-pc-severity="error"] .p-dialog-title i, | ||
| .p-confirmdialog.p-confirm-dialog-error .p-dialog-title i { | ||
| color: ${dt('confirmdialog.extend.extIcon.danger')}; | ||
| } | ||
| `; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мы не планируем кастомизаций этого диалога?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AxyIX дополнил 1627b92