Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
77292861
Commit
77292861
authored
Mar 10, 2021
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added constants file to re-use variables
Added comment to SCSS file Updated category spec
parent
33ded12d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
40 deletions
+27
-40
app/assets/javascripts/emoji/components/emoji_list.vue
app/assets/javascripts/emoji/components/emoji_list.vue
+2
-1
app/assets/javascripts/emoji/components/picker.vue
app/assets/javascripts/emoji/components/picker.vue
+1
-11
app/assets/javascripts/emoji/components/utils.js
app/assets/javascripts/emoji/components/utils.js
+4
-2
app/assets/javascripts/emoji/constants.js
app/assets/javascripts/emoji/constants.js
+14
-0
app/assets/javascripts/emoji/index.js
app/assets/javascripts/emoji/index.js
+2
-10
app/assets/stylesheets/framework/emojis.scss
app/assets/stylesheets/framework/emojis.scss
+1
-0
spec/frontend/emoji/components/category_spec.js
spec/frontend/emoji/components/category_spec.js
+3
-16
No files found.
app/assets/javascripts/emoji/components/emoji_list.vue
View file @
77292861
<
script
>
<
script
>
import
{
chunk
}
from
'
lodash
'
;
import
{
chunk
}
from
'
lodash
'
;
import
{
searchEmoji
}
from
'
~/emoji
'
;
import
{
searchEmoji
}
from
'
~/emoji
'
;
import
{
EMOJIS_PER_ROW
}
from
'
../constants
'
;
import
{
getEmojiCategories
,
generateCategoryHeight
}
from
'
./utils
'
;
import
{
getEmojiCategories
,
generateCategoryHeight
}
from
'
./utils
'
;
export
default
{
export
default
{
...
@@ -18,7 +19,7 @@ export default {
...
@@ -18,7 +19,7 @@ export default {
if
(
this
.
searchValue
!==
''
)
{
if
(
this
.
searchValue
!==
''
)
{
const
emojis
=
chunk
(
const
emojis
=
chunk
(
searchEmoji
(
this
.
searchValue
).
map
(({
emoji
})
=>
emoji
.
name
),
searchEmoji
(
this
.
searchValue
).
map
(({
emoji
})
=>
emoji
.
name
),
9
,
EMOJIS_PER_ROW
,
);
);
return
{
return
{
...
...
app/assets/javascripts/emoji/components/picker.vue
View file @
77292861
...
@@ -2,21 +2,11 @@
...
@@ -2,21 +2,11 @@
import
{
GlIcon
,
GlDropdown
,
GlSearchBoxByType
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlDropdown
,
GlSearchBoxByType
}
from
'
@gitlab/ui
'
;
import
VirtualList
from
'
vue-virtual-scroll-list
'
;
import
VirtualList
from
'
vue-virtual-scroll-list
'
;
import
{
CATEGORY_NAMES
}
from
'
~/emoji
'
;
import
{
CATEGORY_NAMES
}
from
'
~/emoji
'
;
import
{
CATEGORY_ICON_MAP
}
from
'
../constants
'
;
import
Category
from
'
./category.vue
'
;
import
Category
from
'
./category.vue
'
;
import
EmojiList
from
'
./emoji_list.vue
'
;
import
EmojiList
from
'
./emoji_list.vue
'
;
import
{
getEmojiCategories
}
from
'
./utils
'
;
import
{
getEmojiCategories
}
from
'
./utils
'
;
const
CATEGORY_ICON_MAP
=
{
activity
:
'
dumbbell
'
,
people
:
'
smiley
'
,
nature
:
'
nature
'
,
food
:
'
food
'
,
travel
:
'
car
'
,
objects
:
'
object
'
,
symbols
:
'
heart
'
,
flags
:
'
flag
'
,
};
export
default
{
export
default
{
components
:
{
components
:
{
GlIcon
,
GlIcon
,
...
...
app/assets/javascripts/emoji/components/utils.js
View file @
77292861
import
{
chunk
,
memoize
}
from
'
lodash
'
;
import
{
chunk
,
memoize
}
from
'
lodash
'
;
import
{
initEmojiMap
,
getEmojiCategoryMap
}
from
'
~/emoji
'
;
import
{
initEmojiMap
,
getEmojiCategoryMap
}
from
'
~/emoji
'
;
import
{
EMOJIS_PER_ROW
,
EMOJI_ROW_HEIGHT
,
CATEGORY_ROW_HEIGHT
}
from
'
../constants
'
;
export
const
generateCategoryHeight
=
(
emojisLength
)
=>
emojisLength
*
34
+
29
;
export
const
generateCategoryHeight
=
(
emojisLength
)
=>
emojisLength
*
EMOJI_ROW_HEIGHT
+
CATEGORY_ROW_HEIGHT
;
export
const
getEmojiCategories
=
memoize
(
async
()
=>
{
export
const
getEmojiCategories
=
memoize
(
async
()
=>
{
await
initEmojiMap
();
await
initEmojiMap
();
...
@@ -11,7 +13,7 @@ export const getEmojiCategories = memoize(async () => {
...
@@ -11,7 +13,7 @@ export const getEmojiCategories = memoize(async () => {
return
Object
.
freeze
(
return
Object
.
freeze
(
Object
.
keys
(
categories
).
reduce
((
acc
,
category
)
=>
{
Object
.
keys
(
categories
).
reduce
((
acc
,
category
)
=>
{
const
emojis
=
chunk
(
categories
[
category
],
9
);
const
emojis
=
chunk
(
categories
[
category
],
EMOJIS_PER_ROW
);
const
height
=
generateCategoryHeight
(
emojis
.
length
);
const
height
=
generateCategoryHeight
(
emojis
.
length
);
const
newAcc
=
{
const
newAcc
=
{
...
acc
,
...
acc
,
...
...
app/assets/javascripts/emoji/constants.js
0 → 100644
View file @
77292861
export
const
CATEGORY_ICON_MAP
=
{
activity
:
'
dumbbell
'
,
people
:
'
smiley
'
,
nature
:
'
nature
'
,
food
:
'
food
'
,
travel
:
'
car
'
,
objects
:
'
object
'
,
symbols
:
'
heart
'
,
flags
:
'
flag
'
,
};
export
const
EMOJIS_PER_ROW
=
9
;
export
const
EMOJI_ROW_HEIGHT
=
34
;
export
const
CATEGORY_ROW_HEIGHT
=
37
;
app/assets/javascripts/emoji/index.js
View file @
77292861
...
@@ -2,6 +2,7 @@ import { escape, minBy } from 'lodash';
...
@@ -2,6 +2,7 @@ import { escape, minBy } from 'lodash';
import
emojiAliases
from
'
emojis/aliases.json
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
import
AccessorUtilities
from
'
../lib/utils/accessor
'
;
import
AccessorUtilities
from
'
../lib/utils/accessor
'
;
import
axios
from
'
../lib/utils/axios_utils
'
;
import
axios
from
'
../lib/utils/axios_utils
'
;
import
{
CATEGORY_ICON_MAP
}
from
'
./constants
'
;
let
emojiMap
=
null
;
let
emojiMap
=
null
;
let
validEmojiNames
=
null
;
let
validEmojiNames
=
null
;
...
@@ -155,16 +156,7 @@ export function sortEmoji(items) {
...
@@ -155,16 +156,7 @@ export function sortEmoji(items) {
return
[...
items
].
sort
((
a
,
b
)
=>
a
.
score
-
b
.
score
||
a
.
fieldValue
.
localeCompare
(
b
.
fieldValue
));
return
[...
items
].
sort
((
a
,
b
)
=>
a
.
score
-
b
.
score
||
a
.
fieldValue
.
localeCompare
(
b
.
fieldValue
));
}
}
export
const
CATEGORY_NAMES
=
[
export
const
CATEGORY_NAMES
=
Object
.
keys
(
CATEGORY_ICON_MAP
);
'
activity
'
,
'
people
'
,
'
nature
'
,
'
food
'
,
'
travel
'
,
'
objects
'
,
'
symbols
'
,
'
flags
'
,
];
let
emojiCategoryMap
;
let
emojiCategoryMap
;
export
function
getEmojiCategoryMap
()
{
export
function
getEmojiCategoryMap
()
{
...
...
app/assets/stylesheets/framework/emojis.scss
View file @
77292861
...
@@ -24,6 +24,7 @@ gl-emoji {
...
@@ -24,6 +24,7 @@ gl-emoji {
.emoji-picker-emoji
{
.emoji-picker-emoji
{
height
:
30px
;
height
:
30px
;
// Create a width that fits 9 emojis per row
width
:
100
/
9
*
1%
;
width
:
100
/
9
*
1%
;
}
}
...
...
spec/frontend/emoji/components/category_spec.js
View file @
77292861
...
@@ -14,32 +14,24 @@ describe('Emoji category component', () => {
...
@@ -14,32 +14,24 @@ describe('Emoji category component', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
renders emoji groups
'
,
()
=>
{
beforeEach
(
()
=>
{
factory
({
factory
({
category
:
'
Activity
'
,
category
:
'
Activity
'
,
emojis
:
[[
'
thumbsup
'
],
[
'
thumbsdown
'
]],
emojis
:
[[
'
thumbsup
'
],
[
'
thumbsdown
'
]],
});
});
});
it
(
'
renders emoji groups
'
,
()
=>
{
expect
(
wrapper
.
findAll
(
EmojiGroup
).
length
).
toBe
(
2
);
expect
(
wrapper
.
findAll
(
EmojiGroup
).
length
).
toBe
(
2
);
});
});
it
(
'
renders group
'
,
async
()
=>
{
it
(
'
renders group
'
,
async
()
=>
{
factory
({
category
:
'
Activity
'
,
emojis
:
[[
'
thumbsup
'
],
[
'
thumbsdown
'
]],
});
await
wrapper
.
setData
({
renderGroup
:
true
});
await
wrapper
.
setData
({
renderGroup
:
true
});
expect
(
wrapper
.
find
(
EmojiGroup
).
attributes
(
'
rendergroup
'
)).
toBe
(
'
true
'
);
expect
(
wrapper
.
find
(
EmojiGroup
).
attributes
(
'
rendergroup
'
)).
toBe
(
'
true
'
);
});
});
it
(
'
renders group on appear
'
,
async
()
=>
{
it
(
'
renders group on appear
'
,
async
()
=>
{
factory
({
category
:
'
Activity
'
,
emojis
:
[[
'
thumbsup
'
],
[
'
thumbsdown
'
]],
});
wrapper
.
find
(
GlIntersectionObserver
).
vm
.
$emit
(
'
appear
'
);
wrapper
.
find
(
GlIntersectionObserver
).
vm
.
$emit
(
'
appear
'
);
await
nextTick
();
await
nextTick
();
...
@@ -48,11 +40,6 @@ describe('Emoji category component', () => {
...
@@ -48,11 +40,6 @@ describe('Emoji category component', () => {
});
});
it
(
'
emits appear event on appear
'
,
async
()
=>
{
it
(
'
emits appear event on appear
'
,
async
()
=>
{
factory
({
category
:
'
Activity
'
,
emojis
:
[[
'
thumbsup
'
],
[
'
thumbsdown
'
]],
});
wrapper
.
find
(
GlIntersectionObserver
).
vm
.
$emit
(
'
appear
'
);
wrapper
.
find
(
GlIntersectionObserver
).
vm
.
$emit
(
'
appear
'
);
await
nextTick
();
await
nextTick
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment