Skip to content

Commit

Permalink
feat(design): add sidebar mode helpers (#3015)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Aug 21, 2024
1 parent 37a2399 commit 43c762a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libs/design/sidebar/src/helper/is-docked-mode.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DaffSidebarModeEnum } from '@daffodil/design/sidebar';

import { daffSidebarIsDockedMode } from './is-docked-mode';

describe('@daffodil/design/sidebar | daffSidebarIsDockedMode', () => {
it('should be true for side', () => {
expect(daffSidebarIsDockedMode(DaffSidebarModeEnum.Side)).toBeTrue();
});

it('should be true for side fixed', () => {
expect(daffSidebarIsDockedMode(DaffSidebarModeEnum.SideFixed)).toBeTrue();
});

it('should be false for under', () => {
expect(daffSidebarIsDockedMode(DaffSidebarModeEnum.Under)).toBeFalse();
});

it('should be false for over', () => {
expect(daffSidebarIsDockedMode(DaffSidebarModeEnum.Over)).toBeFalse();
});
});
11 changes: 11 additions & 0 deletions libs/design/sidebar/src/helper/is-docked-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DaffSidebarModeEnum } from './sidebar-mode';

const DOCKED_MODES = [
DaffSidebarModeEnum.Side,
DaffSidebarModeEnum.SideFixed,
];

/**
* Returns whether the passed mode is a docked mode, i.e. side or side-fixed.
*/
export const daffSidebarIsDockedMode = (mode: DaffSidebarModeEnum): boolean => DOCKED_MODES.includes(mode);
21 changes: 21 additions & 0 deletions libs/design/sidebar/src/helper/is-floating-mode.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DaffSidebarModeEnum } from '@daffodil/design/sidebar';

import { daffSidebarIsFloatingMode } from './is-floating-mode';

describe('@daffodil/design/sidebar | daffSidebarIsFloatingMode', () => {
it('should be false for side', () => {
expect(daffSidebarIsFloatingMode(DaffSidebarModeEnum.Side)).toBeFalse();
});

it('should be false for side fixed', () => {
expect(daffSidebarIsFloatingMode(DaffSidebarModeEnum.SideFixed)).toBeFalse();
});

it('should be true for under', () => {
expect(daffSidebarIsFloatingMode(DaffSidebarModeEnum.Under)).toBeTrue();
});

it('should be true for over', () => {
expect(daffSidebarIsFloatingMode(DaffSidebarModeEnum.Over)).toBeTrue();
});
});
11 changes: 11 additions & 0 deletions libs/design/sidebar/src/helper/is-floating-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DaffSidebarModeEnum } from './sidebar-mode';

const FLOATING_MODES = [
DaffSidebarModeEnum.Under,
DaffSidebarModeEnum.Over,
];

/**
* Returns whether the passed mode is a floating mode, i.e. under or over.
*/
export const daffSidebarIsFloatingMode = (mode: DaffSidebarModeEnum): boolean => FLOATING_MODES.includes(mode);
2 changes: 2 additions & 0 deletions libs/design/sidebar/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export {
DaffSidebarSide,
DaffSidebarSideEnum,
} from './helper/sidebar-side';
export * from './helper/is-docked-mode';
export * from './helper/is-floating-mode';

0 comments on commit 43c762a

Please sign in to comment.