refactor style using scss

This commit is contained in:
mivinci 2021-08-29 23:55:45 +08:00
parent 31ec816be5
commit 6b55bdedc6
17 changed files with 222 additions and 588 deletions

View file

@ -8,7 +8,7 @@ themeSwitcher.innerHTML = localStorage.theme === LIGHT ? light : dark;
themeSwitcher.addEventListener('click', function () {
const currentTheme = localStorage.theme,
newTheme = currentTheme === LIGHT ? DARK : LIGHT,
{ classList } = document.querySelector('html'),
{ classList } = document.documentElement,
text = newTheme === LIGHT ? light : dark;
classList.remove(currentTheme);
classList.add(newTheme);

119
assets/sass/atom.scss Normal file
View file

@ -0,0 +1,119 @@
* {
line-height: 1;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
$unit: 0.25rem;
$scales: 0, 1, 2, 3, 4, 5, 6, 7, 8, 1.5;
$screens: (
sm\:: 640px,
);
@mixin scale_with_prefix($prefix, $scale) {
$size: $scale * $unit;
.#{$prefix}mt-#{$scale} {
margin-top: $size;
}
.#{$prefix}mb-#{$scale} {
margin-bottom: $size;
}
.#{$prefix}ml-#{$scale} {
margin-left: $size;
}
.#{$prefix}mr-#{$scale} {
margin-right: $size;
}
.#{$prefix}my-#{$scale} {
margin-top: $size;
margin-bottom: $size;
}
.#{$prefix}mx-#{$scale} {
margin-left: $size;
margin-right: $size;
}
}
@each $scale in $scales {
@include scale_with_prefix("", $scale);
@each $screen, $size in $screens {
@media (max-width: $size) {
@include scale_with_prefix($screen, $scale);
}
}
}
@mixin style_with_prefix($prefix) {
.#{$prefix}block {
display: block;
}
.#{$prefix}flex {
display: flex;
}
.#{$prefix}flex-row {
flex-direction: row;
}
.#{$prefix}flex-col {
flex-direction: column;
}
.#{$prefix}flex-col-reverse {
flex-direction: column-reverse;
}
.#{$prefix}justify-between {
justify-content: space-between;
}
.#{$prefix}flex-nowrap {
flex-wrap: nowrap;
}
.#{$prefix}items-center {
align-items: center;
}
.#{$prefix}self-start {
align-self: flex-start;
}
.#{$prefix}hidden {
display: none;
}
.#{$prefix}text-xs {
font-size: .8rem;
}
.#{$prefix}text-sm {
font-size: .9rem;
}
.#{$prefix}text-4xl {
font-size: 2.25rem;
}
}
@include style_with_prefix("");
@each $screen, $size in $screens {
@media (max-width: $size) {
@include style_with_prefix($screen);
}
}
// border width
.bw-0 {
border-width: 0;
}
// width
.min-w-32 {
min-width: 0.25 * 32rem;
}
.whitespace-nowrap {
white-space: nowrap;
}
.overflow-x-auto {
overflow-x: auto;
}
.overflow-y-hidden {
overflow-y: hidden;
}
.cursor-pointer {
cursor: pointer;
}

View file

