Skip to content

Commit

Permalink
add text gradient (premieroctet#118)
Browse files Browse the repository at this point in the history
* add text gradient

* fix hex colorpicker
  • Loading branch information
PierreCrb authored Sep 12, 2022
1 parent 6de48fc commit 26f08c3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/inspector/controls/GradientControl.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactNode, useState, memo, useEffect } from 'react'
import { Box, Select, Button, IconButton } from '@chakra-ui/react'
import { Box, Select, Button, IconButton, Checkbox } from '@chakra-ui/react'
import { SmallCloseIcon } from '@chakra-ui/icons'
import FormControl from './FormControl'
import { useForm } from '~hooks/useForm'
Expand Down Expand Up @@ -28,6 +28,7 @@ const GradientControl = (props: GradientControlPropsType) => {
const [gradientColor, setGradientColor] = useState(['green.200'])
const [directionValue, setDirectionValue] = useState('to right')
const gradient = usePropsSelector(props.name)
const textGradient = usePropsSelector('bgClip')

const choices = props.options

Expand Down Expand Up @@ -108,6 +109,16 @@ const GradientControl = (props: GradientControlPropsType) => {
))}
</Select>
</FormControl>
<FormControl label="Clip to Text">
<Checkbox
defaultChecked={textGradient}
onChange={e =>
e.target.checked
? setValue('bgClip', `text`)
: setValue('bgClip', null)
}
/>
</FormControl>

{gradientColor.map((e, i) => (
<Box textAlign="right" mt={3} key={i}>
Expand All @@ -125,7 +136,7 @@ const GradientControl = (props: GradientControlPropsType) => {
<ColorPickerControl
withFullColor={props.withFullColor}
name={props.name}
gradient={true}
gradient
index={i}
gradientColor={e}
updateGradient={updateGradient}
Expand Down

0 comments on commit 26f08c3

Please sign in to comment.