简体   繁体   English

流星帐户ui样式

[英]Meteor accounts ui styling

I'm developing a small meteor app which uses accounts ui for user authentication. 我正在开发一个小型流星应用程序,该应用程序使用帐户ui进行用户身份验证。

I have the unstyled package added but I don't know how to style it using css, or even (if possible) change the accounts ui html. 我添加了无样式的程序包,但我不知道如何使用CSS设置样式,甚至(如果可能)更改ui html帐户。

How do I do this so I can 'bootstrap it', include it in a navbar and style it to my liking ? 我该如何做才能“引导”它,将其包含在导航栏中并根据自己的喜好对其进行样式设置?

Regards, 问候,

João Bernardo 若昂·贝纳多(JoãoBernardo)

If you want to go in and alter the templates directly the quickest solution short of rolling your own is to remove accounts-ui-unstyled from your package dependencies and then add it directly to your local packages directory where you can edit it freely. 如果您想直接进入并更改模板,除了滚​​动自己的模板之外,最快的解决方案是从软件包依赖项中删除无UI风格的accounts,然后将其直接添加到本地软件包目录中,您可以在其中自由地对其进行编辑。

(You should be using accounts-ui-unstyled and not accounts-ui if you are not interested in any of the prefab css accompanying the ui package, but the steps below apply to both packages). (如果您对ui软件包随附的任何预制css不感兴趣,则应使用无用户界面ui样式的帐户,而不应使用account ui,但以下步骤适用于这两个软件包)。

By doing this you will lose the benefit of future improvements made to the package, and your local package may break due to future improvements. 这样,您将失去对程序包进行将来改进的好处,并且本地程序包可能会因将来的改进而损坏。

First remove accounts-ui-unstyled from the command line: 首先从命令行删除accounts-ui-unstyle:

meteor remove accounts-ui-unstyled

Grab a copy of the package here , rename it and include in your local /packages. 此处获取软件包的副本,将其重命名并包含在本地/ packages中。 Then use meteor add your-package-name on the command line or by hand in .meteor/packages and you should have a local copy to freely alter. 然后使用meteor add your-package-name在命令行上meteor add your-package-name或在.meteor / packages中手动添加,您应该有一个本地副本可以自由更改。

You can place the new css you create with your existing css files if that is convenient. 如果方便,可以将创建的新css与现有css文件一起放置。 Styling it is no different than styling anything else - hook into its ids and classes, etc. or change them as you are now free to do. 设置样式与设置其他样式没有什么不同-可以插入其ID和类等,也可以自由更改它们。

Create your own html template for login and registration similar to this below. 创建您自己的用于登录和注册的html模板,如下所示。 Style it to your taste. 根据您的口味进行样式设置。

meteor add accounts-password accounts-ui

                <template name="login">
                     <form class="login-form">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3>Login</h3>
                            </div>
                            <div class="panel-body">
                                <div class="form-group">
                                    <label>Email</label>
                                    <input type="email"  class="form-control" id="email" placeholder="Email address">
                                </div>
                                <div class="form-group">
                                    <label>Password</label>
                                    <input type="password" class="form-control" id="password" placeholder="password">
                                </div>
                            </div>
                            <div class="panel-footer">
                                <button type="submit" class="btn btn-danger btn-lg">Login</button>
                            </div>
                        </div>
                    </form>
                </template>

You can now call Meteor.loginWithPassword in the template event like so: 现在,您可以在模板事件中调用Meteor.loginWithPassword ,如下所示:

Template.login.events({
    'submit .login-form': function(e) {
        e.preventDefault();
        var email = e.target.email.value;
        var password = e.target.password.value;
      Meteor.loginWithPassword(email, password,function(error){
            if(error) {
                //do something if error occurred or 
            }else{
               FlowRouter.go('/');
            }
        });
     }
 });

You can create another form for registration as well. 您也可以创建另一个表格进行注册。

Just call Accounts.createUser(object, callback); 只需调用Accounts.createUser(object, callback);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM