-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from josemarluedke/docs/add-notifications-demo
Add notifications demo to docs app
- Loading branch information
Showing
10 changed files
with
159 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<div class="flex items-baseline"> | ||
<FormRadioGroup | ||
@containerClass="mr-6" | ||
@label="Placement" | ||
@value={{this.placement}} | ||
@onChange={{this.setPlacement}} | ||
as |Radio| | ||
> | ||
<Radio @value="top-left" @label="top-left" /> | ||
<Radio @value="top-center" @label="top-center" /> | ||
<Radio @value="top-right" @label="top-right" /> | ||
<Radio @value="bottom-left" @label="bottom-left" /> | ||
<Radio @value="bottom-center" @label="bottom-center" /> | ||
<Radio @value="bottom-right" @label="bottom-right" /> | ||
</FormRadioGroup> | ||
|
||
<FormRadioGroup | ||
@label="Appearance" | ||
@value={{this.options.appearance}} | ||
@onChange={{fn this.setValue "appearance"}} | ||
as |Radio| | ||
> | ||
<Radio @value="info" @label="info" /> | ||
<Radio @value="success" @label="success" /> | ||
<Radio @value="warning" @label="warning" /> | ||
<Radio @value="error" @label="error" /> | ||
</FormRadioGroup> | ||
</div> | ||
|
||
<FormCheckbox | ||
@containerClass="mt-6" | ||
@label="Preserve" | ||
@hint="Preserved notifications will not automatically close" | ||
@checked={{this.options.preserve}} | ||
@onChange={{fn this.setValue "preserve"}} | ||
/> | ||
|
||
<FormCheckbox | ||
@containerClass="mt-6" | ||
@label="Allow Closing" | ||
@hint="Allow users to close the notification" | ||
@checked={{this.options.allowClosing}} | ||
@onChange={{fn this.setValue "allowClosing"}} | ||
/> | ||
|
||
<div class="flex items-baseline mt-6 "> | ||
<FormInput | ||
@containerClass="w-24 mr-6" | ||
@label="Duration" | ||
@hint="Duration is in ms" | ||
@value={{this.options.duration}} | ||
@onInput={{fn this.setValue "duration"}} | ||
/> | ||
|
||
<FormSelect | ||
@containerClass="w-64" | ||
@hint="Allow users to take an action on a notification" | ||
@label="Custom Actions" | ||
@options={{this.customActions}} | ||
@isMultiple={{true}} | ||
@selected={{this.options.customActions}} | ||
@onChange={{fn this.setValue "customActions"}} | ||
as |action| | ||
> | ||
{{action.label}} | ||
</FormSelect> | ||
</div> | ||
|
||
<button | ||
type="button" | ||
{{on "click" this.addNotification}} | ||
class="px-4 py-2 mt-6 text-white bg-teal-700 rounded hover:bg-teal-800" | ||
> | ||
Add Notification | ||
</button> | ||
|
||
<NotificationsContainer @placement={{this.placement}} /> |
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,56 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class Demo extends Component { | ||
@service notifications; | ||
@tracked options = { | ||
appearance: 'info', | ||
preserve: false, | ||
duration: 5000, | ||
allowClosing: true | ||
}; | ||
|
||
@tracked placement = 'bottom-right'; | ||
|
||
@tracked customActions = [ | ||
{ | ||
label: 'Ok', | ||
onClick: () => { | ||
// empty | ||
} | ||
}, | ||
{ | ||
label: 'Undo', | ||
onClick: () => { | ||
// empty | ||
} | ||
}, | ||
{ | ||
label: 'Cancel', | ||
onClick: () => { | ||
// empty | ||
} | ||
} | ||
]; | ||
|
||
@action setPlacement(placement) { | ||
this.placement = placement; | ||
} | ||
|
||
@action setValue(key, value) { | ||
const options = { | ||
...this.options, | ||
[key]: value | ||
}; | ||
this.options = options; | ||
} | ||
|
||
@action addNotification() { | ||
this.notifications.add( | ||
'Sed diam nonumy eirmod tempor invidunt ut labore et dolore magna.', | ||
this.options | ||
); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ Packages: | |
- `@frontile/forms` | ||
- `@frontile/changeset-form` | ||
- `@frontile/buttons` | ||
- `@frontile/notifications` |
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,5 @@ | ||
# Notifications Installation | ||
|
||
```sh | ||
ember install @frontile/notifications | ||
``` |
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 @@ | ||
# Notifications | ||
|
||
<Demo::Notifications::Demo /> |
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