Skip to content

Commit

Permalink
feat(ui): add Note component
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Dec 17, 2018
1 parent 4e720ad commit 73fb4a9
Show file tree
Hide file tree
Showing 7 changed files with 315 additions and 66 deletions.
40 changes: 35 additions & 5 deletions src/components/Badge.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template functional>
<span
class="badge"
:class="props.type"
:class="['badge', `is-${props.type}`]"
:style="{backgroundColor: props.color}"
><slot></slot>
>
<slot></slot>
</span>
</template>

Expand All @@ -12,12 +12,42 @@ export default {
name: 'Badge',
props: {
type: {
type: String,
default: 'tip'
type: String
},
color: {
type: String
}
}
}
</script>

<style>
.badge {
display: inline-block;
vertical-align: top;
font-size: 12px;
height: 18px;
line-height: 18px;
border-radius: 9px;
padding: 0 6px;
color: #fff;
margin-right: 5px;
background: #666;
&.is-tip {
background: var(--tip-color);
}
&.is-warning {
background: var(--warning-color);
}
&.is-danger {
background: var(--danger-color);
}
&.is-success {
background: var(--success-color);
}
}
</style>
80 changes: 80 additions & 0 deletions src/components/Note.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<template functional>
<div :class="['note', `is-${props.type}`]">
<span class="note-label" v-if="props.label"
>{{ props.label === true ? props.type : props.label }}:</span
>
<slot></slot>
</div>
</template>

<script>
export default {
name: 'Note',
props: {
type: {
type: String,
default: 'note'
},
label: {
type: [String, Boolean],
default: true
}
}
}
</script>

<style>
.note {
line-height: 1;
padding: 20px 24px;
border-radius: 4px;
border: 1px solid rgb(221, 221, 221);
margin: 20px 0;
& > *:not(.note-label) {
line-height: 1.7;
}
& > *:first-child {
margin-top: 0;
}
& > *:last-child {
margin-bottom: 0;
}
&.is-tip {
border-color: var(--tip-color);
& .note-label {
color: var(--tip-color);
}
}
&.is-danger {
border-color: var(--danger-color);
& .note-label {
color: var(--danger-color);
}
}
&.is-warning {
border-color: var(--warning-color);
& .note-label {
color: var(--warning-color);
}
}
&.is-success {
border-color: var(--success-color);
& .note-label {
color: var(--success-color);
}
}
}
.note-label {
text-transform: uppercase;
font-weight: bold;
display: inline-block;
}
</style>
25 changes: 0 additions & 25 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,3 @@ a {
margin: 0 auto;
}
}

/** Badge */
.badge {
display: inline-block;
vertical-align: top;
font-size: 13px;
height: 18px;
line-height: 18px;
border-radius: 9px;
padding: 0 5px;
color: #fff;
margin-right: 5px;

&.tip {
background: #42b983;
}

&.warn, &.warning {
background: #e7c000;
}

&.danger {
background: #d82f2f;
}
}
5 changes: 5 additions & 0 deletions src/css/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
--border-color: #eaeaea;
--header-height: 60px;
--code-font: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;

--tip-color: rgb(6, 125, 247);
--success-color: #42b983;
--warning-color: #ff9800;
--danger-color: rgb(255, 0, 31);
}
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import alternativeComponents from './utils/alternativeComponents'
import ImageZoom from './components/ImageZoom.vue'
import Badge from './components/Badge.vue'
import DocuteSelect from './components/DocuteSelect.vue'
import Note from './components/Note.vue'
import ExternalLinkIcon from './components/icons/ExternalLinkIcon.vue'

// Built-in plugins
Expand All @@ -18,6 +19,7 @@ import versionsPlugin from './plugins/versions'
Vue.component(ImageZoom.name, ImageZoom)
Vue.component(Badge.name, Badge)
Vue.component(DocuteSelect.name, DocuteSelect)
Vue.component(Note.name, Note)
Vue.component(ExternalLinkIcon.name, ExternalLinkIcon)
Vue.use(alternativeComponents)

Expand Down
121 changes: 100 additions & 21 deletions website/docs/builtin-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ Docute comes with a set of built-in Vue components.

