elapsed_time_element 0.10.3
elapsed_time_element: ^0.10.3 copied to clipboard
Dart Polymer component displaying elapsed time for a DateTime instance. For example, 1 day 2 hours 3 minutes.
Elapsed Time Web Component #
Compares a DateTime to the current time and displays the elapsed time, such as
4 hours 38 minutes
Demonstration code can be exercised by running example/app.html in Dartium. This references a demo web component, which in turn references the 'elapsed-time' element.
Usage #
-
This is the simplest case. DateTime.now() is the default time, and no attributes are set.
-
Units like 'minutes' and 'hours' can be abbreviated for a more succinct presentation. Set "verbose" to "false".
-
A ""prefix"" and/or suffix can be specified (for example, " ago").
-
A message can be specified when the elapse is less than one minute (for example, as "moments ago").
-
A specific date can be specified (for example, two hours ago).
-
A future specific date can be specified (for example, two hours from now).
-
The CSS style of the elapsed time can be explicitly set (for example, "color: red;").
-
CSS style can be dynamically configured via a callback (for example, bold red for 2 hours or more, otherwise green italic).
Dart code:
@published StyleCallbackFunction colorTime = (DateTime dateTime, Duration duration) => duration.inMinutes >= 2 ? "color: red; font-weight: bold" : "color: green; font-style: italic";
-
The tooltip icon can be altered to another core-icons option (for example, to "warning").