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

Dev #32

Merged
merged 2 commits into from
Dec 10, 2023
Merged

Dev #32

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: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"serve": "python3 -m http.server -d dist"
},
"dependencies": {
"jsx-dom-runtime": "^0.59.0",
"jsx-dom-runtime": "^0.60.0",
"rgb-hex": "^4.1.0",
"storeon-velo": "^5.0.0-rc.0",
"tinykeys": "^2.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/components/ColorPicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { RefCallback } from 'jsx-dom-runtime';
import { HexAlphaBase } from 'vanilla-colorful/lib/entrypoints/hex-alpha';

import s from './styles.css';
Expand All @@ -9,7 +10,7 @@ customElements.define('color-picker', HexAlphaBase);
export const ColorPicker: JSX.FC = () => {
const isBigScreen = /*#__PURE__*/ matchMedia('(min-width:700px)').matches;

const ready = (node: HexAlphaBase) => {
const ready: RefCallback<HexAlphaBase> = (node) => {
connect('hex', (state) => {
node.color = '#' + state.hex;
});
Expand Down
17 changes: 8 additions & 9 deletions src/components/Download/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RefCallback } from 'jsx-dom-runtime';
import type { MouseEventHandler } from 'jsx-dom-runtime';

import s from './styles.css';
import { getState } from '../../store';
Expand All @@ -22,14 +22,13 @@ const content = (
);

export const Download: JSX.FC = () => {
const linkHandler: RefCallback<HTMLAnchorElement> = (link) =>
link.addEventListener('click', () => {
const { hex, a } = getState();
const canvas = createCanvas(hex, a);
const linkHandler: MouseEventHandler<HTMLAnchorElement> = ({ currentTarget: link }) => {
const { hex, a } = getState();
const canvas = createCanvas(hex, a);

link.download = createName(hex);
link.href = canvas.toDataURL(TYPE, QUALITY);
});
link.download = createName(hex);
link.href = canvas.toDataURL(TYPE, QUALITY);
};

const buttonHandler: EventListener = async () => {
const { hex, a } = getState();
Expand Down Expand Up @@ -57,7 +56,7 @@ export const Download: JSX.FC = () => {
{content}
</button>
) : (
<a ref={linkHandler} role="button" class={s.btn} href="#">
<a onclick={linkHandler} role="button" class={s.btn} href="#">
{content}
</a>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/HexInputs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { RefCallback } from 'jsx-dom-runtime';

import s from './styles.css';
import { Group } from '../Group';
import { DataList } from './DataList';
import { NOT_HEXADECIMAL, getHex } from '../../utils';
import { connect, dispatch } from '../../store';

export const HexInputs: JSX.FC = () => {
const readyColor = (color: HTMLInputElement) => {
const readyColor: RefCallback<HTMLInputElement> = (color) => {
color.addEventListener('change', () => {
const hex = getHex(color.value);

Expand All @@ -19,7 +21,7 @@ export const HexInputs: JSX.FC = () => {
});
};

const readyAlpha = (alpha: HTMLInputElement) => {
const readyAlpha: RefCallback<HTMLInputElement> = (alpha) => {
alpha.addEventListener('change', () => {
const val = alpha.value
.trim()
Expand Down
10 changes: 4 additions & 6 deletions src/components/Output/RadixSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import type { RefCallback } from 'jsx-dom-runtime';
import type { GenericEventHandler } from 'jsx-dom-runtime';

import s from './RadixSelect.css';
import { setState } from '../../store';

export const RadixSelect: JSX.FC = () => {
const ready: RefCallback<HTMLSelectElement> = (node) =>
node.addEventListener('change', () =>
setState({ radix: ~~node.value }),
);
const change: GenericEventHandler<HTMLSelectElement> = (event) =>
setState({ radix: ~~event.currentTarget.value });

return (
<select
ref={ready}
onchange={change}
class={s.radix}
aria-label="byte base"
>
Expand Down
10 changes: 4 additions & 6 deletions src/components/Output/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RefObject } from 'jsx-dom-runtime';
import type { RefObject, MouseEventHandler } from 'jsx-dom-runtime';

import s from './TextInput.css';
import { setState } from '../../store';
Expand All @@ -8,11 +8,9 @@ interface Props {
ref: RefObject<HTMLInputElement>;
}

const copy: EventListener = (event) => {
const el = event.target as HTMLInputElement;

el.select();
navigator.clipboard.writeText(el.value);
const copy: MouseEventHandler<HTMLInputElement> = ({ currentTarget: input }) => {
input.select();
navigator.clipboard.writeText(input.value);
setState({ toast: true });
};

Expand Down
7 changes: 3 additions & 4 deletions src/components/RgbaInputs/PairInputs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef } from 'jsx-dom-runtime';
import { useRef, type InputEventHandler } from 'jsx-dom-runtime';

import s from './PairInputs.css';
import type { TRgba } from '../../store/types';
Expand All @@ -13,9 +13,8 @@ export const PairInputs: JSX.FC<Props> = ({ param }) => {
const range = useRef<HTMLInputElement>();
const label = `color channel "${param}"`;

const input: EventListener = (event) => {
const el = event.target as HTMLInputElement;
const val = ~~el.valueAsNumber;
const input: InputEventHandler<HTMLInputElement> = (event) => {
const val = ~~event.currentTarget.valueAsNumber;

dispatch('rgba', [param, val > 255 ? 255 : val]);
};
Expand Down