md/src/config/theme.ts

362 lines
7.0 KiB
TypeScript
Raw Normal View History

import { toMerged } from 'es-toolkit'
2024-08-22 22:52:35 +08:00
import type { Theme } from '@/types'
2024-08-22 22:52:35 +08:00
const defaultTheme: Theme = {
2024-08-29 19:43:06 +08:00
base: {
'--md-primary-color': `#000000`,
2024-08-22 22:52:35 +08:00
'text-align': `left`,
'line-height': `1.75`,
},
block: {
// 一级标题
2024-08-22 22:52:35 +08:00
h1: {
'display': `table`,
'padding': `0 1em`,
'border-bottom': `2px solid var(--md-primary-color)`,
'margin': `2em auto 1em`,
2024-08-22 22:52:35 +08:00
'color': `var(--el-text-color-regular)`,
'font-size': `1.2em`,
'font-weight': `bold`,
'text-align': `center`,
2024-08-22 22:52:35 +08:00
},
// 二级标题
2024-08-22 22:52:35 +08:00
h2: {
'display': `table`,
'padding': `0 0.2em`,
'margin': `4em auto 2em`,
2024-08-22 22:52:35 +08:00
'color': `#fff`,
'background': `var(--md-primary-color)`,
'font-size': `1.2em`,
'font-weight': `bold`,
'text-align': `center`,
2024-08-22 22:52:35 +08:00
},
// 三级标题
2024-08-22 22:52:35 +08:00
h3: {
'padding-left': `8px`,
'border-left': `3px solid var(--md-primary-color)`,
'margin': `2em 8px 0.75em 0`,
2024-08-22 22:52:35 +08:00
'color': `var(--el-text-color-regular)`,
'font-size': `1.1em`,
'font-weight': `bold`,
'line-height': `1.2`,
2024-08-22 22:52:35 +08:00
},
// 四级标题
2024-08-22 22:52:35 +08:00
h4: {
'margin': `2em 8px 0.5em`,
'color': `var(--md-primary-color)`,
'font-size': `1em`,
'font-weight': `bold`,
2024-08-22 22:52:35 +08:00
},
// 段落
2024-08-22 22:52:35 +08:00
p: {
'margin': `1.5em 8px`,
'letter-spacing': `0.1em`,
'color': `var(--el-text-color-regular)`,
'text-align': `justify`,
},
// 引用
2024-08-22 22:52:35 +08:00
blockquote: {
'font-style': `normal`,
'border-left': `none`,
'padding': `1em`,
'border-radius': `8px`,
'color': `rgba(0,0,0,0.5)`,
'background': `#f7f7f7`,
'margin': `2em 8px`,
},
// 引用内容
2024-08-22 22:52:35 +08:00
blockquote_p: {
'display': `block`,
'font-size': `1em`,
2024-08-22 22:52:35 +08:00
'letter-spacing': `0.1em`,
'color': `rgb(80, 80, 80)`,
},
// 代码块
2024-08-22 22:52:35 +08:00
code_pre: {
'font-size': `14px`,
'overflow-x': `auto`,
'border-radius': `8px`,
'padding': `1em`,
'line-height': `1.5`,
'margin': `10px 8px`,
},
// 行内代码
2024-08-22 22:52:35 +08:00
code: {
'margin': 0,
'white-space': `nowrap`,
'font-family': `Menlo, Operator Mono, Consolas, Monaco, monospace`,
},
// 图片
2024-08-22 22:52:35 +08:00
image: {
'display': `block`,
'width': `100% !important`,
'margin': `0.1em auto 0.5em`,
'border-radius': `4px`,
2024-08-22 22:52:35 +08:00
},
// 有序列表
2024-08-22 22:52:35 +08:00
ol: {
'padding-left': `1em`,
'margin-left': `0`,
2024-08-22 22:52:35 +08:00
'color': `var(--el-text-color-regular)`,
},
// 无序列表
2024-08-22 22:52:35 +08:00
ul: {
'list-style': `circle`,
'padding-left': `1em`,
'margin-left': `0`,
2024-08-22 22:52:35 +08:00
'color': `var(--el-text-color-regular)`,
},
footnotes: {
'margin': `0.5em 8px`,
'font-size': `80%`,
'color': `var(--el-text-color-regular)`,
},
figure: {
margin: `1.5em 8px`,
color: `var(--el-text-color-regular)`,
},
2024-08-22 22:52:35 +08:00
hr: {
'border-style': `solid`,
'border-width': `1px 0 0`,
'border-color': `rgba(0,0,0,0.1)`,
'-webkit-transform-origin': `0 0`,
'-webkit-transform': `scale(1, 0.5)`,
'transform-origin': `0 0`,
'transform': `scale(1, 0.5)`,
},
},
inline: {
listitem: {
'text-indent': `-1em`,
'display': `block`,
'margin': `0.2em 8px`,
'color': `var(--el-text-color-regular)`,
},
codespan: {
'font-size': `90%`,
'color': `#d14`,
'background': `rgba(27,31,35,.05)`,
'padding': `3px 5px`,
'border-radius': `4px`,
// 'word-break': `break-all`,
},
em: {
'font-style': `italic`,
'font-size': `inherit`,
},
2024-08-22 22:52:35 +08:00
link: {
color: `#576b95`,
},
wx_link: {
'color': `#576b95`,
'text-decoration': `none`,
},
// 字体加粗样式
strong: {
'color': `var(--md-primary-color)`,
2024-08-22 22:52:35 +08:00
'font-weight': `bold`,
'font-size': `inherit`,
2024-08-22 22:52:35 +08:00
},
table: {
'border-collapse': `collapse`,
'text-align': `center`,
'margin': `1em 8px`,
'color': `var(--el-text-color-regular)`,
},
thead: {
'background': `rgba(0, 0, 0, 0.05)`,
'font-weight': `bold`,
'color': `var(--el-text-color-regular)`,
},
td: {
'border': `1px solid #dfdfdf`,
'padding': `0.25em 0.5em`,
'color': `#3f3f3f`,
'word-break': `keep-all`,
2024-08-22 22:52:35 +08:00
},
footnote: {
'font-size': `12px`,
'color': `var(--el-text-color-regular)`,
},
figcaption: {
'text-align': `center`,
'color': `#888`,
'font-size': `0.8em`,
},
},
}
const graceTheme = toMerged(defaultTheme, {
2024-08-29 19:43:06 +08:00
base: {
2024-08-22 22:52:35 +08:00
},
block: {
h1: {
'padding': `0.5em 1em`,
'border-bottom': `2px solid var(--md-primary-color)`,
'font-size': `1.4em`,
2024-08-22 22:52:35 +08:00
'text-shadow': `2px 2px 4px rgba(0,0,0,0.1)`,
},
h2: {
'padding': `0.3em 1em`,
'border-radius': `8px`,
'font-size': `1.3em`,
2024-08-22 22:52:35 +08:00
'box-shadow': `0 4px 6px rgba(0,0,0,0.1)`,
},
h3: {
'padding-left': `12px`,
'font-size': `1.2em`,
'border-left': `4px solid var(--md-primary-color)`,
'border-bottom': `1px dashed var(--md-primary-color)`,
2024-08-22 22:52:35 +08:00
},
h4: {
'font-size': `1.1em`,
},
p: {
},
blockquote: {
'font-style': `italic`,
'padding': `1em 1em 1em 2em`,
'border-left': `4px solid var(--md-primary-color)`,
2024-08-22 22:52:35 +08:00
'border-radius': `6px`,
'color': `rgba(0,0,0,0.6)`,
'background': `linear-gradient(to right, #f7f7f7, #ffffff)`,
'box-shadow': `0 4px 6px rgba(0,0,0,0.05)`,
},
blockquote_p: {
},
code_pre: {
'box-shadow': `inset 0 0 10px rgba(0,0,0,0.05)`,
},
code: {
'white-space': `pre-wrap`,
'font-family': `'Fira Code', Menlo, Operator Mono, Consolas, Monaco, monospace`,
},
image: {
'border-radius': `8px`,
'box-shadow': `0 4px 8px rgba(0,0,0,0.1)`,
},
ol: {
'padding-left': `1.5em`,
},
ul: {
'list-style': `none`,
'padding-left': `1.5em`,
2024-08-22 22:52:35 +08:00
},
footnotes: {
},
figure: {
},
2024-08-22 22:52:35 +08:00
hr: {
height: `1px`,
border: `none`,
2024-08-22 22:52:35 +08:00
margin: `2em 0`,
background: `linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,0.1), rgba(0,0,0,0))`,
2024-08-22 22:52:35 +08:00
},
},
inline: {
listitem: {
margin: `0.5em 8px`,
2024-08-22 22:52:35 +08:00
},
codespan: {
},
em: {
},
2024-08-22 22:52:35 +08:00
link: {
},
wx_link: {
},
strong: {
},
table: {
'border-collapse': `separate`,
'border-spacing': `0`,
'border-radius': `8px`,
2024-08-22 22:52:35 +08:00
'margin': `1em 8px`,
'color': `var(--el-text-color-regular)`,
'box-shadow': `0 4px 6px rgba(0,0,0,0.1)`,
'overflow': `hidden`,
},
thead: {
color: `#fff`,
2024-08-22 22:52:35 +08:00
},
td: {
padding: `0.5em 1em`,
},
footnote: {
color: `rgba(0,0,0,0.5)`,
2024-08-22 22:52:35 +08:00
},
figcaption: {
},
2024-08-22 22:52:35 +08:00
},
})
export const themeOptions = [
{
label: `经典`,
value: `default`,
desc: ``,
},
{
label: `优雅`,
value: `grace`,
desc: ``,
},
]
export const themeMap = {
default: defaultTheme,
grace: graceTheme,
}