-
-
Notifications
You must be signed in to change notification settings - Fork 16
Add support for full image backgrounds #20
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
Add support for full image backgrounds #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's some initial feedback! Good start
api/_lib/parser.ts
Outdated
md: md === '1' || md === 'true', | ||
fontFamily: fontFamily === 'roboto-condensed' ? 'Roboto Condensed' : 'Source Sans Pro', | ||
imageUrl: imageUrl === ''? '': '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic doesn't make sense to me...it says "If the imageUrl is an empty string, return an empty string. Otherwise return an empty string".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zackkrida I agree with you completely on this, kindly refer to this discussion once where I have gone in-depth with issues faced by me, and why I had to use the syntax that I used. I would love your inputs
api/_lib/parser.ts
Outdated
@@ -35,8 +39,10 @@ export function parseRequest(req: IncomingMessage) { | |||
fileType: extension === 'jpeg' ? extension : 'png', | |||
text: decodeURIComponent(text), | |||
theme: theme === 'dark' ? 'dark' : 'light', | |||
backgroundType: backgroundType === 'image' ? 'image' : 'pattern', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backgroundType: backgroundType === 'image' ? 'image' : 'pattern', | |
backgroundType |
This should be all we need (the shorthand for backgroundType: backgroundType
). Since background type can only be 'image' or 'pattern', we can just assign it directly without the use of the ternary logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @zackkrida I tried doing just that, but I am getting the following error:
The type of backgroundType
is BackgroundType
, but we assign to it the backgroundType
received from the destructing {backgroundType} = query || {}
, hence it's type is string | undefined
. Thus we need to only assign it when it is a `string.
Let me know if there is any better method to do this in your mind (Perhaps converting it to a string before assigning it below?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can see the same syntax used for theme: theme === 'dark' ? 'dark' : 'light',
Where theme on the left is of the type Theme
and the one on the right is of the type string | undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zackkrida I'm waiting for your valuable inputs on this.
const backgroundOptions: DropdownOption[] = [ | ||
{ text: 'Pattern', value: 'pattern' }, | ||
{ text: 'Image', value: 'image' }, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good
Hey Zack, I completely missed this review on my PR because I just realised that my notifications were turned off... I was waiting for you to reply on my comment in the main issue page instead. I'll immediately make the requested changes and go ahead with my PR |
Co-authored-by: Zack Krida <zackkrida@pm.me>
Fixes
Fixes #12 by @zackkrida
Description
The following goals have been achieved and the PR is a work in progress:
Tests
Screenshots
Checklist
Update index.md
).main
ormaster
).visible errors.
Developer Certificate of Origin
Developer Certificate of Origin