@ -1,5 +1,4 @@
@import "normalize.scss";
@import "sketch.scss";
@import "atom.scss";
@import "markdown.scss";
@import "syntax.scss";
@ -27,18 +26,15 @@ html.dark {
}
body {
font-family: Helvetica, sans-serif;
font-family: "Helvetica Neue", Helvetica, sans-serif;
max-width: var(--w-mobile);
margin: 50px auto 0;
margin: 3rem auto 0;
font-size: 16px;
font-weight: 400;
color: var(--ft);
background-color: var(--bg);
transition-property: background-color, border-color, color;
transition-duration: 0.5s;
@media (max-width: 640px) {
margin: 1em 2em;
}
}
h1,
@ -46,19 +42,16 @@ h2,
h3,
h4,
h5 {
font-family: "Noto Serif SC", "Times New Roman", sans-serif;
font-family: "Noto Serif SC", 'Times New Roman', Times, sans-serif;
font-weight: 700;
line-height: 1.5;
}
p {
margin-top: 0;
line-height: 1.5;
text-align: left;
line-height: 1.8;
text-align: justify;
}
hr {
margin: 30px 0;
border-width: 0;
border-top: 1px solid var(--bd);
}
@ -103,9 +96,23 @@ main {
animation: showup 0.7s;
}
header nav {
color: var(--tag);
}
details.toc ul {
list-style-type: none;
padding-inline-start: 1em;
margin: 0;
}
details.toc ul > li {
margin: 1em 0;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
width: 4px;
height: 4px;
}
::-webkit-scrollbar-thumb {
@ -119,7 +126,20 @@ main {
background-color: rgb(128, 128, 128);
}
.nowrap::-webkit-scrollbar {
h1::-webkit-scrollbar,
nav::-webkit-scrollbar {
display: none;
width: 0;
}
@keyframes showup {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: none;
}
}

View file

@ -1,7 +1,6 @@
.md blockquote {
background-color: rgba(148, 148, 149, 0.08) ;
margin: 1.5em 0px;
padding: 1.1em 20px 1px 20px;
padding: 1px 1rem;
border-left: 8px solid var(--pm);
font-style: italic;
}
@ -30,10 +29,6 @@
max-width: 100%;
}
.md li {
margin-top: .5em;
}
.md .katex {
overflow: auto hidden;
}
@ -47,6 +42,23 @@
padding-inline-start: 20px;
}
.md li {
margin-bottom: 1rem;
}
.md ol,
.md ul,
.md img,
.md blockquote,
.md .highlight {
margin: 1em 0;
}
margin: .75rem 0;
}
.md hr {
margin: 1.5rem 0;
}
.md .footnotes {
white-space: nowrap;
overflow: auto hidden;
}

View file

