Skip to content

Commit

Permalink
feat(emojis): fixing function to fill multiple emojis and colors from…
Browse files Browse the repository at this point in the history
… theme
  • Loading branch information
mateoguzmana committed Aug 20, 2022
1 parent 82867cd commit ff38c17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function App() {

<TouchableOpacity
onPress={() =>
setComponentToRender(<EmojiPopper emojis={['😀', '😅']} />)
setComponentToRender(<EmojiPopper emojis={['😀', '😊']} />)
}
style={styles.pressable}
>
Expand Down
6 changes: 3 additions & 3 deletions src/utils/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export function colorsFromTheme(theme: string[], itemsToRender: number) {

const randomisedColors = shuffleArray(theme);

new Array(itemsToRender).fill(0).map((_, index) => {
if (index >= randomisedColors.length) {
new Array(itemsToRender).fill(0).map(() => {
if (colorToPushIndex === randomisedColors.length - 1) {
colorToPushIndex = 0;
} else {
colorToPushIndex = index;
colorToPushIndex++;
}

newColors.push(randomisedColors[colorToPushIndex]);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/emojis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export function getEmojisToRender(

const randomisedItems = shuffleArray(emojis);

new Array(itemsToRender).fill(0).map((_, index) => {
if (index >= randomisedItems.length) {
new Array(itemsToRender).fill(0).map(() => {
if (emojiToPushIndex === randomisedItems.length - 1) {
emojiToPushIndex = 0;
} else {
emojiToPushIndex = index;
emojiToPushIndex++;
}

newEmojis.push(randomisedItems[emojiToPushIndex]);
Expand Down

0 comments on commit ff38c17

Please sign in to comment.