Skip to content

Commit

Permalink
Add support of bold weight for text cells #2
Browse files Browse the repository at this point in the history
```
exBS!~*2__b=1\exBS!~*2__bold=1
exBS!~*2__align=r,bold=1\exBS!~*2__bold=1,align=l
```
  • Loading branch information
xingrz committed Feb 10, 2020
1 parent 9629a77 commit 6b9c95b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/components/BSIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div
class="bs-label"
v-if="label"
v-bind:data-align="(label.align || '').toUpperCase()"
v-bind:data-bold="label.params.b || label.params.bold"
v-bind:data-align="(label.params.align || '').toUpperCase()"
v-bind:style="{
width: size + 'px',
height: size + 'px',
Expand All @@ -18,6 +19,14 @@
</template>

<script>
import qs from 'querystring';
function parseTextParams(str) {
return qs.parse(str, ',', '=', {
decodeURIComponent: (s) => s,
});
}
export default {
name: 'BSIcon',
props: {
Expand All @@ -38,10 +47,10 @@ export default {
return this.size * ratio;
},
label() {
if (this.content && this.content.match(/^\*([^_]+)(__align=([^,]+)$)?/)) {
if (this.content && this.content.match(/^\*([^_]+)(__(.+)$)?/)) {
const text = RegExp.$1;
const align = RegExp.$3;
return { text, align };
const params = parseTextParams(RegExp.$3 || '');
return { text, params };
} else {
return null;
}
Expand Down Expand Up @@ -87,4 +96,8 @@ export default {
.bs-label[data-align="E"] span {
vertical-align: bottom;
}
.bs-label[data-bold="1"] {
font-weight: bold;
}
</style>

0 comments on commit 6b9c95b

Please sign in to comment.