import {useCallback, useEffect, useState} from 'react'; import styled from '@emotion/styled'; import Code from 'docs-ui/components/code'; import BooleanField from 'sentry/components/forms/booleanField'; import SelectField from 'sentry/components/forms/selectField'; import space from 'sentry/styles/space'; import {iconProps} from './data'; import IconSample from './sample'; import {ExtendedIconData} from './searchPanel'; type Props = { icon: ExtendedIconData; }; const Details = ({icon}: Props) => { // Editable icon props const [size, setSize] = useState(iconProps.size.default); const [direction, setDirection] = useState( icon.defaultProps?.direction ?? iconProps.direction.default ); const [type, setType] = useState(icon.defaultProps?.type ?? iconProps.type.default); const [isCircled, setIsCircled] = useState(icon.defaultProps?.isCircled ?? false); const [isSolid, setIsSolid] = useState(icon.defaultProps?.isSolid ?? false); /** * Generate and update code sample based on prop states */ const getCodeSample = useCallback(() => { return ``; }, [icon.name, size, isCircled, isSolid]); const [codeSample, setCodeSample] = useState(getCodeSample()); useEffect(() => void setCodeSample(getCodeSample()), [getCodeSample]); return ( setSize(value)} clearable={false} /> {icon.additionalProps?.includes('direction') && ( setDirection(value)} clearable={false} /> )} {icon.additionalProps?.includes('type') && ( setType(value)} clearable={false} /> )} {icon.additionalProps?.includes('isCircled') && ( setIsCircled(value)} /> )} {icon.additionalProps?.includes('isSolid') && ( setIsSolid(value)} /> )} {codeSample} ); }; export default Details; const Wrap = styled('div')` max-width: 20rem; `; const SampleWrap = styled('div')` width: 100%; height: 4rem; display: flex; justify-content: center; align-items: center; margin: 0 auto ${space(3)}; `; const FieldContainer = styled('div')` margin: -${space(2)}; border-top: 1px solid ${p => p.theme.innerBorder}; `;