16.0.0 • Published 8 months ago

@avine/ng-timeline v16.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Timeline

Angular component that displays a list of events in chronological order.

Demo

Check out demo here.

Usage

Component

import { Component } from '@angular/core';
import { TIMELINE_DIRECTIVES, provideTimelineBreakpoint } from '@avine/ng-timeline';

@Component({
  selector: 'app-timeline-demo',
  standalone: true,
  imports: [TIMELINE_DIRECTIVES],
  providers: [provideTimelineBreakpoint('1280px')], // This is optional
  templateUrl: './timeline.component.html',
})
export class TimelineDemoComponent {
  items = ['Step 1', 'Step 2', 'Step 3'];
}

Template

<!-- Using items input -->
<timeline-container [items]="items" />

<!-- Using timeline-item components  -->
<timeline-container>
  <timeline-item>Step 1</timeline-item>

  <timeline-item>Step 2</timeline-item>

  <timeline-item>
    <ng-template timelineIcon>
      <!-- your SVG icon comes here -->
    </ng-template>

    Step 3
  </timeline-item>
</timeline-container>

API

The different sizes should be entered as numbers (you should not specify units such as em or rem).

These sizes will be treated as em relative to the font-size of the root element of the timeline.

InputTypeDefaultDescription
itemsstring[][]The list of items to display.
pendingFromIndexNumberInputundefinedDisplay the items as pending from the specified index.
bgColorstring | undefinedundefinedIndicates the background color of the timeline.
lineSizeTimelineLineSize{}Determines the size of the line between bullets.
bulletPointsBooleanInputfalseDisplay bullet points instead of bullet content.
reverseBooleanInputfalseReverse the bullet and content positions.
verticalBooleanInputfalseDisplay timeline in horizontal or vertical direction.
verticalContentSizeNumberInputfalseLimit the size (width) of the content when the timeline is vertical.
breakpointstring | boolean | nullfalseSwitch between vertical and horizontal timeline based on a breakpoint.

TimelineLineSize

Determines the size of the line between bullets.

interface TimelineLineSize {
  horizontal?: number;
  vertical?: number;
}

Breakpoint

Switch between vertical and horizontal timeline based on a breakpoint.

If breakpoint is set to true then the default value is used (1024px).

You can provide a different default value using the provideTimelineBreakpoint function:

import { provideTimelineBreakpoint } from '@avine/ng-timeline';

@Component({
  providers: [provideTimelineBreakpoint('1280px')],
})
export class TimelineDemoComponent {}

Or by providing the TIMELINE_BREAKPOINT injection token:

import { TIMELINE_BREAKPOINT } from '@avine/ng-timeline';

@Component({
  providers: [{ provide: TIMELINE_BREAKPOINT, useValue: '1280px' }],
})
export class TimelineDemoComponent {}

Sass customization

You can fully customize the Timeline CSS using Sass.

Below the list of Sass variables:

@use 'node_modules/@avine/ng-timeline/src/lib/scss/timeline.scss' with (
  $timeline-background-color: #fff,

  $timeline-line-thickness: 3px,
  $timeline-line-color: #ced4da,

  $timeline-line-size-horizontal: 10,
  $timeline-line-size-vertical: 2,

  $timeline-bullet-font-size: 1.5,
  $timeline-bullet-outline-size: 0.5,
  $timeline-bullet-border-size: 2px,
  $timeline-bullet-size: 3,

  $timeline-bullet-border-color: #6ea8fe,
  $timeline-bullet-background-color: #0d6efd,
  $timeline-bullet-color: #fff,

  $timeline-pending-bullet-scale: 0.875,
  $timeline-pending-bullet-border-color: #dee2e6,
  $timeline-pending-bullet-background-color: #adb5bd,
  $timeline-pending-bullet-color: #e9ecef,
  $timeline-pending-content-color: #999,

  $timeline-vertical-content-size: auto
);

License

MIT

16.0.0

8 months ago

0.5.6

1 year ago

0.5.5

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago