faster classname function
This commit is contained in:
parent
2db30856f9
commit
1477fbfbda
|
@ -60,16 +60,19 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import { classname } from '../_utils/classname'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
computedClass: (pressable, pressed, big, className) => {
|
computedClass: (pressable, pressed, big, className) => {
|
||||||
return [
|
return classname(
|
||||||
'icon-button',
|
'icon-button',
|
||||||
!pressable && 'not-pressable',
|
!pressable && 'not-pressable',
|
||||||
pressed && 'pressed',
|
pressed && 'pressed',
|
||||||
big && 'big-icon',
|
big && 'big-icon',
|
||||||
className
|
className
|
||||||
].filter(Boolean).join(' ')
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
import { store } from '../../_store/store'
|
import { store } from '../../_store/store'
|
||||||
import { goto } from 'sapper/runtime.js'
|
import { goto } from 'sapper/runtime.js'
|
||||||
import { registerClickDelegate, unregisterClickDelegate } from '../../_utils/delegate'
|
import { registerClickDelegate, unregisterClickDelegate } from '../../_utils/delegate'
|
||||||
|
import { classname } from '../../_utils/classname'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
oncreate() {
|
oncreate() {
|
||||||
|
@ -124,11 +125,11 @@
|
||||||
store: () => store,
|
store: () => store,
|
||||||
helpers: {
|
helpers: {
|
||||||
getClasses(originalStatus, timelineType, isStatusInOwnThread) {
|
getClasses(originalStatus, timelineType, isStatusInOwnThread) {
|
||||||
return [
|
return classname(
|
||||||
originalStatus.visibility === 'direct' && 'status-direct',
|
originalStatus.visibility === 'direct' && 'status-direct',
|
||||||
timelineType !== 'search' && 'status-in-timeline',
|
timelineType !== 'search' && 'status-in-timeline',
|
||||||
isStatusInOwnThread && 'status-in-own-thread'
|
isStatusInOwnThread && 'status-in-own-thread'
|
||||||
].filter(Boolean).join(' ')
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
15
routes/_utils/classname.js
Normal file
15
routes/_utils/classname.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
export function classname () {
|
||||||
|
let res = ''
|
||||||
|
let len = arguments.length
|
||||||
|
let i = -1
|
||||||
|
while (++i < len) {
|
||||||
|
let item = arguments[i]
|
||||||
|
if (item) {
|
||||||
|
if (res) {
|
||||||
|
res += ' '
|
||||||
|
}
|
||||||
|
res += item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
Loading…
Reference in a new issue