perak / kitchen-site

Meteor Kitchen site source code
MIT License
282 stars 38 forks source link

Implement "materialize" frontend #138

Open perak opened 9 years ago

kadirerdogan commented 9 years ago

@perak using custom template in the menu is great and it solves lots of problems i have faced but there is still one problem about it. We define the shell of the menu in layout_content_navbar.html file.

I didnt check if it is possbile to define an abstract shell which is convenient for both navbar and sidenav style menus. If not kitchen should still know the type and choose the correct layout.

perak commented 9 years ago

@kadirerdogan

for top level (zone layout), we can define "sidebar" or any other predefined template. Menu will go into element < ... id="menu"> by default (if not specified in menu's "dest_selector" property).

Currently, there is only: "empty", "navbar" and "sticky_footer" layouts. Default: "navbar".

Actually, when we make (useful) GUI - then this will not be a problem anymore - you'l choose empty layout, drag&drop one "div" into it, set div's class (to be for example at the top) and drag & drop "navbar" into it.

Without GUI, it's a lot of work (and produces confusing, large json) if we define divs, rows, columns etc. and add menu at the end into it... that's why I created these three predefined layouts.

Feel free to create "sidebar" layout (~/.meteor/templates/ui/layouts/layout_content_sidebar.html & .js), but please keep it as much "universal" as possible (without too much app-specific css classes etc.).

kadirerdogan commented 9 years ago

Ok let me try to add side menu to the semantic-ui template with a custom layout.

perak commented 9 years ago

Great! :+1:

kadirerdogan commented 9 years ago

@perak your advice works good. You can see the working demo from http://kitchen-semantic-admin.meteor.com.

i have cloned menu.html to sidemenu.html and layout_content_navbar.html to layout_content_sidemenu.html (their js files too). Then modified them according to semantic-ui side menu. With the below menu definition i have right and left menus. Btw i have also changed zone layouts to "sidemenu" (my custom layout)

{
                    "name": "left_menu",
                    "type": "menu",
                    "template":"sidemenu",
                    "class": "ui icon left inline vertical sidebar menu left_menu",
                    "dest_selector": "#menu",
                    "items": [
                        { "title": "Home", "route": "home_public","icon_class":"blue home icon" }
                    ]
                },

                {
                    "name": "right_menu",
                    "type": "menu",
                    "template":"sidemenu",
                    "class": "ui icon right inline vertical sidebar menu right_menu",
                    "dest_selector": "#menu",
                    "items": [
                        { "title": "Register", "route": "register","icon_class":"orange add user icon" },
                        { "title": "Login", "route": "login","icon_class":"blue sign in icon" }
                    ]
                }

What i feel missing is that i dont know how to change menu labels and icons using the json file.

I can repack semantic-ui template with this new additions and some minor fixes if you didnt modify the one i have sent before.

kadirerdogan commented 9 years ago

Btw, i have used the admin example json file for the demo. There are very few changes in the original file.

kadirerdogan commented 9 years ago

@palpinter have you tried materialize with meteor-kitchen? When i try to add materialize to the project it gives some javascript errors and the project doesnt work.

perak commented 9 years ago

@kadirerdogan looks awesome! Please send me the files. Btw, I already modified templates you sent me before (without git life is sad :)), but feel free to send me and I'l add sidebar layout and menu

perak commented 9 years ago

Modified semantic-ui wil be included into v0.9.49, and when I finaly open the cli source - we'll breathe easier with using git for this

kadirerdogan commented 9 years ago

I have sent you the link for the files.

kadirerdogan commented 9 years ago

@palpinter i think i have saccessfully added materialize to kitchen. It was a known problem for materialize's latest version. Meteor works with the previous version of materialize so using "materialize:materialize@=0.97.0" as the package name is the fix.

I have cloned my version of semantic-ui template and modified sidemenu.html layout_content_sidemenu.html files (and js files of course) to create a sidebar demo using materializecss. I have also modified register.html, login.html and jumbotron.html to see what we can do with materialize. The materialize template is not complete yet but it will be a very good start for you. There are lots of things to fix especially for the form and dataview components.

You can see the working but not complete demo at: http://kitchen-materialize-admin.meteor.com Template: http://esraerdogan.com.tr/materialize.tgz json (modified admin example) : http://esraerdogan.com.tr/m_admin.json

perak commented 9 years ago

@kadirerdogan excellent! Thank you!

kadirerdogan commented 8 years ago

@perak FIELD_VALUE in templates html files replaces with {{value}} is there a way of just getting value?

i am trying to fix materializecss label overlapping problem for form fields I have added

<label class="{{isClassActive FIELD_VALUE}}" for="FIELD_NAME">FIELD_TITLE</label>

this to form fields But it renders to

<label class="{{isClassActive {{value}}}}" for="FIELD_NAME">FIELD_TITLE</label> 

where i need it to be rendered to

<label class="{{isClassActive value}}" for="FIELD_NAME">FIELD_TITLE</label>
perak commented 8 years ago

OK @kadirerdogan I'll add something like RAW_FIELD_VALUE which will render without mustaches.

Btw, about label overlaping: I had that problem with materialize while working on some project, it doesnt happen if label have class "active" set (but in that case, no fancy label animation on focus/blur)

perak commented 8 years ago

