Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | import { DecrementIcon } from './icons/decrement'; import { IncrementIcon } from './icons/increment'; import { Box, Flex, Text, BoxProps, FlexProps, color } from '@stacks/ui'; import { increment, decrement } from '@utils/mutate-numbers'; import { formatCycles } from '@utils/stacking'; import React, { FC } from 'react'; interface StepperProps extends BoxProps { amount: number; onIncrement(amount: number): void; onDecrement(amount: number): void; } const border = `1px solid ${color('border')}`; const ChangeStepButton: FC<FlexProps> = ({ children, ...props }) => ( <Flex as="button" type="button" alignItems="center" justifyContent="center" width="52px" height="48px" border={border} outline={0} zIndex={1} _focus={{ borderColor: '#C5CCFF', boxShadow: '0 0 0 3px rgba(170,179,255,0.75)', }} {...props} > {children} </Flex> ); export const Stepper: FC<StepperProps> = props => { const { amount, onIncrement, onDecrement, ...rest } = props; return ( <Box {...rest}> <Flex> <ChangeStepButton color={color(amount === 1 ? 'text-caption' : 'brand')} pointerEvents={amount === 1 ? 'none' : 'all'} onClick={() => onDecrement(decrement(amount))} borderRadius="6px 0 0 6px" > <DecrementIcon /> </ChangeStepButton> <Flex borderTop={border} borderBottom={border} flexDirection="column" justifyContent="center" alignItems="center" minWidth="100px" > <Text textStyle="body.small" mb="3px" mx="base"> {formatCycles(amount)} </Text> </Flex> <ChangeStepButton color={color(amount === 12 ? 'text-caption' : 'brand')} pointerEvents={amount === 12 ? 'none' : 'all'} onClick={() => onIncrement(increment(amount))} borderRadius="0 6px 6px 0" > <IncrementIcon /> </ChangeStepButton> </Flex> </Box> ); }; |