-
Notifications
You must be signed in to change notification settings - Fork 0
menu: стилизация, сторисы, обёртки #34
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
37e722d
menu: стилизация, сторисы, обёртки
7593a1c
фикс состояния активного пункта меню при наведении
7896268
menu: добавлен itemTemplate для кастомизации элемента меню
49b3c9f
Merge branch 'feature/styles-debug' into menu.menu
khaliulin 0b96fe8
Merge branch 'feature/styles-debug' into menu.menu
khaliulin 0f93319
заменил p-button на ButtonComponent
ef0716b
regular для fontWeight
a5ac52b
Merge branch 'feature/styles-debug' into menu.menu
AxyIX 0dc7706
DS-513
AxyIX d35df90
DS-513
AxyIX 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
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
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 @@ | ||
| import { Component, Input, TemplateRef, ViewChild } from '@angular/core'; | ||
| import { NgTemplateOutlet } from '@angular/common'; | ||
| import { Menu } from 'primeng/menu'; | ||
| import { MenuItem, PrimeTemplate } from 'primeng/api'; | ||
|
|
||
| export interface ExtraMenuModel extends MenuItem { | ||
| caption?: string; | ||
| } | ||
|
|
||
| @Component({ | ||
| selector: 'extra-menu', | ||
| host: { style: 'display: contents' }, | ||
| standalone: true, | ||
| imports: [Menu, PrimeTemplate, NgTemplateOutlet], | ||
| template: ` | ||
| <p-menu #menuRef [model]="model" [popup]="popup" [appendTo]="popup ? 'body' : null"> | ||
| <ng-template pTemplate="item" let-item> | ||
|
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. опять же вопрос с кастомизациями. разработчикам не придется свои шаблоны передавать?
Author
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. |
||
| @if (itemTemplate) { | ||
| <ng-container [ngTemplateOutlet]="itemTemplate" | ||
| [ngTemplateOutletContext]="{ $implicit: item }"> | ||
| </ng-container> | ||
| } @else { | ||
| <a | ||
| class="p-menu-item-link" | ||
| role="menuitem" | ||
| tabindex="0" | ||
| [class.p-disabled]="item.disabled" | ||
| [attr.href]="item.url || null" | ||
| [attr.target]="item.target || null" | ||
| (click)="!item.disabled && item.command && item.command({ originalEvent: $event, item: item })" | ||
| > | ||
| @if (item.icon) { | ||
| <span [class]="item.icon + ' p-menu-item-icon'"></span> | ||
| } | ||
| @if ($any(item).caption) { | ||
| <div class="menu-item-label"> | ||
| <span class="p-menu-item-label">{{ item.label }}</span> | ||
| <small class="menu-item-caption">{{ $any(item).caption }}</small> | ||
| </div> | ||
| } @else { | ||
| <span class="p-menu-item-label">{{ item.label }}</span> | ||
| } | ||
| </a> | ||
| } | ||
| </ng-template> | ||
| </p-menu> | ||
| `, | ||
| }) | ||
| export class ExtraMenuComponent { | ||
| @ViewChild('menuRef') menuRef!: Menu; | ||
|
|
||
| @Input() model: ExtraMenuModel[] = []; | ||
| @Input() popup = false; | ||
| @Input() itemTemplate: TemplateRef<any> | null = null; | ||
|
|
||
| toggle(event: Event): void { | ||
| this.menuRef.toggle(event); | ||
| } | ||
| } | ||
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,7 @@ | ||
| { | ||
| "$schema": "ng-packagr/ng-package.schema.json", | ||
| "lib": { | ||
| "entryFile": "public_api.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,4 @@ | ||
| export * from './menu.component'; | ||
|
|
||
|
|
||
|
|
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,67 @@ | ||
| export const menuCss = ({ dt }: { dt: (token: string) => string }): string => ` | ||
| .p-menu.p-component { | ||
| padding: ${dt('menu.extend.paddingY')} ${dt('menu.extend.paddingX')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item-content .p-menu-item-link .p-menu-item-label { | ||
| font-family: ${dt('fonts.fontFamily.base')}; | ||
| font-size: ${dt('fonts.fontSize.300')}; | ||
| font-weight: ${dt('fonts.fontWeight.regular')}; | ||
| line-height: ${dt('fonts.lineHeight.400')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item-content .menu-item-label { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: ${dt('menu.extend.extItem.caption.gap')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item-content .menu-item-caption { | ||
| font-family: ${dt('fonts.fontFamily.base')}; | ||
| font-size: ${dt('fonts.fontSize.200')}; | ||
| font-weight: ${dt('fonts.fontWeight.regular')}; | ||
| color: ${dt('menu.colorScheme.light.extend.extItem.caption.color')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item:not(.p-disabled) .p-menu-item-content:hover, | ||
| .p-menu .p-menu-item:not(.p-disabled) .p-menu-item-content:hover .p-menu-item-link, | ||
| .p-menu .p-menu-item:not(.p-disabled) .p-menu-item-content:hover .p-menu-item-label, | ||
| .p-menu .p-menu-item:not(.p-disabled) .p-menu-item-content:hover .p-menu-item-icon { | ||
| background: ${dt('menu.colorScheme.light.item.focusBackground')}; | ||
| color: ${dt('menu.colorScheme.light.item.focusColor')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item.p-menuitem-checked > .p-menu-item-content, | ||
| .p-menu .p-menu-item.p-focus > .p-menu-item-content { | ||
| background: ${dt('menu.extend.extItem.activeBackground')}; | ||
| color: ${dt('menu.extend.extItem.activeColor')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item.p-menuitem-checked > .p-menu-item-content .p-menu-item-link, | ||
| .p-menu .p-menu-item.p-menuitem-checked > .p-menu-item-content .p-menu-item-label, | ||
| .p-menu .p-menu-item.p-focus > .p-menu-item-content .p-menu-item-link, | ||
| .p-menu .p-menu-item.p-focus > .p-menu-item-content .p-menu-item-label { | ||
| color: ${dt('menu.extend.extItem.activeColor')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item.p-menuitem-checked > .p-menu-item-content .p-menu-item-icon, | ||
| .p-menu .p-menu-item.p-focus > .p-menu-item-content .p-menu-item-icon { | ||
| color: ${dt('menu.colorScheme.light.extend.extItem.icon.activeColor')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item.p-menuitem-checked:not(.p-disabled) > .p-menu-item-content:hover { | ||
| background: ${dt('menu.colorScheme.light.item.focusBackground')}; | ||
| color: ${dt('menu.colorScheme.light.item.focusColor')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-item.p-menuitem-checked:not(.p-disabled) > .p-menu-item-content:hover .p-menu-item-icon { | ||
| color: ${dt('menu.colorScheme.light.item.focusColor')}; | ||
| } | ||
|
|
||
| .p-menu .p-menu-submenu-label { | ||
| text-transform: uppercase; | ||
| font-size: ${dt('fonts.fontSize.200')}; | ||
| font-family: ${dt('fonts.fontFamily.heading')}; | ||
| line-height: ${dt('fonts.lineHeight.400')}; | ||
| } | ||
| `; |
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
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.
для чего?
Uh oh!
There was an error while loading. Please reload this page.
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 делает хост-элемент menu прозрачным для layout (flex/grid родителя его не видят). Без этого menu был бы блочным элементом, ломающим позиционирование.