|
2 | 2 |
|
3 | 3 | <link rel="import" href="../iron-icon/iron-icon.html">
|
4 | 4 | <link rel="import" href="../iron-image/iron-image.html">
|
| 5 | +<link rel="import" href="../iron-flex-layout/iron-flex-layout.html"> |
| 6 | +<link rel="import" href="../iron-media-query/iron-media-query.html"> |
| 7 | + |
5 | 8 | <link rel="import" href="../paper-button/paper-button.html">
|
6 | 9 | <link rel="import" href="../paper-menu-button/paper-menu-button.html">
|
7 | 10 | <link rel="import" href="../paper-menu/paper-menu.html">
|
8 | 11 | <link rel="import" href="../paper-item/paper-item.html">
|
| 12 | + |
9 | 13 | <link rel="import" href="../neon-animation/animations/scale-up-animation.html">
|
10 | 14 | <link rel="import" href="../neon-animation/animations/fade-out-animation.html">
|
11 | 15 |
|
12 |
| -<link rel="import" href="./firebase-auth-dialog.html"> |
13 |
| -<link rel="import" href="./firebase-icons.html"> |
14 | 16 | <link rel="import" href="./firebase-state.html">
|
15 | 17 |
|
16 | 18 | <!--
|
17 | 19 | `<firebase-account-menu>` is a navigation menu to be placed inside a `<paper-toolbar>` that provides and hook the authentication functionnality of `<firebase-auth-manager>`.
|
18 |
| -Signing up and signing in is done thanks to a self-registered `<firebase-auth-dialog>` declared somewhere else. |
| 20 | +Signing Up and Signing In is done thanks to a self-registered `<firebase-auth-dialog>` declared somewhere else. |
19 | 21 | It also provides access to the menu dedicated to account actions with a default logout action.
|
20 | 22 |
|
21 | 23 | Example:
|
22 | 24 |
|
23 | 25 | <firebase-account-menu>
|
24 |
| - TODO PG: add paper-item item |
| 26 | + <paper-item on-tap="menu1Open">Menu 1</paper-item> |
| 27 | + <paper-item on-tap="menu2Open">Menu 2</paper-item> |
25 | 28 | </firebase-account-menu>
|
26 | 29 |
|
27 |
| -@group GoogleWebComponents Elements |
28 |
| -@element firebase-account-menu |
| 30 | +### Styling |
| 31 | +
|
| 32 | +The following custom properties and mixins are available for styling: |
| 33 | +
|
| 34 | +Custom property | Description | Default |
| 35 | +----------------|-------------|---------- |
| 36 | +`--firebase-account-menu` | Mixin applied to the account menu | `{}` |
| 37 | +`--firebase-account-menu-image` | Mixin applied to the iron-image | `{}` |
| 38 | +
|
29 | 39 | @demo demo/index.html
|
30 |
| -@hero hero.svg |
31 | 40 | -->
|
32 | 41 | <dom-module id="firebase-account-menu">
|
33 | 42 | <template>
|
34 | 43 | <style>
|
35 |
| - /* TODO PG: beautify and provide styling hook? */ |
36 | 44 | :host {
|
37 | 45 | display: block;
|
| 46 | + |
| 47 | + @apply(--firebase-account-menu); |
38 | 48 | }
|
39 | 49 |
|
40 | 50 | #signedIn, #signedOut {
|
41 |
| - display: flex; |
42 |
| - align-items: center; |
| 51 | + @apply(--layout-horizontal); |
| 52 | + @apply(--layout-center-center); |
43 | 53 | }
|
44 | 54 |
|
45 | 55 | iron-image {
|
46 |
| - width: 45px; |
47 |
| - height: 45px; |
48 |
| - border-radius: 10px; |
| 56 | + width: 40px; |
| 57 | + height: 40px; |
| 58 | + border-radius: 20px; |
| 59 | + |
| 60 | + @apply(--firebase-account-menu-image); |
49 | 61 | }
|
50 | 62 |
|
51 | 63 | #profileLabel {
|
|
57 | 69 | }
|
58 | 70 | </style>
|
59 | 71 |
|
60 |
| - <firebase-state logged="{{logged}}" profile="{{profile}}"></firebase-state> |
| 72 | + <firebase-state logged="{{_logged}}" profile="{{_profile}}"></firebase-state> |
| 73 | + |
| 74 | + <iron-media-query query="(max-width: 600px)" query-matches="{{_isMobile}}"></iron-media-query> |
61 | 75 |
|
62 |
| - <paper-menu-button hidden$="[[!logged]]" |
| 76 | + <paper-menu-button hidden$="[[!_logged]]" |
63 | 77 | vertical-offset="72"
|
64 | 78 | horizontal-align="right"
|
65 | 79 | horizontal-offset="12">
|
66 | 80 | <paper-button id="signedIn" class="dropdown-trigger">
|
67 |
| - <iron-image src="[[profile.picture]]" sizing="cover"></iron-image> |
68 |
| - <span id="profileLabel">[[profile.displayName]]</span> |
| 81 | + <iron-image src="[[_profile.picture]]" sizing="cover"></iron-image> |
| 82 | + <span id="profileLabel" hidden$="[[_isMobile]]">[[_profile.displayName]]</span> |
69 | 83 | <iron-icon icon="expand-more"></iron-icon>
|
70 | 84 | </paper-button>
|
71 | 85 | <paper-menu class="dropdown-content">
|
72 |
| - <!-- TODO PG: here comes the user specific menu... --> |
73 | 86 | <content></content>
|
74 | 87 | <paper-item on-tap="signOutButton">Sign Out</paper-item>
|
75 | 88 | </paper-menu>
|
76 | 89 | </paper-menu-button>
|
77 |
| - <div id="signedOut" hidden$="[[logged]]"> |
| 90 | + |
| 91 | + <div id="signedOut" hidden$="[[_logged]]"> |
78 | 92 | <paper-button on-tap="signUpButton">Sign-Up</paper-button>
|
79 | 93 | <paper-button on-tap="signInButton">Sign-In</paper-button>
|
80 | 94 | </div>
|
|
85 | 99 | is: 'firebase-account-menu',
|
86 | 100 |
|
87 | 101 | properties: {
|
88 |
| - profile: { |
| 102 | + _logged: { |
| 103 | + type: Boolean |
| 104 | + }, |
| 105 | + _profile: { |
89 | 106 | type: Object
|
90 |
| - } |
| 107 | + }, |
| 108 | + _isMobile: { |
| 109 | + type: Boolean |
| 110 | + }, |
91 | 111 | },
|
92 | 112 |
|
93 | 113 | get _firebaseAuthDialog() {
|
|
0 commit comments