Coder Social home page Coder Social logo

dunest / materialdesignlite Goto Github PK

View Code? Open in Web Editor NEW
40.0 8.0 20.0 6.22 MB

This project prime goal is to bind the google's Material Design Lite project to Seaside and as second goal to build widgets on top of Material Design to help Seaside developers to create web applications with material design faster.

Home Page: https://mdl.ferlicot.fr/

License: MIT License

Smalltalk 100.00%
seaside google-material material-ui pharo gui smalltalk gemstone

materialdesignlite's Introduction

MaterialDesignLite for Seaside

Coverage:

Coverage Status

This project has as first goal to bind the Google's Material Design Lite project to Seaside and as second goal to build widgets on top of Material Design to help Seaside developers in creating fast web application with flat design. For a tutorial on Seaside check http://book.seaside.st.

A migration guide from v1 to v2 can be found here.

Documentation

Version management

This project use semantic versioning to define the releases. This means that each stable release of the project will be assigned a version number of the form vX.Y.Z.

  • X defines the major version number
  • Y defines the minor version number
  • Z defines the patch version number

When a release contains only bug fixes, the patch number increases. When the release contains new features that are backward compatible, the minor version increases. When the release contains breaking changes, the major version increases.

Thus, it should be safe to depend on a fixed major version and moving minor version of this project.

Install MDL Seaside

In Pharo

To install MaterialDesignLite on your Pharo image, execute the following script: Spotter Cloud Workspace Url. See ZnWorkspace section for installing a ZnWorkspace if you so want.

    Metacello new
    	githubUser: 'DuneSt' project: 'MaterialDesignLite' commitish: 'v2.x.x' path: 'src';
    	baseline: 'MaterialDesignLite';
    	onWarningLog;
    	load

To add MaterialDesignLite Seaside to your baseline:

    spec
    	baseline: 'MaterialDesignLite'
    	with: [ spec repository: 'github://DuneSt/MaterialDesignLite:v2.x.x/src' ]

Note that you can replace the #master by another branch such as #development or a tag such as #v2.0.0, #v2.? or #v2.1.? .

In GemStone

Gemstone is only supported on v1 of the project. This does not mean no fix or feature can be added to it. We can still release new patch and feature version if asked.

    Metacello new
    	githubUser: 'DuneSt' project: 'MaterialDesignLite' commitish: 'v1.x.x' path: 'src';
    	baseline: 'MaterialDesignLite';
    	onWarningLog;
    	load

To add MaterialDesignLite Seaside to your baseline just add this:

    spec
    	baseline: 'MaterialDesignLite'
    	with: [ spec repository: 'github://DuneSt/MaterialDesignLite:v1.x.x/src' ]

Note that you can replace the #master by another branch such as #development or a tag such as #v1.0.0, #v1.? or #v1.2.? .

Getting started

We use as a base the files product by Google's Material Design Lite. To have a working Material Design Seaside application we need to add those files. Most of them can be easily added via a file library but one file need to be explicitely added because this file change depending on the colors you wish for your application.

For now MDL Seaside is based on version 1.3.0 of Google's Material Design Lite.

Add the right libraries and file

To use MaterialDesign you will need to add JQuery and Material Design library to your application:

	(WAAdmin register: self asApplicationAt: 'myApplication')
		addLibrary: JQDeploymentLibrary;
		addLibrary: MDLLibrary

Then you will need to add the css file with the colors. To do so, you will have two options:

  • Add it to your file library
  • Add it in your #updateRoot:

You can find the files on https://getmdl.io/customize/index.html

They are in the form of: https://storage.googleapis.com/code.getmdl.io/1.3.0/material.XXX-YYY.min.css

Where

  • XXX = primary color
  • YYY = accent color

Add the css file in the updateRoot of your application:

    MyApplication>>updateRoot: anHtmlRoot
	    super updateRoot: anHtmlRoot.
	    anHtmlRoot beHtml5.
	    anHtmlRoot stylesheet url: (WAUrl absolute: 'https://storage.googleapis.com/code.getmdl.io/1.3.0/material.XXX-YYY.min.css').

Add specific style for extensions

In order to make the extentions work properly, you should define some colors specific rules for your application in your css. To do so, just define:

    .mdl-pagination__current{
        box-shadow: inset 0px -4px 0px 0px #XXXXXX !important;
    }

Where XXXXXX is the hex code of the accent color of your MDL application. To find your code you can select the #A200 color in the following page: https://www.materialui.co/colors

Subclassing MDLApplication

Another simple way to start with MDL is to subclass MDLApplication to create your root component. MDLApplication is a class to help you to start an application easily. It will keep in a FileLibrary most of MDL's files.

Since MaterialDesignLite works with a primary color and an accent color you will need to set them. To do so you will need to add this to your #initialize method:

    self primaryColor: MDLColor indigo secondaryColor: MDLColor pink

You can find the possible colors into the class MDLColor class.

Examples

You can find multiple examples when the application will be installed at the url: http://localhost:8080/MDLDemo

When you install in a plain Pharo image you need to start the seaside server first by opening World menu > Tools > Seaside Control Panel and adding and starting an appropropriate ZnZincServerAdaptor. If you do not use port 8080, change the port in the URL.

Since v2 you can also open the demo from the menu bar under MaterialDesignLite.

You can find a demo at: https://mdl.ferlicot.fr/

ZnWorkspace

If you look at a cloud workspace page, you'll see it mentions a ZnWorkspace. This is how you can load it up.

Gofer it
  squeaksource: 'ZincHTTPComponents';
  package: 'Zinc-WWS-Client';
  load.

To open one, just do a

ZnWorkspace openUrl: 'http://ws.stfx.eu/1JIZRQS7OI00'

Latest supported Dependencies

Smalltalk versions compatibility

MDL version Compatible Pharo versions Compatible Gemstone versions
1.1.x Pharo 50, 60, 61 None
1.2.x Pharo 50, 60, 61 None
1.3.x Pharo 50, 60, 61 Gemstone 3.4.1 (*) (**)
2.x.x Pharo 61, 70, 80, 90, 10 None
Dev Pharo 61, 70, 80, 90, 10 None

(*) This version of Gemstone is tested. Older versions might work but we did not tested it. (**) The compatibility is not total. MaterialDesignLite uses Pharo's Traits to provide the users composables components. Thus, if the Gemstone users wants to use those components they will have to flatten themself the Traits in their Seaside application

Ports

A port of MDL for Seaside to Dolphin Smalltalk has been made and can be found at:

Under the hood

Understanding what is going on under the hood is always useful. Have a look at (http://www.tutorialspark.com/Google_MaterialDesignLite_Tutorials/index.php) for a tutorial.

Contact

If you have any questions or problems do not hesitate to open an issue or contact cyril (a) ferlicot.me

materialdesignlite's People

Contributors

hoemac avatar jccfd avatar jecisc avatar juliendelplanque avatar krono avatar lesageyann avatar mabdi avatar pdebruic avatar philippeback avatar stephaneggermont avatar tomaskukol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

materialdesignlite's Issues

Clean Dialog javascript

For now the javascript is hard coded during the rendering. We should use dataset to improve the code and have a file with all the js. Those we will only need one function to call to initialize a dialog.

We should be able to have multiple opening buttons for a dialog

For now we can only have on button to open a dialog since it use id. We should be able to open them with multiple buttons.

I will still let the opening with the id to be backward compatible but I will also add a way to open a dialog via the class of a button.

Tooltip of NestedList is not usable

For now the list use a transform3D and this messup with the tooltip. We should remove this.
Also the tooltips charged dynamically are not usable.

Does not load on Squeak due to incomplete filetree directories

I can't use Metacello or Filetree to load this project in Squeak as (its version of) filetree expects this layout for the monticello.meta dir:

monticello.meta
├── categories.st
├── initializers.st
├── package
└── version

but all packages here only provide a directory without version

monticello.meta
├── categories.st
├── initializers.st
└── package

making filetree think metadata is there (b/c of the directory) but it fails when it tries to read the version file.

(Sidenote: This won't happen on GemStone, as there, filetree explicitly checks for both the directory and the version file before trying a plan B: https://github.com/dalehenrich/filetree/blob/1b11ee48091bf20d26a8b289961fd770e9eb6752/repository/MonticelloFileTree-Core.package/MCFileTreeAbstractReader.class/instance/hasMonticelloMetadata.st

/cc @dalehenrich
)

EDIT by jecisc:

When it will be corrected:

  • Add Squeak 5.1 to Travis build
  • Add compatible smalltalks to the README

Baseline need a cleanup.

Sometimes in baseline packages names are string and sometimes symbols. We should unify it.

Also Magritte is not part of group #all. But it should.

MDLDialog>>openButtonId: missing .close eventListener

currently, in openButtonId:, there is missing the following statement:

dialog.querySelector(''.close'').addEventListener(''click'', function() \{
      dialog.close();
    });

Without this, it is not possible to close the dialog, except with clicking at the backdrop.
But if the user clicks on "ok" and some action is done, the programmer should have the possibility to close the dialog. Adding the following line allows this by adding the class .close to the button.

It is documented here in the examples:
https://getmdl.io/components/index.html#dialog-section

so, please change it from:

openButtonId: id
   self id ifNil: [ self id: id, '-dialog' ].
    self script: (JSStream on: 
        ('(function() \{
         var dialog = document.querySelector(''#{1}'');
       var showDialogButton = document.querySelector(''#{2}'');
       if (! dialog.showModal) \{
         dialogPolyfill.registerDialog(dialog);
       }
       showDialogButton.addEventListener(''click'', function() \{
         dialog.showModal();
            document.querySelector(''.backdrop'').addEventListener(''click'', function() \{
                dialog.close();
            });
            document.querySelector(''._dialog_overlay'').style.display = "none";
       });
        })()' format: {self id.  id}))

to:

openButtonId: id
   self id ifNil: [ self id: id, '-dialog' ].
    self script: (JSStream on: 
        ('(function() \{
         var dialog = document.querySelector(''#{1}'');
       var showDialogButton = document.querySelector(''#{2}'');
       if (! dialog.showModal) \{
         dialogPolyfill.registerDialog(dialog);
       }
       showDialogButton.addEventListener(''click'', function() \{
         dialog.showModal();
            document.querySelector(''.backdrop'').addEventListener(''click'', function() \{
                dialog.close();
            });
    "This is the new statement"     
        dialog.querySelector(''.close'').addEventListener(''click'', function() \{
        dialog.close();
    });
"end of new statement"

            document.querySelector(''._dialog_overlay'').style.display = "none";
       });
        })()' format: {self id.  id}))

Pagination Widget

It could be cool to have a pagination widget.

See example: https://raw.githubusercontent.com/Crawlink/material-angular-paging/master/demo/paging-demo.png

I imagine the API like this:

| myColl |
myColl := 1 to: 150.
(MDLPaginationWidget numberOfPages: [ myColl size / 24 roundUpTo: 1 ])    "Note the use of a block. If my collection change, the number of pages will be updated."
    adjacentPagesToShow: 3;
    yourself

Or with ajax:

MDLPaginationWidget
    numberOfPages: [ self numbersOfPages ]
    updateBlock: [ :s :html | 
        (s << (html jQuery id: #'main-content') load)
            html: [ :ajaxHtml | self renderMainContentOn: ajaxHtml ];
            onComplete: 'componentHandler.upgradeDom();' ] "The onComplete will update réinitialize the MDL elements"

adjacentPagesToShow would allow to know how many numbers we want to see.

For example if we have 20 pages and 2 adjacent pages to show.
We are on the first page:

<< < 1 2 3 … > >>

On page 13:

<< < … 11 12 13 14 15 … > >>

For example if we have 20 pages and 3 adjacent pages to show.
We are on the first page:

<< < 1 2 3 4 … > >>

On page 13:

<< < … 10 11 12 13 14 15 16 … > >>

Link as buttons

If we want to change of page we need a link. But in some case we want the link to have the look of a button. For now we can wrap a button inside an anchor. But this is not valid HTML5.

We should have MDLAnchors with the same API than the buttons to customize them.

Copy examples on click

It could be cool to copy an example to the clipboard when the user click on the source code of an example inside the MDLApplicationDemo.

Check chips

With the latest release of MDL we got chips. But I already added those.

We need to check if we replace the chips and if we need to adapt the API.

Improve the sliders to add some features

Features wanted:

  • Possibility to have a label with MD style
  • Possibility to add an icon (as MD recommandation say)
  • Possibility to show the output with MD stlye
  • Possibility to show the bounds
  • Add a demo with all this

`MDColor` has a lowercase class variable

MDColor uses colors as a class variable.

In Squeak the compiler complains because it wants to help distinguish class variables (capitalized) from class instance variables (lowercase)

Could colors either be a class instance variable or be capitalized?

MDLButton>> initialize, please remove type="button"

in MDLButton>> initialize there is now

self resetType.

I ask for removing that line.

Reason: it adds
type="button"and that causes callback not to work.

Example:

renderContentOn: html
    html form
        attributeAt: 'target' put: '_top';
        with: [ html mdlButton
                rippleEffect;
                id: #saveButtonID;
                callback: [ 'callback' inspect ];
                onClick: (html jQuery ajax script: [ :s | 'onClick' inspect ]) , html jQuery ajax serializeThis;
                with: 'Test' ]

with the resetType -> onClick works but not callback
without the resetType -> onClick works, also callback

Those who need resetType button can add it themselves but I don't have possibility to remove it easily

Or is there something wrong with my example?

Split widgets into MD and MD extension

Currently there is some widget that are directly describe by Material Design and there is also some that are not describe by Material Design but they integrate well with it.

We should have a package Material-Design-Extension for those.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.