-
Notifications
You must be signed in to change notification settings - Fork 0
стилизация компонента button #11
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
feature/styles-debug
Choose a base branch
from
feature/button-example
base: feature/styles-debug
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
2e5947f
example of button component
AxyIX 97d2422
style: add space before closing brace in `ButtonSizesComponent`
630c163
button: пропс badge
c70bdb2
пропсы fluid, ariaLabel, autofocus, tabindex
1e7db4f
удаление логов от mcp
18e19a7
игнор файла documentation.json
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 |
|---|---|---|
|
|
@@ -117,5 +117,8 @@ | |
| } | ||
| } | ||
| } | ||
| }, | ||
| "cli": { | ||
| "analytics": false | ||
| } | ||
| } | ||
Binary file not shown.
Binary file not shown.
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,73 @@ | ||
| import { Component, Input } from '@angular/core'; | ||
| import { Button } from 'primeng/button'; | ||
| import { Badge } from 'primeng/badge'; | ||
|
|
||
| export type ExtraButtonVariant = 'primary' | 'secondary' | 'outlined' | 'text' | 'link'; | ||
| export type ExtraButtonSeverity = 'success' | 'warning' | 'danger' | 'info' | null; | ||
| export type ExtraButtonSize = 'small' | 'base' | 'large' | 'xlarge'; | ||
| export type ExtraButtonIconPos = 'prefix' | 'postfix' | null; | ||
|
|
||
| @Component({ | ||
| selector: 'extra-button', | ||
| standalone: true, | ||
| imports: [Button, Badge], | ||
| styleUrl: './button.component.scss', | ||
| template: ` | ||
| <p-button | ||
| [label]="iconOnly ? '' : label" | ||
| [disabled]="disabled" | ||
| [loading]="loading" | ||
| [size]="primeSize" | ||
| [styleClass]="size === 'xlarge' ? 'p-button-xlg' : ''" | ||
| [rounded]="rounded" | ||
| [outlined]="variant === 'outlined'" | ||
| [text]="variant === 'text' || text" | ||
| [link]="variant === 'link'" | ||
| [icon]="icon" | ||
| [iconPos]="primeIconPos" | ||
| [severity]="primeSeverity" | ||
| [badge]="showBadge ? (badge || ' ') : null" | ||
| [badgeSeverity]="badgeSeverity" | ||
| [fluid]="fluid" | ||
| [ariaLabel]="ariaLabel" | ||
| [autofocus]="autofocus" | ||
| [tabindex]="tabindex" | ||
| ></p-button> | ||
| ` | ||
| }) | ||
| export class ExtraButtonComponent { | ||
| @Input() label = 'Button'; | ||
| @Input() variant: ExtraButtonVariant = 'primary'; | ||
| @Input() severity: ExtraButtonSeverity = null; | ||
| @Input() size: ExtraButtonSize = 'base'; | ||
| @Input() rounded = false; | ||
| @Input() iconPos: ExtraButtonIconPos = null; | ||
| @Input() iconOnly = false; | ||
| @Input() icon = ''; | ||
| @Input() disabled = false; | ||
| @Input() loading = false; | ||
|
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. |
||
| @Input() badge = ''; | ||
| @Input() badgeSeverity: 'success' | 'info' | 'warning' | 'danger' | 'secondary' | 'contrast' | null = null; | ||
| @Input() showBadge = false; | ||
| @Input() fluid = false; | ||
| @Input() ariaLabel: string | undefined = undefined; | ||
| @Input() autofocus = false; | ||
| @Input() tabindex: number | undefined = undefined; | ||
| @Input() text = false; | ||
|
|
||
| get primeSize(): 'small' | 'large' | undefined { | ||
| if (this.size === 'small') return 'small'; | ||
| if (this.size === 'large') return 'large'; | ||
| return undefined; | ||
| } | ||
|
|
||
| get primeIconPos(): 'left' | 'right' { | ||
| return this.iconPos === 'postfix' ? 'right' : 'left'; | ||
| } | ||
|
|
||
| get primeSeverity(): string | null { | ||
| if (this.variant === 'secondary') return 'secondary'; | ||
| if (this.severity === 'warning') return 'warn'; | ||
| return this.severity; | ||
| } | ||
| } | ||
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,3 @@ | ||
| <p-button [size]="innerSize" [styleClass]="size === 'xlarge' ? 'p-button-xlg' : ''" [text]="text"> | ||
| <ng-content></ng-content> | ||
| </p-button> |
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,15 @@ | ||
| :host ::ng-deep { | ||
| .p-button { | ||
| position: relative; | ||
| overflow: visible; | ||
|
|
||
| .p-badge { | ||
| position: absolute; | ||
| inset-block-start: 0; | ||
| inset-inline-end: 0; | ||
| transform: translate(50%, -50%); | ||
| transform-origin: 100% 0; | ||
| margin: 0; | ||
| } | ||
| } | ||
| } |
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,23 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { ButtonComponent } from './button.component'; | ||
|
|
||
| describe('ButtonComponent', () => { | ||
| let component: ButtonComponent; | ||
| let fixture: ComponentFixture<ButtonComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [ButtonComponent] | ||
| }) | ||
| .compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(ButtonComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
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,28 @@ | ||
| import { Component, Input } from '@angular/core'; | ||
| import { Button } from 'primeng/button'; | ||
|
|
||
| /** | ||
| * как использовать | ||
| * ``` | ||
| * <app-button size="xlarge"> | ||
| * <div>content</div> // это то, на что заменится <ng-content></ng-content> внутри компонента | ||
| * </app-button> | ||
| *``` | ||
| */ | ||
|
|
||
| @Component({ | ||
| selector: 'app-button', | ||
| standalone: true, | ||
| imports: [Button], | ||
| templateUrl: './button.component.html', | ||
| styleUrl: './button.component.scss' | ||
| }) | ||
| export class ButtonComponent { | ||
| @Input() size!: 'small' | undefined | 'large' | 'xlarge'; | ||
|
|
||
| @Input() text: boolean = false; | ||
|
|
||
| get innerSize(): 'small' | undefined | 'large' { | ||
| return (this.size === 'xlarge' || !this.size) ? undefined : (this.size as 'small' | 'large'); | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -1,45 +1,15 @@ | ||
| import { Preset } from '@primeuix/themes/types'; | ||
| import type { ComponentsDesignTokens } from '@primeuix/themes/types'; | ||
| import type { AuraBaseDesignTokens } from '@primeuix/themes/aura/base'; | ||
|
|
||
| import primitive from './tokens/primitive-default.json'; | ||
| import semantic from './tokens/semantic-default.json'; | ||
| import components from './tokens/components-default.json'; | ||
| import themeLight from './tokens/theme-light.json'; | ||
| import themeDark from './tokens/theme-dark.json'; | ||
| import sizingBase from './tokens/sizing-base.json'; | ||
| import sizingSm from './tokens/sizing-sm.json'; | ||
| import sizingLg from './tokens/sizing-lg.json'; | ||
| import sizingXlg from './tokens/sizing-xlg.json'; | ||
|
|
||
| import button from './tokens/components/button.json'; | ||
| import primitive from './tokens/primitive'; | ||
| import semantic from './tokens/semantic'; | ||
| import components from './tokens/components'; | ||
|
|
||
| const presetTokens: Preset<AuraBaseDesignTokens> = { | ||
| primitive, | ||
| semantic, | ||
| components: { ...components, ...button } | ||
| primitive: primitive as AuraBaseDesignTokens['primitive'], | ||
| semantic: semantic as unknown as AuraBaseDesignTokens['semantic'], | ||
| components: components as ComponentsDesignTokens | ||
| }; | ||
|
|
||
| if (presetTokens?.semantic) { | ||
| presetTokens.semantic.colorScheme = { | ||
| light: themeLight, | ||
| dark: themeDark | ||
| }; | ||
| } | ||
|
|
||
| presetTokens.semantic = { ...presetTokens.semantic, ...sizingBase }; | ||
|
|
||
| const semanticLink: Record<string, any> = presetTokens.semantic; | ||
|
|
||
| function applySizing(semantic: Record<string, any>, sizing: Record<string, any>, sizeKey: 'sm' | 'lg' | 'xlg') { | ||
| Object.keys(sizing).forEach((key) => { | ||
| if (semantic[key]) { | ||
| semantic[key][sizeKey] = sizing[key]?.root ?? sizing[key]; | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| applySizing(semanticLink, sizingSm, 'sm'); | ||
| applySizing(semanticLink, sizingLg, 'lg'); | ||
| applySizing(semanticLink, sizingXlg, 'xlg'); | ||
|
|
||
| export default presetTokens; |
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 возможно, ты имел ввиду Badge – https://primeng.org/button#badge? да, его планируем передавать в кнопку; фикс здесь 630c163