【问题标题】:Meteor: how to style useraccountsMeteor:如何设置用户帐户的样式
【发布时间】:2016-05-09 01:34:46
【问题描述】:

我正在使用 meteor-useraccounts 处理用户帐户 - 包括 useraccounts:bootstrap。我的 boilerplate 直接来自 repo。

我的问题: 我不明白要放置我自己的 HTML/CSS。

我的 config.js:

// Options
AccountsTemplates.configure({
    defaultLayout: 'emptyLayout',
    showForgotPasswordLink: true,
    overrideLoginErrors: true,
    enablePasswordChange: true,

    showLabels: false,
    showPlaceholders: true,

    negativeValidation: true,
    positiveValidation: true,
    negativeFeedback: true,
    positiveFeedback: true,
});

AccountsTemplates.addFields([
    {
        _id: 'firstName',
        type: 'text',
        placeholder: "First Name",
        required: true,
        re: /^[^\d]{2,}$/i,
        errStr: "Please enter your first name.",
    },
    {
        _id: 'surName',
        type: 'text',
        placeholder: "Sur Name",
        required: true,
        re: /^[^\d]{2,}$/i,
        errStr: "Please enter your first name.",
    },
    {
        _id: 'institution',
        type: 'text',
        placeholder: "Institution/Company",
        required: true,
        re: /^[^\d]{2,}$/i,
        errStr: "Please enter the institution or company you work for.",
    },
    {
        _id: 'position',
        type: 'text',
        placeholder: "Position",
        required: true,
        re: /^[^\d]{2,}$/i,
        errStr: "Please enter the your position in the institution/company.",
    },
]);

我在文档中阅读了您应该用自己的模板替换原始模板,这就是我对Template.myAtForm.replaces("atForm"); 和以下模板所做的:

<template name="myAtForm">
  {{#unless hide}}
    <div class="at-form">
      {{#if showTitle}}
        {{> atTitle}}
      {{/if}}
      {{#if showError}}
        {{> atError}}
      {{/if}}
      {{#if showResult}}
        {{> atResult}}
      {{/if}}
      {{#if showOauthServices}}
        {{> atOauth}}
      {{/if}}
      {{#if showServicesSeparator}}
        {{> atSep}}
      {{/if}}
      {{#if showPwdForm}}
        {{> atPwdForm}}
      {{/if}}
      {{#if showTermsLink}}
        {{> atTermsLink}}
      {{/if}}
      {{#if showSignInLink}}
        {{> atSigninLink}}
      {{/if}}
      {{#if showSignUpLink}}
        {{> atSignupLink}}
      {{/if}}
    </div> <!-- end main div -->
  {{/unless}}
</template>

这是给定的线框:

例如,我必须在哪里添加引导类,以便我在一行中有两个输入字段(但不是在 WF 中看到的每一行)?或者,我如何设计自己的上传按钮(据我所知,甚至没有 type:file)?

useraccounts:unstyled 包的事件,我不明白 HTML/CSS 应该放在哪里。

非常感谢任何帮助。

【问题讨论】:

  • 构建您的模板,然后手动调用Accounts.createUserAccounts.loginWith&lt;service&gt;..(不需要用户帐户:*)
  • @webdeb:我考虑过,但 useraccounts 已经做得很好并且处理了很多其他事情。如果我能以某种方式添加 html/css ...

标签: html css twitter-bootstrap meteor user-accounts


【解决方案1】:

答案:最好自己写模板

我确信useraccounts 做得很好。但它的目标是更简单的 UI。我想大多数应用程序都对此感到满意。

但是,您可以使用 CSS 设置所有字段的样式。您的字段模板(_id 字段)中添加了一些类。查看生成的 html 和useraccounts:unstyled 包的来源。然后你就会清楚它的渲染算法是如何工作的。

但正如您在原始帖子中提到的,例如,没有文件字段。这意味着您必须自己添加模板,并管理文件上传逻辑/验证。

【讨论】:

  • 好的。非常感谢您。 :) 所以我应该只写自己的用户界面,但仍然使用useraccounts,对吧?
  • 编写您自己的 ui 并使用 Meteor Accounts API 处理它
猜你喜欢
  • 1970-01-01
  • 2016-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多