Skip to content

Commit 572f70d

Browse files
committed
client: the new card now supports auto as a value
1 parent ac32f61 commit 572f70d

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

client/src/components/form/PageSix.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ const PageSix = () => {
1111
<FormWrapper title="Badges">
1212
<P>
1313
On this page you can customize the most important part of the card: the
14-
badges. You set the number of lines you want on the previous page.
14+
badges. You have already set the number of lines you want on the
15+
previous page.
1516
</P>
1617

1718
<Quote variant="Info">
18-
You can drag and drop the badges to rearrange them or double-click to
19-
delete them.
19+
&minus; You can drag and drop the badges to rearrange them or
20+
double-click to delete them.
21+
<br />
22+
&minus; To infer the original icon color, you can type "auto" instead of
23+
picking a color from the color picker.
2024
</Quote>
2125

2226
{card.lines.map((line) => (

client/src/components/lines/NewBadge.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,16 @@ const NewBadge = ({ addBadge }: Props) => {
8686
value={color}
8787
onChange={(e) => setColor(e.target.value)}
8888
setColor={(c) => setColor(c)}
89-
placeholder={file === null ? "#58a6ff" : ""}
89+
placeholder={file === null ? "#58a6ff" : "auto"}
90+
canBeAuto={true}
9091
/>
9192
</InputWrapper>
9293

9394
<Button
9495
disabled={
9596
!(file === null
96-
? HEX_COLOR_REGEX.test(color) && ICON_REGEX.test(icon)
97+
? (HEX_COLOR_REGEX.test(color) || color.toLowerCase() === "auto") &&
98+
ICON_REGEX.test(icon)
9799
: true)
98100
}
99101
aria-label="Add Badge"

client/src/components/ui/ColorInput.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ import { BsArrowRepeat } from "react-icons/bs";
1111
interface ColorInputProps
1212
extends Omit<InputHTMLAttributes<HTMLInputElement>, "type"> {
1313
setColor: (color: string) => void;
14+
canBeAuto?: boolean;
1415
}
1516

1617
const ColorInput = forwardRef<HTMLInputElement, ColorInputProps>(
17-
({ className, required, value = "", disabled, setColor, ...props }, ref) => {
18+
(
19+
{
20+
className,
21+
required,
22+
value = "",
23+
disabled,
24+
setColor,
25+
canBeAuto = false,
26+
...props
27+
},
28+
ref
29+
) => {
1830
value = value.toString();
1931

2032
const [isPickerActive, setIsPickerActive] = useState(false);
@@ -33,7 +45,9 @@ const ColorInput = forwardRef<HTMLInputElement, ColorInputProps>(
3345
onFocus={() => setIsPickerActive(true)}
3446
type="text"
3547
required={required}
36-
pattern={`^${required ? "" : "[]{0}|"}#[a-fA-F0-9]{6}$`}
48+
pattern={`^${required ? "" : "[]{0}|"}${
49+
canBeAuto ? "auto|" : ""
50+
}#[a-fA-F0-9]{6}$`}
3751
className={cn(
3852
"z-10 rounded-br-none rounded-tr-none [border-right:none!important]",
3953
isPickerActive ? "outline-2 outline-gh-blue" : ""

client/src/const.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Card } from "./types";
22

3-
export const ICON_REGEX = /^[a-zA-Z-_ ]{2,32}$/;
3+
export const ICON_REGEX = /^[a-zA-Z-_. ]{2,32}$/;
44
export const HEX_COLOR_REGEX = /#[a-fA-F0-9]{6}$/;
55
export const INITIAL_CARD: Card = {
66
title: "My Tech Stack",

0 commit comments

Comments
 (0)