Skip to content

Commit

Permalink
fix: remove under positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
blidblid committed Apr 14, 2023
1 parent 0fe6c3e commit 5066451
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<mat-label>Top left position</mat-label>
<mat-select [formControl]="layoutFormControls.topLeftPosition">
<mat-option
*ngFor="let position of ['above', 'beside', 'under']"
*ngFor="let position of ['above', 'beside']"
[value]="position"
>{{ position }}</mat-option
>
Expand All @@ -82,7 +82,7 @@
<mat-label>Top right position</mat-label>
<mat-select [formControl]="layoutFormControls.topRightPosition">
<mat-option
*ngFor="let position of ['above', 'beside', 'under']"
*ngFor="let position of ['above', 'beside']"
[value]="position"
>{{ position }}</mat-option
>
Expand All @@ -93,7 +93,7 @@
<mat-label>Bottom left position</mat-label>
<mat-select [formControl]="layoutFormControls.bottomLeftPosition">
<mat-option
*ngFor="let position of ['below', 'beside', 'under']"
*ngFor="let position of ['below', 'beside']"
[value]="position"
>{{ position }}</mat-option
>
Expand All @@ -104,7 +104,7 @@
<mat-label>Bottom right position</mat-label>
<mat-select [formControl]="layoutFormControls.bottomRightPosition">
<mat-option
*ngFor="let position of ['below', 'beside', 'under']"
*ngFor="let position of ['below', 'beside']"
[value]="position"
>{{ position }}</mat-option
>
Expand Down
2 changes: 1 addition & 1 deletion libs/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@berg-layout/angular",
"version": "5.2.0",
"version": "5.1.3",
"devDependencies": {
"@berg-layout/testing": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion libs/core/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@berg-layout/core",
"version": "5.2.0"
"version": "5.1.3"
}
8 changes: 1 addition & 7 deletions libs/core/src/lib/components/layout/layout-config-private.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
export const BERG_LAYOUT_CLASS = 'berg-layout';
export const BERG_LAYOUT_TOP_ABOVE_LEFT_CLASS = 'berg-layout-top-above-left';
export const BERG_LAYOUT_TOP_ABOVE_RIGHT_CLASS = 'berg-layout-top-above-right';
export const BERG_LAYOUT_TOP_UNDER_LEFT_CLASS = 'berg-layout-top-under-left';
export const BERG_LAYOUT_TOP_UNDER_RIGHT_CLASS = 'berg-layout-top-under-right';
export const BERG_LAYOUT_NO_TRANSITION_CLASS = 'berg-layout-no-transition';
export const BERG_LAYOUT_BOTTOM_BELOW_LEFT_CLASS =
'berg-layout-bottom-below-left';
export const BERG_LAYOUT_BOTTOM_BELOW_RIGHT_CLASS =
'berg-layout-bottom-below-right';
export const BERG_LAYOUT_BOTTOM_UNDER_LEFT_CLASS =
'berg-layout-bottom-under-left';
export const BERG_LAYOUT_BOTTOM_UNDER_RIGHT_CLASS =
'berg-layout-bottom-under-right';
export const BERG_LAYOUT_NO_TRANSITION_CLASS = 'berg-layout-no-transition';
export const BERG_LAYOUT_RESIZING_VERTICAL_CLASS =
'berg-layout-resizing-vertical';
export const BERG_LAYOUT_RESIZING_HORIZONTAL_CLASS =
Expand Down
4 changes: 2 additions & 2 deletions libs/core/src/lib/components/layout/layout-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface BergLayoutInputs {
export type BergLayoutInput = keyof BergLayoutInputs;

/** Positions of the top panel. */
export type BergLayoutTopPosition = 'above' | 'beside' | 'under';
export type BergLayoutTopPosition = 'above' | 'beside';

/** Positions of the bottom panel. */
export type BergLayoutBottomPosition = 'below' | 'beside' | 'under';
export type BergLayoutBottomPosition = 'below' | 'beside';
4 changes: 2 additions & 2 deletions libs/core/src/lib/components/layout/layout-util-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
export function validateBergLayoutTopPosition(
position: string
): BergLayoutTopPosition {
if (position !== 'above' && position !== 'beside' && position !== 'under') {
if (position !== 'above' && position !== 'beside') {
throw new Error(`Invalid layout top position: ${position}`);
}

Expand All @@ -16,7 +16,7 @@ export function validateBergLayoutTopPosition(
export function validateBergLayoutBottomPosition(
position: string
): BergLayoutBottomPosition {
if (position !== 'below' && position !== 'beside' && position !== 'under') {
if (position !== 'below' && position !== 'beside') {
throw new Error(`Invalid layout bottom position: ${position}`);
}

Expand Down
32 changes: 8 additions & 24 deletions libs/core/src/lib/components/layout/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ import {
import {
BERG_LAYOUT_BOTTOM_BELOW_LEFT_CLASS,
BERG_LAYOUT_BOTTOM_BELOW_RIGHT_CLASS,
BERG_LAYOUT_BOTTOM_UNDER_LEFT_CLASS,
BERG_LAYOUT_BOTTOM_UNDER_RIGHT_CLASS,
BERG_LAYOUT_CLASS,
BERG_LAYOUT_TOP_ABOVE_LEFT_CLASS,
BERG_LAYOUT_TOP_ABOVE_RIGHT_CLASS,
BERG_LAYOUT_TOP_UNDER_LEFT_CLASS,
BERG_LAYOUT_TOP_UNDER_RIGHT_CLASS,
} from './layout-config-private';
import { BergLayoutInputs } from './layout-model';
import {
Expand Down Expand Up @@ -52,43 +48,31 @@ export class BergLayoutElement extends WebComponent<BergLayoutInputs> {
},
{
topLeftPosition: () => {
this.classList.remove(BERG_LAYOUT_TOP_ABOVE_LEFT_CLASS);
this.classList.remove(BERG_LAYOUT_TOP_UNDER_LEFT_CLASS);

if (this.values.topLeftPosition === 'above') {
this.classList.add(BERG_LAYOUT_TOP_ABOVE_LEFT_CLASS);
} else if(this.values.topLeftPosition === 'under') {
this.classList.add(BERG_LAYOUT_TOP_UNDER_LEFT_CLASS);
} else {
this.classList.remove(BERG_LAYOUT_TOP_ABOVE_LEFT_CLASS);
}
},
topRightPosition: () => {
this.classList.remove(BERG_LAYOUT_TOP_ABOVE_RIGHT_CLASS);
this.classList.remove(BERG_LAYOUT_TOP_UNDER_RIGHT_CLASS);

if (this.values.topRightPosition === 'above') {
this.classList.add(BERG_LAYOUT_TOP_ABOVE_RIGHT_CLASS);
} else if(this.values.topRightPosition === 'under') {
this.classList.add(BERG_LAYOUT_TOP_UNDER_RIGHT_CLASS);
} else {
this.classList.remove(BERG_LAYOUT_TOP_ABOVE_RIGHT_CLASS);
}
},
bottomLeftPosition: () => {
this.classList.remove(BERG_LAYOUT_BOTTOM_BELOW_LEFT_CLASS);
this.classList.remove(BERG_LAYOUT_BOTTOM_UNDER_LEFT_CLASS);

if (this.values.bottomLeftPosition === 'below') {
this.classList.add(BERG_LAYOUT_BOTTOM_BELOW_LEFT_CLASS);
} else if(this.values.bottomLeftPosition === 'under') {
this.classList.add(BERG_LAYOUT_BOTTOM_UNDER_LEFT_CLASS);
} else {
this.classList.remove(BERG_LAYOUT_BOTTOM_BELOW_LEFT_CLASS);
}
},
bottomRightPosition: () => {
this.classList.remove(BERG_LAYOUT_BOTTOM_BELOW_RIGHT_CLASS);
this.classList.remove(BERG_LAYOUT_BOTTOM_UNDER_RIGHT_CLASS);

if (this.values.bottomRightPosition === 'below') {
this.classList.add(BERG_LAYOUT_BOTTOM_BELOW_RIGHT_CLASS);
} else if(this.values.bottomRightPosition === 'under') {
this.classList.add(BERG_LAYOUT_BOTTOM_UNDER_RIGHT_CLASS);
} else {
this.classList.remove(BERG_LAYOUT_BOTTOM_BELOW_RIGHT_CLASS);
}
},
topInset: () => {
Expand Down
8 changes: 4 additions & 4 deletions libs/core/src/lib/styles/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ $transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
top: calc(var(--berg-layout-top-inset) - var(--berg-panel-top-size));
}

.berg-layout-top-above-left &, .berg-layout-top-under-left & {
.berg-layout-top-above-left & {
left: var(--berg-layout-left-inset);
}

.berg-layout-top-above-right &, .berg-layout-top-under-right & {
.berg-layout-top-above-right & {
right: var(--berg-layout-right-inset);
}

Expand Down Expand Up @@ -123,11 +123,11 @@ $transition: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
);
}

.berg-layout-bottom-below-left &, .berg-layout-bottom-under-left & {
.berg-layout-bottom-below-left & {
left: var(--berg-layout-left-inset);
}

.berg-layout-bottom-below-right &, .berg-layout-bottom-under-right & {
.berg-layout-bottom-below-right & {
right: var(--berg-layout-right-inset);
}

Expand Down
2 changes: 1 addition & 1 deletion libs/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@berg-layout/react",
"version": "5.2.0",
"version": "5.1.3",
"devDependencies": {
"@berg-layout/testing": "*"
}
Expand Down
65 changes: 0 additions & 65 deletions libs/testing/src/lib/run-layout-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,6 @@ export const runLayoutTests = (
);
});

it('should render top panel under left', async () => {
await render({
layout: {
topLeftPosition: 'under',
},
});

expect(harness.assertedTop.getBoundingClientRect().left).toBe(
harness.assertedLeft.getBoundingClientRect().left
);

expect(harness.assertedTop.getBoundingClientRect().top).toBe(
harness.assertedLeft.getBoundingClientRect().top
);
});

it('should render top panel above right', async () => {
await render({
layout: {
Expand All @@ -72,22 +56,6 @@ export const runLayoutTests = (
);
});

it('should render top panel under right', async () => {
await render({
layout: {
topRightPosition: 'under',
},
});

expect(harness.assertedTop.getBoundingClientRect().right).toBe(
harness.assertedRight.getBoundingClientRect().right
);

expect(harness.assertedTop.getBoundingClientRect().top).toBe(
harness.assertedRight.getBoundingClientRect().top
);
});

it('should render bottom panel below left', async () => {
await render({
layout: {
Expand All @@ -112,23 +80,6 @@ export const runLayoutTests = (
);
});

it('should render bottom panel under left', async () => {
await render({
layout: {
bottomLeftPosition: 'under',
},
});

expect(harness.assertedBottom.getBoundingClientRect().left).toBe(
harness.assertedLeft.getBoundingClientRect().left
);

expect(harness.assertedBottom.getBoundingClientRect().bottom).toBe(
harness.assertedLeft.getBoundingClientRect().bottom
);
});


it('should render bottom panel below right', async () => {
await render({
layout: {
Expand All @@ -152,22 +103,6 @@ export const runLayoutTests = (
harness.assertedRight.getBoundingClientRect().left
);
});

it('should render bottom panel under right', async () => {
await render({
layout: {
bottomRightPosition: 'under',
},
});

expect(harness.assertedBottom.getBoundingClientRect().right).toBe(
harness.assertedRight.getBoundingClientRect().right
);

expect(harness.assertedBottom.getBoundingClientRect().bottom).toBe(
harness.assertedRight.getBoundingClientRect().bottom
);
});
});

describe('insets', () => {
Expand Down
3 changes: 1 addition & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@
"style": "scss"
}
}
},
"defaultProject": "demo"
}
}

0 comments on commit 5066451

Please sign in to comment.