-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authenticator "modal" variation (#757)
- Loading branch information
1 parent
038075d
commit d47ed6b
Showing
31 changed files
with
228 additions
and
229 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
19 changes: 18 additions & 1 deletion
19
docs/src/pages/components/authenticator/quick-start.react.mdx
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,6 +1,23 @@ | ||
For React, import and wrap your app using the `withAuthenticator` | ||
import { Tabs, TabItem } from '@aws-amplify/ui-react'; | ||
|
||
For React, you can use the `Authenticator` component directly, or wrap your app in `withAuthenticator` | ||
[Higher-Order Component](https://reactjs.org/docs/higher-order-components.html): | ||
|
||
<Tabs> | ||
<TabItem title="Authenticator"> | ||
|
||
```js{3-4,11-12} file=../../../../../examples/next/pages/ui/components/authenticator/sign-in-with-username/index.page.tsx | ||
|
||
``` | ||
|
||
</TabItem> | ||
<TabItem title="withAuthenticator"> | ||
|
||
The `withAuthenticator` automatically sets the [`variation`](#variation) to `modal`. | ||
|
||
```js{3-4,9,18} file=../../../../../examples/next/pages/ui/components/authenticator/withAuthenticator/index.page.tsx | ||
|
||
``` | ||
|
||
</TabItem> | ||
</Tabs> |
3 changes: 3 additions & 0 deletions
3
docs/src/pages/components/authenticator/variation.default.angular.mdx
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,3 @@ | ||
```html{1} file=../../../../../examples/angular/src/pages/ui/components/authenticator/sign-in-with-username/sign-in-with-username.component.html | ||
``` |
3 changes: 3 additions & 0 deletions
3
docs/src/pages/components/authenticator/variation.default.react.mdx
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,3 @@ | ||
```tsx{3} file=../../../../../examples/next/pages/ui/components/authenticator/sign-in-with-username/index.page.tsx#L9- | ||
``` |
3 changes: 3 additions & 0 deletions
3
docs/src/pages/components/authenticator/variation.default.vue.mdx
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,3 @@ | ||
```html{2} file=../../../../../examples/vue/src/pages/ui/components/authenticator/sign-in-with-username/index.vue#L10- | ||
``` |
3 changes: 3 additions & 0 deletions
3
docs/src/pages/components/authenticator/variation.modal.angular.mdx
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,3 @@ | ||
```html{1} file=../../../../../examples/angular/src/pages/ui/components/authenticator/modal/modal.component.html | ||
``` |
3 changes: 3 additions & 0 deletions
3
docs/src/pages/components/authenticator/variation.modal.react.mdx
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,3 @@ | ||
```tsx{3} file=../../../../../examples/next/pages/ui/components/authenticator/modal/index.page.tsx#L9- | ||
``` |
3 changes: 3 additions & 0 deletions
3
docs/src/pages/components/authenticator/variation.modal.vue.mdx
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,3 @@ | ||
```html{2} file=../../../../../examples/vue/src/pages/ui/components/authenticator/modal/index.vue#L10- | ||
``` |
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
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
10 changes: 10 additions & 0 deletions
10
examples/angular/src/pages/ui/components/authenticator/modal/modal.component.html
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,10 @@ | ||
<amplify-authenticator variation="modal"> | ||
<ng-template | ||
amplifySlot="authenticated" | ||
let-user="user" | ||
let-signOut="signOut" | ||
> | ||
<h2>Welcome, {{ user.username }}!</h2> | ||
<button (click)="signOut()">Sign Out</button> | ||
</ng-template> | ||
</amplify-authenticator> |
14 changes: 14 additions & 0 deletions
14
examples/angular/src/pages/ui/components/authenticator/modal/modal.component.ts
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,14 @@ | ||
import { Component } from '@angular/core'; | ||
import { Amplify } from 'aws-amplify'; | ||
|
||
import awsExports from '@environments/auth-with-username-no-attributes/src/aws-exports'; | ||
|
||
@Component({ | ||
selector: 'modal', | ||
templateUrl: 'modal.component.html', | ||
}) | ||
export class ModalComponent { | ||
constructor() { | ||
Amplify.configure(awsExports); | ||
} | ||
} |
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
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
15 changes: 15 additions & 0 deletions
15
examples/next/pages/ui/components/authenticator/modal/index.page.tsx
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,15 @@ | ||
import { Amplify } from 'aws-amplify'; | ||
|
||
import { Authenticator } from '@aws-amplify/ui-react'; | ||
import '@aws-amplify/ui-react/styles.css'; | ||
|
||
import awsExports from '@environments/auth-with-username-no-attributes/src/aws-exports'; | ||
Amplify.configure(awsExports); | ||
|
||
export default function App({ signOut }) { | ||
return ( | ||
<Authenticator variation="modal"> | ||
{({ signOut }) => <button onClick={signOut}>Sign out</button>} | ||
</Authenticator> | ||
); | ||
} |
17 changes: 12 additions & 5 deletions
17
examples/next/pages/ui/components/authenticator/sign-in-with-username/index.page.tsx
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,13 +1,20 @@ | ||
import { Amplify } from 'aws-amplify'; | ||
|
||
import { withAuthenticator } from '@aws-amplify/ui-react'; | ||
import { Authenticator } from '@aws-amplify/ui-react'; | ||
import '@aws-amplify/ui-react/styles.css'; | ||
|
||
import awsExports from '@environments/auth-with-username-no-attributes/src/aws-exports'; | ||
Amplify.configure(awsExports); | ||
|
||
function App({ signOut }) { | ||
return <button onClick={signOut}>Sign out</button>; | ||
export default function App() { | ||
return ( | ||
<Authenticator> | ||
{({ signOut, user }) => ( | ||
<> | ||
<h1>Hello {user.username}</h1> | ||
<button onClick={signOut}>Sign out</button> | ||
</> | ||
)} | ||
</Authenticator> | ||
); | ||
} | ||
|
||
export default withAuthenticator(App); |
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
17 changes: 17 additions & 0 deletions
17
examples/vue/src/pages/ui/components/authenticator/modal/index.vue
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,17 @@ | ||
<script setup lang="ts"> | ||
import Amplify from 'aws-amplify'; | ||
import { Authenticator } from '@aws-amplify/ui-vue'; | ||
import '@aws-amplify/ui-vue/styles.css'; | ||
import aws_exports from '@environments/auth-with-username/src/aws-exports'; | ||
Amplify.configure(aws_exports); | ||
</script> | ||
|
||
<template> | ||
<authenticator variation="modal"> | ||
<template v-slot="{ user, signOut }"> | ||
<h1>Hello {{ user.username }}!</h1> | ||
<button @click="signOut">Sign Out</button> | ||
</template> | ||
</authenticator> | ||
</template> |
Oops, something went wrong.