🎉 Initial commit

This commit is contained in:
Jimmy Cai
2020-08-22 13:20:08 +02:00
commit c698d944e6
69 changed files with 3781 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-archive" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<rect x="3" y="4" width="18" height="4" rx="2" />
<path d="M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-10" />
<line x1="10" y1="12" x2="14" y2="12" />
</svg>

After

Width:  |  Height:  |  Size: 432 B

+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-back" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M9 11l-4 4l4 4m-4 -4h11a4 4 0 0 0 0 -8h-1" />
</svg>

After

Width:  |  Height:  |  Size: 338 B

+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-chevron-left" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<polyline points="15 6 9 12 15 18" />
</svg>

After

Width:  |  Height:  |  Size: 323 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-chevrons-left" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<polyline points="11 7 6 12 11 17" />
<polyline points="17 7 12 12 17 17" />
</svg>

After

Width:  |  Height:  |  Size: 365 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-chevrons-right" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<polyline points="7 7 12 12 7 17" />
<polyline points="13 7 18 12 13 17" />
</svg>

After

Width:  |  Height:  |  Size: 365 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<circle cx="12" cy="12" r="9" />
<polyline points="12 7 12 12 15 15" />
</svg>

After

Width:  |  Height:  |  Size: 352 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copyright" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<circle cx="12" cy="12" r="9" />
<path d="M14.5 9a3.5 4 0 1 0 0 6" />
</svg>

After

Width:  |  Height:  |  Size: 354 B

+9
View File
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-hash" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<line x1="5" y1="9" x2="19" y2="9" />
<line x1="5" y1="15" x2="19" y2="15" />
<line x1="11" y1="4" x2="7" y2="20" />
<line x1="17" y1="4" x2="13" y2="20" />
</svg>

After

Width:  |  Height:  |  Size: 440 B

+8
View File
@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-home" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<polyline points="5 12 3 12 12 3 21 12 19 12" />
<path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
<path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>

After

Width:  |  Height:  |  Size: 441 B

+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-infinity" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M9.828 9.172a4 4 0 1 0 0 5.656 a10 10 0 0 0 2.172 -2.828a10 10 0 0 1 2.172 -2.828 a4 4 0 1 1 0 5.656a10 10 0 0 1 -2.172 -2.828a10 10 0 0 0 -2.172 -2.828" />
</svg>

After

Width:  |  Height:  |  Size: 447 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" />
<path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" />
</svg>

After

Width:  |  Height:  |  Size: 418 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-messages" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M21 14l-3 -3h-7a1 1 0 0 1 -1 -1v-6a1 1 0 0 1 1 -1h9a1 1 0 0 1 1 1v10" />
<path d="M14 15v2a1 1 0 0 1 -1 1h-7l-3 3v-10a1 1 0 0 1 1 -1h2" />
</svg>

After

Width:  |  Height:  |  Size: 431 B

+8
View File
@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-rss" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<circle cx="5" cy="19" r="1" />
<path d="M4 4a16 16 0 0 1 16 16" />
<path d="M4 11a9 9 0 0 1 9 9" />
</svg>

After

Width:  |  Height:  |  Size: 381 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-tag" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<path d="M11 3L20 12a1.5 1.5 0 0 1 0 2L14 20a1.5 1.5 0 0 1 -2 0L3 11v-4a4 4 0 0 1 4 -4h4" />
<circle cx="9" cy="9" r="2" />
</svg>

After

Width:  |  Height:  |  Size: 402 B

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z"/>
<circle cx="12" cy="7" r="4" />
<path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
</svg>

After

Width:  |  Height:  |  Size: 366 B

+349
View File
@@ -0,0 +1,349 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input { /* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select { /* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
+12
View File
@@ -0,0 +1,12 @@
@mixin box_shadow($level) {
@if $level == 1 {
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 0px 2px rgba(0, 0, 0, 0.06), 0px 0px 1px rgba(0, 0, 0, 0.04);
} @else if $level == 2 {
box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.04), 0px 2px 6px rgba(0, 0, 0, 0.04), 0px 0px 1px rgba(0, 0, 0, 0.04);
} @else if $level == 3 {
box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.04), 0px 2px 6px rgba(0, 0, 0, 0.04), 0px 0px 1px rgba(0, 0, 0, 0.04);
} @else if $level == 4 {
box-shadow: 0px 24px 32px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04),
0px 4px 8px rgba(0, 0, 0, 0.04), 0px 0px 1px rgba(0, 0, 0, 0.04);
}
}
+254
View File
@@ -0,0 +1,254 @@
/* Default article style */
.article-list {
display: flex;
flex-direction: column;
article {
display: flex;
flex-direction: column;
margin-bottom: 40px;
background-color: var(--card-background);
@include box_shadow(1);
border-radius: var(--card-border-radius);
overflow: hidden;
.article-image {
img {
width: 100%;
height: 250px;
object-fit: cover;
@media (max-width: $on-tablet) {
height: 150px;
}
@media (max-width: $on-desktop) {
height: 200px;
}
}
}
@for $i from 1 through length($defaultTagBackgrounds) {
&:nth-child(#{length($defaultTagBackgrounds)}n + #{$i}) {
.article-category a {
background: nth($defaultTagBackgrounds, $i);
color: nth($defaultTagColors, $i);
}
}
}
}
}
.article-details {
display: flex;
flex-direction: column;
justify-content: center;
padding: 25px 20px;
@media (max-width: $on-desktop) {
padding: 20px;
}
}
.article-category {
margin-bottom: 10px;
a {
display: inline-block;
text-decoration: none;
padding: 8px 16px;
font-size: 1.4rem;
background: nth($defaultTagBackgrounds, 1);
color: nth($defaultTagColors, 1);
border-radius: var(--tag-border-radius);
@media (max-width: $on-phone) {
font-size: 1.25rem;
padding: 8px 14px;
}
}
}
.article-title {
font-size: 2.4rem;
font-weight: 600;
margin: 10px 0;
a {
color: var(--card-text-color-main);
&:hover {
color: var(--card-text-color-main);
}
}
@media (max-width: $on-desktop) {
font-size: 1.5em;
}
}
.article-subtitle {
font-weight: lighter;
font-size: 2rem;
color: var(--card-text-color-secondary);
margin: 5px 0;
line-height: 1.5;
@media (max-width: $on-desktop) {
font-size: 1.8rem;
}
}
.article-time {
display: flex;
align-items: center;
color: var(--card-text-color-tertiary);
margin-top: 10px;
svg {
vertical-align: middle;
margin-right: 8px;
}
time {
font-size: 16px;
@media (max-width: $on-desktop) {
font-size: 14px;
}
}
}
.article-tags {
& + .article-copyright {
margin-top: 30px;
}
a {
color: var(--accent-color-text);
background-color: var(--accent-color);
padding: 8px 18px;
border-radius: var(--tag-border-radius);
display: inline-block;
font-size: 1.4rem;
margin-right: 10px;
margin-bottom: 10px;
transition: background-color 0.5s ease;
&:hover {
color: var(--accent-color-text);
background-color: var(--accent-color-darker);
}
}
}
/* Compact style article list */
.article-list--compact {
border-radius: var(--card-border-radius);
@include box_shadow(1);
background-color: var(--card-background);
padding: 0 15px;
& + .pagination {
margin-top: 40px;
}
article {
display: flex;
align-items: center;
padding: 25px 10px;
&:not(:last-of-type) {
border-bottom: 2px solid var(--card-separator-color);
}
.article-details {
flex-grow: 1;
padding: 0;
padding-right: 15px;
}
.article-title {
margin: 0;
font-size: 2rem;
@media (max-width: $on-phone) {
font-size: 1.6rem;
}
}
.article-image {
img {
width: 60px;
height: 60px;
}
}
}
}
/* Tile style article list */
.article-list--tile {
article {
border-radius: var(--card-border-radius);
overflow: hidden;
position: relative;
height: 350px;
width: 250px;
@include box_shadow(1);
transition: box-shadow 0.3s ease;
background-color: var(--card-background);
&:hover {
@include box_shadow(2);
}
&.has-image {
.article-details {
background-color: rgba(#000, 0.25);
}
.article-title {
color: #fff;
}
}
.article-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.article-details {
border-radius: var(--card-border-radius);
position: relative;
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
z-index: 2;
padding: 20px;
@media (max-width: $on-phone) {
padding: 15px;
}
}
.article-title {
font-size: 2.2rem;
font-weight: 500;
color: var(--card-text-color-main);
@media (max-width: $on-phone) {
font-size: 2rem;
}
}
}
}
+17
View File
@@ -0,0 +1,17 @@
html {
font-size: 62.5%;
font-display: swap;
}
* {
box-sizing: border-box;
}
body {
background: var(--body-background);
margin: 0;
font-family: $base-font-family;
font-size: 1.6rem;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
+30
View File
@@ -0,0 +1,30 @@
footer.site-footer {
padding: 20px 0 40px 0;
font-size: 1.4rem;
line-height: 1.75;
&:before {
content: "";
display: block;
height: 3px;
width: 50px;
background: var(--body-text-color);
margin-bottom: 20px;
}
.copyright {
color: var(--accent-color);
font-weight: bold;
margin-bottom: 5px;
}
.powerby {
color: var(--body-text-color);
font-weight: normal;
font-size: 1.2rem;
a {
color: var(--body-text-color);
}
}
}
+6
View File
@@ -0,0 +1,6 @@
.not-found-card {
background-color: var(--card-background);
@include box_shadow(1);
border-radius: var(--card-border-radius);
padding: 30px;
}
+32
View File
@@ -0,0 +1,32 @@
.archive-group {
margin-bottom: 40px;
.archive-date {
text-transform: uppercase;
margin-bottom: 10px;
font-size: 1.6rem;
font-weight: 500;
a {
color: var(--body-text-color);
}
}
}
.template-archive {
.category-list {
margin-bottom: 40px;
overflow-x: auto;
.article-list--tile {
display: flex;
padding-bottom: 15px;
article {
width: 250px;
height: 150px;
margin-right: 20px;
flex-shrink: 0;
}
}
}
}
+303
View File
@@ -0,0 +1,303 @@
@import "variables.scss";
.article-page {
.left-sidebar {
@media (max-width: $on-tablet) {
display: none;
}
}
.article-sidebar {
position: sticky;
top: 50px;
flex-shrink: 0;
@media (max-width: $on-tablet) {
display: none;
}
@media (min-width: $on-tablet) {
padding-left: 15px;
margin-left: 1%;
}
@media (min-width: $on-tablet) {
width: 25%;
margin-right: 1%;
}
@media (min-width: $on-desktop) {
width: 30%;
}
}
article {
background: var(--card-background);
border-radius: var(--card-border-radius);
@include box_shadow(1);
overflow: hidden;
&.main-article {
margin-bottom: 40px;
}
.article-header {
.article-image {
img {
height: auto;
width: 100%;
max-height: 500px;
width: 100%;
object-fit: cover;
}
}
.article-details {
padding: 30px 30px 0 30px;
@media (max-width: $on-tablet) {
padding: 20px 20px 0 20px;
}
}
}
.article-content {
margin: 30px 0;
padding: 0 30px;
line-height: 1.75;
color: var(--card-text-color-main);
@media (max-width: $on-tablet) {
padding: 0 20px;
font-size: 1.6rem;
}
img {
max-width: 100%;
height: auto;
}
}
.article-footer {
padding: 30px;
@media (max-width: $on-phone) {
padding: 20px;
}
.article-copyright {
color: var(--card-text-color-tertiary);
text-transform: uppercase;
display: flex;
align-items: center;
svg {
margin-right: 15px;
stroke-width: 1.33;
}
}
}
}
}
#TableOfContents {
background: var(--card-background);
border-radius: var(--card-border-radius);
@include box_shadow(1);
ul {
padding: 0;
margin: 0;
list-style: none;
li {
padding: 15px 30px;
padding-right: 50px;
position: relative;
&:not(:last-of-type) {
border-bottom: 1px solid var(--card-separator-color);
}
a {
color: var(--accent-color);
}
ul {
border-top: 1px solid var(--card-separator-color);
margin-top: 15px;
}
}
}
}
#article-toolbar {
background: var(--card-background);
@include box_shadow(1);
border-radius: var(--card-border-radius);
margin-bottom: 20px;
padding: 15px 20px;
display: flex;
align-items: center;
@media (max-width: $on-phone) {
margin-top: 15px;
}
@media (min-width: $on-tablet) {
display: none;
}
.back-home {
color: var(--card-text-color-secondary);
margin-right: 30px;
display: inline-flex;
align-items: center;
svg {
margin-right: 5px;
}
span {
font-weight: 500;
}
}
}
.related-contents--wrapper {
margin-bottom: 40px;
.widget-title {
//padding-left: 15px;
}
}
.related-contents {
overflow-x: auto;
//padding: 0 15px;
padding-bottom: 15px;
& > .flex {
float: left;
}
article {
margin-right: 15px;
flex-shrink: 0;
overflow: hidden;
@media (max-width: $on-phone) {
height: 250px;
width: 200px;
}
@media (min-width: $on-phone) {
height: 200px;
width: 300px;
}
.article-title {
font-size: 1.8rem;
}
.article-details {
transition: background-color 0.5s ease;
}
}
}
.article-content {
font-family: -apple-system, BlinkMacSystemFont, "noto-sans", "Segoe UI", "Droid Sans", "Helvetica Neue",
"PingFang SC", "Hiragino Sans GB", "Droid Sans Fallback", "Microsoft YaHei", sans-serif;
p {
margin: 1.5em 0;
}
figure {
margin: 0 auto;
text-align: center;
figcaption {
font-size: 1.6rem;
}
}
blockquote {
position: relative;
margin: 10px 0;
border-left: 4px solid var(--card-separator-color);
padding-left: 20px;
}
hr {
width: 100px;
margin: 40px 0;
background: var(--card-text-color-tertiary);
height: 4px;
border: 0;
}
code {
color: #808080;
font-size: 0.96em;
background-color: #f9f9f7;
padding: 1px 2px;
border: 1px solid #eee;
border-radius: 3px;
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
word-wrap: break-word;
}
.gallery {
position: relative;
display: flex;
flex-direction: row;
justify-content: center;
margin: 20px 0;
figure {
margin: 0 5px;
a:after {
display: none;
}
img {
//width: 100%;
}
}
}
pre {
overflow-x: auto;
display: block;
background-color: #fafafa;
color: #999;
font-family: Consolas, monospace;
line-height: 1.428571429;
word-break: break-all;
padding: 20px;
border-radius: var(--card-border-radius);
code {
color: unset;
border: none;
background: none;
padding: 0;
}
}
a {
position: relative;
&:after {
content: "";
display: block;
position: absolute;
bottom: -3px;
left: 0;
width: 100%;
background-color: var(--accent-color);
opacity: 0.2;
height: 3px;
}
}
}
+56
View File
@@ -0,0 +1,56 @@
.taxonomy-type {
text-transform: uppercase;
color: var(--body-text-color);
font-weight: 500;
margin-bottom: 5px;
font-size: 1.6rem;
}
.taxonomy-card {
border-radius: var(--card-border-radius);
background-color: var(--card-background);
padding: 20px 20px;
@include box_shadow(1);
margin-bottom: 40px;
display: flex;
align-items: center;
.taxonomy-term {
font-size: 2.2rem;
margin: 0;
margin-top: 15px;
color: var(--card-text-color-main);
& + .taxonomy-description {
margin-top: 15px;
}
}
.taxonomy-description {
font-weight: normal;
color: var(--card-text-color-secondary);
font-size: 1.8rem;
margin: 0;
}
.taxonomy-details {
flex-grow: 1;
padding: 10px 0;
margin-right: 20px;
}
.taxonomy-image {
img {
width: 60px;
height: 60px;
}
}
.taxonomy-count {
color: var(--card-text-color-tertiary);
font-size: 1.4rem;
margin: 0;
font-weight: 500;
text-transform: uppercase;
}
}
+214
View File
@@ -0,0 +1,214 @@
/*!
* Hamburgers
* @description Tasty CSS-animated hamburgers
* @author Jonathan Suh @jonsuh
* @site https://jonsuh.com/hamburgers
* @link https://github.com/jonsuh/hamburgers
*/
.hamburger {
padding-top: 10px;
display: inline-block;
cursor: pointer;
transition-property: opacity, filter;
transition-duration: 0.15s;
transition-timing-function: linear;
font: inherit;
color: inherit;
text-transform: none;
background-color: transparent;
border: 0;
margin: 0;
overflow: visible;
}
.hamburger:hover {
opacity: 0.7;
}
.hamburger.is-active:hover {
opacity: 0.7;
}
.hamburger.is-active .hamburger-inner,
.hamburger.is-active .hamburger-inner::before,
.hamburger.is-active .hamburger-inner::after {
background-color: #000;
}
.hamburger-box {
width: 30px;
height: 24px;
display: inline-block;
position: relative;
}
.hamburger-inner {
display: block;
top: 50%;
margin-top: -2px;
}
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
width: 30px;
height: 2px;
background-color: var(--card-text-color-main);
border-radius: 4px;
position: absolute;
transition-property: transform;
transition-duration: 0.15s;
transition-timing-function: ease;
}
.hamburger-inner::before,
.hamburger-inner::after {
content: "";
display: block;
}
.hamburger-inner::before {
top: -10px;
}
.hamburger-inner::after {
bottom: -10px;
}
.hamburger--spin .hamburger-inner {
transition-duration: 0.22s;
transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
.hamburger--spin .hamburger-inner::before {
transition: top 0.1s 0.25s ease-in, opacity 0.1s ease-in;
}
.hamburger--spin .hamburger-inner::after {
transition: bottom 0.1s 0.25s ease-in, transform 0.22s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
.hamburger--spin.is-active .hamburger-inner {
transform: rotate(225deg);
transition-delay: 0.12s;
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
.hamburger--spin.is-active .hamburger-inner::before {
top: 0;
opacity: 0;
transition: top 0.1s ease-out, opacity 0.1s 0.12s ease-out;
}
.hamburger--spin.is-active .hamburger-inner::after {
bottom: 0;
transform: rotate(-90deg);
transition: bottom 0.1s ease-out, transform 0.22s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
}
#toggle-menu {
background: none;
border: none;
position: absolute;
right: 30px;
top: 30px;
z-index: 2;
cursor: pointer;
@media (min-width: $on-phone + 1) {
display: none;
}
outline: none;
&.is-active {
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
background-color: var(--accent-color);
}
}
}
/* Menu style */
.menu {
list-style: none;
display: flex;
flex-direction: column;
margin: 30px 0;
@media (max-width: $on-phone) {
background-color: var(--card-background);
margin-top: 0;
padding: 15px 0;
@include box_shadow(1);
display: none;
&.show {
display: block;
}
}
@media (min-width: $on-phone + 1) {
align-items: flex-end;
}
li {
position: relative;
vertical-align: middle;
padding: 10px 0;
&:not(:last-of-type) {
margin-bottom: 20px;
@media (max-width: $on-desktop) {
margin-bottom: 10px;
}
}
@media (max-width: $on-phone) {
padding: 10px 30px;
}
@media (min-width: $on-phone + 1) and (max-width: ($on-desktop - 1)) {
padding: 10px 0;
}
@media (min-width: $on-phone + 1) {
width: 100%;
}
svg {
width: 32px;
height: 32px;
stroke-width: 1.33;
margin-right: 40px;
@media (max-width: $on-desktop) {
width: 30px;
height: 30px;
}
}
a {
height: 100%;
display: inline-flex;
align-items: center;
color: var(--body-text-color);
@media (max-width: $on-desktop) {
font-size: 1.5rem;
}
}
span {
flex: 1;
}
&.current {
a {
color: var(--accent-color);
font-weight: bold;
}
}
}
}
@media (max-width: $on-phone) {
.show-menu {
.site-info {
//@include box_shadow(2);
}
}
}
+21
View File
@@ -0,0 +1,21 @@
.pagination {
display: flex;
background-color: var(--card-background);
@include box_shadow(1);
border-radius: var(--card-border-radius);
overflow: hidden;
flex-wrap: wrap;
margin-bottom: 40px;
.page-link {
padding: 16px 32px;
display: inline-flex;
&.current {
font-weight: bold;
background-color: var(--card-background-selected);
color: var(--card-text-color-main);
}
color: var(--card-text-color-secondary);
}
}
+150
View File
@@ -0,0 +1,150 @@
.sidebar {
padding: 0 15px;
&.sticky {
@media (min-width: ($on-phone + 1)) {
position: sticky;
}
}
}
.left-sidebar {
display: flex;
flex-direction: column;
flex-shrink: 0;
@media (max-width: $on-phone) {
width: 100%;
padding: 30px 0;
max-width: none;
}
&.sticky {
top: 30px;
}
@media (min-width: $on-phone + 1) {
//justify-content: right;
//text-align: right;
width: 25%;
margin-right: 1%;
}
@media (min-width: $on-tablet) {
width: 25%;
margin-right: 1%;
}
@media (min-width: $on-desktop) {
width: 20%;
}
@media (min-width: $on-desktop-large) {
width: 15%;
}
}
.right-sidebar {
flex-shrink: 0;
&.sticky {
top: 30px;
}
@media (max-width: $on-desktop - 1) {
display: none;
}
@media (min-width: $on-tablet) {
width: 25%;
margin-left: 1%;
}
@media (min-width: $on-desktop + 1) {
width: 25%;
}
}
.site-info {
z-index: 1;
transition: box-shadow 0.5s ease;
@media (max-width: $on-phone) {
padding: 15px 30px;
}
.site-avatar {
position: relative;
margin: 0;
margin-bottom: 30px;
width: 150px;
height: 150px;
@media (min-width: $on-phone + 1) {
//margin-left: auto;
}
@media (max-width: $on-desktop) {
height: 120px;
width: 120px;
}
.site-logo {
width: 100%;
height: 100%;
border-radius: 100%;
@include box_shadow(1);
}
.emoji {
position: absolute;
width: 50px;
height: 50px;
line-height: 50px;
border-radius: 100%;
bottom: 0;
right: 0;
text-align: center;
font-size: 20px;
background-color: var(--card-background);
@include box_shadow(2);
@media (max-width: $on-desktop) {
width: 40px;
height: 40px;
line-height: 40px;
}
}
}
.site-name {
color: var(--accent-color);
font-size: 2.4rem;
margin: 0;
}
.site-description {
color: var(--body-text-color);
font-weight: lighter;
margin: 10px 0;
font-size: 2rem;
@media (max-width: $on-desktop) {
font-size: 1.8rem;
}
}
}
.sidebar {
.widget {
&:not(:last-of-type) {
margin-bottom: 40px;
&:after {
content: "";
width: 100px;
height: 2px;
background-color: var(--body-text-color);
display: block;
margin-top: 40px;
}
}
}
}
+79
View File
@@ -0,0 +1,79 @@
.widget {
.widget-title {
text-transform: uppercase;
color: var(--body-text-color);
font-weight: normal;
margin: 0;
margin-bottom: 10px;
font-size: 1.6rem;
}
.widget-icon {
svg {
width: 32px;
height: 32px;
stroke-width: 1.33px;
color: var(--body-text-color);
}
}
}
/* Tag cloud widget */
.tagCloud {
.tagCloud-tags {
display: flex;
flex-wrap: wrap;
a {
background: var(--card-background);
@include box_shadow(1);
border-radius: var(--tag-border-radius);
padding: 8px 20px;
color: var(--card-text-color-main);
margin-bottom: 10px;
margin-right: 5px;
font-size: 1.4rem;
}
}
}
/* Tweet widget */
.tweet-container {
.tweet--item {
.tweet--text {
font-size: 1.6rem;
color: var(--accent-color);
line-height: 1.75;
}
.tweet--time {
text-transform: uppercase;
a {
color: var(--body-text-color);
}
}
}
}
.widget.archive {
.archive-year {
margin-bottom: 10px;
a {
background-color: var(--card-background);
padding: 15px 25px;
border-radius: var(--card-border-radius);
@include box_shadow(1);
display: flex;
span.year {
flex: 1;
color: var(--card-text-color-main);
}
span.count {
color: var(--card-text-color-tertiary);
}
}
}
}
+131
View File
@@ -0,0 +1,131 @@
@import "variables.scss";
@import "helper/shadow.scss";
@import "external/normalize.scss";
@import "partials/menu.scss";
@import "partials/article.scss";
@import "partials/widgets.scss";
@import "partials/footer.scss";
@import "partials/pagination.scss";
@import "partials/sidebar.scss";
@import "partials/base.scss";
@import "partials/layout/archive.scss";
@import "partials/layout/article.scss";
@import "partials/layout/taxonomy.scss";
@import "partials/layout/404.scss";
a {
text-decoration: none;
color: var(--accent-color);
transition: color 0.3s ease;
&:hover {
color: var(--accent-color-darker);
}
}
.container {
margin-left: auto;
margin-right: auto;
&.extended {
@media (min-width: $on-phone) {
max-width: 720px;
}
@media (min-width: $on-tablet) {
max-width: 972px;
}
@media (min-width: $on-desktop) {
max-width: 1200px;
}
@media (min-width: $on-desktop-large) {
max-width: 1536px;
}
}
}
#content {
@media (min-width: $on-phone) {
padding-top: 30px;
}
@media (min-width: $on-tablet) {
padding-top: 50px;
}
}
main.main {
min-width: 0;
padding: 0 15px;
max-width: 100%;
@media (min-width: $on-phone + 1) {
padding: 0 15px;
}
flex-grow: 1;
}
.main-grid {
@media (max-width: $on-phone) {
flex-direction: column;
}
}
.flex {
display: flex;
flex-direction: row;
&.column {
flex-direction: column;
}
&.on-phone--column {
@media (max-width: $on-phone) {
flex-direction: column;
}
}
&.align-items--flex-start {
align-items: flex-start;
}
.grow {
flex-grow: 1;
}
.do-not-shrink {
flex-shrink: 0;
}
.do-not-overflow {
min-width: 0;
flex-shrink: 1;
max-width: 100%;
}
.full-width {
width: 100%;
}
}
.alert {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 5;
background: var(--card-background);
max-width: 400px;
padding: 15px 20px;
border-radius: var(--card-border-radius);
line-height: 1.75;
@include box_shadow(2);
color: var(--card-text-color-secondary);
@media (max-width: $on-phone) {
max-width: 100vw;
width: calc(100% - 30px);
left: 15px;
}
}
+92
View File
@@ -0,0 +1,92 @@
$fallback-font-family: -apple-system, "Noto Sans", "Helvetica Neue", Helvetica, "Nimbus Sans L", Arial,
"Liberation Sans", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Source Han Sans CN",
"Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti", SimHei, "WenQuanYi Zen Hei Sharp",
sans-serif;
$base-font-family: "Lato", $fallback-font-family;
$container-width: 1200px;
$container-padding: 15px;
$defaultTagBackgrounds: #8ea885, #df7988, #0177b8, #ffb900, #6b69d6;
$defaultTagColors: #fff, #fff, #fff, #fff, #fff;
$on-phone: 740px;
$on-tablet: 1024px;
$on-desktop: 1519px;
$on-desktop-large: 1920px;
/*
* CSS Variables
*/
$body-background: #f5f5fa;
$accent-color: #34495e;
$accent-color-darker: #2c3e50;
$accent-color-text: #fff;
$card-background: #fff;
$card-background-selected: #eaeaea;
$card-text-color-main: #000;
$card-text-color-secondary: #747474;
$card-text-color-tertiary: #bababa;
$card-separator-color: rgba(218, 218, 218, 0.5);
$card-border-radius: 10px;
$body-text-color: #bababa;
$tag-border-radius: 4px;
:root {
--body-background: #{$body-background};
--accent-color: #{$accent-color};
--accent-color-darker: #{$accent-color-darker};
--accent-color-text: #{$accent-color-text};
--card-background: #{$card-background};
--card-background-selected: #{$card-background-selected};
--card-text-color-main: #{$card-text-color-main};
--card-text-color-secondary: #{$card-text-color-secondary};
--card-text-color-tertiary: #{$card-text-color-tertiary};
--card-separator-color: #{$card-separator-color};
--card-border-radius: #{$card-border-radius};
--body-text-color: #{$body-text-color};
--tag-border-radius: #{$tag-border-radius};
}
@media (prefers-color-scheme: dark) {
:root {
$body-background: #303030;
$accent-color: #ecf0f1;
$accent-color-darker: #bdc3c7;
$accent-color-text: #000;
$card-background: #424242;
$card-background-selected: rgba(255, 255, 255, 0.16);
$card-text-color-main: rgba(255, 255, 255, 0.9);
$card-text-color-secondary: rgba(255, 255, 255, 0.7);
$card-text-color-tertiary: rgba(255, 255, 255, 0.5);
$card-separator-color: rgba(255, 255, 255, 0.12);
$body-text-color: rgba(255, 255, 255, 0.7);
--body-background: #{$body-background};
--accent-color: #{$accent-color};
--accent-color-darker: #{$accent-color-darker};
--accent-color-text: #{$accent-color-text};
--card-background: #{$card-background};
--card-background-selected: #{$card-background-selected};
--card-text-color-main: #{$card-text-color-main};
--card-text-color-secondary: #{$card-text-color-secondary};
--card-text-color-tertiary: #{$card-text-color-tertiary};
--card-separator-color: #{$card-separator-color};
--body-text-color: #{$body-text-color};
}
}
+49
View File
@@ -0,0 +1,49 @@
interface colorScheme {
DarkMuted: {
hex: string,
rgb: Number[],
bodyTextColor: string
},
Vibrant: {
hex: string,
rgb: Number[],
bodyTextColor: string
}
}
let colorsCache: { [key: string]: colorScheme } = {};
if (localStorage.hasOwnProperty('colorsCache')) {
try {
colorsCache = JSON.parse(localStorage.getItem('colorsCache'));
}
catch (e) {
colorsCache = {};
}
}
async function getColor(imageURL: string) {
if (!colorsCache.hasOwnProperty(imageURL)) {
const palette = await Vibrant.from(imageURL).getPalette();
colorsCache[imageURL] = {
Vibrant: {
hex: palette.Vibrant.hex,
rgb: palette.Vibrant.rgb,
bodyTextColor: palette.Vibrant.bodyTextColor
},
DarkMuted: {
hex: palette.DarkMuted.hex,
rgb: palette.DarkMuted.rgb,
bodyTextColor: palette.DarkMuted.bodyTextColor
}
}
localStorage.setItem('colorsCache', JSON.stringify(colorsCache));
}
return colorsCache[imageURL];
}
export {
getColor
}
+287
View File
@@ -0,0 +1,287 @@
import { loadScript, loadStyle } from './utils';
/**
* Init PhotoSwipe
* From: https://photoswipe.com/documentation/getting-started.html
* @param gallerySelector
*/
var initPhotoSwipeFromDOM = function (gallerySelector) {
// parse slide data (url, title, size ...) from DOM elements
// (children of gallerySelector)
var parseThumbnailElements = function (el) {
var thumbElements = el.childNodes,
numNodes = thumbElements.length,
items = [],
figureEl,
linkEl,
size,
item;
for (var i = 0; i < numNodes; i++) {
figureEl = thumbElements[i]; // <figure> element
// include only element nodes
if (figureEl.nodeType !== 1) {
continue;
}
linkEl = figureEl.children[0]; // <a> element
size = linkEl.getAttribute('data-size').split('x');
// create slide object
item = {
src: linkEl.getAttribute('href'),
w: parseInt(size[0], 10),
h: parseInt(size[1], 10)
};
if (figureEl.children.length > 1) {
// <figcaption> content
item.title = figureEl.children[1].innerHTML;
}
if (linkEl.children.length > 0) {
// <img> thumbnail element, retrieving thumbnail url
item.msrc = linkEl.children[0].getAttribute('src');
}
item.el = figureEl; // save link to element for getThumbBoundsFn
items.push(item);
}
return items;
};
// find nearest parent element
var closest = function closest(el, fn) {
return el && (fn(el) ? el : closest(el.parentNode, fn));
};
// triggers when user clicks on thumbnail
var onThumbnailsClick = function (e) {
e = e || window.event;
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var eTarget = e.target || e.srcElement;
// find root element of slide
var clickedListItem = closest(eTarget, function (el) {
return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
});
if (!clickedListItem) {
return;
}
// find index of clicked item by looping through all child nodes
// alternatively, you may define index via data- attribute
var clickedGallery = clickedListItem.parentNode,
childNodes = clickedListItem.parentNode.childNodes,
numChildNodes = childNodes.length,
nodeIndex = 0,
index;
for (var i = 0; i < numChildNodes; i++) {
if (childNodes[i].nodeType !== 1) {
continue;
}
if (childNodes[i] === clickedListItem) {
index = nodeIndex;
break;
}
nodeIndex++;
}
if (index >= 0) {
// open PhotoSwipe if valid index found
openPhotoSwipe(index, clickedGallery);
}
return false;
};
// parse picture index and gallery index from URL (#&pid=1&gid=2)
var photoswipeParseHash = function () {
var hash = window.location.hash.substring(1),
params = {};
if (hash.length < 5) {
return params;
}
var vars = hash.split('&');
for (var i = 0; i < vars.length; i++) {
if (!vars[i]) {
continue;
}
var pair = vars[i].split('=');
if (pair.length < 2) {
continue;
}
params[pair[0]] = pair[1];
}
if (params.gid) {
params.gid = parseInt(params.gid, 10);
}
return params;
};
var openPhotoSwipe = function (index, galleryElement, disableAnimation, fromURL) {
var pswpElement = document.querySelectorAll('.pswp')[0],
gallery,
options,
items;
items = parseThumbnailElements(galleryElement);
// define options (if needed)
options = {
// define gallery index (for URL)
galleryUID: galleryElement.getAttribute('data-pswp-uid'),
getThumbBoundsFn: function (index) {
// See Options -> getThumbBoundsFn section of documentation for more info
var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail
pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
rect = thumbnail.getBoundingClientRect();
return { x: rect.left, y: rect.top + pageYScroll, w: rect.width };
}
};
// PhotoSwipe opened from URL
if (fromURL) {
if (options.galleryPIDs) {
// parse real index when custom PIDs are used
// http://photoswipe.com/documentation/faq.html#custom-pid-in-url
for (var j = 0; j < items.length; j++) {
if (items[j].pid == index) {
options.index = j;
break;
}
}
} else {
// in URL indexes start from 1
options.index = parseInt(index, 10) - 1;
}
} else {
options.index = parseInt(index, 10);
}
// exit if index not found
if (isNaN(options.index)) {
return;
}
if (disableAnimation) {
options.showAnimationDuration = 0;
}
// Pass data to PhotoSwipe and initialize it
gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
};
// loop through all gallery elements and bind events
var galleryElements = document.querySelectorAll(gallerySelector);
for (var i = 0, l = galleryElements.length; i < l; i++) {
galleryElements[i].setAttribute('data-pswp-uid', i + 1);
galleryElements[i].onclick = onThumbnailsClick;
}
// Parse URL and open gallery if it contains #&pid=3&gid=1
var hashData = photoswipeParseHash();
if (hashData.pid && hashData.gid) {
openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true);
}
};
/**
* Wrap adjacent figure tags with div.gallery, and append style
* Reference: https://github.com/xieranmaya/blog/issues/6
* @param gallery
*/
function wrap(gallery: HTMLElement[]) {
let galleryContainer = document.createElement('div');
galleryContainer.className = 'gallery';
let parentNode = gallery[0].parentNode,
first = gallery[0];
parentNode.insertBefore(galleryContainer, first)
for (let j = 0; j < gallery.length; ++j) {
const width = gallery[j].querySelector('img').width,
height = gallery[j].querySelector('img').height;
gallery[j].style.flexGrow = `${width * 100 / height}`;
gallery[j].style.flexBasis = `${width * 240 / height}px`;
galleryContainer.appendChild(gallery[j]);
}
}
/**
* Load PhotoSwipe library dynamically
*/
function loadPhotoSwipe() {
const tasks = [
loadScript("https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.3/photoswipe.min.js"),
loadScript("https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.3/photoswipe-ui-default.min.js"),
loadStyle("https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.3/photoswipe.min.css"),
loadStyle("https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.3/default-skin/default-skin.min.css")
];
return Promise.all(tasks);
}
/**
* Create gallery
* @param selector
*/
function createGallery(selector: string) {
const figures = document.querySelector(selector).querySelectorAll('figure');
if (figures.length) {
let currentGallery = [figures[0]];
for (let i = 1; i < figures.length; ++i) {
if (figures[i].previousElementSibling === currentGallery[currentGallery.length - 1]) {
/* Adjacent */
currentGallery.push(figures[i]);
}
else {
/* End gallery */
wrap(currentGallery);
currentGallery = [figures[i]];
}
}
if (currentGallery.length > 0) {
wrap(currentGallery);
}
/**
* Load PhotoSwipe library, and then initialize
*/
loadPhotoSwipe().then(() => {
const pswp = document.querySelector('.pswp') as HTMLDivElement;
pswp.style.removeProperty('display');
initPhotoSwipeFromDOM(`${selector} .gallery`);
})
}
}
export {
createGallery
}
+96
View File
@@ -0,0 +1,96 @@
import { createGallery } from "./gallery"
import { getColor } from './color';
import menu from './menu';
let Stack = {
init: () => {
/**
* Bind menu event
*/
menu();
/**
* Add timeago
*/
const timeagoElements = document.querySelectorAll('article time[data-timeago=true]');
if (timeagoElements.length) {
timeago.render(timeagoElements);
}
if (document.querySelector('.article-content')) {
createGallery('.article-content');
}
/**
* Add color to tags
*/
document.querySelectorAll('.color-tag').forEach(async (tag: HTMLLinkElement) => {
const imageURL = tag.getAttribute('data-image');
const colors = await getColor(imageURL);
tag.style.color = colors.Vibrant.bodyTextColor;
tag.style.background = colors.Vibrant.hex;
})
/**
* Add linear gradient background to tile style article
*/
const articleTile = document.querySelector('.article-list--tile');
if (articleTile) {
let observer = new IntersectionObserver(async (entries, observer) => {
entries.forEach(entry => {
if (!entry.isIntersecting) return;
observer.unobserve(entry.target);
const articles = entry.target.querySelectorAll('article.has-image');
articles.forEach(async articles => {
const image = articles.querySelector('img'),
imageURL = image.src,
articleDetails: HTMLDivElement = articles.querySelector('.article-details');
const colors = await getColor(imageURL);
articleDetails.style.background = `
linear-gradient(0deg,
rgba(${colors.DarkMuted.rgb[0]}, ${colors.DarkMuted.rgb[1]}, ${colors.DarkMuted.rgb[2]}, 0.5) 0%,
rgba(${colors.Vibrant.rgb[0]}, ${colors.Vibrant.rgb[1]}, ${colors.Vibrant.rgb[2]}, 0.75) 100%)`;
})
})
});
observer.observe(articleTile)
}
},
alert: (content, time = 5000, animationSpeed = 500) => {
const alert = document.createElement('div');
alert.innerHTML = content;
alert.className = 'alert';
alert.style.visibility = 'hidden';
document.body.appendChild(alert);
alert.style.transform = `translateY(${alert.clientHeight + 50}px)`;
alert.style.transition = `transform ${animationSpeed / 1000}s ease`;
setTimeout(() => {
alert.style.removeProperty('visibility');
alert.style.transform = `translateY(0)`;
}, animationSpeed);
setTimeout(() => {
alert.style.transform = `translateY(${alert.clientHeight + 50}px)`;
}, animationSpeed + time);
setTimeout(() => {
alert.remove();
}, 2 * animationSpeed + time);
}
}
window.addEventListener('load', () => {
setTimeout(function () {
Stack.init();
}, 0);
})
window.Stack = Stack;
+83
View File
@@ -0,0 +1,83 @@
/**
* Slide up/down
* Code from https://dev.to/bmsvieira/vanilla-js-slidedown-up-4dkn
* @param target
* @param duration
*/
let slideUp = (target: HTMLElement, duration = 500) => {
target.classList.add('transiting');
target.style.transitionProperty = 'height, margin, padding';
target.style.transitionDuration = duration + 'ms';
///target.style.boxSizing = 'border-box';
target.style.height = target.offsetHeight + 'px';
target.offsetHeight;
target.style.overflow = 'hidden';
target.style.height = "0";
target.style.paddingTop = "0";
target.style.paddingBottom = "0";
target.style.marginTop = "0";
target.style.marginBottom = "0";
window.setTimeout(() => {
target.classList.remove('show')
target.style.removeProperty('height');
target.style.removeProperty('padding-top');
target.style.removeProperty('padding-bottom');
target.style.removeProperty('margin-top');
target.style.removeProperty('margin-bottom');
target.style.removeProperty('overflow');
target.style.removeProperty('transition-duration');
target.style.removeProperty('transition-property');
target.classList.remove('transiting');
}, duration);
}
let slideDown = (target: HTMLElement, duration = 500) => {
target.classList.add('transiting');
target.style.removeProperty('display');
target.classList.add('show');
let height = target.offsetHeight;
target.style.overflow = 'hidden';
target.style.height = "0";
target.style.paddingTop = "0";
target.style.paddingBottom = "0";
target.style.marginTop = "0";
target.style.marginBottom = "0";
target.offsetHeight;
///target.style.boxSizing = 'border-box';
target.style.transitionProperty = "height, margin, padding";
target.style.transitionDuration = duration + 'ms';
target.style.height = height + 'px';
target.style.removeProperty('padding-top');
target.style.removeProperty('padding-bottom');
target.style.removeProperty('margin-top');
target.style.removeProperty('margin-bottom');
window.setTimeout(() => {
target.style.removeProperty('height');
target.style.removeProperty('overflow');
target.style.removeProperty('transition-duration');
target.style.removeProperty('transition-property');
target.classList.remove('transiting');
}, duration);
}
let slideToggle = (target, duration = 500) => {
if (window.getComputedStyle(target).display === 'none') {
return slideDown(target, duration);
} else {
return slideUp(target, duration);
}
}
export default function () {
const toggleMenu = document.getElementById('toggle-menu');
if (toggleMenu) {
toggleMenu.addEventListener('click', () => {
if (document.getElementById('main-menu').classList.contains('transiting')) return;
document.body.classList.toggle('show-menu');
slideToggle(document.getElementById('main-menu'), 300);
toggleMenu.classList.toggle('is-active');
});
}
}
+43
View File
@@ -0,0 +1,43 @@
/**
* Load script asynchronous
* @return {Promise}
* @param url
*/
const loadScript = function (url) {
return new Promise(resolve => {
var scriptTag = document.createElement('script');
scriptTag.src = url;
scriptTag.onload = () => {
resolve();
};
document.head.appendChild(scriptTag);
})
};
/**
* Load style asynchronous
* @return {Promise}
* @param url
*/
const loadStyle = function (url) {
return new Promise(resolve => {
var link = document.createElement('link');
link.href = url;
link.type = "text/css";
link.rel = "stylesheet";
link.onload = () => {
resolve();
};
document.head.appendChild(link);
});
};
export {
loadScript,
loadStyle
}