Style tweaks to the color picker

(temporary, until Mariusz re-works the color picker)
This commit is contained in:
Aria Minaei 2022-04-20 12:52:54 +02:00
parent a2cee85ee8
commit 567c83f957
7 changed files with 49 additions and 40 deletions

View file

@ -13,7 +13,7 @@ import {RgbaColorPicker} from '@theatre/studio/uiComponents/colorPicker'
import styled from 'styled-components' import styled from 'styled-components'
import usePopover from '@theatre/studio/uiComponents/Popover/usePopover' import usePopover from '@theatre/studio/uiComponents/Popover/usePopover'
import BasicStringInput from '@theatre/studio/uiComponents/form/BasicStringInput' import BasicStringInput from '@theatre/studio/uiComponents/form/BasicStringInput'
import BasicPopover from '@theatre/studio/uiComponents/Popover/BasicPopover' import {popoverBackgroundColor} from '@theatre/studio/uiComponents/Popover/BasicPopover'
const RowContainer = styled.div` const RowContainer = styled.div`
display: flex; display: flex;
@ -31,7 +31,7 @@ const Puck = styled.div.attrs<PuckProps>((props) => ({
background: props.background, background: props.background,
}, },
}))<PuckProps>` }))<PuckProps>`
height: calc(100% - 4px); height: calc(100% - 12px);
aspect-ratio: 1; aspect-ratio: 1;
border-radius: 2px; border-radius: 2px;
` `
@ -42,6 +42,24 @@ const HexInput = styled(BasicStringInput)`
const noop = () => {} const noop = () => {}
const Popover = styled.div`
position: absolute;
background-color: ${popoverBackgroundColor};
color: white;
padding: 0;
margin: 0;
cursor: default;
border-radius: 3px;
z-index: 10000;
backdrop-filter: blur(8px);
padding: 4;
pointer-events: all;
border: none;
box-shadow: none;
`
const RgbaPropEditor: React.FC<{ const RgbaPropEditor: React.FC<{
propConfig: PropTypeConfig_Rgba propConfig: PropTypeConfig_Rgba
pointerToProp: SheetObject['propsP'] pointerToProp: SheetObject['propsP']
@ -65,13 +83,7 @@ const RgbaPropEditor: React.FC<{
const [popoverNode, openPopover] = usePopover({}, () => { const [popoverNode, openPopover] = usePopover({}, () => {
return ( return (
<BasicPopover> <Popover>
<div
style={{
margin: 8,
pointerEvents: 'all',
}}
>
<RgbaColorPicker <RgbaColorPicker
color={{ color={{
r: stuff.value.r, r: stuff.value.r,
@ -90,8 +102,7 @@ const RgbaPropEditor: React.FC<{
}} }}
discardTemporaryValue={stuff.discardTemporaryValue} discardTemporaryValue={stuff.discardTemporaryValue}
/> />
</div> </Popover>
</BasicPopover>
) )
}) })

View file

@ -12,8 +12,8 @@ import styled from 'styled-components'
const Container = styled.div` const Container = styled.div`
position: relative; position: relative;
height: 24px; height: 16px;
border-radius: 4px; border-radius: 2px;
// Checkerboard // Checkerboard
background-color: #fff; background-color: #fff;
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><rect x="8" width="8" height="8"/><rect y="8" width="8" height="8"/></svg>'); background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><rect x="8" width="8" height="8"/><rect y="8" width="8" height="8"/></svg>');

View file

@ -15,7 +15,7 @@ import styled from 'styled-components'
const Container = styled.div` const Container = styled.div`
position: relative; position: relative;
display: flex; display: flex;
gap: 8px; gap: 4px;
flex-direction: column; flex-direction: column;
width: 200px; width: 200px;
height: 200px; height: 200px;

View file

@ -11,8 +11,8 @@ import styled from 'styled-components'
const Container = styled.div` const Container = styled.div`
position: relative; position: relative;
height: 24px; height: 16px;
border-radius: 4px; border-radius: 2px;
background: linear-gradient( background: linear-gradient(
to right, to right,

View file

@ -9,12 +9,12 @@ const Container = styled.div`
position: absolute; position: absolute;
z-index: 1; z-index: 1;
box-sizing: border-box; box-sizing: border-box;
width: 28px; width: 16px;
height: 28px; height: 16px;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
background-color: #fff; background-color: #fff;
border: 2px solid #fff; border: 1px solid #ffffff00;
border-radius: 4px; border-radius: 2px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
${StyledInteractive}:focus & { ${StyledInteractive}:focus & {

View file

@ -13,7 +13,7 @@ const Container = styled.div`
flex-grow: 1; flex-grow: 1;
border-color: transparent; /* Fixes https://github.com/omgovich/react-colorful/issues/139 */ border-color: transparent; /* Fixes https://github.com/omgovich/react-colorful/issues/139 */
border-bottom: 12px solid #000; border-bottom: 12px solid #000;
border-radius: 4px 4px 4px 4px; border-radius: 2px;
background-image: linear-gradient(to top, #000, rgba(0, 0, 0, 0)), background-image: linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); linear-gradient(to right, #fff, rgba(255, 255, 255, 0));

View file

@ -54,8 +54,6 @@ export function useColorManipulation<T extends AnyColor>(
!equalColorObjects(hsva, tempCache.current.hsva) && !equalColorObjects(hsva, tempCache.current.hsva) &&
!colorModel.equal(newColor, tempCache.current.color) !colorModel.equal(newColor, tempCache.current.color)
) { ) {
console.log('hsva', hsva)
console.log('hsva cache', tempCache.current.hsva)
tempCache.current = {hsva, color: newColor} tempCache.current = {hsva, color: newColor}
setEditingValue(newColor) setEditingValue(newColor)