@ -1,351 +0,0 @@
/*! 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;
}

View file

@ -1,170 +0,0 @@
.row {
display: flex;
align-items: center;
}
.col {
display: flex;
flex-direction: column;
}
.jc-bt {
justify-content: space-between;
}
.as-s {
align-self: start;
}
.ai-c {
align-items: center;
}
.gap-0_5 {
gap: 0.8rem;
}
.gap-1 {
gap: 1rem;
row-gap: 1rem;
}
.gap-2 {
gap: 2rem;
row-gap: 2rem;
}
.gap-3 {
gap: 3rem;
row-gap: 3rem;
}
.lg-1 {
font-size: 1.2em;
}
.sm-1 {
font-size: 0.8em;
}
.mtb-1 {
margin: 1em 0;
}
.mtb-2 {
margin: 2em 0;
}
.mb-1 {
margin-bottom: 1em;
}
.mb-0 {
margin-bottom: 0;
}
.mt-2 {
margin-top: 2em;
}
.ml-1 {
margin-left: 1em;
}
.ml-2 {
margin-left: 2em;
}
.mx-0_4 {
margin: 0 0.4rem;
}
.mr-1 {
margin-right: 1rem;
}
.mr-2 {
margin-right: 2em;
}
.mw-6 {
min-width: 6em;
}
.c-tag {
color: var(--tag);
}
.btn {
cursor: pointer;
}
.hidden {
display: none;
}
.tag-pm {
font-size: 0.7em;
font-weight: bold;
line-height: 1;
color: #fff;
background-color: var(--pm);
border-radius: 20px;
padding: 2px 8px;
}
details.toc ul {
list-style-type: none;
padding-inline-start: 1em;
margin: 0;
}
details.toc ul > li {
margin: 1em 0;
}
.nowrap {
white-space: nowrap;
overflow: auto;
}
@keyframes showup {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: none;
}
}
@media (max-width: 640px) {
.row-mob {
flex-direction: column;
align-items: flex-start;
gap: 0;
row-gap: 0;
}
.al-c-mob {
align-items: center;
}
.col-rev-mob {
flex-direction: column-reverse;
}
.sm-2-mob {
font-size: 0.9em;
}
.mb-0_5-mob {
margin-bottom: 0.5em;
}
.mb-1_5-mob {
margin-bottom: 1.5em;
}
}

View file

@ -23,7 +23,7 @@ description = "This is Minima, a clean and minimal Hugo theme porting from Minim
# iam is the beginning words of your self-introduction.
iam = "I am"
# The subtitle will be shown after the title of your blog site
# in a format "title - subtitle".
# in a format like "title - subtitle".
subtitle = ""
# Comment decides the comment plugin used on your blog site,
# available plugins: disqus, ovo.

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
{{ partial "head.html" . }}
<body>
<body class=" sm:mx-5 sm:my-0">
{{ partial "header.html" . }}
{{ block "main" . }} {{ end }}

View file

@ -7,8 +7,8 @@
{{ end }}
<div>
{{ range .Data.Pages }}
<div class="row row-mob mb-1 mb-1_5-mob gap-3">
<div class="sm-2-mob mb-0_5-mob">{{ dateFormat "Jan 2, 2006" .Date }}</div>
<div class="flex sm:flex-col my-5 sm:mb-6 sm:mt-3">
<div class="min-w-32 sm:mb-2">{{ dateFormat .Site.Params.timeformat .Date }}</div>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
</div>
{{ end }}

View file

@ -1,18 +1,18 @@
{{ define "main" }}
{{ if .Params.toc }}
{{ partial "toc.html" . }}
{{ end }}
<main>
<h1>{{ .Title }}</h1>
<div class="sm-1 mtb-1">
<h1 class="my-6">{{ .Title }}</h1>
<div class="mb-3 text-xs">
Posted at &mdash; {{ dateFormat .Site.Params.timeformat .Date }}
{{ if .Draft }}
<span class="tag ml-1">
<span class="ml-1">
DRAFT
</span>
{{ end }}
</div>
<p>{{ .Description | markdownify | safeHTML }}</p>
{{ if .Params.toc }}
{{ partial "toc.html" . }}
{{ end }}
<article class="md">
{{ .Content }}
</article>

View file

@ -1,12 +1,12 @@
{{ define "main" }}
<main>
<h2>{{ .Title }}</h2>
<nav class="col">
<nav class="flex flex-col">
{{ $data := .Data }}
{{ range $key, $value := .Data.Terms.ByCount }}
<a class="row as-s mb-1" href="/{{ $data.Plural }}/{{ $value.Name }}">
<a class="mb-5 self-start" href="/{{ $data.Plural }}/{{ $value.Name }}">
{{ $value.Name }}
<span class="tag-pm ml-1">{{ $value.Count }}</span>
<span class="">{{ $value.Count }}</span>
</a>
{{ end }}
</nav>

View file

@ -1,19 +1,19 @@
{{ define "main" }}
<main>
<h2 class="mb-0">{{ .Site.Params.iam }} {{ .Site.Author.name }}</h2>
<p>{{ .Site.Author.slogon }}</p>
<p>{{ .Site.Author.description | markdownify | safeHTML }}</p>
<h2 class="mt-5 mb-1">{{ .Site.Params.iam }} {{ .Site.Author.name }}</h2>
<p class="my-0">{{ .Site.Author.slogon }}</p>
<p class="my-3">{{ .Site.Author.description | markdownify | safeHTML }}</p>
{{ if eq .Paginator.PageNumber 1 }}
<h3>Recent Posts</h3>
<h3 class="my-5">Recent Posts</h3>
{{ else }}
<h3>All Posts</h3>
<h3 class="my-5">Older Posts</h3>
{{ end }}
<div>
{{ $paginator := .Paginate (where .Site.RegularPages "Kind" "page") }}
{{ range $paginator.Pages }}
<div class="row row-mob mb-1 mb-1_5-mob gap-3">
<div class="sm-2-mob mb-0_5-mob mw-6">{{ dateFormat .Site.Params.timeformat .Date }}</div>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
<div class="flex sm:flex-col my-5 sm:mb-6 sm:mt-3">
<div class="min-w-32 sm:mb-2">{{ dateFormat .Site.Params.timeformat .Date }}</div>
<a class="self-start" href="{{ .RelPermalink }}">{{ .Title }}</a>
</div>
{{ end }}
{{ partial "paginator.html" . }}

View file

@ -1,12 +1,12 @@
<footer class="row row-mob al-c-mob col-rev-mob sm-2-mob jc-bt mtb-2">
<p class="c-tag">
<footer class="flex sm:flex-col-reverse justify-between items-center">
<p class="mt-0 text-sm">
{{ .Site.Copyright }} |
<a href="https://github.com/mivinci/hugo-theme-minima" target="_blank" rel="noopener noreferrer">Minima</a> on
<a href="https://gohugo.io" target="_blank" rel="noopener noreferrer">Hugo</a>
<a href="https://github.com/mivinci/hugo-theme-minima" target="_blank" rel="noopener noreferrer">MINIMA</a> ON
<a href="https://gohugo.io" target="_blank" rel="noopener noreferrer">HUGO</a>
</p>
<p class="row">
<p class="flex items-center mt-0">
{{ range $_, $key := .Site.Params.Social }}
<a class="icon mx-0_4" href="{{ $key.url }}" title="{{ $key.name }}">
<a class="icon mx-2" href="{{ $key.url }}" title="{{ $key.name }}">
{{ if $key.svg }}
{{ $key.svg | safeHTML }}
{{ else }}

View file

@ -1,12 +1,16 @@
<header>
<h1 class="row gap-1 nowrap">
<div id="theme-switcher" class="btn lg-1"></div>
{{ .Site.Title }}
</h1>
<nav class="row">
{{ range .Site.Menus.main }}
<a class="mr-1" href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
<div class="flex justify-between items-center">
<h1 class="mb-5 flex items-center
whitespace-nowrap overflow-x-auto overflow-y-hidden">
{{ .Site.Title }}
</h1>
<div id="theme-switcher" class="text-4xl ml-4 cursor-pointer">{{ index .Site.Params.switch 1 }}</div>
</div>
<nav class="mb-5 flex items-center
whitespace-nowrap overflow-x-auto overflow-y-hidden">
{{ range .Site.Menus.main }}
<a class="mr-3" href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</nav>
<hr>
</header>

View file

@ -1,5 +1,5 @@
<div id="ovo_thread" class="mt-2">
<div class="col ai-c">评论插件加载中 OvO</div>
<div id="ovo_thread" class="my-6">
<div class="flex flex-col items-center">评论插件加载中 OvO</div>
</div>
<link rel="stylesheet" href="//unpkg.com/@ovojs/ovo/dist/style.css">
<script type="text/javascript">

View file

@ -1,12 +1,12 @@
{{ $page := $.Paginator }}
{{ if gt $page.TotalPages 1 }}
<div class="mt-2">
<div class="my-5 flex justify-between">
{{ if $page.HasPrev }}
<a href="{{ $page.Prev.URL }}" class="mr-2">← Newer</a>
<a href="{{ $page.Prev.URL }}">← Newer</a>
{{ end }}
{{ if $page.HasNext }}
<a href="{{ $page.Next.URL }}" class="ml-2">Older →</a>
<a href="{{ $page.Next.URL }}">Older →</a>
{{ end }}
</div>
{{ end }}

View file

@ -1,5 +1,5 @@
<details class="toc">
<summary class="btn">Table of Contents</summary>
<details class="toc mt-5 mb-4">
<summary>Table of Contents</summary>
<div>
{{ .TableOfContents }}
</div>