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

feat: Invite to OpenSauced #20

Merged
merged 31 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9f73529
refactor: Moved matchers to a separate dir
Anush008 Apr 18, 2023
a833452
chore: Updated getOpenSaucedUser() to return a bool
Anush008 Apr 18, 2023
8269c6f
refactor: Moved injectViewOnOpenSauced to utils
Anush008 Apr 18, 2023
96c19b3
feat: Invite to OS(WIP)
Anush008 Apr 18, 2023
913a3e0
chore: Removed unused listener
Anush008 Apr 18, 2023
74bdbb7
chore: Fomatting
Anush008 Apr 18, 2023
46e2393
chore: Fomatting
Anush008 Apr 18, 2023
2f93509
chore: Added social icons span
Anush008 Apr 18, 2023
c9fef90
chore: Removed explicit book return and err handling
Anush008 Apr 19, 2023
a1bfa7b
Update src/components/InviteToOpenSauced/InviteToOpenSaucedModal.ts
Anush008 Apr 19, 2023
67efb60
chore: Top level await for getOpenSaucedUser()
Anush008 Apr 19, 2023
c7c72ef
chores: Aggregated matchers, updated file-names
Anush008 Apr 19, 2023
0350a97
chore: createHtmlElement() with added typings
Anush008 Apr 19, 2023
40a45ee
chore: Updated elements to use the new createHtmlElement()
Anush008 Apr 19, 2023
9c138ae
refactor: restructured utilities
Anush008 Apr 19, 2023
ddba946
chore: remove config imports for now
Anush008 Apr 19, 2023
817a4a5
chore: Improved typing in createHtmlElement() and formatting
Anush008 Apr 19, 2023
6ac449b
chore: Added conditional rendering of social share icons
Anush008 Apr 19, 2023
c96682a
Merge branch 'main' into invite-to-opensauced
Anush008 Apr 20, 2023
e792985
chore: updated injector functions for empty bio
Anush008 Apr 20, 2023
275bba3
chore: Updated button-text sizing
Anush008 Apr 20, 2023
3b06d3c
chore: Updated LinkedIn share button href
Anush008 Apr 20, 2023
9612f4e
chore: updated null checks
Anush008 Apr 20, 2023
6d0c1e6
chore: Updated inviteToOS button colors
Anush008 Apr 20, 2023
4d566a5
chore: Update LinkedIn username matcher and modal sizing
Anush008 Apr 20, 2023
4ebfe46
Apply copy suggestions from code review
bdougie Apr 20, 2023
f1f8128
Apply injectViewOnOS rename suggestions from code review
bdougie Apr 20, 2023
9e156f1
refactor: renamedViewOnOpenSauced()
Anush008 Apr 21, 2023
6066c99
refactor: updated matcher file name and imports
Anush008 Apr 21, 2023
7a91203
refactor: Moved the modal display trigger to the component definition
Anush008 Apr 21, 2023
b303f2b
chore: update matchers filename to urlMatchers
Anush008 Apr 21, 2023
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
3 changes: 1 addition & 2 deletions src/components/InviteToOpenSauced/InviteToOpenSaucedModal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "../../index.css";
import { TEST } from "../../config.json";

interface Socials {
emailAddress?: string;
Expand All @@ -9,7 +8,7 @@ interface Socials {

export const InviteToOpenSaucedModal = (
username: string,
{ mailAddress, twitterUsername, linkedInUsername }: Socials = {}
{ emailAddress, twitterUsername, linkedInUsername }: Socials = {}
) => {
//TODO: Conditionally render social icons
const socialIcons = `<span class="flex flex-nowrap space-x-3"> <a href="https://github.com/bdougie">
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fetchOpenSaucedApiData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const getOpenSaucedUser = async (username) => {
export const getOpenSaucedUser = async (username: string) => {
try {
const response = await fetch(`https://api.opensauced.pizza/v1/users/${username}`);
return response.status === 200;
Expand Down
10 changes: 5 additions & 5 deletions src/utils/invite-to-OS.ts β†’ src/utils/inviteToOpenSauced.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//import {USER_BIO_SELECTOR} from "../config.json";
import { InviteToOpenSaucedButton } from "../components/InviteToOpenSauced/InviteToOpenSaucedButton";
import { InviteToOpenSaucedModal } from "../components/InviteToOpenSauced/InviteToOpenSaucedModal";
import { getTwitterUsername } from "./matchers/tw-username-matcher";
import { getLinkedInUsername } from "./matchers/li-username-matcher";
import { getTwitterUsername } from "./matchers";
Anush008 marked this conversation as resolved.
Show resolved Hide resolved
import { getLinkedInUsername } from "./matchers";

const injectViewOnOS = (username: string) => {
const mailAddress: string | undefined = (
const emailAddress: string | undefined = (
document.querySelector(`a[href^="mailto:"]`) as HTMLAnchorElement
)?.href.substr(7);
const twitterUrl: string | undefined = (
Expand All @@ -15,13 +15,13 @@ const injectViewOnOS = (username: string) => {
document.querySelector(`a[href*="linkedin.com"]`) as HTMLAnchorElement
)?.href;
console.log(linkedInUrl);
if (!(mailAddress || twitterUrl || linkedInUrl)) return;
if (!(emailAddress || twitterUrl || linkedInUrl)) return;

const twitterUsername = twitterUrl && getTwitterUsername(twitterUrl);
const linkedInUsername = linkedInUrl && getLinkedInUsername(linkedInUrl);
const inviteToOpenSaucedButton = InviteToOpenSaucedButton();
const inviteToOpenSaucedModal = InviteToOpenSaucedModal(username, {
mailAddress,
emailAddress,
twitterUsername,
linkedInUsername,
});
Expand Down
18 changes: 18 additions & 0 deletions src/utils/matchers.ts
diivi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const getGithubUsername = (url: string) => {
const match = url.match(/github\.com\/([^/]+)/);
return match && match[1];
};

export const getLinkedInUsername = (url: string) => {
const match = url.match(
/https:\/\/www\.linkedin\.com\/in\/(?<username>[a-zA-Z0-9]{3,100})\/?/
);
return match ? match[1] : undefined;
};

export const getTwitterUsername = (url: string) => {
const match = url.match(
/(?:https?:\/\/)?(?:www\.)?twitter\.com\/(?:#!\/)?@?([^\/\?\s]*)/
);
return match ? match[1] : undefined;
};
4 changes: 0 additions & 4 deletions src/utils/matchers/gh-username-matcher.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/utils/matchers/li-username-matcher.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/utils/matchers/tw-username-matcher.ts

This file was deleted.

Anush008 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//import {USER_BIO_SELECTOR} from "../config.json" assert { type: 'json' };
import { ViewOnOpenSaucedButton } from "../components/ViewOnOpenSaucedButton/ViewOnOpenSaucedButton";

const injectViewOnOpenSauced = (username: string) => {
Expand Down