Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow UfAlert style customization #634

Closed
lcharette opened this issue Feb 3, 2017 · 3 comments
Closed

Allow UfAlert style customization #634

lcharette opened this issue Feb 3, 2017 · 3 comments
Assignees
Labels
templating Related to the template feature
Milestone

Comments

@lcharette
Copy link
Member

Currently the alerts are rendered by uf-alerts.js, which doesn't allow style customization through a sprinkle and/or Twig template. A Twig template file should be used to define the html code of the full alert. The alert should then be rendered using Handlebar.js or a rendered version should be loaded via Ajax instead of loading only the son data.

Fixing this should probably fix #621 at the same time.

@lcharette lcharette added templating Related to the template feature V4 labels Feb 3, 2017
@lcharette lcharette added this to the 4.0 milestone Feb 3, 2017
@alexweissman
Copy link
Member

Or, we can just have a Handlebars template in the DOM (wrapped in a <script type="text/x-handlebars-template"> block), and then pass that to uf-alerts. This is basically how things work for uf-table.

For example, the Handlebars template for the "user info" cell of the users table:

    <script id="user-table-column-info" type="text/x-handlebars-template">
        <td data-text="{{row.last_name}}">
            <strong>
                <a href="{{site.uri.public}}/admin/users/u/{{row.user_name}}">{{row.first_name}} {{row.last_name}} ({{row.user_name}})</a>
            </strong>
            <div class="js-copy-container">
                <span class="js-copy-target">{{row.email}}</span>
                <button class="btn btn-xs js-copy-trigger"><i class="fa fa-copy"></i></button>
            </div>
        </td>
    </script>

This is a Handlebars template, so ufTable extracts it from the DOM and then uses it to generate the table cells.

@lcharette
Copy link
Member Author

I looked at Handlebar doc and I guess it would be the easiest way to do this. The actual Handlebar template should be in a separate html.twig file and included in the DOM so it's easy for a Sprinkle to overwrite that template.

At the same time, I was thinking about splitting multiple alert into different alert box instead of a <ul> list. The "dismiss" button and even icon could be added too.

I'll assign this to myself since I do want to try out and learn how Handlebar work. Might be useful in my own project ;)

@lcharette
Copy link
Member Author

This is implemented in commit above. Alerts style can be customized by overwriting app/sprinkles/core/assets/local/core/css/uf-alerts.css and/or app/sprinkles/core/templates/components/alerts.html.twig in a sprinkle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
templating Related to the template feature
Projects
None yet
Development

No branches or pull requests

2 participants