|
@@ -1,13 +1,11 @@
|
|
|
-import { Form, Switch, Button, Popover, Select } from 'antd';
|
|
|
+import { Form, Switch, Select } from 'antd';
|
|
|
import hljs from 'highlight.js/lib/core';
|
|
|
import React from 'react';
|
|
|
-import { ChromePicker } from 'react-color';
|
|
|
import styled from 'styled-components';
|
|
|
import shallow from 'zustand/shallow';
|
|
|
import { breakpoints } from '../layout';
|
|
|
import { rgbToString } from './Output';
|
|
|
-import { SectionTitle } from './SectionTitle';
|
|
|
-import SliderInput from './SliderInput';
|
|
|
+import { SectionTitle, SliderInput, ChromePickerColor, ColorPicker } from './subcomponents';
|
|
|
import { ColorType, useInputStore } from '~/components/store';
|
|
|
|
|
|
export const CssControls: React.FC = () => {
|
|
@@ -72,41 +70,17 @@ export const CssControls: React.FC = () => {
|
|
|
<Select.Option value="conic">conic</Select.Option>
|
|
|
</Select>
|
|
|
</Form.Item>
|
|
|
- <ColorPick>
|
|
|
- <Popover
|
|
|
- placement="bottom"
|
|
|
- style={{ padding: 0 }}
|
|
|
- content={
|
|
|
- <ChromePicker
|
|
|
- color={color1}
|
|
|
- onChange={(c: ChromePickerColor) => setValues('color1', c.rgb)}
|
|
|
- />
|
|
|
- }
|
|
|
- trigger="click"
|
|
|
- >
|
|
|
- <ColorAndButton>
|
|
|
- <ColorSample color={rgbToString(color1)} />
|
|
|
- <Button>Color 1</Button>
|
|
|
- </ColorAndButton>
|
|
|
- </Popover>
|
|
|
- </ColorPick>
|
|
|
- <ColorPick>
|
|
|
- <Popover
|
|
|
- placement="bottom"
|
|
|
- content={
|
|
|
- <ChromePicker
|
|
|
- color={color2}
|
|
|
- onChange={(c: ChromePickerColor) => setValues('color2', c.rgb)}
|
|
|
- />
|
|
|
- }
|
|
|
- trigger="click"
|
|
|
- >
|
|
|
- <ColorAndButton>
|
|
|
- <ColorSample color={rgbToString(color2)} />
|
|
|
- <Button>Color 2</Button>
|
|
|
- </ColorAndButton>
|
|
|
- </Popover>
|
|
|
- </ColorPick>
|
|
|
+ <ColorPicker
|
|
|
+ label="Color 1"
|
|
|
+ color={color1}
|
|
|
+ style={{ padding: 0 }}
|
|
|
+ onChange={(c: ChromePickerColor) => setValues('color1', c.rgb)}
|
|
|
+ />
|
|
|
+ <ColorPicker
|
|
|
+ label="Color 2"
|
|
|
+ color={color2}
|
|
|
+ onChange={(c: ChromePickerColor) => setValues('color2', c.rgb)}
|
|
|
+ />
|
|
|
</GradientControls>
|
|
|
|
|
|
{['linear', 'conic'].includes(gradientType) && (
|
|
@@ -152,46 +126,9 @@ export const CssControls: React.FC = () => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-//https://casesandberg.github.io/react-color/
|
|
|
-type ChromePickerColor = {
|
|
|
- hex: string;
|
|
|
- rgb: {
|
|
|
- r: number;
|
|
|
- g: number;
|
|
|
- b: number;
|
|
|
- a: number;
|
|
|
- };
|
|
|
- hsl: {
|
|
|
- h: number;
|
|
|
- s: number;
|
|
|
- l: number;
|
|
|
- a: number;
|
|
|
- };
|
|
|
-};
|
|
|
-
|
|
|
const GradientControls = styled.div`
|
|
|
display: flex;
|
|
|
@media screen and (max-width: ${breakpoints.md - 1}px) {
|
|
|
flex-direction: column;
|
|
|
}
|
|
|
`;
|
|
|
-
|
|
|
-const ColorPick = styled.div`
|
|
|
- margin-left: 15px;
|
|
|
- @media screen and (max-width: ${breakpoints.md - 1}px) {
|
|
|
- margin: 10px 0;
|
|
|
- }
|
|
|
-`;
|
|
|
-
|
|
|
-const ColorSample = styled.div`
|
|
|
- width: 30px;
|
|
|
- height: 30px;
|
|
|
- background: linear-gradient(0, ${(p) => p.color}, ${(p) => p.color}), url(/checkers.png);
|
|
|
- border-radius: 1px;
|
|
|
- cursor: pointer;
|
|
|
-`;
|
|
|
-
|
|
|
-const ColorAndButton = styled.div`
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
-`;
|