react-icons/io#IoIosFlash TypeScript Examples
The following examples show how to use
react-icons/io#IoIosFlash.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomPropsPanel.tsx From openchakra with MIT License | 4 votes |
CustomPropsPanel = () => {
const dispatch = useDispatch()
const inputRef = useRef<HTMLInputElement>(null)
const activePropsRef = useInspectorState()
const { props, id } = useSelector(getSelectedComponent)
const { setValue } = useForm()
const [quickProps, setQuickProps] = useState('')
const [hasError, setError] = useState(false)
const onDelete = (propsName: string) => {
dispatch.components.deleteProps({
id,
name: propsName,
})
}
const activeProps = activePropsRef || []
const customProps = Object.keys(props).filter(
propsName => !activeProps.includes(propsName),
)
return (
<>
<form
onSubmit={(event: FormEvent) => {
event.preventDefault()
const [name, value] = quickProps.split(SEPARATOR)
if (name && value) {
setValue(name, value)
setQuickProps('')
setError(false)
} else {
setError(true)
}
}}
>
<InputGroup mb={3} size="sm">
<InputRightElement
children={<Box as={IoIosFlash} color="gray.300" />}
/>
<Input
ref={inputRef}
isInvalid={hasError}
value={quickProps}
placeholder={`props${SEPARATOR}value`}
onChange={(event: ChangeEvent<HTMLInputElement>) =>
setQuickProps(event.target.value)
}
/>
</InputGroup>
</form>
{customProps.map((propsName, i) => (
<Flex
key={propsName}
alignItems="center"
px={2}
bg={i % 2 === 0 ? 'white' : 'gray.50'}
fontSize="xs"
justifyContent="space-between"
>
<SimpleGrid width="100%" columns={2} spacing={1}>
<Box fontWeight="bold">{propsName}</Box>
<Box>{props[propsName]}</Box>
</SimpleGrid>
<ButtonGroup display="flex" size="xs" isAttached>
<IconButton
onClick={() => {
setQuickProps(`${propsName}=`)
if (inputRef.current) {
inputRef.current.focus()
}
}}
variant="ghost"
size="xs"
aria-label="edit"
icon={<EditIcon path="" />}
/>
<IconButton
onClick={() => onDelete(propsName)}
variant="ghost"
size="xs"
aria-label="delete"
icon={<SmallCloseIcon path="" />}
/>
</ButtonGroup>
</Flex>
))}
</>
)
}