This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
wcui/src/markd/index.wc

285 lines
4.0 KiB
Plaintext

<template>
<div><slot /></div>
</template>
<style lang="scss">
:host {
display: block;
line-height: 1.5;
color: nth($cd, 1);
font-size: 14px;
}
a {
text-decoration: underline;
color: nth($ct, 2);
}
a:hover {
color: nth($ct, 1);
text-decoration: none;
}
em,
del {
color: nth($cgr, 2);
}
strong,
strong em,
strong,
del {
color: nth($cd, 3);
}
a {
strong,
em {
color: inherit;
}
}
em,
strong,
del {
padding: 0 2px;
}
p {
margin: 15px 0;
}
img {
max-width: 100%;
}
blockquote.md-quote {
margin: 10px 0;
padding: 5px 10px;
line-height: 1.5;
border-left: 5px solid nth($ct, 1);
background: #f2faf7;
color: nth($cgr, 1);
p {
margin: 0;
}
}
/* 提醒文本 */
.md-warn,
.md-mark {
display: inline-block;
position: relative;
min-height: 35px;
margin: 3px 0;
padding: 3px 8px 3px 35px;
line-height: 27px;
border: 1px solid nth($co, 2);
border-radius: 5px;
background: #fffbed;
color: nth($co, 3);
word-break: break-all;
p {
margin: 0 !important;
}
i {
position: absolute;
left: 8px;
top: 6px;
line-height: 1;
font-size: 20px;
color: nth($cr, 2);
}
}
.md-mark {
border-color: nth($ct, 1);
color: nth($ct, 3);
background: #edfbf8;
i {
color: nth($ct, 3);
}
}
.md-task {
position: relative;
display: inline-block;
width: auto;
height: 30px;
padding-right: 10px;
line-height: 30px;
text-align: center;
cursor: default;
&__box {
float: left;
width: 18px;
height: 18px;
margin: 6px;
margin-left: 0;
line-height: 1;
border: 1px solid nth($cgr, 1);
border-radius: 3px;
font-size: 16px;
text-align: center;
}
&.done {
.md-task__box {
color: nth($cgr, 1);
border-color: nth($cp, 3);
background: nth($cp, 3);
}
.md-task__text {
color: nth($cgr, 1);
text-decoration: line-through;
}
}
}
fieldset.md-hr {
margin: 30px 0;
border: 0;
border-top: 1px dashed nth($cp, 3);
legend {
padding: 0 5px;
color: nth($cgr, 1);
text-align: center;
&::before {
content: '华丽丽的分割线';
}
}
}
ol {
margin-left: 1em;
list-style: decimal outside none;
}
ul {
margin-left: 1em;
list-style: disc outside none;
}
li {
margin: 0.5em 0;
}
li ol {
margin-left: 1em;
}
li ul {
margin-left: 1em;
list-style-type: circle;
}
li ol ul,
li ul ul {
list-style-type: square;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 15px 0;
line-height: 2;
font-weight: bold;
font-size: 16px;
code.inline {
background: none;
}
a {
text-decoration: none;
color: #333;
}
}
h3,
h4,
h5,
h6 {
a {
&::before {
content: '# ';
color: nth($ct, 1);
font-weight: normal;
}
}
}
h1 {
margin: 0 0 30px;
font-size: 24px;
text-align: center;
}
h2 {
margin: 20px 0;
font-size: 22px;
border-bottom: 1px solid nth($cp, 2);
}
h3 {
margin: 20px 0 15px;
font-size: 20px;
}
h4 {
font-size: 18px;
}
table {
width: 100%;
border-spacing: 0;
border-collapse: collapse;
tr {
background-color: #fff;
}
thead tr {
background: nth($cp, 1);
}
th,
td {
padding: 6px 13px;
border: 1px solid #ddd;
}
th {
font-weight: bold;
}
tr:nth-child(2n) {
background-color: #fbfbfb;
}
}
code.inline {
display: inline-block;
margin: 0 2px;
padding: 0 2px;
color: nth($co, 3);
background: nth($cp, 1);
border-radius: 2px;
font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
}
</style>
<script>
import $ from '../utils'
import '../code/index'
import markd from './core'
export default class Markd {
props = {
toc: false
}
__init__() {
/* render */
var elem = this.root.children[1]
this.__BOX__ = elem
}
mounted() {
this.__BOX__.innerHTML = markd(this.textContent)
this.textContent = ''
$.bind(this.__BOX__, 'click', ev => {
if (ev.target.className === 'md-head-link') {
var ot = ev.target.offsetTop
document.documentElement.scrollTop = ot
}
})
}
}
</script>
wcui是一套基于`Web Components`的UI组件库, 宗旨是追求简单、实用、不花哨。
JavaScript 95.2%
CSS 4.8%