diff --git a/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx b/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx index 9030949..7c20ab5 100644 --- a/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx +++ b/src/components/Common/Inputs/SlotSelector/SlotSelector.tsx @@ -26,24 +26,31 @@ export function SlotSelector({ setPrefixMask(findPrefixCount(tempFormattedItems)); }, [items]); + const getNextIndex = (i: number) => (i + 1) % items.length; + const getPreviousIndex = (i: number) => i - 1 >= 0 ? i - 1 : items.length - 1; + const onClick = () => { - const nextIndex = (index + 1) % items.length; + const nextIndex = getNextIndex(index); setIndex(nextIndex); onChange(items[nextIndex]); }; + const getItem = (i: number) => + formattedItems.length && + removePrefix && + formattedItems[0].length !== prefixMask ? + formattedItems[i].slice(prefixMask) : + formattedItems[i]; + + const currentItem = getItem(index); + const nextItem = getItem(getNextIndex(index)); + return ( - - {formattedItems.length && - removePrefix && formattedItems[0].length !== prefixMask ? - formattedItems[index].slice(prefixMask) - : - formattedItems[index] - } - + {currentItem} + {nextItem} ); } diff --git a/src/components/Common/Inputs/SlotSelector/styles.ts b/src/components/Common/Inputs/SlotSelector/styles.ts index c4fe8c4..efc24e5 100644 --- a/src/components/Common/Inputs/SlotSelector/styles.ts +++ b/src/components/Common/Inputs/SlotSelector/styles.ts @@ -2,8 +2,7 @@ import styled from "styled-components"; export const SlotWindow = styled.div` position: relative; - height: 1.2em; - height: 100%; + height: 1.7em; width: 200px; border-radius: 0.6em; @@ -19,6 +18,7 @@ export const SlotWindow = styled.div` `; export const SlotText = styled.span` + display: block; margin-left: .4em; position: relative; font-family: ${p => p.theme.fonts.f1Regular};