项目作者: pinterweb

项目描述 :
Aurelia plugin to easily switch CSS frameworks
高级语言: TypeScript
项目地址: git://github.com/pinterweb/aurelia-phd.git
创建时间: 2019-11-19T21:34:26Z
项目社区:https://github.com/pinterweb/aurelia-phd

开源协议:MIT License

下载


aurelia-phd

A plugin that allows you to choose a supported CSS framework for your aurelia app.

Conventional Commits

This project is an experiment, in its infancy and is not ready for production yet…

This project is bootstrapped by aurelia-cli.
For a full length tutorial, visit Aurelia plugin guide.

Inspired by aurelia-forms, which seems dead,
trying to refactor applications off bootstrap 3 and a general interest to reduce application setup time

Installation

Not available via NPM. If you are interested, install it with the github link

  1. $ npm i -S pinterweb/aurelia-phd

Supported Frameworks

  1. Bulma
  2. Bootstrap3

..More to come

Usage

Set the framework in your main.ts then use one of the custom elements in your view models. For a full list
of elements see the src/elements folder.

  1. import { PLATFORM } from "aurelia-framework";
  2. export function configure(aurelia) {
  3. aurelia.use
  4. .standardConfiguration()
  5. .plugin(PLATFORM.moduleName("aurelia-phd"), { framework: "bulma" });
  6. // other code ...
  7. return aurelia
  8. .start()
  9. .then(() => aurelia.setRoot(PLATFORM.moduleName("app")));
  10. }

Table Example

For the full table api see src/models.ts. Note: nested tables are supported

app.ts

  1. type Column = import("aurelia-phd").Column;
  2. type Page = import("aurelia-phd").Page;
  3. export class App {
  4. _page: Page = {
  5. size: 10,
  6. pageNumber: 0
  7. };
  8. _columns: Column[] = [];
  9. _data = []; // fill your data
  10. constructor() {
  11. this._columns = [
  12. {
  13. // custom elements supported
  14. renderer: () =>
  15. '<a style="color:#000000" route-href="route: project; params.bind: { projectId: row.item.projectId }"><i class="fa fa-edit pointer"></i></a>'
  16. },
  17. {
  18. field: "projectId",
  19. header: "#"
  20. },
  21. {
  22. field: "task"
  23. }
  24. ];
  25. }
  26. }

app.html

  1. <template>
  2. <phd-search-bar
  3. items.bind="_data"
  4. filtered.delegate="_filteredItems=$event.detail.filteredItems"
  5. ></phd-search-bar
  6. ><br />
  7. <phd-table
  8. items.bind="_filteredItems"
  9. page.bind="_page"
  10. columns.bind="_columns"
  11. >
  12. </phd-table>
  13. <phd-pager
  14. items.bind="_filteredItems"
  15. size.bind="_page.size"
  16. page-number.bind="_page.pageNumber"
  17. page-changed.delegate="_page.pageNumber=$event.detail.pageNumber"
  18. ></phd-pager>
  19. </template>

Dependencies

Building the Plugin

To build the plugin, follow these steps.

  1. From the project folder, execute the following command:
  1. npm install && npm run build

This will transpile all files from src/ folder to dist/native-modules/ and dist/commonjs/.

Note all other files in dev-app/ folder are for the dev app, they would not appear in the published npm package.

Running the examples

Run au run, then open http://localhost:9000

To open browser automatically, do au run --open or npm start -- --open.

To change dev server port, do au run --port 8888.

To change dev server host, do au run --host 127.0.0.1

Running the tests

Run au test, au karma or npm t

To run in watch mode, au test --watch or au karma --watch.