Skip to content

Commit

Permalink
feat: twitter provider (#743)
Browse files Browse the repository at this point in the history
* feat: twitter provider

* chore: build files

* chore: build again

* feat: add option to use legacy twitter logo

* incorporate review changes

* fix naming confustion

* update change log
  • Loading branch information
Chakravarthy7102 authored Sep 27, 2023
1 parent 0ad878b commit fbad845
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added new social provider `twitter`

- Introduced a new option `logo` for thirdparty custom providers to set a custom logo, just like the `name` property.

Following is an example of how to use this new `logo` property.
Expand Down
1 change: 1 addition & 0 deletions lib/build/recipe/thirdparty/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/build/recipe/thirdparty/providers/twitter.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/build/recipe/thirdpartyemailpassword/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/build/recipe/thirdpartypasswordless/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 41 additions & 18 deletions lib/build/thirdparty-shared.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/build/thirdparty.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/build/thirdpartyemailpassword.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/build/thirdpartypasswordless.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/ts/recipe/thirdparty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default class Wrapper {
static ActiveDirectory = ActiveDirectory;
static BoxySAML = BoxySAML;
static Okta = Okta;
static Twitter = Twitter;
static ComponentsOverrideProvider = RecipeComponentsOverrideContextProvider;
}

Expand Down
52 changes: 39 additions & 13 deletions lib/ts/recipe/thirdparty/providers/twitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ import type { BuiltInProviderConfig } from "./types";

import Provider from ".";

export type TwitterProviderConfig = BuiltInProviderConfig & {
useLegacyTwitterLogo?: boolean;
};

/*
* Class.
*/
export default class Twitter extends Provider {
private useLegacyTwitterLogo = false;
/*
* Static Attributes.
*/
Expand All @@ -33,34 +38,55 @@ export default class Twitter extends Provider {
/*
* Constructor.
*/
constructor(config?: BuiltInProviderConfig) {
constructor(config?: TwitterProviderConfig) {
let id = "x";
let name = "X";
const normalisedUseLegacyTwitterLogo = config?.useLegacyTwitterLogo === true;

if (normalisedUseLegacyTwitterLogo) {
id = "twitter";
name = "Twitter";
}

super({
id: "twitter",
name: "Twitter",
id,
name,
...config,
});

this.useLegacyTwitterLogo = normalisedUseLegacyTwitterLogo;
}

getLogo = (): JSX.Element => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="20.129" height="16.356" viewBox="0 0 20.129 16.356">
<g>
if (this.useLegacyTwitterLogo === true) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="20.129" height="16.356" viewBox="0 0 20.129 16.356">
<g>
<path
fill="#04ABEE"
d="M45.232 35.964a8.242 8.242 0 0 1-2.372.649 4.141 4.141 0 0 0 1.816-2.284 8.268 8.268 0 0 1-2.623 1 4.133 4.133 0 0 0-7.037 3.771 11.724 11.724 0 0 1-8.516-4.317 4.133 4.133 0 0 0 1.282 5.517 4.1 4.1 0 0 1-1.87-.517v.052a4.132 4.132 0 0 0 3.313 4.049 4.147 4.147 0 0 1-1.865.071 4.134 4.134 0 0 0 3.858 2.868 8.338 8.338 0 0 1-6.114 1.71 11.745 11.745 0 0 0 18.08-9.894q0-.268-.012-.534a8.374 8.374 0 0 0 2.061-2.137z"
transform="translate(34.799 -7.41) translate(2.201 4.266) translate(-62.103 -30.883)"
/>
<g>
<path
fill="#04ABEE"
d="M45.232 35.964a8.242 8.242 0 0 1-2.372.649 4.141 4.141 0 0 0 1.816-2.284 8.268 8.268 0 0 1-2.623 1 4.133 4.133 0 0 0-7.037 3.771 11.724 11.724 0 0 1-8.516-4.317 4.133 4.133 0 0 0 1.282 5.517 4.1 4.1 0 0 1-1.87-.517v.052a4.132 4.132 0 0 0 3.313 4.049 4.147 4.147 0 0 1-1.865.071 4.134 4.134 0 0 0 3.858 2.868 8.338 8.338 0 0 1-6.114 1.71 11.745 11.745 0 0 0 18.08-9.894q0-.268-.012-.534a8.374 8.374 0 0 0 2.061-2.137z"
transform="translate(34.799 -7.41) translate(2.201 4.266) translate(-62.103 -30.883)"
/>
</g>
</g>
</g>
</svg>
);
}
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 1200 1227">
<path
d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z"
fill="#000"
/>
</svg>
);
};

/*
* Static Methods
*/
static init(config?: BuiltInProviderConfig): Provider {
static init(config?: TwitterProviderConfig): Provider {
if (Twitter.instance !== undefined) {
console.warn("Twitter Provider was already initialized");
return Twitter.instance;
Expand Down
3 changes: 3 additions & 0 deletions lib/ts/recipe/thirdpartyemailpassword/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ActiveDirectory,
BoxySAML,
Okta,
Twitter,
} from "../thirdparty/";
import { redirectToThirdPartyLogin as UtilsRedirectToThirdPartyLogin } from "../thirdparty/utils";

Expand Down Expand Up @@ -273,6 +274,7 @@ export default class Wrapper {
static ActiveDirectory = ActiveDirectory;
static BoxySAML = BoxySAML;
static Okta = Okta;
static Twitter = Twitter;
static ComponentsOverrideProvider = RecipeComponentsOverrideContextProvider;
}

Expand Down Expand Up @@ -304,6 +306,7 @@ export {
ActiveDirectory,
BoxySAML,
Okta,
Twitter,
ThirdpartyEmailPasswordComponentsOverrideProvider,
signOut,
submitNewPassword,
Expand Down
3 changes: 3 additions & 0 deletions lib/ts/recipe/thirdpartypasswordless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ActiveDirectory,
BoxySAML,
Okta,
Twitter,
} from "../thirdparty/";
import { redirectToThirdPartyLogin as UtilsRedirectToThirdPartyLogin } from "../thirdparty/utils";

Expand Down Expand Up @@ -277,6 +278,7 @@ export default class Wrapper {
static ActiveDirectory = ActiveDirectory;
static BoxySAML = BoxySAML;
static Okta = Okta;
static Twitter = Twitter;
static ComponentsOverrideProvider = RecipeComponentsOverrideContextProvider;
}

Expand Down Expand Up @@ -313,6 +315,7 @@ export {
ActiveDirectory,
BoxySAML,
Okta,
Twitter,
redirectToThirdPartyLogin,
thirdPartySignInAndUp,
getThirdPartyStateAndOtherInfoFromStorage,
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fbad845

Please sign in to comment.