-
Notifications
You must be signed in to change notification settings - Fork 1
/
LuxIconBase.vue
110 lines (106 loc) · 2.53 KB
/
LuxIconBase.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<div class="lux-icon">
<svg
xmlns="http://www.w3.org/2000/svg"
:width="width"
:height="height"
viewBox="0 0 24 24"
:aria-labelledby="iconTitleId"
:aria-hidden="iconHide"
role="img"
>
<title v-if="iconName" :id="iconTitleId" lang="en">{{ iconName }}</title>
<g :fill="iconColor">
<slot></slot>
</g>
</svg>
</div>
</template>
<script>
/**
* Icons are used to visually communicate core parts of the product and
* available actions. Please be aware that all elements must have closing tags (not "self-closing").
* To add additional icons, please consult [the instructions](/#/Adding%20Icons).
*/
export default {
name: "LuxIconBase",
status: "ready",
release: "1.0.0",
type: "Element",
props: {
/**
* The name of the icon to display. Also used as the accessible name of the icon.
*/
iconName: {
required: false,
type: String,
default: "",
},
/**
* The width of the icon. For square icons use values of `11px, 13px,
* 16px, 24px, 36px, 48px, 64px` to follow visual heirachy set by
* typography.
*/
width: {
type: [Number, String],
default: 24,
},
/**
* The height of the icon. For square icons use values of `11px, 13px,
* 16px, 24px, 36px, 48px, 64px` to follow visual heirachy set by
* typography.
*/
height: {
type: [Number, String],
default: 24,
},
/**
* The fill color of the SVG icon.
*/
iconColor: {
type: String,
default: "currentColor",
},
/**
* Hides decorative icon from screen readers
*/
iconHide: {
type: [String, Boolean],
default: false,
},
},
computed: {
// Present the iconName prop in a format suitable for use as an element's ID.
// Only ASCII letters, digits, '_', and '-' should be used in an id, per
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
iconTitleId() {
return this.iconName
.toLowerCase()
.replace(/[^\w\d\s-_]/g, "")
.trim()
.replace(/\s/g, "-")
},
},
}
</script>
<style lang="scss" scoped>
@import "../../assets/styles/variables.css";
.lux-icon {
display: inline-flex;
align-self: center;
margin: 0 var(--space-xx-small);
svg {
top: 0.125em;
position: relative;
}
}
</style>
<docs>
```jsx
<div>
<lux-icon-base width="30" height="30" icon-name="file">
<lux-icon-file></lux-icon-file>
</lux-icon-base>
</div>
```
</docs>