Skip to content

Commit

Permalink
small ui and ux improvment for pop-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Alaev committed Dec 2, 2020
1 parent 930957a commit 45c4e73
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/components/colorTool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { h } from 'preact'
import { useState } from 'preact/hooks'
import { TwitterPicker } from 'react-color'

import { colorToolMode, gradientPickerStyle } from '../constants'
import {
colorToolMode,
gradientPickerStyle,
colorPickerLightStyle,
} from '../constants'
import GradientPicker from './gradientPicker'

import CloseSVG from './../assets/001-cross-sign.svg'
Expand Down Expand Up @@ -47,6 +51,7 @@ function ColorTool({
}

const isGradient = colorTool === colorToolMode.GRADIENT
const isColor = colorTool === colorToolMode.COLOR

return (
<div className="relative flex items-center w-full justify-evenly">
Expand Down Expand Up @@ -114,26 +119,32 @@ function ColorTool({
<div className="absolute w-full color-tool">
<button
onClick={() => setShowTool(false)}
className="absolute bottom-0 right-0 z-20 m-3 scale-in-center"
className="absolute top-0 right-0 z-20 m-3 scale-in-center"
>
{isDark ? (
<img src={CloseWhiteSVG} alt="close svg" width="10" />
) : (
<img src={CloseSVG} alt="close svg" width="10" />
)}
</button>
{colorTool === colorToolMode.COLOR && (
{isColor && (
<TwitterPicker
color={fillColor}
onChangeComplete={({ hex }) => handleColorChange(hex)}
width="100%"
z-index="20"
triangle="hide"
styles={isDark ? colorPickerDarkStyle : gradientPickerStyle}
className="scale-in-center"
styles={
isDark
? colorPickerDarkStyle
: isColor
? colorPickerLightStyle
: gradientPickerStyle
}
className="py-6 scale-in-center"
/>
)}
{colorTool === colorToolMode.GRADIENT && (
{isGradient && (
<GradientPicker
onGradColorsChange={onGradColorsChange}
gradColors={gradColors}
Expand Down
2 changes: 1 addition & 1 deletion src/components/gradientPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function GradientPicker({ gradColors, onGradColorsChange, isDark }) {
)

return (
<div className="flex flex-col w-full bg-white rounded-lg custom-shadow scale-in-center dark:bg-darkish-blue">
<div className="flex flex-col w-full py-6 bg-white rounded-lg custom-shadow scale-in-center dark:bg-darkish-blue">
<div className="flex">
{colorBoxes}
{gradientBox}
Expand Down
11 changes: 11 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ export const colorPickerDarkStyle = {
default: {
card: {
boxShadow: 'none',
borderRadius: '.5rem',
backgroundColor: 'hsl(210,38%,15%)',
},
},
}

export const colorPickerLightStyle = {
default: {
card: {
border: 'none',
borderRadius: '.5rem',
boxShadow: '0 16px 40px rgba(0,0,0,0.12)',
},
},
}

export const gradientPickerStyle = {
default: {
card: {
Expand Down
5 changes: 5 additions & 0 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,11 @@ video {
padding-right: 1.25rem;
}

.py-6 {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
}

.pb-0 {
padding-bottom: 0;
}
Expand Down

0 comments on commit 45c4e73

Please sign in to comment.