-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add header name suggestions (#31)
- Loading branch information
Showing
6 changed files
with
231 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react"; | ||
|
||
const escapeRegExp = (str: string): string => | ||
str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | ||
|
||
const Highlight = ({ | ||
highlight, | ||
text, | ||
}: { | ||
highlight: string; | ||
text: string; | ||
}) => { | ||
if (!highlight.trim()) { | ||
return text; | ||
} | ||
|
||
const highlightChars = highlight.split("").map(escapeRegExp).join("|"); | ||
const regex = new RegExp(`(${highlightChars})`, "gi"); | ||
|
||
return text.split(regex).map((part, index) => | ||
regex.test(part) ? ( | ||
<mark className="font-bold bg-zuplo-primary/50 text-white" key={index}> | ||
{part} | ||
</mark> | ||
) : ( | ||
part | ||
), | ||
); | ||
}; | ||
|
||
export default Highlight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
import React from "react"; | ||
import cn from "classnames"; | ||
|
||
const Input = ({ | ||
value, | ||
onChange, | ||
className, | ||
textarea, | ||
...props | ||
}: { textarea?: boolean } & React.InputHTMLAttributes< | ||
HTMLInputElement | HTMLTextAreaElement | ||
>) => { | ||
type InputProps = { | ||
textarea?: boolean; | ||
} & React.InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>; | ||
|
||
const Input = React.forwardRef< | ||
HTMLInputElement | HTMLTextAreaElement, | ||
InputProps | ||
>(({ value, onChange, className, textarea, ...props }, ref) => { | ||
const Comp = textarea ? "textarea" : "input"; | ||
return ( | ||
<Comp | ||
ref={ref as any} | ||
value={value} | ||
onChange={onChange} | ||
className={cn( | ||
"bg-transparent border font-mono p-1 px-2 border-slate-700 flex-grow rounded", | ||
"focus:ring-4 focus:outline-none focus:ring-slate-700/50", | ||
"focus:ring-4 focus:outline-none focus:ring-slate-700/50 hover:bg-black/25", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
}); | ||
|
||
Input.displayName = "Input"; | ||
|
||
export default Input; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export const CommonHeaders = [ | ||
"Accept", | ||
"Accept-Charset", | ||
"Accept-Encoding", | ||
"Accept-Language", | ||
"Accept-Patch", | ||
"Accept-Ranges", | ||
"Access-Control-Allow-Credentials", | ||
"Access-Control-Allow-Headers", | ||
"Access-Control-Allow-Methods", | ||
"Access-Control-Allow-Origin", | ||
"Access-Control-Expose-Headers", | ||
"Access-Control-Max-Age", | ||
"Age", | ||
"Authorization", | ||
"Cache-Control", | ||
"Connection", | ||
"Content-Disposition", | ||
"Content-Encoding", | ||
"Content-Language", | ||
"Content-Length", | ||
"Content-Location", | ||
"Content-Range", | ||
"Content-Security-Policy", | ||
"Content-Transfer-Encoding", | ||
"Content-Type", | ||
"Date", | ||
"ETag", | ||
"Expect", | ||
"Expires", | ||
"Forwarded", | ||
"If-Match", | ||
"If-Modified-Since", | ||
"If-None-Match", | ||
"If-Unmodified-Since", | ||
"Keep-Alive", | ||
"Last-Modified", | ||
"Link", | ||
"Location", | ||
"Origin", | ||
"Pragma", | ||
"Proxy-Authenticate", | ||
"Range", | ||
"Referer", | ||
"Referrer-Policy", | ||
"Retry-After", | ||
"Server", | ||
"Set-Cookie", | ||
"Strict-Transport-Security", | ||
"TE", | ||
"Trailer", | ||
"Transfer-Encoding", | ||
"Upgrade", | ||
"User-Agent", | ||
"Vary", | ||
"Via", | ||
"WWW-Authenticate", | ||
"Warning", | ||
"X-Content-Type-Options", | ||
"X-DNS-Prefetch-Control", | ||
"X-Forwarded-For", | ||
"X-Frame-Options", | ||
"X-Powered-By", | ||
"X-Requested-With", | ||
"X-Robots-Tag", | ||
"X-UA-Compatible", | ||
"X-XSS-Protection", | ||
"X-XSS-Protection", | ||
]; |