-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat(components/layout): use standalone components and signal inputs for fluid grid #3031
Closed
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
98b4f08
refactor(components/layout): use standalone components for fluid grid
Blackbaud-SteveBrush 2777f47
tests
Blackbaud-SteveBrush 08437bb
fix tests
Blackbaud-SteveBrush f857a66
Merge remote-tracking branch 'origin/main' into fluid-grid-standalone
Blackbaud-SteveBrush c445eca
fix harness
Blackbaud-SteveBrush 2b5c80e
remove new type
Blackbaud-SteveBrush 4a291cc
fix styles
Blackbaud-SteveBrush 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 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 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
1 change: 0 additions & 1 deletion
1
libs/components/layout/src/lib/modules/fluid-grid/column.component.html
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -26,6 +26,10 @@ | |
} | ||
} | ||
|
||
sky-column { | ||
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. I'm removing all the extraneous |
||
display: block; | ||
} | ||
|
||
sky-column.sky-column { | ||
padding-right: map-get($gutter-sizes, large); | ||
padding-left: map-get($gutter-sizes, large); | ||
|
This file contains 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
98 changes: 39 additions & 59 deletions
98
libs/components/layout/src/lib/modules/fluid-grid/column.component.ts
This file contains 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,103 +1,83 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
HostBinding, | ||
Input, | ||
OnChanges, | ||
OnInit, | ||
SimpleChanges, | ||
ViewEncapsulation, | ||
computed, | ||
input, | ||
numberAttribute, | ||
} from '@angular/core'; | ||
|
||
import { SkyFluidGridColumnSize } from './types/fluid-grid-column-size'; | ||
|
||
/** | ||
* Displays a column within a row of the fluid grid. | ||
*/ | ||
@Component({ | ||
selector: 'sky-column', | ||
templateUrl: './column.component.html', | ||
styleUrls: ['./column.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
standalone: false, | ||
host: { | ||
'[class]': 'classnames()', | ||
}, | ||
selector: 'sky-column', | ||
template: '<ng-content />', | ||
styleUrl: './column.component.scss', | ||
}) | ||
export class SkyColumnComponent implements OnInit, OnChanges { | ||
export class SkyColumnComponent { | ||
/** | ||
* The number of columns (1-12) on extra-small screens | ||
* (less than 768px). If you do not specify a value, the fluid grid displays | ||
* the column at the full width of the screen. | ||
* @default 12 | ||
* The number of columns (1-12) on extra-small screens (less than 768px). If | ||
* you do not specify a value, the fluid grid displays the column at the full | ||
* width of the screen. | ||
*/ | ||
@Input() | ||
public set screenXSmall(value: number | undefined) { | ||
this.#_screenXSmall = value ?? 12; | ||
} | ||
|
||
public get screenXSmall(): number { | ||
return this.#_screenXSmall; | ||
} | ||
public screenXSmall = input<SkyFluidGridColumnSize, unknown>(12, { | ||
transform: (value) => numberAttribute(value, 12) as SkyFluidGridColumnSize, | ||
}); | ||
|
||
/** | ||
* The number of columns (1-12) on small screens | ||
* (768-991px). If you do not specify a value, the column inherits | ||
* the `screenXSmall` value. | ||
*/ | ||
@Input() | ||
public screenSmall: number | undefined; | ||
public screenSmall = input<SkyFluidGridColumnSize | undefined>(); | ||
|
||
/** | ||
* The number of columns (1-12) on medium screens | ||
* (992-1199px). If you do not specify a value, the column inherits | ||
* the `screenSmall` value. | ||
*/ | ||
@Input() | ||
public screenMedium: number | undefined; | ||
|
||
public screenMedium = input<SkyFluidGridColumnSize | undefined>(); | ||
|
||
/** | ||
* The number of columns (1-12) on large screens | ||
* (more than 1200px). If you do not specify a value, the column | ||
* inherits the `screenMedium` value. | ||
*/ | ||
@Input() | ||
public screenLarge: number | undefined; | ||
|
||
@HostBinding('class') | ||
public classnames: string | undefined; | ||
public screenLarge = input<SkyFluidGridColumnSize | undefined>(); | ||
|
||
#_screenXSmall = 12; | ||
|
||
public ngOnChanges(changes: SimpleChanges) { | ||
/* istanbul ignore else */ | ||
if ( | ||
changes['screenXSmall'] || | ||
changes['screenSmall'] || | ||
changes['screenMedium'] || | ||
changes['screenLarge'] | ||
) { | ||
this.classnames = this.getClassNames(); | ||
} | ||
} | ||
|
||
public getClassNames(): string { | ||
protected classnames = computed(() => { | ||
const classnames = ['sky-column']; | ||
|
||
if (this.screenXSmall) { | ||
classnames.push(`sky-column-xs-${this.screenXSmall}`); | ||
const screenXSmall = this.screenXSmall(); | ||
const screenSmall = this.screenSmall(); | ||
const screenMedium = this.screenMedium(); | ||
const screenLarge = this.screenLarge(); | ||
|
||
if (screenXSmall) { | ||
classnames.push(`sky-column-xs-${screenXSmall}`); | ||
} | ||
|
||
if (this.screenSmall) { | ||
classnames.push(`sky-column-sm-${this.screenSmall}`); | ||
if (screenSmall) { | ||
classnames.push(`sky-column-sm-${screenSmall}`); | ||
} | ||
|
||
if (this.screenMedium) { | ||
classnames.push(`sky-column-md-${this.screenMedium}`); | ||
if (screenMedium) { | ||
classnames.push(`sky-column-md-${screenMedium}`); | ||
} | ||
|
||
if (this.screenLarge) { | ||
classnames.push(`sky-column-lg-${this.screenLarge}`); | ||
if (screenLarge) { | ||
classnames.push(`sky-column-lg-${screenLarge}`); | ||
} | ||
|
||
return classnames.join(' '); | ||
} | ||
|
||
public ngOnInit(): void { | ||
this.classnames = this.getClassNames(); | ||
} | ||
}); | ||
} |
4 changes: 3 additions & 1 deletion
4
libs/components/layout/src/lib/modules/fluid-grid/fixtures/column.component.fixture.ts
This file contains 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
3 changes: 2 additions & 1 deletion
3
libs/components/layout/src/lib/modules/fluid-grid/fixtures/fluid-grid.component.fixture.ts
This file contains 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
12 changes: 0 additions & 12 deletions
12
libs/components/layout/src/lib/modules/fluid-grid/fixtures/fluid-grid.module.fixture.ts
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
libs/components/layout/src/lib/modules/fluid-grid/fluid-grid.component.html
This file was deleted.
Oops, something went wrong.
This file contains 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.
Using
numberAttribute
transform on these inputs creates a simpler API.