Added missing Icon

This commit is contained in:
Grzegorz Leoniec 2019-02-25 09:58:29 +01:00
parent 105ab19424
commit 85114b78d6
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377
3 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,73 @@
<template>
<component
:is="tag"
:aria-label="ariaLabel"
:class="[size && `ds-icon-size-${size}`]"
class="ds-icon"
>
<component
v-if="svgComponent"
:is="svgComponent"
class="ds-icon-svg" />
</component>
</template>
<script>
import icons from '@@/icons'
/**
* Icons are used to add meaning and improve accessibility.
* @version 1.0.0
*/
export default {
name: 'DsIcon',
props: {
/**
* The name of the icon.
*/
name: {
type: String,
required: true
},
/**
* Descriptive text to be read to screenreaders.
*/
ariaLabel: {
type: String,
default: 'icon'
},
/**
* The html element name used for the icon.
*/
tag: {
type: String,
default: 'span'
},
/**
* Which size should the icon have?
* `xx-small, x-small, small, base, large, x-large, xx-large, xxx-large`
*/
size: {
type: String,
default: null,
validator: value => {
return value.match(
/(xx-small|x-small|small|base|large|x-large|xx-large|xxx-large)/
)
}
}
},
computed: {
svgComponent() {
const icon = icons[this.name]
if (!icon) {
return false
}
return icon.render ? icon : icon.default
}
}
}
</script>
<style lang="scss" src="./style.scss"></style>
<docs src="./demo.md"></docs>

View File

@ -0,0 +1,16 @@
## Basic usage
Simply provide the name for the icon.
```
<ds-icon name="plus"></ds-icon>
<ds-icon name="user"></ds-icon>
<ds-icon name="comments"></ds-icon>
<ds-icon name="ban"></ds-icon>
```
## Icon list
Below is a list of all available icons. If you want to change these icons or want to add new ones, put them in `system/icons/svg`.
<icon-list></icon-list>

View File

@ -0,0 +1,45 @@
.ds-icon {
@include reset;
display: inline-flex;
align-items: center;
vertical-align: middle;
height: 1em;
}
.ds-icon-svg {
line-height: 1;
height: 1.2em;
// Use this if the icons are build with strokes
// stroke: currentColor;
// stroke-width: 2.5px;
// stroke-linejoin: miter;
// stroke-linecap: miter;
// overflow: visible;
// Use this if the icons are build with solids
fill: currentColor
}
.ds-icon-size-xx-small {
font-size: $font-size-xx-small
}
.ds-icon-size-x-small {
font-size: $font-size-x-small
}
.ds-icon-size-small {
font-size: $font-size-small
}
.ds-icon-size-base {
font-size: $font-size-base
}
.ds-icon-size-large {
font-size: $font-size-large
}
.ds-icon-size-x-large {
font-size: $font-size-x-large
}
.ds-icon-size-xx-large {
font-size: $font-size-xx-large
}
.ds-icon-size-xxx-large {
font-size: $font-size-xxx-large
}