Skip to content

Commit ba78730

Browse files
committed
client: base for img upload
1 parent 263cd14 commit ba78730

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

client/src/components/lines/NewBadge.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { GoPlus } from "react-icons/go";
66
import ColorInput from "../ui/ColorInput";
77
import { useState } from "react";
88
import { HEX_COLOR_REGEX, ICON_REGEX } from "../../const";
9+
import SvgInput from "./SvgInput";
910

1011
type Props = {
1112
addBadge: (badge: Badge) => void;
@@ -18,9 +19,8 @@ const NewBadge = ({ addBadge }: Props) => {
1819

1920
return (
2021
<fieldset className="flex items-start gap-4">
21-
<InputWrapper description="The name of the icon">
22-
<Input
23-
formNoValidate
22+
<InputWrapper description="The icon in the badge">
23+
<SvgInput
2424
value={icon}
2525
onChange={(e) => setIcon(e.target.value)}
2626
placeholder="react"
@@ -29,7 +29,6 @@ const NewBadge = ({ addBadge }: Props) => {
2929

3030
<InputWrapper description="The label shown on the badge">
3131
<Input
32-
formNoValidate
3332
value={label}
3433
onChange={(e) => setLabel(e.target.value)}
3534
placeholder="react"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { InputHTMLAttributes, forwardRef } from "react";
2+
import Input from "../ui/Input";
3+
import { cn } from "../ui/utils";
4+
import { AiOutlineCloudUpload } from "react-icons/ai";
5+
import Button from "../ui/Button";
6+
7+
// eslint-disable-next-line
8+
interface SvgInputProps
9+
extends Omit<InputHTMLAttributes<HTMLInputElement>, "type"> {}
10+
11+
const SvgInput = forwardRef<HTMLInputElement, SvgInputProps>(
12+
({ className, required, value = "", ...props }, ref) => {
13+
return (
14+
<div className={cn("group flex items-stretch", className)}>
15+
<Input
16+
ref={ref}
17+
value={value}
18+
type="text"
19+
required={required}
20+
pattern={`^${required ? "" : "[]{0}|"}#[a-fA-F0-9]{6}$`}
21+
className="z-10 rounded-br-none rounded-tr-none transition-none [border-right:none!important]"
22+
{...props}
23+
/>
24+
25+
<Button
26+
variant="secondary"
27+
className="rounded-bl-none rounded-tl-none bg-gh-bg px-3 text-lg"
28+
icon={<AiOutlineCloudUpload />}
29+
/>
30+
</div>
31+
);
32+
}
33+
);
34+
35+
export default SvgInput;

client/src/components/ui/ColorInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const ColorInput = forwardRef<HTMLInputElement, ColorInputProps>(
1717
type="text"
1818
required={required}
1919
pattern={`^${required ? "" : "[]{0}|"}#[a-fA-F0-9]{6}$`}
20-
className="z-10 rounded-br-none rounded-tr-none transition-none"
20+
className="z-10 rounded-br-none rounded-tr-none transition-none [border-right:none!important]"
2121
{...props}
2222
/>
2323

@@ -26,7 +26,7 @@ const ColorInput = forwardRef<HTMLInputElement, ColorInputProps>(
2626
value={
2727
HEX_COLOR_REGEX.test(value.toString() ?? "") ? value : "#58a6ff"
2828
}
29-
className="h-[30.67px] w-10 rounded-br-md rounded-tr-md border border-l-0 border-gh-border bg-gh-bg-dark px-2 py-1 outline-0 outline-offset-0 outline-gh-blue [outline-style:solid]"
29+
className="h-[30.67px] w-10 cursor-pointer rounded-br-md rounded-tr-md border border-gh-border bg-gh-bg px-2 py-1 outline-0 outline-offset-0 outline-gh-blue transition-all duration-150 [outline-style:solid] hover:border-gh-border-active hover:bg-gh-gray-active"
3030
{...props}
3131
/>
3232
</div>

0 commit comments

Comments
 (0)