src/app/features/attendance/add-day-attendance/roll-call/roll-call-tab/roll-call-tab.component.ts

Metadata

Relationships

Depends on

No results matching.

Index

Properties
Inputs

Inputs

position
Type : number
Default value : 0

Properties

Readonly positionClass
Type : unknown
Default value : computed(() => { const position = this.position(); let posState: PositionState; if (position < 0) { posState = "left"; } else if (position > 0) { posState = "right"; } else { posState = "center"; } return `tab-${posState}`; })
import {
  Component,
  ChangeDetectionStrategy,
  computed,
  input,
} from "@angular/core";

/**
 * These position states are used internally as animation states for the tab body. Setting the
 * position state to left, right, or center will transition the tab body from its current
 * position to its respective state. If there is no current position (void, in the case of a new
 * tab body), then there will be no transition animation to its state.
 *
 * In the case of a new tab body that should immediately be centered with an animating transition,
 * then left-origin-center or right-origin-center can be used, which will use left or right as its
 * pseudo-prior state.
 */
type PositionState = "left" | "center" | "right";

@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  selector: "app-roll-call-tab",
  template: "<ng-content></ng-content>",
  styleUrls: ["./roll-call-tab.component.scss"],
  host: {
    "[class]": "positionClass()",
  },
  standalone: true,
})
export class RollCallTabComponent {
  position = input<number>(0);

  readonly positionClass = computed(() => {
    const position = this.position();
    let posState: PositionState;
    if (position < 0) {
      posState = "left";
    } else if (position > 0) {
      posState = "right";
    } else {
      posState = "center";
    }
    return `tab-${posState}`;
  });
}

./roll-call-tab.component.scss

:host {
  width: 100%;
  display: block !important;
  transition:
    transform 500ms cubic-bezier(0.35, 0, 0.25, 1),
    visibility 500ms cubic-bezier(0.35, 0, 0.25, 1);

  &.tab-center {
    transform: none;
  }

  &.tab-left {
    transform: translate(-110%);
    // If the tab is either on the left or right, we additionally add a `min-height` of 1px
    // in order to ensure that the element has a height before its state changes. This is
    // necessary because Chrome does seem to skip the transition in RTL mode if the element does
    // not have a static height and is not rendered. See related issue: #9465
    min-height: 1px;
    visibility: hidden;
  }

  &.tab-right {
    transform: translate(110%);
    min-height: 1px;
    visibility: hidden;
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""