Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { GUTTER_NUM_TOKEN } from './gutter-num-token'

@Directive({
selector: '[asSplitGutterDragHandle]',
standalone: true,
})
export class SplitGutterDragHandleDirective implements OnDestroy {
private readonly gutterNum = inject(GUTTER_NUM_TOKEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface SplitGutterDynamicInjectorTemplateContext {
*/
@Directive({
selector: '[asSplitGutterDynamicInjector]',
standalone: true,
})
export class SplitGutterDynamicInjectorDirective {
private readonly vcr = inject(ViewContainerRef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { GUTTER_NUM_TOKEN } from './gutter-num-token'

@Directive({
selector: '[asSplitGutterExcludeFromDrag]',
standalone: true,
})
export class SplitGutterExcludeFromDragDirective implements OnDestroy {
private readonly gutterNum = inject(GUTTER_NUM_TOKEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface SplitGutterTemplateContext {

@Directive({
selector: '[asSplitGutter]',
standalone: true,
})
export class SplitGutterDirective {
readonly template = inject<TemplateRef<SplitGutterTemplateContext>>(TemplateRef)
Expand Down
32 changes: 15 additions & 17 deletions projects/angular-split/src/lib/split-area/split-area.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
ChangeDetectionStrategy,
Component,
HostBinding,
Signal,
booleanAttribute,
computed,
Expand All @@ -16,7 +15,6 @@ import { SplitAreaSize, areaSizeTransform, boundaryAreaSizeTransform } from '../

@Component({
selector: 'as-split-area',
standalone: true,
exportAs: 'asSplitArea',
templateUrl: './split-area.component.html',
styleUrl: './split-area.component.css',
Expand All @@ -27,6 +25,12 @@ import { SplitAreaSize, areaSizeTransform, boundaryAreaSizeTransform } from '../
},
],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class]': 'hostClasses()',
'[style.grid-column]': 'hostGridColumnStyle()',
'[style.grid-row]': 'hostGridRowStyle()',
'[style.position]': 'hostPositionStyle()',
},
})
export class SplitAreaComponent {
protected readonly split = inject(SplitComponent)
Expand Down Expand Up @@ -58,28 +62,22 @@ export class SplitAreaComponent {
*/
readonly _normalizedMaxSize = computed(() => this.normalizeMaxSize())
private readonly index = computed(() => this.split._areas().findIndex((area) => area === this))
private readonly gridAreaNum = computed(() => this.index() * 2 + 1)
private readonly hostClasses = computed(() =>
protected readonly gridAreaNum = computed(() => this.index() * 2 + 1)
protected readonly hostClasses = computed(() =>
createClassesString({
['as-split-area']: true,
['as-min']: this.visible() && this._internalSize() === this._normalizedMinSize(),
['as-max']: this.visible() && this._internalSize() === this._normalizedMaxSize(),
['as-hidden']: !this.visible(),
}),
)

@HostBinding('class') protected get hostClassesBinding() {
return this.hostClasses()
}
@HostBinding('style.grid-column') protected get hostGridColumnStyleBinding() {
return this.split.direction() === 'horizontal' ? `${this.gridAreaNum()} / ${this.gridAreaNum()}` : undefined
}
@HostBinding('style.grid-row') protected get hostGridRowStyleBinding() {
return this.split.direction() === 'vertical' ? `${this.gridAreaNum()} / ${this.gridAreaNum()}` : undefined
}
@HostBinding('style.position') protected get hostPositionStyleBinding() {
return this.split._isDragging() ? 'relative' : undefined
}
protected readonly hostGridColumnStyle = computed(() =>
this.split.direction() === 'horizontal' ? `${this.gridAreaNum()} / ${this.gridAreaNum()}` : undefined,
)
protected readonly hostGridRowStyle = computed(() =>
this.split.direction() === 'vertical' ? `${this.gridAreaNum()} / ${this.gridAreaNum()}` : undefined,
)
protected readonly hostPositionStyle = computed(() => (this.split._isDragging() ? 'relative' : undefined))

private normalizeMinSize() {
const defaultMinSize = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { DOCUMENT } from '@angular/common'
*/
@Directive({
selector: '[asSplitCustomEventsBehavior]',
standalone: true,
})
export class SplitCustomEventsBehaviorDirective {
private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef)
Expand Down
15 changes: 5 additions & 10 deletions projects/angular-split/src/lib/split/split.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ChangeDetectionStrategy,
Component,
ElementRef,
HostBinding,
InjectionToken,
NgZone,
afterRenderEffect,
Expand Down Expand Up @@ -84,6 +83,10 @@ export const SPLIT_AREA_CONTRACT = new InjectionToken<SplitAreaComponent>('Split
templateUrl: './split.component.html',
styleUrl: './split.component.css',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class]': 'hostClasses()',
'[dir]': 'dir()',
},
})
export class SplitComponent {
private readonly document = inject(DOCUMENT)
Expand Down Expand Up @@ -131,7 +134,7 @@ export class SplitComponent {
*/
readonly _visibleAreas = computed(() => this._areas().filter((area) => area.visible()))
private readonly gridTemplateColumnsStyle = computed(() => this.createGridTemplateColumnsStyle())
private readonly hostClasses = computed(() =>
protected readonly hostClasses = computed(() =>
createClassesString({
[`as-${this.direction()}`]: true,
[`as-${this.unit()}`]: true,
Expand All @@ -151,14 +154,6 @@ export class SplitComponent {
*/
readonly _alignedVisibleAreasSizes = computed(() => this.createAlignedVisibleAreasSize())

@HostBinding('class') protected get hostClassesBinding() {
return this.hostClasses()
}

@HostBinding('dir') protected get hostDirBinding() {
return this.dir()
}

constructor() {
if (isDevMode()) {
// Logs warnings to console when the provided areas sizes are invalid
Expand Down