mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-02-06 09:55:50 +00:00
Added missing Icon
This commit is contained in:
parent
105ab19424
commit
85114b78d6
73
src/system/components/typography/Icon/Icon.vue
Normal file
73
src/system/components/typography/Icon/Icon.vue
Normal 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>
|
||||
16
src/system/components/typography/Icon/demo.md
Normal file
16
src/system/components/typography/Icon/demo.md
Normal 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>
|
||||
45
src/system/components/typography/Icon/style.scss
Normal file
45
src/system/components/typography/Icon/style.scss
Normal 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
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user