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

优化表单组件的样式;switch组件增加状态文字;md编辑器开始重构

old
宇天 2019-09-27 11:35:15 +08:00
parent b16ec4af3e
commit 8ef894f899
14 changed files with 236 additions and 4 deletions

1
src/css/marked.css Normal file

File diff suppressed because one or more lines are too long

View File

@ -105,7 +105,7 @@
h3 {margin:20px 0 15px;font-size:20px;}
h4 {font-size:18px;}
table {overflow:auto;width:100%;border-spacing:0;border-collapse:collapse;
table {border-spacing:0;border-collapse:collapse;
tr {border-top:1px solid #ccc;background-color: #fff;}
th, td {padding:6px 13px;border:1px solid #ddd;}

View File

@ -19,8 +19,9 @@
height: 32px;
padding: 0 5px;
line-height: 0;
user-select: none;
-moz-user-select: none;
user-select: none;
white-space: nowrap;
cursor: inherit;
color: nth($cgr, 3);
}

View File

@ -77,6 +77,7 @@ li {
padding: 0 10px;
line-height: 0;
background: nth($cp, 1);
white-space: nowrap;
}
.prepend {
border-right: 1px solid nth($cp, 3);

View File

@ -19,8 +19,9 @@
height: 32px;
padding: 0 5px;
line-height: 0;
user-select: none;
-moz-user-select: none;
user-select: none;
white-space: nowrap;
cursor: inherit;
color: nth($cgr, 3);

View File

@ -65,6 +65,7 @@
width: auto;
height: 30px;
padding: 0 10px;
white-space: nowrap;
background: nth($cp, 1);
}
.prepend {

View File

@ -15,6 +15,7 @@
display: flex;
justify-content: center;
align-items: center;
white-space: nowrap;
}
label {
display: flex;
@ -110,6 +111,8 @@
import { bind, unbind } from '../utils'
export default class Switch {
props = {
'active-text': null,
'inactive-text': null,
checked: false,
disabled: false
}
@ -161,6 +164,15 @@ export default class Switch {
return
}
this.checked = !this.checked
if (this.checked) {
if (this.props['active-text'] !== null) {
this.textContent = this.props['active-text']
}
} else {
if (this.props['inactive-text'] !== null) {
this.textContent = this.props['inactive-text']
}
}
this.dispatchEvent(new CustomEvent('input'))
})
}
@ -175,6 +187,10 @@ export default class Switch {
case 'disabled':
this[name] = true
break
case 'active-text':
case 'inactive-text':
this.props[name] = val + ''
break
}
}
}

188
src/markdown/index.wc Normal file
View File

@ -0,0 +1,188 @@
<template>
<wc-scroll></wc-scroll>
</template>
<style lang="scss">
:host {
display: flex;
line-height: 1.5;
font-size: 13px;
color: nth($cd, 1);
}
a {
text-decoration: underline;
color: nth($ct, 2);
}
a:hover {
color: nth($ct, 1);
text-decoration: none;
}
em {
color: nth($cgr, 3);
}
strong {
color: nth($cd, 3);
}
em,
strong,
del {
padding: 0 3px;
}
p {
margin: 15px 0;
}
img {
max-width: 100%;
}
blockquote {
&.md-quote {
margin: 10px 0;
padding: 5px 10px;
border-left: 5px solid nth($ct, 1);
background: #f2f5fc;
color: nth($cgr, 1);
p {
margin: 0;
}
}
}
hr {
height: 1px;
margin: 30px 0;
line-height: 1px;
border: 0;
color: nth($cgr, 1);
background-color: nth($cgr, 1);
}
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 {
position: relative;
margin: 15px 0;
font-size: 16px;
span {
position: relative;
display: inline-block;
padding: 0 5px;
color: inherit;
}
a {
visibility: hidden;
position: absolute;
left: -25px;
width: 25px;
padding: 0 3px;
font-weight: bold;
text-decoration: none;
text-align: center;
}
&:hover a {
visibility: visible;
}
}
h1 {
margin: 0 0 30px;
font-size: 24px;
}
h2 {
margin: 20px 0;
font-size: 22px;
}
h3 {
margin: 20px 0 15px;
font-size: 20px;
}
h4 {
font-size: 18px;
}
table {
border-spacing: 0;
border-collapse: collapse;
tr {
border-top: 1px solid #ccc;
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;
}
}
</style>
<script>
import '../scroll/index'
import '../marked/index'
export default class Markdown {
props = {
value: ''
}
__init__() {
/* render */
}
set value(val) {
this.root.children[1].innerHTML = marked(val)
}
mounted() {
this.value = `
## hello world
> dsfksjdhf
>> dsfg
`
}
watch() {
switch (name) {
case 'value':
this.value = val
this.removeAttribute('value')
break
}
}
}
</script>

View File

@ -4,7 +4,7 @@
* https://github.com/chjj/marked
*/
import 'css/marked.scss'
// import 'css/marked.scss'
/**
* Block-Level Grammar
*/

23
src/meditor/index.wc Normal file
View File

@ -0,0 +1,23 @@
<template>
<div class="meditor">
<section class="toolbar"></section>
<textarea cols="30" rows="10"></textarea>
<wc-markdown></wc-markdown>
</div>
</template>
<style lang="scss"></style>
<script>
import '../markdown/index'
export default class Meditor {
props = {
value: ''
}
__init__() {
// /* render */
}
}
</script>