Use medium-style zoom effect to display certain image.

|Prop|Type|Default|Description|
|---|---|---|---|
|url|`string`|N/A|URL to image|
|alt|`string`|N/A|Placeholder text|
|border|`boolean`|`false`|Show border around image|
|width|`string`|N/A|Image width|
| Prop | Type | Default | Description |
| ------ | --------- | ------- | ------------------------ |
| url | `string` | N/A | URL to image |
| alt | `string` | N/A | Placeholder text |
| border | `boolean` | `false` | Show border around image |
| width | `string` | N/A | Image width |

Example:
<br>

Example:

```markdown
<ImageZoom
Expand All @@ -25,30 +27,107 @@ Example:

<ImageZoom url="https://i.loli.net/2018/09/24/5ba8e878850e9.png" :border="true" width="300"/>


## `<Badge>`

A small count and labeling component.

|Prop|Type|Default|Description|
|---|---|---|---|
|type|<code>'tip' &#x7C; 'warning' &#x7C; 'danger'</code>|`'tip'`|Badge type|
|color|`string`|N/A|Custom background color|
|children|`string`|N/A|Badge text|
| Prop | Type | Default | Description |
| -------- | --------------------------------------------------- | ------- | ----------------------- |
| type | <code>'tip' &#x7C; 'success' &#x7C; 'warning' &#x7C; 'danger'</code> | N/A | Badge type |
| color | `string` | N/A | Custom background color |
| children | `string` | N/A | Badge text |

<br>

Example:

```markdown
- Feature 1 <Badge>Stable</Badge>
- Feature 2 <Badge type="warning">Beta</Badge>
- Feature 3 <Badge type="danger">Deprecated</Badge>
- Feature 4 <Badge color="magenta">Custom Color</Badge>
- Feature 1 <Badge>Badge</Badge>
- Feature 2 <Badge type="tip">Tip</Badge>
- Feature 3 <Badge type="success">Success</Badge>
- Feature 4 <Badge type="warning">Warning</Badge>
- Feature 5 <Badge type="danger">Danger</Badge>
- Feature 6 <Badge color="magenta">Custom Color</Badge>
```

- Feature 1 <Badge>Stable</Badge>
- Feature 2 <Badge type="warning">Beta</Badge>
- Feature 3 <Badge type="danger">Deprecated</Badge>
- Feature 4 <Badge color="magenta">Custom Color</Badge>
- Feature 1 <Badge>Badge</Badge>
- Feature 2 <Badge type="tip">Tip</Badge>
- Feature 3 <Badge type="success">Success</Badge>
- Feature 4 <Badge type="warning">Warning</Badge>
- Feature 5 <Badge type="danger">Danger</Badge>
- Feature 6 <Badge color="magenta">Custom Color</Badge>

## `<Note>`

Colored note blocks, to emphasize part of your page.

| Prop | Type | Default | Description |
| -------- | ------------------------------------------------------------------- | ------------------- | ------------------------------------------------- |
| type | <code>'tip' &#x7C; 'warning' &#x7C; 'alert' &#x7C; 'success'</code> | N/A | Note type |
| label | `string` `boolean` | The value of `type` | Custom note label text, use `false` to hide label |
| children | `string` | N/A | Note content |

<br>

Examples:

```markdown
<Note>

This is a note that details something important.<br>
[A link to helpful information.](https://docute.org)

</Note>

<!-- Tip Note -->
<Note type="tip">

This is a tip for something that is possible.

</Note>

<!-- Warning Note -->
<Note type="warning">

This is a warning for something very important.

</Note>

<!-- Danger Note -->
<Note type="danger">

This is a danger for something to take action for.

</Note>
```

<Note>

This is a note that details something important.<br>
[A link to helpful information.](https://docute.org)

</Note>

<!-- Tip Note -->
<Note type="tip">

This is a tip for something that is possible.

</Note>

<!-- Warning Note -->
<Note type="warning">

This is a warning for something very important.

</Note>

<!-- Danger Note -->
<Note type="danger">

This is a danger for something to take action for.

</Note>

## `<v-style>` `<v-script>`

Expand Down
Loading

0 comments on commit 73fb4a9

Please sign in to comment.