import React from 'react'; import styled from '@emotion/native'; import { TouchableHighlightProps as TouchableHighlightPropsBase } from 'react-native'; import { variant } from 'styled-system'; import { ColorName, ViewStyle } from '@emotion/react'; import { Text } from 'components/text'; import { Row, StyleSystemThemedProps, TouchableHighlight } from 'components/layout'; import { Visible } from 'components/visible'; const variants: Record = { outline: { borderRadius: 'chip', borderWidth: 1, borderColor: 'caption-01', }, plain: { borderRadius: 'chip', }, }; const colorVariants: Record = { transparent: { backgroundColor: 'transparent', }, base: { backgroundColor: 'base', }, 'base-01': { backgroundColor: 'base-01', }, 'base-02': { backgroundColor: 'base-02', }, secondary: { backgroundColor: 'secondary', }, 'secondary-01': { backgroundColor: 'secondary-01', }, success: { backgroundColor: 'success', }, 'success-01': { backgroundColor: 'success-01', }, }; const sizeVariants: Record = { 'extra-small': { py: '3xs', px: '2xs', }, small: { py: '3xs', px: 'xs', }, medium: { py: '2xs', px: 's', }, large: { py: 'xs', px: 'm', }, }; export const ChipLocal = styled(TouchableHighlight)( variant({ variants, }), variant({ prop: 'sizeVariant', variants: sizeVariants, }), variant({ prop: 'colorVariant', variants: colorVariants, }), { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', } ); export const Chip: React.FC = ({ title, titleColor = 'caption', centerElement, leftElement, rightElement, ...props }) => { return ( <> {leftElement} {title} <>{centerElement} {rightElement} ); }; type ChipType = StyleSystemThemedProps & TouchableHighlightProps & ChipProps; export type ChipVariant = 'outline' | 'plain'; export type ChipSizeVariant = 'extra-small' | 'small' | 'medium' | 'large'; export type ChipColorVariant = | 'transparent' | 'base' | 'base-01' | 'base-02' | 'success' | 'success-01' | 'secondary' | 'secondary-01'; export interface TouchableHighlightProps extends TouchableHighlightPropsBase { variant: ChipVariant; sizeVariant?: ChipSizeVariant; colorVariant: ChipColorVariant; } export interface ChipProps { title?: string | number; titleColor?: ColorName; centerElement?: JSX.Element; leftElement?: JSX.Element; rightElement?: JSX.Element; icon?: JSX.Element; }