-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
/
ColorsPage.vue
176 lines (158 loc) Β· 4.88 KB
/
ColorsPage.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template lang="pug">
views-doc
template(slot-scope="{ namespace }")
section#classes
helpers-section-head(:value="`${namespace}.classesHeader`")
helpers-section-text(:value="`${namespace}.classesText`")
helpers-example(
readonly
file="colors/classes"
)
helpers-section-text(:value="`${namespace}.classesText2`")
helpers-example(
readonly
file="colors/textClasses"
)
section#javascript-color-pack
helpers-section-head(:value="`${namespace}.javascriptPackHeader`")
helpers-section-text(:value="`${namespace}.javascriptPackText`")
helpers-markup(lang="js")
| // src/index.js
|
| // Libraries
| import Vue from 'vue'
| import Vuetify from 'vuetify'
|
| // Helpers
| import colors from 'vuetify/es5/util/colors'
|
| Vue.use(Vuetify, {
| theme: {
| primary: colors.red.darken1, // #E53935
| secondary: colors.red.lighten4, // #FFCDD2
| accent: colors.indigo.base // #3F51B5
| }
| })
section#stylus-color-pack
helpers-section-head(:value="`${namespace}.stylusPackHeader`")
helpers-section-text(:value="`${namespace}.stylusPackText`")
helpers-markup(lang="stylus").mb-3
| // src/assets/stylus/main.styl
|
| $color-pack = false
|
| @import '~vuetify/src/stylus/main'
helpers-section-text(:value="`${namespace}.stylusPackText2`")
helpers-markup(lang="js").mb-3
| // src/index.js
|
| import './assets/stylus/main.styl'
| // or
| require('./assets/stylus/main.styl')
core-alert(error :value="`${namespace}.alert`")
helpers-section-text(:value="`${namespace}.stylusPackText3`")
helpers-markup(lang="vue")
| <style lang="stylus">
| $color-pack = false
|
| @import '~vuetify/src/stylus/main'
| </style>
section#material-colors
helpers-section-head(:value="`${namespace}.colorHeader`")
helpers-section-text(:value="`${namespace}.colorText`")
v-container(fluid grid-list-xl).pa-0
v-layout(row wrap)
v-flex(xs12).mb-3
v-text-field(
prepend-icon="filter_list"
solo
label="Search"
single-line
v-model="search"
)
v-flex(
xs6 sm6 md4
v-for="(color, key) in computedColors"
:key="key"
)
v-card(
:color="key"
tile
)
v-card-text
h3 {{ key }}
v-card(
v-for="(subColor, key2) in color"
:color="`${key} ${convertToClass(key2)}`"
:class="getColorClass(key2)"
:key="key2"
tile
)
v-card-text
v-layout
v-flex(xs8).caption
span(v-if="key !== 'shades'") {{ key }}
span(v-if="key2 !== 'base'") {{ key2.replace(/(.*)(\d)/, '$1-$2') }}
v-flex(xs4).text-xs-right
span(v-if="subColor !== 'transparent'") {{ subColor.toUpperCase() }}
</template>
<script>
import colors from 'vuetify/es5/util/colors'
import { kebab } from '@/util/helpers'
export default {
data: () => ({
colors,
search: ''
}),
computed: {
computedColors () {
const colors = {}
const search = this.search.toLowerCase()
Object.keys(this.colors).forEach(key => {
const kebabKey = kebab(key).toLowerCase()
if (kebabKey.indexOf(search) > -1) {
colors[kebabKey] = this.colors[key]
}
})
return colors
}
},
methods: {
endStr (str) {
return str[str.length - 1]
},
convertToClass (str) {
const end = this.endStr(str)
const sub = str.substr(0, str.length - 1)
if (isNaN(parseInt(end))) return str
return `${sub}-${end}`
},
getColorClass (key) {
if (['white', 'transparent'].includes(key) ||
key.indexOf('light') > -1 ||
key.indexOf('accent') > -1
) return 'black--text'
return 'white--text'
}
}
}
</script>
<style lang="stylus">
#colors-page #colors
.flex
margin: 1rem 0
.v-card
color: #fff
font-weight: 500
letter-spacing: .5px
padding: 1rem
border-radius: 0
.v-card__text
h3
color: #fff
align-self: flex-start
font-size: 1.5rem
margin: 0
.v-card__text
padding: 0
</style>