Timeline

documentation for this timeline template

Getting Started

Below, you'll find a series of steps outlining how to make the most out of our timeline template. I've tried to keep things clear and simple, because I know the struggles of using something which has a lot of steps.


  1. Go to the github repository
  2. Find the code structure there
  3. It should be something like this:

  4. - prism/
      - script.js
      - style.css
    - scripts/
      - doc-script.js
      - script.js
    - src/
      - script.js
      - styles.css
    - styles/
      - docs-styles.css
      - style.css
    - docs.html
    - index.html
    - README.md

  5. The files you need are in the src folder => styles.css and script.js

HTML

Navigate to index.html and scroll down till you see the .container element. From there, you can see the basic format for the timeline.



This is basically it for the HTML. Only thing customizable through the HTML is the class on the .container element. It's direction is set by the class name, which is by default .vertical as most people would prefer timelines going from up to down. You can replace the class with horizontal to make it scrollable from left to right. See Custom properties for more information.

CSS

CSS code is a bit lengthy. I would recommend you to directly copy the code from src/styles.css instead of the page styles. It will be better that way. On top of the styles file, you will see a kind of config created at the :root of the HTML page



The above are CSS variables and will be used to customize most of the things in the timeline like colors, gap from timeline, card padding, margin, etc.


Although I would not recommend this, you can even link the src/styles.css as a <link> element in your page. It's not recommended as the styles will not be readily available to you and it will be difficult to customize them. It's better if you just take the styles and put them on your own CSS file

Javascript

Javascript is minimal for this project and is not really required. The only use is to animate the cards when they are visible in the viewport. The threshold property of IntersectionObserver API determines the segment of card visible to run the code out of 1. I have set it to .7. Besides that, there is one other variable at the top of the file hideAfterScroll


const hideAfterScroll = false;

If you set this to true, the cards, after appearing, can be hidden again when the user scrolls away from them. Then they will again have the appearing animation.

For those of you who do not want the animations on appear / dissapear, then you also need to make one change to the CSS =>


/* REMOVE THE FOLLOWING CODE FROM THE CSS AS INSTRUCTED */ .card { background-color: var(--overlay); padding: 1.5rem; border-radius: .5rem; position: relative; /* remove the below styles */ opacity: 0; pointer-events: none; transition: 300ms ease-in-out; transition-property: opacity, transform; } .container.vertical .card { width: calc(50% - var(--box-padding)); /* remove the below line */ transform: translateX(-20%); } /* just remove this whole statement */ .container.vertical .card:nth-of-type(2n) { transform: translateX(20%); } .container.horizontal .card { height: 95%; min-width: 25rem !important; /* remove this transform statement */ transform: translateY(-10%); } /* remove this statement too as the card will never have an active class (javascript is removed) */ .card.active { opacity: 1; pointer-events: all; transform: unset !important; }

Now, if you completed the above steps correctly, the timeline will work fine without javascript.

Extra

Here are some things you might want to know. Some things will be repeated in case you missed an important thing.
The timeline is made for purely custom timelines, which means that you can easily change the sizes and colors of the timeline without any issues. All colors and element sizes are divided into CSS variables



CSS Variables

all sizes and colors are put into CSS variables for you to be able to easily customize the timeline according to your theme or design. To check where the colors are used, you can either check the below list, or change the colors and styles in the home page. Given below are all the css variables



  • --overlay
  • default value: #363c4b
    Used in:



  • --gray
  • default value: #dcf4ff
    Used in:



  • --muted
  • default value: #dddddd43
    Used in:



  • --gap-from-line
  • default value: 4rem
    Used in:



  • --line-dimension
  • default value: 1px
    Used in:



  • --signal-dimension
  • default value: 1rem
    Used in:



  • --box-padding
  • default value: 4rem (inherited from --gap-from-line)
    Used in:


    It is recommended that you keep the --box-padding and --gap-from-line variables same.



    Responsiveness

    By default, the timeline comes with 2 breakpoints. Horizontal mode has no changes whatsoever. It does not take into account the width of the screen as it is scrollable. Vertical mode is the only layout affected by width, so you have one layout for bigger or medium sized screens, and the other for mobile or small tablets screen.

    Breakpoint 1: max-width: 900px => fits the cards to take the remaining screen size on their respective side
    Breakpoint 2: max-width: 725px => puts the cards on the timeline at the center of the screen

    Future

    One major update planned is for vertical layouts which will theoretically give the option for users to change mobile layouts. Currently a user on mobile will see all cards centered and on the timeline, but the future update will be that the you will be able to change where the timeline is (left/right) and where the cards are (centered on the timeline/besides the timeline)