Will it work?
This commit is contained in:
parent
79f7c4c16f
commit
f74c86f4b1
19 changed files with 193 additions and 78 deletions
7
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
7
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="CssInvalidAtRule" enabled="false" level="ERROR" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
7
.idea/vagrant.xml
generated
Normal file
7
.idea/vagrant.xml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VagrantProjectSettings">
|
||||||
|
<option name="instanceFolder" value="" />
|
||||||
|
<option name="provider" value="" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.stylelintrc
Normal file
9
.stylelintrc
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"at-rule-no-unknown": [
|
||||||
|
true, {
|
||||||
|
"ignoreAtRules": ["use", "mixin", "include"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/dummy.scss
Normal file
8
src/dummy.scss
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
@use "styles";
|
||||||
|
@use "page/about/about";
|
||||||
|
@use "page/background/background";
|
||||||
|
@use "page/content/content";
|
||||||
|
@use "page/footer/footer";
|
||||||
|
@use "page/image-viewer/image-viewer";
|
||||||
|
@use "page/timeline/timeline";
|
||||||
|
@use "page/timeline/timeline-element/timeline-element";
|
||||||
|
|
@ -4,15 +4,22 @@ import { PageEventType } from "./page-event";
|
||||||
export class Page extends PageElement {
|
export class Page extends PageElement {
|
||||||
public constructor(
|
public constructor(
|
||||||
children: Array<PageElement>,
|
children: Array<PageElement>,
|
||||||
private rootElement: HTMLElement
|
private rootElement: HTMLElement,
|
||||||
|
isRootPage = false
|
||||||
) {
|
) {
|
||||||
super(children);
|
super(children);
|
||||||
this.setElement(rootElement);
|
this.setElement(rootElement);
|
||||||
|
if (isRootPage) {
|
||||||
this.broadcastEvent(
|
this.broadcastEvent(
|
||||||
{ type: PageEventType.eventBroadcasterChanged, data: this },
|
{ type: PageEventType.eventBroadcasterChanged, data: this },
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
rootElement.append(...children.map(e => e.getElement()).filter(e => e));
|
rootElement.append(...children.map(e => e.getElement()).filter(e => e));
|
||||||
|
|
||||||
|
if (isRootPage) {
|
||||||
this.broadcastEvent({ type: PageEventType.onLoad }, this);
|
this.broadcastEvent({ type: PageEventType.onLoad }, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ export const generate = (
|
||||||
aPictureOf: string
|
aPictureOf: string
|
||||||
): html => `
|
): html => `
|
||||||
<section id="about">
|
<section id="about">
|
||||||
|
<div class="container">
|
||||||
<header>
|
<header>
|
||||||
<img alt="${aPictureOf} ${name}" src="${picture}"/>
|
<img alt="${aPictureOf} ${name}" src="${picture}"/>
|
||||||
<h1>${name}</h1>
|
<h1>${name}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
</div>
|
||||||
</section>`;
|
</section>`;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,13 @@
|
||||||
@import "../../style/vars";
|
@import "../../style/vars";
|
||||||
|
|
||||||
#about {
|
#about {
|
||||||
margin-top: $normal-margin - $small-margin;
|
width: 100%;
|
||||||
padding: $small-margin;
|
backdrop-filter: blur($blur-radius);
|
||||||
|
padding: $normal-margin;
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: $body-width;
|
||||||
|
margin: auto;
|
||||||
|
|
||||||
header {
|
header {
|
||||||
@include center-children();
|
@include center-children();
|
||||||
|
|
@ -19,9 +24,20 @@
|
||||||
margin-right: 1.5ex;
|
margin-right: 1.5ex;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: $breakpoint-width) {
|
||||||
|
flex-direction: column;
|
||||||
|
img {
|
||||||
|
margin: 0 0 $small-margin 0;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ export class PageHeader extends PageElement {
|
||||||
const root = createElement(generate(header, aPictureOf));
|
const root = createElement(generate(header, aPictureOf));
|
||||||
const content = new PageContent(header.about);
|
const content = new PageContent(header.about);
|
||||||
|
|
||||||
root.appendChild(content.getElement());
|
|
||||||
super([content]);
|
super([content]);
|
||||||
this.setElement(root);
|
this.setElement(root);
|
||||||
|
this.query(".container").appendChild(content.getElement());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ export const generate = (
|
||||||
count: number,
|
count: number,
|
||||||
color?: () => string,
|
color?: () => string,
|
||||||
height?: () => number,
|
height?: () => number,
|
||||||
|
isAnimated?: (index) => boolean,
|
||||||
transform?: () => string
|
transform?: () => string
|
||||||
): html => `
|
): html => `
|
||||||
<section class="background">
|
<section class="background">
|
||||||
|
|
@ -13,8 +14,12 @@ export const generate = (
|
||||||
? new Array(count)
|
? new Array(count)
|
||||||
.fill(0, 0, count)
|
.fill(0, 0, count)
|
||||||
.map(
|
.map(
|
||||||
_ =>
|
(_, i) => `
|
||||||
`<div style="background-color: ${color()}; height: ${height()}px; transform: ${transform()}"></div>`
|
<div class="${
|
||||||
|
isAnimated(i) ? "animated" : ""
|
||||||
|
}" style="background-color: ${color()}; height: ${height()}px; transform: ${transform()}"
|
||||||
|
></div>
|
||||||
|
`
|
||||||
)
|
)
|
||||||
.join("")
|
.join("")
|
||||||
: ""
|
: ""
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,25 @@
|
||||||
transform-style: preserve-3d;
|
transform-style: preserve-3d;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
transition: height $slow-transition-time, width $slow-transition-time;
|
||||||
|
|
||||||
div {
|
div {
|
||||||
border-radius: 10000px;
|
border-radius: 10000px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 160px;
|
width: 160px;
|
||||||
|
|
||||||
|
&.animated {
|
||||||
|
animation: fade-in 1s linear forwards;
|
||||||
|
@keyframes fade-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ export class PageBackground extends PageElement {
|
||||||
private colors = ["#fff9e077", "#ffd6d677"];
|
private colors = ["#fff9e077", "#ffd6d677"];
|
||||||
private blobSize = 150; // with margin
|
private blobSize = 150; // with margin
|
||||||
private perspective = 5;
|
private perspective = 5;
|
||||||
|
private currentRealHeight = 0;
|
||||||
|
private currentRealWidth = 0;
|
||||||
|
private currentBlobCount = 0;
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
@ -39,6 +42,7 @@ export class PageBackground extends PageElement {
|
||||||
siblings.map(c => {
|
siblings.map(c => {
|
||||||
const computedStyle = window.getComputedStyle(c);
|
const computedStyle = window.getComputedStyle(c);
|
||||||
return (
|
return (
|
||||||
|
// ignores margin collapse
|
||||||
c.clientHeight +
|
c.clientHeight +
|
||||||
parseInt(computedStyle.marginTop) +
|
parseInt(computedStyle.marginTop) +
|
||||||
parseInt(computedStyle.marginBottom) +
|
parseInt(computedStyle.marginBottom) +
|
||||||
|
|
@ -48,13 +52,21 @@ export class PageBackground extends PageElement {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const random = randomFactory(42);
|
if (height > this.currentRealHeight || width > this.currentRealWidth) {
|
||||||
|
this.currentRealHeight = height;
|
||||||
|
this.currentRealWidth = width;
|
||||||
|
|
||||||
|
const random = randomFactory(44);
|
||||||
|
|
||||||
const count = Math.round((width * height) / this.blobSize ** 2);
|
const count = Math.round((width * height) / this.blobSize ** 2);
|
||||||
|
|
||||||
const randomWithKnownZ = (z: number, bound: number): number => {
|
const randomWithKnownZ = (z: number, bound: number): number => {
|
||||||
const l = (bound * (this.perspective + z)) / this.perspective;
|
const l = (bound * (this.perspective + z)) / this.perspective;
|
||||||
return randomInInterval(-(l / 2 - bound / 2), l / 2 + bound / 2, random);
|
return randomInInterval(
|
||||||
|
-(l / 2 - bound / 2),
|
||||||
|
l / 2 + bound / 2,
|
||||||
|
random
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setElement(
|
this.setElement(
|
||||||
|
|
@ -63,6 +75,7 @@ export class PageBackground extends PageElement {
|
||||||
count,
|
count,
|
||||||
() => choose(this.colors, random),
|
() => choose(this.colors, random),
|
||||||
() => randomInInterval(160, 750, random),
|
() => randomInInterval(160, 750, random),
|
||||||
|
i => i >= this.currentBlobCount,
|
||||||
() => {
|
() => {
|
||||||
const z = randomInInterval(-12, -25, random);
|
const z = randomInInterval(-12, -25, random);
|
||||||
return `
|
return `
|
||||||
|
|
@ -76,6 +89,8 @@ export class PageBackground extends PageElement {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.currentBlobCount = count;
|
||||||
|
}
|
||||||
this.getElement().style.width = `${width}px`;
|
this.getElement().style.width = `${width}px`;
|
||||||
this.getElement().style.height = `${height}px`;
|
this.getElement().style.height = `${height}px`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
@import "../../style/vars";
|
@use "../../style/vars";
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
margin-top: $small-margin;
|
margin-top: vars.$small-margin;
|
||||||
|
|
||||||
* {
|
* {
|
||||||
margin-top: $line-height;
|
margin-top: vars.$line-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ footer#page-footer {
|
||||||
margin: $small-margin auto 0 auto;
|
margin: $small-margin auto 0 auto;
|
||||||
padding: $normal-margin $normal-margin $line-height $normal-margin;
|
padding: $normal-margin $normal-margin $line-height $normal-margin;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
backdrop-filter: blur(5px);
|
backdrop-filter: blur($blur-radius);
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
@include title-font();
|
@include title-font();
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#image-viewer {
|
#image-viewer {
|
||||||
@include center-children();
|
@include center-children();
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
@ -22,6 +21,7 @@
|
||||||
#cancel {
|
#cancel {
|
||||||
@include square($icon-size);
|
@include square($icon-size);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
box-sizing: content-box;
|
||||||
padding: $normal-margin;
|
padding: $normal-margin;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@ export class PageImageViewer extends PageElement {
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super();
|
super();
|
||||||
const root = createElement(generate());
|
const root = createElement(generate());
|
||||||
(root.querySelector("#cancel") as HTMLElement).onclick = () =>
|
|
||||||
PageImageViewer.hide(root);
|
|
||||||
this.setElement(root);
|
this.setElement(root);
|
||||||
|
this.query("#cancel").onclick = () => PageImageViewer.hide(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected handleEvent(event: PageEvent, parent: PageElement) {
|
protected handleEvent(event: PageEvent, parent: PageElement) {
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,21 @@ import { Page } from "../framework/page";
|
||||||
|
|
||||||
export const create = ({ config, header, timeline, footer }: Portfolio) => {
|
export const create = ({ config, header, timeline, footer }: Portfolio) => {
|
||||||
document.title = header.name;
|
document.title = header.name;
|
||||||
|
new Page(
|
||||||
|
[
|
||||||
|
new PageImageViewer(),
|
||||||
new Page(
|
new Page(
|
||||||
[
|
[
|
||||||
new PageBackground(),
|
new PageBackground(),
|
||||||
new PageHeader(header, config.aPictureOf),
|
new PageHeader(header, config.aPictureOf),
|
||||||
new PageTimeline(timeline, config.showMore, config.showLess),
|
new PageTimeline(timeline, config.showMore, config.showLess),
|
||||||
new PageFooter(footer),
|
new PageFooter(footer)
|
||||||
new PageImageViewer()
|
|
||||||
],
|
],
|
||||||
document.body.querySelector("main")
|
document.body.querySelector("main"),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
],
|
||||||
|
document.body,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
@include square($icon-size);
|
@include square($icon-size);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 33%;
|
top: 33%;
|
||||||
left: -0.5 * $icon-size - (1.5 * $line-width);
|
left: calc(-0.5 * #{$icon-size} - (1.5 * #{$line-width}));
|
||||||
border: $line-width solid $normal-text-color;
|
border: $line-width solid $normal-text-color;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
background: $background;
|
background: $background;
|
||||||
|
|
|
||||||
|
|
@ -37,21 +37,31 @@ export class PageTimelineElement extends PageElement {
|
||||||
this.more.style.height = "0";
|
this.more.style.height = "0";
|
||||||
PageTimelineElement.show(showMore);
|
PageTimelineElement.show(showMore);
|
||||||
PageTimelineElement.hide(showLess);
|
PageTimelineElement.hide(showLess);
|
||||||
|
this.notifyOfHeightChange();
|
||||||
} else {
|
} else {
|
||||||
this.openMoreToFullHeight();
|
|
||||||
PageTimelineElement.hide(showMore);
|
PageTimelineElement.hide(showMore);
|
||||||
PageTimelineElement.show(showLess);
|
PageTimelineElement.show(showLess);
|
||||||
|
this.openMoreToFullHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isOpen = !this.isOpen;
|
this.isOpen = !this.isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private notifyOfHeightChange(change: number = null) {
|
||||||
|
const notify = () =>
|
||||||
this.eventBroadcaster?.broadcastEvent({
|
this.eventBroadcaster?.broadcastEvent({
|
||||||
type: PageEventType.onBodyDimensionsChanged
|
type: PageEventType.onBodyDimensionsChanged,
|
||||||
|
data: change
|
||||||
});
|
});
|
||||||
|
notify();
|
||||||
|
setTimeout(notify, 350);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static hide(element: HTMLElement) {
|
private static hide(element: HTMLElement) {
|
||||||
element.style.opacity = "0";
|
element.style.opacity = "0";
|
||||||
setTimeout(() => (element.style.visibility = "hidden"), 350);
|
setTimeout(() => {
|
||||||
|
element.style.visibility = "hidden";
|
||||||
|
}, 350);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static show(element: HTMLElement) {
|
private static show(element: HTMLElement) {
|
||||||
|
|
@ -61,6 +71,7 @@ export class PageTimelineElement extends PageElement {
|
||||||
|
|
||||||
private openMoreToFullHeight() {
|
private openMoreToFullHeight() {
|
||||||
this.more.style.height = `${this.more.scrollHeight.toString()}px`;
|
this.more.style.height = `${this.more.scrollHeight.toString()}px`;
|
||||||
|
this.notifyOfHeightChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleResize() {
|
private handleResize() {
|
||||||
|
|
|
||||||
|
|
@ -13,21 +13,30 @@ $scrollbar-color: #ffd6d6;
|
||||||
|
|
||||||
$fast-transition-time: 220ms;
|
$fast-transition-time: 220ms;
|
||||||
$slow-transition-time: 350ms;
|
$slow-transition-time: 350ms;
|
||||||
$line-width: 3px;
|
$line-width: var(--line-width);
|
||||||
$border-radius: 5px;
|
$border-radius: 5px;
|
||||||
$breakpoint-width: 900px;
|
$breakpoint-width: 900px;
|
||||||
|
|
||||||
$normal-margin: 45px;
|
$normal-margin: var(--normal-margin);
|
||||||
$small-margin: 25px;
|
$small-margin: var(--small-margin);
|
||||||
$line-height: 2ch;
|
$line-height: 2ch;
|
||||||
|
|
||||||
$icon-size: 25px;
|
$blur-radius: 6px;
|
||||||
$body-width: 765px;
|
$icon-size: var(--icon-size);
|
||||||
|
$body-width: var(--body-width);
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--line-width: 3px;
|
||||||
|
--normal-margin: 45px;
|
||||||
|
--small-margin: 25px;
|
||||||
|
--icon-size: 25px;
|
||||||
|
--body-width: 765px;
|
||||||
|
|
||||||
@media (max-width: $breakpoint-width) {
|
@media (max-width: $breakpoint-width) {
|
||||||
$line-width: 2px;
|
--line-width: 2px;
|
||||||
$normal-margin: 25px;
|
--normal-margin: 35px;
|
||||||
$small-margin: 20px;
|
--small-margin: 15px;
|
||||||
$icon-size: 20px;
|
--icon-size: 20px;
|
||||||
$body-width: 85%;
|
--body-width: 85%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue