-
Notifications
You must be signed in to change notification settings - Fork 4
feat(button): add native type #640
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
lukasmatta
merged 8 commits into
master
from
637-allow-buttoncomponent-to-accept-a-configurable-type-prop
May 29, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
300f67a
feat(button): Add native type
lukasmatta c831d32
Merge branch 'master' into 637-allow-buttoncomponent-to-accept-a-conf…
lukasmatta 0a637d4
Handle wrong nativeType in runtime
lukasmatta 3e402ff
Add example demostrating button's native type
lukasmatta 2f02313
Add tests to cover null/undefined handling
lukasmatta 246d10f
Check console.warn + invalid string values for nativeType
lukasmatta 5cd9379
Fix layout shift
lukasmatta 7e470d8
Merge branch 'master' into 637-allow-buttoncomponent-to-accept-a-conf…
lukasmatta 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
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
59 changes: 59 additions & 0 deletions
59
projects/composition/src/app/pages/button-page/button-page.examples.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 |
|---|---|---|
| @@ -1,123 +1,182 @@ | ||
| export const buttonExamples: Record<string, { html: string; ts?: string }> = { | ||
| solid: { | ||
| html: ` | ||
| <!-- large --> | ||
| <cps-button label="Large button" size="large" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Large button" size="large"></cps-button> | ||
| <cps-button icon="add" label="Large button" color="surprise" iconPosition="after" size="large"></cps-button> | ||
| <cps-button icon="add" label="Large button" color="luxury" size="large" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="large" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- normal --> | ||
| <cps-button label="Normal button" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Normal button"></cps-button> | ||
| <cps-button icon="add" label="Normal button" color="surprise" iconPosition="after"></cps-button> | ||
| <cps-button icon="add" label="Normal button" color="luxury" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- small --> | ||
| <cps-button label="Small button" size="small" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Small button" size="small"></cps-button> | ||
| <cps-button icon="add" label="Small button" color="surprise" iconPosition="after" size="small"></cps-button> | ||
| <cps-button icon="add" label="Small button" color="luxury" size="small" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="small" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- xsmall --> | ||
| <cps-button label="XSmall button" size="xsmall" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" size="xsmall"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" color="surprise" iconPosition="after" size="xsmall"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" color="luxury" size="xsmall" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="xsmall" ariaLabel="Loading button"></cps-button>` | ||
| }, | ||
|
|
||
| outlined: { | ||
| html: ` | ||
| <!-- large --> | ||
| <cps-button label="Large button" size="large" type="outlined" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Large button" size="large" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="Large button" color="surprise" iconPosition="after" size="large" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="Large button" color="luxury" size="large" type="outlined" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="large" type="outlined" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- normal --> | ||
| <cps-button label="Normal button" type="outlined" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Normal button" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="Normal button" color="surprise" iconPosition="after" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="Normal button" color="luxury" type="outlined" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" type="outlined" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- small --> | ||
| <cps-button label="Small button" size="small" type="outlined" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Small button" size="small" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="Small button" color="surprise" iconPosition="after" size="small" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="Small button" color="luxury" size="small" type="outlined" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="small" type="outlined" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- xsmall --> | ||
| <cps-button label="XSmall button" size="xsmall" type="outlined" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" size="xsmall" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" color="surprise" iconPosition="after" size="xsmall" type="outlined"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" color="luxury" size="xsmall" type="outlined" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="xsmall" type="outlined" ariaLabel="Loading button"></cps-button>` | ||
| }, | ||
|
|
||
| borderless: { | ||
| html: ` | ||
| <!-- large --> | ||
| <cps-button label="Large button" size="large" type="borderless" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Large button" size="large" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="Large button" color="surprise" iconPosition="after" size="large" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="Large button" color="luxury" size="large" type="borderless" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="large" type="borderless" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- normal --> | ||
| <cps-button label="Normal button" type="borderless" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Normal button" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="Normal button" color="surprise" iconPosition="after" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="Normal button" color="luxury" type="borderless" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" type="borderless" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- small --> | ||
| <cps-button label="Small button" size="small" type="borderless" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="Small button" size="small" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="Small button" color="surprise" iconPosition="after" size="small" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="Small button" color="luxury" size="small" type="borderless" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="small" type="borderless" ariaLabel="Loading button"></cps-button> | ||
|
|
||
| <!-- xsmall --> | ||
| <cps-button label="XSmall button" size="xsmall" type="borderless" color="luxury"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" size="xsmall" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" color="surprise" iconPosition="after" size="xsmall" type="borderless"></cps-button> | ||
| <cps-button icon="add" label="XSmall button" color="luxury" size="xsmall" type="borderless" [disabled]="true"></cps-button> | ||
| <cps-button [loading]="true" size="xsmall" type="borderless" ariaLabel="Loading button"></cps-button>` | ||
| }, | ||
|
|
||
| nativeTypes: { | ||
| html: ` | ||
| <form | ||
| class="native-types-form" | ||
| [formGroup]="nativeForm" | ||
| (ngSubmit)="onNativeSubmit($event)" | ||
| (reset)="onNativeReset()"> | ||
| <cps-input label="Name" formControlName="name"></cps-input> | ||
| <div class="buttons-group-row"> | ||
| <cps-button | ||
| label="Plain button" | ||
| nativeType="button" | ||
| type="outlined" | ||
| (clicked)="onNativePlainClick()"></cps-button> | ||
| <cps-button | ||
| label="Submit" | ||
| nativeType="submit" | ||
| color="luxury"></cps-button> | ||
| <cps-button | ||
| label="Reset" | ||
| nativeType="reset" | ||
| type="borderless" | ||
| color="surprise"></cps-button> | ||
| </div> | ||
| @if (nativeSubmitMessage) { | ||
| <div class="native-types-form__message">{{ nativeSubmitMessage }}</div> | ||
| } | ||
| </form>`, | ||
| ts: ` | ||
| private readonly fb = inject(FormBuilder); | ||
|
|
||
| componentData = ComponentData; | ||
| isLoading = false; | ||
|
|
||
| nativeForm = this.fb.nonNullable.group({ | ||
| name: ['', Validators.required] | ||
| }); | ||
|
|
||
| nativeSubmitMessage = ''; | ||
|
|
||
| onNativePlainClick() { | ||
| this.nativeSubmitMessage = 'Plain button clicked (no form action).'; | ||
| } | ||
|
|
||
| onNativeSubmit(event: Event) { | ||
| event.preventDefault(); | ||
| if (this.nativeForm.invalid) { | ||
| this.nativeSubmitMessage = 'Form is invalid.'; | ||
| return; | ||
| } | ||
| this.nativeSubmitMessage = "Form submitted with name: " + this.nativeForm.value.name; | ||
| } | ||
|
|
||
| onNativeReset() { | ||
| this.nativeForm.reset(); | ||
| this.nativeSubmitMessage = ''; | ||
| }` | ||
| }, | ||
|
|
||
| misc: { | ||
| html: ` | ||
| <!-- Interactive loading state --> | ||
| <cps-button | ||
| label="Click to load" | ||
| type="outlined" | ||
| color="white" | ||
| [loading]="isLoading" | ||
| (clicked)="onClickForLoading()"> | ||
| </cps-button> | ||
|
|
||
| <!-- Icon-only --> | ||
| <cps-button color="white" type="outlined" icon="like" ariaLabel="Like" size="large"></cps-button> | ||
| <cps-button color="graphite" icon="eye" size="large" ariaLabel="View"></cps-button> | ||
|
|
||
| <!-- Custom size --> | ||
| <cps-button label="Custom size" borderRadius="2rem" width="300" height="60" color="white" type="outlined" icon="avatar-top-menu"></cps-button> | ||
|
|
||
| <!-- Block / full-width --> | ||
| <cps-button label="Block large button" borderRadius="0" width="100%" size="large" color="depth"></cps-button>`, | ||
| ts: ` | ||
| isLoading = false; | ||
|
|
||
| onClickForLoading(): void { | ||
| this.isLoading = true; | ||
| setTimeout(() => (this.isLoading = false), 2000); | ||
| }` | ||
| } | ||
| }; | ||
2 changes: 1 addition & 1 deletion
2
projects/cps-ui-kit/src/lib/components/cps-button/cps-button.component.html
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.