@chakra-ui/icons#SmallCloseIcon TypeScript Examples
The following examples show how to use
@chakra-ui/icons#SmallCloseIcon.
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: Header.tsx From openchakra with MIT License | 4 votes |
Header = () => {
const showLayout = useSelector(getShowLayout)
const showCode = useSelector(getShowCode)
const dispatch = useDispatch()
return (
<DarkMode>
<Flex
justifyContent="space-between"
bg="#1a202c"
as="header"
height="3rem"
px="1rem"
>
<Flex
width="14rem"
height="100%"
backgroundColor="#1a202c"
color="white"
as="a"
fontSize="xl"
flexDirection="row"
alignItems="center"
aria-label="Chakra UI, Back to homepage"
>
<Box fontSize="2xl" as={AiFillThunderbolt} mr={1} color="teal.100" />{' '}
<Box fontWeight="bold">open</Box>chakra
</Flex>
<Flex flexGrow={1} justifyContent="space-between" alignItems="center">
<HStack spacing={4} justify="center" align="center">
<Box>
<HeaderMenu />
</Box>
<FormControl flexDirection="row" display="flex" alignItems="center">
<Tooltip
zIndex={100}
hasArrow
bg="yellow.100"
aria-label="Builder mode help"
label="Builder mode adds extra padding/borders"
>
<FormLabel
cursor="help"
color="gray.200"
fontSize="xs"
htmlFor="preview"
pb={0}
mb={0}
mr={2}
whiteSpace="nowrap"
>
Builder mode
</FormLabel>
</Tooltip>
<LightMode>
<Switch
isChecked={showLayout}
colorScheme="teal"
size="sm"
onChange={() => dispatch.app.toggleBuilderMode()}
id="preview"
/>
</LightMode>
</FormControl>
<FormControl display="flex" flexDirection="row" alignItems="center">
<FormLabel
color="gray.200"
fontSize="xs"
mr={2}
mb={0}
htmlFor="code"
pb={0}
whiteSpace="nowrap"
>
Code panel
</FormLabel>
<LightMode>
<Switch
isChecked={showCode}
id="code"
colorScheme="teal"
onChange={() => dispatch.app.toggleCodePanel()}
size="sm"
/>
</LightMode>
</FormControl>
</HStack>
<Stack direction="row">
<CodeSandboxButton />
<Popover>
{({ onClose }) => (
<>
<PopoverTrigger>
<Button
ml={4}
rightIcon={<SmallCloseIcon path="" />}
size="xs"
variant="ghost"
>
Clear
</Button>
</PopoverTrigger>
<LightMode>
<PopoverContent zIndex={100} bg="white">
<PopoverArrow />
<PopoverCloseButton />
<PopoverHeader>Are you sure?</PopoverHeader>
<PopoverBody fontSize="sm">
Do you really want to remove all components on the
editor?
</PopoverBody>
<PopoverFooter display="flex" justifyContent="flex-end">
<Button
size="sm"
variant="ghost"
colorScheme="red"
rightIcon={<CheckIcon path="" />}
onClick={() => {
dispatch.components.reset()
if (onClose) {
onClose()
}
}}
>
Yes, clear
</Button>
</PopoverFooter>
</PopoverContent>
</LightMode>
</>
)}
</Popover>
</Stack>
</Flex>
<Stack
justifyContent="flex-end"
width="13rem"
align="center"
direction="row"
spacing="2"
>
<Link isExternal href="https://github.com/premieroctet/openchakra">
<Box as={DiGithubBadge} size={32} color="gray.200" />
</Link>
<Box lineHeight="shorter" color="white" fontSize="xs">
by{' '}
<Link isExternal href="https://premieroctet.com" color="teal.100">
Premier Octet
</Link>
</Box>
</Stack>
</Flex>
</DarkMode>
)
}
Example #2
Source File: GradientControl.tsx From openchakra with MIT License | 4 votes |
GradientControl = (props: GradientControlPropsType) => {
const { setValue } = useForm()
const [gradientColor, setGradientColor] = useState(['green.200'])
const [directionValue, setDirectionValue] = useState('to right')
const gradient = usePropsSelector(props.name)
const choices = props.options
const updateValue = () => {
if (
gradientColor.length >= 2 &&
gradient !== `linear(${directionValue}, ${gradientColor.toString()})`
) {
setValue(
props.name,
`linear(${directionValue}, ${gradientColor.toString()})`,
)
}
}
useEffect(() => {
updateValue()
//eslint-disable-next-line
}, [directionValue, gradientColor])
useEffect(() => {
if (gradient === '' || gradient === null) {
setGradientColor(['green.200'])
} else {
try {
let gradientValue = gradient.split('(')[1]
let actualDirection = gradientValue.split(',')[0]
let actualColor = gradientValue.split(',')
let colorArray = actualColor.splice(1, actualColor.length)
colorArray[colorArray.length - 1] = colorArray[
colorArray.length - 1
].split(')')[0]
colorArray[0] = colorArray[0].split(' ')[1]
setDirectionValue(actualDirection)
setGradientColor(colorArray)
} catch (e) {
console.log(e)
}
}
}, [gradient])
const updateGradient = async (value: string, index: number) => {
let colorCopy = [...gradientColor]
colorCopy[index] = value
setGradientColor(colorCopy)
}
const removeGradient = async (index: number) => {
let colorCopy = [...gradientColor]
colorCopy.splice(index, 1)
if (colorCopy.length >= 2) {
setGradientColor(colorCopy)
} else {
setGradientColor(colorCopy)
setValue(props.name, null)
}
}
return (
<>
<FormControl label={props.label}>
<Select
size="sm"
id={directionValue || 'direction'}
name={directionValue || 'direction'}
value={directionValue || ''}
onChange={(value: React.ChangeEvent<HTMLSelectElement>) => {
setDirectionValue(value.target.value)
gradientColor.length >= 2 &&
setValue(
props.name,
`linear(${directionValue}, ${gradientColor.toString()})`,
)
}}
>
{choices?.map((choice: string) => (
<option key={choice}>{choice}</option>
))}
</Select>
</FormControl>
{gradientColor.map((e, i) => (
<Box textAlign="right" mt={3} key={i}>
{i >= 1 && (
<IconButton
onClick={() => removeGradient(i)}
variant="ghost"
marginRight={2}
size="xs"
aria-label="delete"
icon={<SmallCloseIcon path="" />}
/>
)}
<ColorPickerControl
withFullColor={props.withFullColor}
name={props.name}
gradient={true}
index={i}
gradientColor={e}
updateGradient={updateGradient}
/>
</Box>
))}
<Box textAlign="right" mt={3}>
<Button
variant="ghost"
size="xs"
onClick={() => setGradientColor([...gradientColor, 'blue.500'])}
>
+ Add
</Button>
</Box>
</>
)
}
Example #3
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>
))}
</>
)
}