ISSUE-020 - Making a checkpoint in my work. SlotSelector written a little better. Animation work coming next.
This commit is contained in:
1 parent
35ca424dd6
commit
9b3ae2dae2
2 files changed
+18
-11
No files matched your search
@@ -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 (
|
||||
<SlotWindow
|
||||
onClick={onClick}
|
||||
>
|
||||
<SlotText>
|
||||
{formattedItems.length &&
|
||||
removePrefix && formattedItems[0].length !== prefixMask ?
|
||||
formattedItems[index].slice(prefixMask)
|
||||
:
|
||||
formattedItems[index]
|
||||
}
|
||||
</SlotText>
|
||||
<SlotText>{currentItem}</SlotText>
|
||||
<SlotText>{nextItem}</SlotText>
|
||||
</SlotWindow>
|
||||
);
|
||||
}
|
||||
@@ -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};
|
||||
|
||||
Reference in new issue
Block a user