Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

color box enhancements #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react": "^17.0.1",
"react-color": "^2.19.3",
"react-dom": "^17.0.1",
"react-json-pretty": "^2.2.0",
"react-redux": "^7.2.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
Expand Down
10 changes: 10 additions & 0 deletions public/copyIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/main-app/sidebar-wrapper/colors-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ColorsInput() {
<a
href="#add"
onClick={() => addColor()}
class="iconButton fa fa-lg fa-plus"
className="iconButton fa fa-lg fa-plus"
>
{' '}
</a>
Expand Down
16 changes: 15 additions & 1 deletion src/components/main-app/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { URL_COLORS, URL_OPACITY } from 'config';
import React, { useEffect, useState } from 'react';
import { StringParam, useQueryParam } from 'use-query-params';
import { copyColor, getColorsArray } from 'utils';
import JSONPretty from 'react-json-pretty';
import {
TilesInput,
ShapeInput,
Expand All @@ -14,6 +15,8 @@ export default function Sidebar() {
const [opacity] = useQueryParam(URL_OPACITY, StringParam);
const [text, setText] = useState('');

const data = JSON.stringify(text);

useEffect(() => {
const colorArray = getColorsArray(colors);
setText(copyColor(colorArray, opacity));
Expand All @@ -37,7 +40,18 @@ export default function Sidebar() {
<AlphaInput />
<br />
<br />
<div>{JSON.stringify(text)}</div>
<div>
<JSONPretty themeClassName="custom-json-pretty" id="json-pretty" data={data}></JSONPretty>
<div style={{marginTop: '10px' }}>
<button
onClick={() => {
navigator.clipboard.writeText(data);
}}
>
Copy
</button>
</div>
</div>
</div>
</div>
);
Expand Down