ahhh, whatabout just writting {{labelClass value}} (instead {{labelClass FIELD_VALUE}}) :)

kadirerdogan commented 8 years ago

I have updated my above comment since github removed some tags.

If you look again you'll see that i am trying to use a helper to decide if the class will be "active" or not.

helper returns active if the value is not null. So this way fancy label animation can be used :)

kadirerdogan commented 8 years ago

Btw {{labelClass value}} wont work since i'am doing this at the template file. I dont know what will be the value :)

kadirerdogan commented 8 years ago

I have tried to pass field name instead of the value to the helper and then use the field name as a jquery selector to get the value of the field so that i can return active class if the value is not null. But somehow it doesnt work.

My guess is that helper runs before page is rendered so there is no such element in the dom at that moment.

I think the best solution is your RAW_FIELD_VALUE suggestion. If i have fix the generated forms manually fancy label animation works nicely.

perak commented 8 years ago

Ok, will be in. 0.9.50. Maybe tomorrow.

perak commented 8 years ago

@kadirerdogan I just implemented FIELD_VALUE_RAW in forms. But, it will not work with date fields because FIELD_VALUE produces something like {{formatDate query_name.field_name 'MM/DD/YYYY'}}, and FIELD_VALUE_RAW will produce formatDate query_name.field_name 'MM/DD/YYYY'

But, in latest version of meteor, passing another helper as argument to helper is now supported, but with different syntax (I didn't dive deeper into it yet - to be honest).

perak commented 8 years ago

https://github.com/meteor/meteor/tree/devel/packages/spacebars#nested-sub-expressions

kadirerdogan commented 8 years ago

i have tested below expression and it works as intended.

{{someHelper (formatDate query_name.field_name 'MM/DD/YYYY')}}

But there is another problem about the default values of the form fields. For the default values, values are not variables but actual values. For instance if you use - as the default value for phone fields (as in dataview example) created template will be like below and meteor gives error.

<label class="{{isClassActive -}}" for="FIELD_NAME">FIELD_TITLE</label>

What should be created is

<label class="{{isClassActive '-'}}" for="FIELD_NAME">FIELD_TITLE</label>

But in the template there is no way of knowing if the value is a variable or an actual value.

perak commented 8 years ago

@kadirerdogan OK, now FIELD_VALUE_RAW renders as follows:

(version 0.9.50 - not uploaded yet)

perak commented 8 years ago

@kadirerdogan I just uploaded 0.9.50

kadirerdogan commented 8 years ago

@perak I think you should change the order of string replacement for FIELD_VALUE and FIELD_VALUE_RAW at the kitchen. When i use FIELD_VALUE_RAW it renders to below ( oops :) )

Or use FIELD_RAW_VALUE.

<label class="{{isClassActive {{customer.phone}}_RAW}}" for="phone">
perak commented 8 years ago

ooops :)

perak commented 8 years ago

@kadirerdogan 0.9.51 is just uploaded - I fixed string replacement order for FIELD_VALUE_RAW

kadirerdogan commented 8 years ago

Using FIELD_VALUE_RAW renders to <label class="{{isClassActive {{customer.name}}}}" for="name"> in update form. There are still unwanted number of mustaches.

neither (someHelper value) does work. Date field renders to <label class="{{isClassActive {{formatDate customer.date ''}}}}" for="date">

insert form works as expected.

perak commented 8 years ago

@kadirerdogan fixed, will be available in v0.9.53

kadirerdogan commented 8 years ago

:+1:

Materialize labels work now with below template. Thanks (i have removed helper)

<label class="{{#if FIELD_VALUE_RAW}}active{{/if}}" for="FIELD_NAME">FIELD_TITLE</label>

perak commented 8 years ago

@kadirerdogan would you push or send me latest materialize templates, so I can include them in next version? (planning 0.9.54 in monday night).

perak commented 8 years ago

btw, if hou have materialize example, let's add it to "official" examples.

P.S. thank you for your work!

kadirerdogan commented 8 years ago

I have created a "pull request" to kitchen-templates with fixed labels. There are 4 example json in the request.

Admin example navbar version with semantic-ui and materializecss Admin example sidemenu with semantic-ui and materializecss (drawer style side menu)

I can create a pull request to kitchen-examples with above example jsons but current templates (0.9.53) does not include sidemenu component and layout for semantic-ui.

perak commented 8 years ago

@kadirerdogan cool! Thank you! Merging...

P.S. If you change something more until Monday night - just pull request.

kadirerdogan commented 8 years ago

I have made 2 pull requests. One for kitchen-examples and one for kitchen-templates.

perak commented 8 years ago

Hey @kadirerdogan I just played with templates and examples you made.

First to say - I am working on a semantic-ui templates too, so maybe it's better if you focus on a materialize.

Second, It's great - now we have working materialize templates! I'll include them in next version :+1:

Third, I'll be free to say that there are some visual issues I don't like:

(Don't get me wrong - I respect your work - those are just small visual issues that makes site looks "non-polished").

Thank you (again!) :) :+1:

kadirerdogan commented 8 years ago

@perak Below my comments about your long list :smile:

perak commented 8 years ago

@kadirerdogan thank you very much! :+1:

perak commented 8 years ago

New materialize templates and example application is uploaded now (v0.9.54)