Most features done

This commit is contained in:
Schmelczer András 2019-12-23 11:31:53 +01:00
parent cdaa423b8a
commit c8679b77bf
43 changed files with 803 additions and 648 deletions

View file

@ -0,0 +1,37 @@
import { TimelineElement } from "../../../model/portfolio";
import { html } from "../../../model/misc";
export const generate = (
{ date, title, picture, description, more, link }: TimelineElement,
showMore: string,
showLess: string
): html => `
<section class="timeline-element">
<div class="line">
<p class="date-wide-screen">${date}</p>
</div>
<div class="card">
<h2>${title}</h2>
<p class="date-narrow-screen">${date}</p>
<img src="${picture}" alt="${picture}"/>
<p class="description">${description}</p>
${
more
? `
<div id="more"></div>
<div class="buttons">
<a id="show-more">${showMore}</a>
<a id="show-less">${showLess}</a>
</div>
`
: ""
}
${
link
? `
<a href="${link}" target="_blank">${link}</a>`
: ""
}
</div>
</section>
`;

View file

@ -6,7 +6,7 @@
.date-narrow-screen,
.date-wide-screen {
font: $text-font;
@include insignificant-font();
}
.line {
@ -31,7 +31,8 @@
.date-wide-screen {
position: relative;
top: calc(33% + #{$icon-size} + 1ch);
top: calc(33% + #{$icon-size} + 2ch);
transform: rotate(30deg);
margin: 0 $normal-margin 0 calc(#{$line-width} + 1ex);
width: 100px;
}
@ -43,9 +44,14 @@
.card {
@include card();
overflow: hidden;
& > *:not(:first-child) {
margin-top: $line-height;
}
h2 {
font: $sub-title-font;
@include sub-title-font();
}
.date-narrow-screen {
@ -57,23 +63,40 @@
color: $light-text-color;
}
img {
cursor: pointer;
}
.description {
font-style: italic;
}
#more {
overflow: hidden;
height: 0;
transition: height $transition-time;
margin-top: 0;
transition: height $slow-transition-time;
}
.buttons {
position: relative;
margin-top: $small-margin;
* {
position: absolute;
left: 50%;
transform: translateX(-50%);
transition: opacity $transition-time;
transition: opacity $slow-transition-time;
}
#show-more {
opacity: 1;
}
#show-less {
opacity: 0;
visibility: hidden;
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
}
}
}

View file

@ -3,49 +3,21 @@ import { PageContent } from "../../content/content";
import "./timeline-element.scss";
import { PageElement } from "../../../framework/page-element";
import { createElement } from "../../../framework/element-factory";
import { generate } from "./timeline-element.html";
export class PageTimelineElement extends PageElement {
private isOpen;
private more: HTMLElement;
public constructor(
{ date, title, picture, description, more, link }: TimelineElement,
timelineElement: TimelineElement,
showMore: string,
showLess: string
) {
const root = createElement(`
<section class="timeline-element">
<div class="line">
<p class="date-wide-screen">${date}</p>
</div>
<div class="card">
<h2>${title}</h2>
<p class="date-narrow-screen">${date}</p>
<img src="${picture}" alt="${picture}"/>
<p class="description">${description}</p>
${
more
? `
<div id="more"></div>
<div class="buttons">
<a id="show-more">${showMore}</a>
<a id="show-less">${showLess}</a>
</div>
`
: ""
}
${
link
? `
<a href="${link}" target="_blank">${link}</a>`
: ""
}
</div>
</section>
`);
const root = createElement(generate(timelineElement, showMore, showLess));
if (more) {
const content = new PageContent(more);
if (timelineElement.more) {
const content = new PageContent(timelineElement.more);
super([content]);
this.isOpen = false;
this.more = root.querySelector("#more");
@ -67,17 +39,27 @@ export class PageTimelineElement extends PageElement {
) as HTMLElement;
if (this.isOpen) {
this.more.style.height = "0";
showMore.style.opacity = "1";
showLess.style.opacity = "0";
PageTimelineElement.show(showMore);
PageTimelineElement.hide(showLess);
} else {
this.openMoreToFullHeight();
showMore.style.opacity = "0";
showLess.style.opacity = "1";
PageTimelineElement.hide(showMore);
PageTimelineElement.show(showLess);
}
this.isOpen = !this.isOpen;
}
private static hide(element: HTMLElement) {
element.style.opacity = "0";
setTimeout(() => (element.style.visibility = "hidden"), 350);
}
private static show(element: HTMLElement) {
element.style.visibility = "visible";
element.style.opacity = "1";
}
private openMoreToFullHeight() {
this.more.style.height = `${this.more.scrollHeight.toString()}px`;
}

View file

@ -0,0 +1,5 @@
import { html } from "../../model/misc";
export const generate = (): html => `
<main id="timeline"></main>
`;

View file

@ -1,5 +1 @@
@import "../../style/vars";
#timeline {
margin-top: $normal-margin;
}

View file

@ -3,6 +3,7 @@ import "./timeline.scss";
import { PageElement } from "../../framework/page-element";
import { createElement } from "../../framework/element-factory";
import { PageTimelineElement } from "./timeline-element/timeline-element";
import { generate } from "./timeline.html";
export class PageTimeline extends PageElement {
public constructor(
@ -10,7 +11,7 @@ export class PageTimeline extends PageElement {
showMore: string,
showLess: string
) {
const root = createElement(`<main id="timeline"></main>`);
const root = createElement(generate());
const elements = timeline.map(
e => new PageTimelineElement(e, showMore, showLess)
);