评论区样式
This commit is contained in:
@@ -21,8 +21,7 @@ export const messages = [
|
|||||||
|
|
||||||
export const twikooConfig = {
|
export const twikooConfig = {
|
||||||
envId: import.meta.env.PUBLIC_TWIKOO_ENV_ID ?? "",
|
envId: import.meta.env.PUBLIC_TWIKOO_ENV_ID ?? "",
|
||||||
scriptSrc: "https://cdn.jsdelivr.net/npm/twikoo@1.7.7/dist/twikoo.nocss.js",
|
scriptSrc: "https://cdn.jsdelivr.net/npm/twikoo@1.7.7/dist/twikoo.min.js",
|
||||||
styleSrc: "https://cdn.jsdelivr.net/npm/twikoo@1.7.7/dist/twikoo.css",
|
|
||||||
path: "/messages/",
|
path: "/messages/",
|
||||||
lang: "zh-CN"
|
lang: "zh-CN"
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-104
@@ -2,6 +2,7 @@
|
|||||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||||
import { featuredMessage, messagesIntro, twikooConfig } from "../data/messages";
|
import { featuredMessage, messagesIntro, twikooConfig } from "../data/messages";
|
||||||
import { site } from "../data/site";
|
import { site } from "../data/site";
|
||||||
|
import twikooThemeUrl from "../styles/twikoo2.css";
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout title={`${messagesIntro.title} · ${site.className}`}>
|
<BaseLayout title={`${messagesIntro.title} · ${site.className}`}>
|
||||||
@@ -25,7 +26,7 @@ import { site } from "../data/site";
|
|||||||
{
|
{
|
||||||
twikooConfig.envId ? (
|
twikooConfig.envId ? (
|
||||||
<div
|
<div
|
||||||
id="tcomment"
|
id="twikoo"
|
||||||
class="twikoo-sticky-wall"
|
class="twikoo-sticky-wall"
|
||||||
data-env-id={twikooConfig.envId}
|
data-env-id={twikooConfig.envId}
|
||||||
data-path={twikooConfig.path}
|
data-path={twikooConfig.path}
|
||||||
@@ -47,111 +48,11 @@ import { site } from "../data/site";
|
|||||||
{
|
{
|
||||||
twikooConfig.envId && (
|
twikooConfig.envId && (
|
||||||
<>
|
<>
|
||||||
<link rel="stylesheet" href={twikooConfig.styleSrc} />
|
<link rel="stylesheet" href={twikooThemeUrl} />
|
||||||
<style is:inline>
|
|
||||||
#tcomment.twikoo-sticky-wall {
|
|
||||||
--sticky-1: #fff1a8;
|
|
||||||
--sticky-2: #dff1c7;
|
|
||||||
--sticky-3: #d8ebf7;
|
|
||||||
--sticky-4: #f8d7d0;
|
|
||||||
--sticky-5: #eadcf4;
|
|
||||||
--sticky-tape: rgba(255, 255, 255, 0.62);
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-submit {
|
|
||||||
margin-bottom: 2rem !important;
|
|
||||||
padding: 1.25rem !important;
|
|
||||||
border: 1px solid var(--line) !important;
|
|
||||||
border-radius: 8px !important;
|
|
||||||
background: #fffdf7 !important;
|
|
||||||
box-shadow: var(--shadow) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-send {
|
|
||||||
border-color: var(--green) !important;
|
|
||||||
background: var(--green) !important;
|
|
||||||
color: #fffdf7 !important;
|
|
||||||
font-weight: 800 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-title {
|
|
||||||
margin: 1.5rem 0 0.75rem !important;
|
|
||||||
color: var(--green) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment {
|
|
||||||
position: relative !important;
|
|
||||||
margin-top: 1.35rem !important;
|
|
||||||
padding: 1.25rem !important;
|
|
||||||
border-radius: 3px !important;
|
|
||||||
background: var(--sticky-1) !important;
|
|
||||||
box-shadow:
|
|
||||||
0 16px 30px rgba(39, 55, 52, 0.14),
|
|
||||||
inset 0 -18px 28px rgba(255, 255, 255, 0.18) !important;
|
|
||||||
transform: rotate(-0.7deg) !important;
|
|
||||||
transform-origin: center !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment:nth-of-type(5n + 2) {
|
|
||||||
background: var(--sticky-2) !important;
|
|
||||||
transform: translateY(6px) rotate(0.6deg) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment:nth-of-type(5n + 3) {
|
|
||||||
background: var(--sticky-3) !important;
|
|
||||||
transform: rotate(-0.3deg) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment:nth-of-type(5n + 4) {
|
|
||||||
background: var(--sticky-4) !important;
|
|
||||||
transform: translateY(8px) rotate(0.8deg) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment:nth-of-type(5n) {
|
|
||||||
background: var(--sticky-5) !important;
|
|
||||||
transform: rotate(-0.5deg) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment::before {
|
|
||||||
content: "" !important;
|
|
||||||
position: absolute !important;
|
|
||||||
top: 0.45rem !important;
|
|
||||||
left: 50% !important;
|
|
||||||
width: 3.5rem !important;
|
|
||||||
height: 0.8rem !important;
|
|
||||||
background: var(--sticky-tape) !important;
|
|
||||||
box-shadow: 0 1px 4px rgba(39, 55, 52, 0.13) !important;
|
|
||||||
transform: translateX(-50%) rotate(2deg) !important;
|
|
||||||
pointer-events: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment .tk-content,
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment .tk-content p {
|
|
||||||
color: var(--ink) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment .tk-replies .tk-comment {
|
|
||||||
background: rgba(255, 253, 247, 0.6) !important;
|
|
||||||
border-radius: 6px !important;
|
|
||||||
padding: 0.75rem !important;
|
|
||||||
transform: none !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment .tk-replies .tk-comment::before {
|
|
||||||
content: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 560px) {
|
|
||||||
#tcomment.twikoo-sticky-wall .tk-comments-container > .tk-comment {
|
|
||||||
transform: none !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script is:inline src={twikooConfig.scriptSrc} defer></script>
|
<script is:inline src={twikooConfig.scriptSrc} defer></script>
|
||||||
<script is:inline>
|
<script is:inline>
|
||||||
window.addEventListener("DOMContentLoaded", function () {
|
window.addEventListener("DOMContentLoaded", function () {
|
||||||
const container = document.querySelector("#tcomment");
|
const container = document.querySelector("#twikoo");
|
||||||
|
|
||||||
if (!container || !window.twikoo) {
|
if (!container || !window.twikoo) {
|
||||||
return;
|
return;
|
||||||
@@ -159,7 +60,7 @@ import { site } from "../data/site";
|
|||||||
|
|
||||||
window.twikoo.init({
|
window.twikoo.init({
|
||||||
envId: container.dataset.envId,
|
envId: container.dataset.envId,
|
||||||
el: "#tcomment",
|
el: "#twikoo",
|
||||||
path: container.dataset.path || location.pathname,
|
path: container.dataset.path || location.pathname,
|
||||||
lang: container.dataset.lang || "zh-CN"
|
lang: container.dataset.lang || "zh-CN"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
/* ========================================
|
||||||
|
Twikoo 便利贴主题 CSS
|
||||||
|
覆盖原始样式,粘贴到博客自定义 CSS 即可
|
||||||
|
======================================== */
|
||||||
|
|
||||||
|
/* 便利贴颜色变量 */
|
||||||
|
#twikoo {
|
||||||
|
--tk-note-1: #fff9c4;
|
||||||
|
--tk-note-2: #d7f7c2;
|
||||||
|
--tk-note-3: #cce8ff;
|
||||||
|
--tk-note-4: #f0d6ff;
|
||||||
|
--tk-note-5: #ffe4cc;
|
||||||
|
--tk-note-shadow: 2px 3px 0 rgba(0, 0, 0, 0.10), 0 1px 0 rgba(0, 0, 0, 0.06);
|
||||||
|
--tk-note-hover-shadow: 4px 10px 20px rgba(0, 0, 0, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 评论容器:瀑布流/网格布局 */
|
||||||
|
#twikoo .tk-comments-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||||
|
gap: 1.5rem;
|
||||||
|
align-items: start;
|
||||||
|
min-height: 10rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 隐藏原有竖向分隔线 */
|
||||||
|
#twikoo .tk-comment {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 单张便利贴 ---- */
|
||||||
|
#twikoo .tk-comment {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 14px 14px 36px;
|
||||||
|
box-shadow: var(--tk-note-shadow);
|
||||||
|
transition: transform 0.18s ease, box-shadow 0.18s ease, z-index 0s;
|
||||||
|
cursor: default;
|
||||||
|
min-height: 130px;
|
||||||
|
border: none;
|
||||||
|
word-break: break-word;
|
||||||
|
/* 去掉原来的 flex-direction: row */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 五色轮换 */
|
||||||
|
#twikoo .tk-comment:nth-child(5n+1) { background: var(--tk-note-1); transform: rotate(-1.2deg); }
|
||||||
|
#twikoo .tk-comment:nth-child(5n+2) { background: var(--tk-note-2); transform: rotate(0.7deg); }
|
||||||
|
#twikoo .tk-comment:nth-child(5n+3) { background: var(--tk-note-3); transform: rotate(-0.4deg); }
|
||||||
|
#twikoo .tk-comment:nth-child(5n+4) { background: var(--tk-note-4); transform: rotate(1.3deg); }
|
||||||
|
#twikoo .tk-comment:nth-child(5n+5) { background: var(--tk-note-5); transform: rotate(-0.8deg); }
|
||||||
|
|
||||||
|
/* 悬停浮起 */
|
||||||
|
#twikoo .tk-comment:hover {
|
||||||
|
transform: rotate(0deg) scale(1.04) translateY(-4px) !important;
|
||||||
|
box-shadow: var(--tk-note-hover-shadow);
|
||||||
|
z-index: 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 顶部胶带条 */
|
||||||
|
#twikoo .tk-comment::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: -11px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 48px;
|
||||||
|
height: 22px;
|
||||||
|
background: rgba(255, 255, 255, 0.55);
|
||||||
|
border-radius: 1px;
|
||||||
|
border: 0.5px solid rgba(0, 0, 0, 0.08);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 底部折角效果 */
|
||||||
|
#twikoo .tk-comment::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0 0 16px 16px;
|
||||||
|
border-color: transparent transparent rgba(0, 0, 0, 0.10) transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 头像区域 ---- */
|
||||||
|
#twikoo .tk-comment > .tk-avatar {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 0;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background: rgba(0, 0, 0, 0.10);
|
||||||
|
}
|
||||||
|
|
||||||
|
#twikoo .tk-comment > .tk-avatar .tk-avatar-img {
|
||||||
|
height: 30px;
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 主体内容区 */
|
||||||
|
#twikoo .tk-comment > .tk-main {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 昵称 */
|
||||||
|
#twikoo .tk-comment .tk-nick-link {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: rgba(0, 0, 0, 0.6);
|
||||||
|
}
|
||||||
|
#twikoo .tk-comment .tk-nick-link:hover {
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 操作按钮(点赞等)浮在右侧 */
|
||||||
|
#twikoo .tk-comment .tk-row {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 正文内容 */
|
||||||
|
#twikoo .tk-comment .tk-content {
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.65;
|
||||||
|
color: rgba(0, 0, 0, 0.75);
|
||||||
|
max-height: 200px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 元信息(时间、地区等) */
|
||||||
|
#twikoo .tk-comment .tk-extras {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 8px;
|
||||||
|
left: 14px;
|
||||||
|
right: 20px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: rgba(0, 0, 0, 0.38);
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
#twikoo .tk-comment .tk-extra {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 点赞按钮颜色适配 */
|
||||||
|
#twikoo .tk-comment .tk-action-link {
|
||||||
|
color: rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
#twikoo .tk-comment .tk-action-icon {
|
||||||
|
color: rgba(0, 0, 0, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 回复子评论 ---- */
|
||||||
|
#twikoo .tk-comment .tk-replies {
|
||||||
|
margin-top: 8px;
|
||||||
|
max-height: none;
|
||||||
|
overflow: visible;
|
||||||
|
padding-left: 8px;
|
||||||
|
border-left: 2px solid rgba(0, 0, 0, 0.10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 评论框 ---- */
|
||||||
|
#twikoo .tk-submit {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
background: rgba(255, 255, 255, 0.6);
|
||||||
|
border: 1.5px dashed rgba(0, 0, 0, 0.15);
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 1rem;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 分页 ---- */
|
||||||
|
#twikoo .tk-pagination {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 深色模式适配 ---- */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
#twikoo {
|
||||||
|
--tk-note-1: #4a4520;
|
||||||
|
--tk-note-2: #1f3b1a;
|
||||||
|
--tk-note-3: #1a2e42;
|
||||||
|
--tk-note-4: #32204a;
|
||||||
|
--tk-note-5: #3f2b18;
|
||||||
|
--tk-note-shadow: 2px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 0 rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
#twikoo .tk-comment .tk-nick-link { color: rgba(255, 255, 255, 0.75); }
|
||||||
|
#twikoo .tk-comment .tk-content { color: rgba(255, 255, 255, 0.80); }
|
||||||
|
#twikoo .tk-comment .tk-extras { color: rgba(255, 255, 255, 0.40); }
|
||||||
|
#twikoo .tk-comment .tk-action-link,
|
||||||
|
#twikoo .tk-comment .tk-action-icon { color: rgba(255, 255, 255, 0.45); }
|
||||||
|
#twikoo .tk-comment::before { background: rgba(255, 255, 255, 0.15); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 主题框架深色模式(Hexo/Hugo 常见的 class) */
|
||||||
|
.night #twikoo,
|
||||||
|
.darkmode #twikoo,
|
||||||
|
.DarkMode #twikoo,
|
||||||
|
[data-theme="dark"] #twikoo,
|
||||||
|
[data-user-color-scheme="dark"] #twikoo {
|
||||||
|
--tk-note-1: #4a4520;
|
||||||
|
--tk-note-2: #1f3b1a;
|
||||||
|
--tk-note-3: #1a2e42;
|
||||||
|
--tk-note-4: #32204a;
|
||||||
|
--tk-note-5: #3f2b18;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- 移动端:单列 ---- */
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
#twikoo .tk-comments-container {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
#twikoo .tk-comment {
|
||||||
|
transform: rotate(0deg) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user