@acpaas-ui/ngx-user-menu 中文文档教程

发布于 3年前 浏览 11 更新于 3年前

@acpaas-ui/ngx-user-menu

UserMenu

可以在网页上使用用户菜单组件来提供可视化的登录和注销按钮。 如果注销,该组件会显示一个按钮,使用户能够登录。 如果已登录,该组件会提供一个头像按钮,显示一个带有注销按钮的弹出按钮。

该组件在其标签内使用 content projection,这意味着包含任何 html aui-user-menu 标签之间的内容将插入弹出部分。 显示注销按钮 默认情况下,但如果您希望实现自定义注销按钮,则可以将其禁用。

两个输出事件可用于挂钩登录或注销功能到界面:

  • login$: Triggered when user clicks on the login button
  • logout$: Triggered when user clicks on the logout button

您负责提供登录和注销功能,此组件仅提供视觉效果。

Usage

在您的模块中:

import { UserMenuModule } from '@acpaas-ui/ngx-user-menu';

@NgModule({
    imports: [
        UserMenuModule
    ]
})
export class AppModule { }

在您的模板中:

<aui-user-menu [user]="userObject" flyoutSize="Medium" [notificationsCount]="100" (logout$)="logoutUser()" (login$)="loginUser()" [translations]="translations">
    <div class="u-margin-lg u-text-center">
        Your Content Here
    </div>
</aui-user-menu>

组件输入:

public mockUser: UserMenu.IUser = {
        firstName: 'John',
        lastName: 'Doe',
        avatarUrl: 'https://gravatar.com/avatar/66f865ee03bc019d2f06af6ec0c434ce?s=200'
    };
public translations: UserMenu.ITranslations = {
    login: 'Login',
    logout: 'Logout',
    userAvatar: 'User avatar',
};
public logoutUser(){
    alert('User is logged out!');
}
public loginUser(){
    alert('User is logged in!');
}

Documentation

Component Inputs

InputTypeRequiredDefault Value
userUserMenu.IUserYes, if logged in-
directionstring: 'right''left'-
flyoutSizeFlyout.EFlyoutSize-FlyoutSize.Small
notificationsCountnumber--
showLogoutButtonboolean-true
translationsUserMenu.ITranslations-EN labels

Component Outputs

OutputTypeRequiredDefault Value
login$EventEmitter-EventEmitter
logout$EventEmitter-EventEmitter

访问我们的文档网站,获取完整的操作文档和指南

Contributing

访问我们的 Contribution Guidelines 获取更多关于如何贡献的信息。

@acpaas-ui/ngx-user-menu

UserMenu

The User Menu component can be used on a webpage to provide visual login and logout buttons. If logged out, the component displays a single button enabling the user to login. If logged in, the component provides an avatar button, displaying a flyout where a logout button is featured.

This component uses content projection inside it's tag, meaning whatever html is included between the aui-user-menu tag will be inserted in the flyout section. The logout button is displayed by default but can be disabled if you wish to implement your custom logout button.

Two output events may be used to hook to login or logout functionality to the interface:

  • login$: Triggered when user clicks on the login button
  • logout$: Triggered when user clicks on the logout button

You are responsible for providing login and logout functionality, this component only provides visuals.

Usage

In your module:

import { UserMenuModule } from '@acpaas-ui/ngx-user-menu';

@NgModule({
    imports: [
        UserMenuModule
    ]
})
export class AppModule { }

In your template:

<aui-user-menu [user]="userObject" flyoutSize="Medium" [notificationsCount]="100" (logout$)="logoutUser()" (login$)="loginUser()" [translations]="translations">
    <div class="u-margin-lg u-text-center">
        Your Content Here
    </div>
</aui-user-menu>

Component inputs:

public mockUser: UserMenu.IUser = {
        firstName: 'John',
        lastName: 'Doe',
        avatarUrl: 'https://gravatar.com/avatar/66f865ee03bc019d2f06af6ec0c434ce?s=200'
    };
public translations: UserMenu.ITranslations = {
    login: 'Login',
    logout: 'Logout',
    userAvatar: 'User avatar',
};
public logoutUser(){
    alert('User is logged out!');
}
public loginUser(){
    alert('User is logged in!');
}

Documentation

Component Inputs

InputTypeRequiredDefault Value
userUserMenu.IUserYes, if logged in-
directionstring: 'right''left'-
flyoutSizeFlyout.EFlyoutSize-FlyoutSize.Small
notificationsCountnumber--
showLogoutButtonboolean-true
translationsUserMenu.ITranslations-EN labels

Component Outputs

OutputTypeRequiredDefault Value
login$EventEmitter-EventEmitter
logout$EventEmitter-EventEmitter

Visit our documentation site for full how-to docs and guidelines

Contributing

Visit our Contribution Guidelines for more information on how to contribute.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文