diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index 62c846f..0000000 --- a/.cargo/config +++ /dev/null @@ -1,5 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" - -[target.'cfg(target_arch = "wasm32")'] -runner = 'wasm-bindgen-test-runner' \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 08cd9ac..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,5 +0,0 @@ -# These are supported funding model platforms - -ko_fi: dudochkin -liberapay: dudochkin -open_collective: dudochkin \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index d845929..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Bug report -about: About unexpected behaviors -title: "[BUG] " -labels: bug -assignees: '' - ---- - -**Describe the bug** -Describe what is expected, what you actually get. -It would be nice to have screenshot or result image uploaded - -**To Reproduce** -Some minimal reproduce code is highly recommended - -**Version Information** -Please give us what version you are using. If you are pulling `YMC` directly from git repo, please mention this as well diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 6b3f659..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea to YMC maintainers -title: "[Feature Request]" -labels: feature request -assignees: '' - ---- - -### What is the feature ? -*Detailed feature descrption* - -### (Optional) Why this feature is useful and how people would use the feature ? -*Explain why this feature is important* - -### (Optional) Additional Information -*More details are appreciated:)* diff --git a/.github/ISSUE_TEMPLATE/general-questions.md b/.github/ISSUE_TEMPLATE/general-questions.md deleted file mode 100644 index 96d4e89..0000000 --- a/.github/ISSUE_TEMPLATE/general-questions.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: General Questions -about: Any other issues -title: '' -labels: '' -assignees: '' - ---- - - diff --git a/.github/codecov.yml b/.github/codecov.yml deleted file mode 100644 index f2cf6e4..0000000 --- a/.github/codecov.yml +++ /dev/null @@ -1,9 +0,0 @@ -comment: - layout: "diff, flags, files" - require_changes: true - -coverage: - status: - project: - default: - informational: true diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml deleted file mode 100644 index e0c79d5..0000000 --- a/.github/workflows/audit.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Security audit -on: - pull_request: - push: - branches: - - master - schedule: - - cron: '0 0 * * 0' - -jobs: - security_audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml deleted file mode 100644 index 950c0e7..0000000 --- a/.github/workflows/coverage.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Test coverage - -#on: -# push: -# branches: -# - main -# pull_request: - -on: [push, pull_request] - -env: - CARGO_TERM_COLOR: always - RUST_BACKTRACE: full - -jobs: - coverage: - name: Coverage - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: wasm32-unknown-unknown - override: true - profile: minimal - default: true - - - name: Restore cache - uses: Swatinem/rust-cache@v1 - - - name: Run cargo-tarpaulin - uses: actions-rs/tarpaulin@v0.1 - with: - args: '--all-features --run-types Doctests,Tests' - timeout: 120 - - - name: Upload to codecov.io - uses: codecov/codecov-action@239febf655bba88b16ff5dea1d3135ea8663a1f9 - with: - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Archive code coverage results - uses: actions/upload-artifact@v2 - with: - name: code-coverage-report - path: cobertura.xml - retention-days: 30 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..18e8e9f --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,30 @@ +# This is a basic workflow to help you get started with Actions + +# On every push this script is executed + +name: Documentation + +on: + push: + branches: + - docs + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: '0.4.6' + # mdbook-version: 'latest' + + - run: mdbook build + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.TOKEN }} + publish_dir: ./book diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 607f583..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Tests - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: wasm32-unknown-unknown - override: true - profile: minimal - default: true - - - name: Build - run: cargo build --verbose - - name: Install test runner - run: cargo install wasm-bindgen-cli - - name: Run tests - run: cargo test --verbose - - clippy_check: - - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: wasm32-unknown-unknown - override: true - profile: minimal - default: true - - - run: rustup component add clippy - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features diff --git a/.gitignore b/.gitignore index 9c869bf..3597896 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,5 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -/refs +.idea +.vscode +.DS_Store +/public/ +/book/ diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 1d6474d..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,24 +0,0 @@ -# Changelog - -## Package vX.X.X (YYYY-MM-DD) - -### Improved - -- A here your changes - -### Added - -- A here your changes - -### Fixed - -- A here your changes - -### Improvement - -- A here your changes - -### Removed - -- A here your changes - diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 8dea5d4..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,129 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community -* Accepting and using the preferred gender pronouns of all people who have specified them involved in the project. - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement by emailing -`dudochkin.victor@gmail.com`. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index b4d1406..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,186 +0,0 @@ -## Contributing to Angular Rust - -This describes how developers may contribute to Angular Rust. - -## Mission - -Angular Rust's mission is to provide a batteries-included framework for making large scale web and desktop application development as efficient and maintainable as possible. - -The design should be configurable and modular so that it can grow with the developer. However, it should provide a wonderful un-boxing experience and default configuration that can woo new developers and make simple web and desktop apps straight forward. The framework should have an opinion about how to do all of the common tasks in web and desktop development to reduce unnecessary cognitive load. - -Perhaps most important of all, Angular Rust should be a joy to use. We want to reduce the time spent on tedious boilerplate functionality and increase the time -available for creating polished solutions for your application's target users. - -## How to Contribute - -### Join the Community - -The first step to improving Angular Rust is to join the community and help grow it! You can find the community on: - - [![](https://img.shields.io/badge/Facebook-1877F2?style=for-the-badge&logo=facebook&logoColor=white)](https://www.facebook.com/groups/angular.rust) - [![](https://img.shields.io/badge/Stack_Overflow-FE7A16?style=for-the-badge&logo=stack-overflow&logoColor=white)](https://stackoverflow.com/questions/tagged/angular-rust) - [![](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/channel/UCBJTkSl_JWShuolUy4JksTQ) - [![](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white)](https://medium.com/@angular.rust) - [![](https://img.shields.io/gitter/room/angular_rust/angular_rust?style=for-the-badge)](https://gitter.im/angular_rust/community) - -We believe the wider community can create better code. The first tool for improving the community is to tell the developers about the project by giving it a star. More stars - more members. - - ![Star a repo](https://dudochkin-victor.github.io/assets/star-me-wide.svg) - -Once you've joined, there are many ways to contribute to Angular Rust: - -* Report bugs (via GitHub) -* Answer questions of other community members (via Gitter or GitHub Discussions) -* Give feedback on new feature discussions (via GitHub and Gitter) -* Propose your own ideas (via Gitter or GitHub) - -### How Angular Rust is Developed - -We have begun to formalize the development process by adopting pragmatic practices such as: - -* Developing on the `develop` branch -* Merging `develop` branch to `main` branch in 6 week iterations -* Tagging releases with MAJOR.MINOR syntax (e.g. v0.8) -** We may also tag MAJOR.MINOR.HOTFIX releases as needed (e.g. v0.8.1) to address urgent bugs. Such releases will not introduce or change functionality -* Managing bugs, enhancements, features and release milestones via GitHub's Issue Tracker -* Using feature branches to create pull requests -* Discussing new features **before** hacking away at it - - -## Dive into code - -### Fork this repository - -fork this repository - -Fork this repository by clicking on the fork button on the top of this page. -This will create a copy of this repository in your account. - -
- -### Clone the repository - -clone this repository - -Now clone the forked repository to your machine. Go to your GitHub account, open the forked repository, click on the code button and then click the _copy to clipboard_ icon. - -Open a terminal and run the following git command: - -``` -git clone "url you just copied" -``` - -where "url you just copied" (without the quotation marks) is the url to this repository (your fork of this project). See the previous steps to obtain the url. - -> use SSH tab to copy proper URL - -copy URL to clipboard - -For example: - -``` -git clone git@github.com:$USER/yew-components.git -``` - -where `$USER` is your GitHub username. Here you're copying the contents of the `yew-components` repository on GitHub to your computer. - - -
- -### Create a branch - -Change to the repository directory on your computer (if you are not already there): - -``` -cd yew-components -``` - -Now create a branch using the `git checkout` command: - -``` -git checkout -b origin/develop -``` -replacing `` with the adequate name of the feature you will develop. - -### Make necessary changes and commit those changes - -Now that you've properly installed and forked Angular Rust, you are ready to start coding (assuming you have a validated your ideas with other community members)! - -### Format Your Code - -Remember to run `cargo fmt` before committing your changes. -Many Go developers opt to have their editor run `cargo fmt` automatically when saving Go files. - -Additionally, follow the [core Rust style conventions](https://rustc-dev-guide.rust-lang.org/conventions.html) to have your pull requests accepted. - -### Write Tests (and Benchmarks for Bonus Points) - -Significant new features require tests. Besides unit tests, it is also possible to test a feature by exercising it in one of the sample apps and verifying its -operation using that app's test suite. This has the added benefit of providing example code for developers to refer to. - -Benchmarks are helpful but not required. - -### Run the Tests - -Typically running the main set of unit tests will be sufficient: - -``` -$ cargo test -``` -### Document Your Feature - -Due to the wide audience and shared nature of Angular Rust, documentation is an essential addition to your new code. **Pull requests risk not being accepted** until proper documentation is created to detail how to make use of new functionality. - -### Add yourself to the list of contributors - -Open `CONTRIBUTORS.md` file in a text editor, add your name to it. Don't add it at the beginning or end of the file. Put it anywhere in between. Now, save the file. - -git status - -If you go to the project directory and execute the command `git status`, you'll see there are changes. - -Add those changes to the branch you just created using the `git add` command: - -``` -git add . -``` - -Now commit those changes using the `git commit` command: - -``` -git commit -m "$COMMENT" -``` - -replacing `$COMMENT` with appropriate description of your changes. - -### Push changes to GitHub - -Push your changes using the command `git push`: - -``` -git push origin -``` - -replacing `` with the name of the branch you created earlier. - -### Submit your changes for review - -Once you've done all of the above & pushed your changes to your fork, you can create a pull request for review and acceptance. - -If you go to your repository on GitHub, you'll see a `Compare & pull request` button. Click on that button. - -create a pull request - -Now submit the pull request. -Do not forget to set develop branch for your pull request. - -submit pull request - - -## Where to go from here? - -Congrats! You just completed the standard _fork -> clone -> edit -> pull request_ workflow that you'll encounter often as a contributor! - -You can check more details in our **[detailed contribution guide](https://angular-rust.github.io/contributing/)**. - -You could join our gitter team in case you need any help or have any questions. [Join gitter team](https://gitter.im/angular_rust/community). diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md deleted file mode 100644 index bcf7cbf..0000000 --- a/CONTRIBUTORS.md +++ /dev/null @@ -1,10 +0,0 @@ -YEW Components contributors (sorted alphabetically) -============================================ - -* **[Victor Dudochkin](https://github.com/dudochkin.victor)** - - * Core development - - - -**[Full contributors list](https://github.com/angular-rust/yew-components/contributors).** \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 14d25a8..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,121 +0,0 @@ -[package] -name = "ymc" -version = "0.1.0" -authors = ["Victor Dudochkin "] -readme = "README.md" -homepage = "https://angular-rust.github.io/yew-components" -repository = "https://github.com/angular-rust/yew-components" -documentation = "https://docs.rs/ymc" -description = "Materail Components for YEW" -keywords = ["wasm", "web", "material", "yew", "material-components"] -categories = ["wasm", "web-programming", "gui"] -edition = "2018" -license = "MPL-2.0" - -[badges] -maintenance = { status = "actively-developed" } - -[features] -banner = [] -button = [] -barchart = ["ux-animate", "ux-dataflow", "ux-charts"] -card = [] -charts = ["barchart", "gaugechart", "linechart", "piechart", "radarchart"] -checkbox = [] -chips = [] -circular-progress-four-color = [] -circular-progress = [] -data-table = [] -dialog = [] -drawer = [] -fab = [] -formfield = [] -gaugechart = ["ux-animate", "ux-dataflow", "ux-charts"] -icon-button-toggle = [] -icon-button = [] -icon = [] -image-list = [] -linechart = ["ux-animate", "ux-dataflow", "ux-charts"] -linear-progress = [] -list = [] -menu = [] -piechart = ["ux-animate", "ux-dataflow", "ux-charts"] -radarchart = ["ux-animate", "ux-dataflow", "ux-charts"] -radio = [] -select = [] -slider = [] -snackbar = [] -switch = [] -tabs = [] -textarea = [] -textfield = [] -tooltip = [] -top-app-bar-fixed = [] -top-app-bar = [] -full = [ - "banner", - "button", - "card", - "charts", - "checkbox", - "chips", - "circular-progress-four-color", - "circular-progress", - "data-table", - "dialog", - "drawer", - "fab", - "formfield", - "icon-button-toggle", - "icon-button", - "icon", - "image-list", - "linear-progress", - "list", - "menu", - "radio", - "select", - "slider", - "snackbar", - "switch", - "tabs", - "textarea", - "textfield", - "tooltip", - "top-app-bar-fixed", - "top-app-bar", -] -default = ["full"] - -[dependencies] -wasm-bindgen = "0.2" -wasm-bindgen-futures = "0.4" -wasm-logger = "0.2" -gloo = "0.2" -js-sys = "0.3" -log = "0.4" -wee_alloc = { version = "0.4", optional = true } -yew = "0.17" -yew-router = "0.14" - -ux-dataflow = { version = "0.1.1", optional = true } -ux-animate = { version = "0.1.3", optional = true } -ux-charts = { version = "0.1.2", optional = true } - -[dev-dependencies] -wasm-bindgen-test = "0.3" -doc-comment = "0.3" - -[dependencies.web-sys] -version = "0.3" -features = [ - 'KeyboardEvent', - "ValidityState", - "CustomEvent", - "Node", - "Element", - "HtmlElement", - "Window", - "Document", - "HtmlCanvasElement", -] diff --git a/README.md b/README.md index cf1f0a7..42b281b 100644 --- a/README.md +++ b/README.md @@ -1,182 +1 @@ -# - -
- -[![](https://dudochkin-victor.github.io/assets/yew-components/logo.svg)](#top) -# YEW Material Components - -[![API Docs][docrs-badge]][docrs-url] -[![Crates.io][crates-badge]][crates-url] -[![Code coverage][codecov-badge]][codecov-url] -[![Tests][tests-badge]][tests-url] -[![MPL-2.0 licensed][license-badge]][license-url] -[![Gitter chat][gitter-badge]][gitter-url] -[![loc][loc-badge]][loc-url] -
- -[docrs-badge]: https://img.shields.io/docsrs/ymc?style=flat-square -[docrs-url]: https://docs.rs/uymc/ -[crates-badge]: https://img.shields.io/crates/v/ymc.svg?style=flat-square -[crates-url]: https://crates.io/crates/ymc -[license-badge]: https://img.shields.io/badge/license-MPL--2.0-blue.svg?style=flat-square -[license-url]: https://github.com/angular-rust/yew-components/blob/master/LICENSE -[gitter-badge]: https://img.shields.io/gitter/room/angular_rust/community.svg?style=flat-square -[gitter-url]: https://gitter.im/angular_rust/community -[tests-badge]: https://img.shields.io/github/workflow/status/angular-rust/yew-components/Tests?label=tests&logo=github&style=flat-square -[tests-url]: https://github.com/angular-rust/yew-components/actions/workflows/tests.yml -[codecov-badge]: https://img.shields.io/codecov/c/github/angular-rust/yew-components?logo=codecov&style=flat-square&token=OWZIWBTGII -[codecov-url]: https://codecov.io/gh/angular-rust/yew-components -[loc-badge]: https://img.shields.io/tokei/lines/github/angular-rust/yew-components?style=flat-square -[loc-url]: https://github.com/angular-rust/yew-components - -Material Design Components for the Yew framework. - -**Angular Rust** is a high productivity, `platform-agnostic` frontend framework for the [Rust language](https://www.rust-lang.org/). It now supports desktop and web development. Angular Rust currently uses GTK for desktop development and WebAssembly for web development. We are planning to add support for mobile development. - -Yew Material Components is a components library for [Yew framework](https://yew.rs/) which is a wrapper around [Material Design Components](https://github.com/material-components/material-components-web) exposing Yew components. All modern browsers are supported. - - -## Getting started - -### Installation - -Currently, this library is available from [crates.io](https://crates.io/). Add it using `cargo-edit` -``` -cargo add ymc -``` - -Cargo features are used to pick the components. See [features](#features) - -`Cargo.toml`: -```toml -[dependencies] -ymc = { version = "0.1", features = ["full"] } -``` -Material icons and a Material font can also be imported for full functionality. -`index.html`: -```html - - -``` - -It's also important to note that you need `viewport` `meta` tag for the Material Components to be responsive. -```html - -``` - -### Features - -Following are all the cargo features available (each feature corresponds to its respective component): - -- [x] `banner` -- [x] `button` -- [x] `card` -- [x] `checkbox` -- [x] `chips` -- [x] `circular-progress-four-color` -- [x] `circular-progress` -- [x] `data-table` -- [x] `dialog` -- [x] `drawer` -- [x] `fab` -- [x] `formfield` -- [x] `icon-button-toggle` -- [x] `icon-button` -- [x] `icon` -- [x] `image-list` -- [x] `linear-progress` -- [x] `list` -- [x] `menu` -- [x] `radio` -- [x] `select` -- [x] `slider` -- [x] `slider` -- [x] `snackbar` -- [x] `switch` -- [x] `tabs` -- [x] `textarea` -- [x] `textfield` -- [x] `tooltip` -- [x] `top-app-bar-fixed` -- [x] `top-app-bar` - -`full` feature enables all the components - -## Adding additional components -This is still a work in progress... feel free to add additional components. - -To port a component that hasn't been ported yet open [TODO](https://github.com/angular-rust/yew-components/blob/main/TODO.md) - -Implement a component you need and add it to the src/ directory. - -## Theming - -These components respect the theming applied to Material Design Components using stylesheets. [Learn about how to theme Material Design Components.](https://github.com/material-components/material-components-web-components/blob/master/docs/theming.md) - - -## Learn More - -* [Manual, Docs, etc](https://angular-rust.github.io/) -* [Samples](https://github.com/angular-rust/ux-samples) -* [Apps using Angular Rust](https://github.com/angular-rust/yew-components/wiki/Apps-in-the-Wild) -* [Articles Featuring Angular Rust](https://github.com/angular-rust/yew-components/wiki/Articles) - - -## Community - - [![](https://img.shields.io/badge/Facebook-1877F2?style=for-the-badge&logo=facebook&logoColor=white)](https://www.facebook.com/groups/angular.rust) - [![](https://img.shields.io/badge/Stack_Overflow-FE7A16?style=for-the-badge&logo=stack-overflow&logoColor=white)](https://stackoverflow.com/questions/tagged/angular-rust) - [![](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/channel/UCBJTkSl_JWShuolUy4JksTQ) - [![](https://img.shields.io/badge/Medium-12100E?style=for-the-badge&logo=medium&logoColor=white)](https://medium.com/@angular.rust) - [![](https://img.shields.io/gitter/room/angular_rust/angular_rust?style=for-the-badge)](https://gitter.im/angular_rust/community) - - -## Contributing - -We believe the wider community can create better code. The first tool for improving the community is to tell the developers about the project by giving it a star. More stars - more members. - - [![](https://dudochkin-victor.github.io/assets/star-me-wide.svg)](https://github.com/angular-rust/yew-components#top) - -Angular Rust is a community effort and we welcome all kinds of contributions, big or small, from developers of all backgrounds. We want the Angular Rust community to be a fun and friendly place, so please review our [Code of Conduct](CODE_OF_CONDUCT.md) to learn what behavior will not be tolerated. - -### New to Angular Rust? - -Start learning about the framework by helping us improve our [documentation](https://angular-rust.github.io/). Pull requests which improve test coverage are also very welcome. - -### Looking for inspiration? - -Check out the community curated list of awesome things related to Angular Rust / WebAssembly at [awesome-angular-rust](https://github.com/angular-rust/awesome-angular-rust). - -### Confused about something? - -Feel free to drop into our [Gitter chatroom](https://gitter.im/angular_rust/community) or open a [new "Question" issue](https://github.com/angular-rust/yew-components/issues/new/choose) to get help from contributors. Often questions lead to improvements to the ergonomics of the framework, better documentation, and even new features! - -### Ready to dive into the code? - -After reviewing the [Contributing Code Guidelines](CONTRIBUTING.md), check out the ["Good First Issues"](https://github.com/angular-rust/yew-components/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) (they are eager for attention!). Once you find one that interests you, feel free to assign yourself to an issue and don't hesitate to reach out for guidance, the issues vary in complexity. - -### Let's help each other! - -Come help us on the [issues that matter that the most](https://github.com/angular-rust/yew-components/labels/%3Adollar%3A%20Funded%20on%20Issuehunt) and receive a small cash reward for your troubles. We use [Issuehunt](https://issuehunt.io/r/angular-rust/yew-components/) to fund issues from our Open Collective funds. If you really care about an issue, you can choose to add funds yourself! - -### Found a bug? - -Please [report all bugs!](https://github.com/angular-rust/yew-components/issues/new/choose) We are happy to help support developers fix the bugs they find if they are interested and have the time. - -## Todo -- [ ] Documentation - -## Alternatives - -- https://github.com/Follpvosten/yew-mdc -- https://github.com/AlephAlpha/muicss-yew - -## Resources - -- https://github.com/material-components/material-components-web -- https://github.com/material-components/material-components-web-react -- https://material-components.github.io/material-components-web-catalog/#/ -- https://github.com/jamesmfriedman/rmwc -- https://github.com/pgbross/vue-material-adapter -- https://github.com/material-components/material-components-web/blob/master/docs/integrating-into-frameworks.md -- https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md +# yew-components github pages \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 27f409c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,13 +0,0 @@ -# Security Policy - -If you believe you have found a security vulnerability in Angular Rust, we encourage you to let us know right away. We will investigate all legitimate reports and do our best to quickly fix the problem. - -## Reporting a Vulnerability - -To report a security vulnerability, please create a Github issue [here](https://github.com/angular-rust/yew-components/issues/new). - -If you can, please include the following details: -* An MCVE (minimum complete verifiable example) – this is a short code snippet which demonstrates the error in the -the simplest possible (or just a simple) way. -* Which versions of Angular Rust the vulnerability is present in -* What effects the vulnerability has and how serious the vulnerability is \ No newline at end of file diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 06f0827..0000000 --- a/TODO.md +++ /dev/null @@ -1,35 +0,0 @@ -## From Spec - -- [ ] Dividers -- [ ] Backdrop -- [ ] Sheets -- [ ] Time pickers -- [ ] Date pickers - -## From Vuetify - -- [ ] Stepper -- [ ] Treeview -- [ ] Rating -- [ ] Color Picker -- [ ] Parallax -- [ ] Pagination -- [ ] Overlays -- [ ] Groups - - [ ] Button Group - - [ ] Chip Group - - [ ] Item Group - - [ ] ListItem Group - - [ ] Side Group - - [ ] Windows -- [ ] Grid System -- [ ] TimeLine -- [ ] Selects -- [ ] Footers -- [ ] Expansion Panel -- [ ] Carousel -- [ ] Calendar -- [ ] BreadCrumbs -- [ ] Badges -- [ ] Avatars -- [ ] Allerts diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..7d69777 --- /dev/null +++ b/book.toml @@ -0,0 +1,10 @@ +[book] +title = "Yew Material Components" +authors = ["Victor Dudochkin"] +language = "en" +multilingual = false +src = "src" + +[output.html] +theme = "src/theme" +site-url = "/yew-components/" diff --git a/src/SUMMARY.md b/src/SUMMARY.md new file mode 100644 index 0000000..7390c82 --- /dev/null +++ b/src/SUMMARY.md @@ -0,0 +1,3 @@ +# Summary + +- [Chapter 1](./chapter_1.md) diff --git a/src/banner.rs b/src/banner.rs deleted file mode 100644 index 6806b49..0000000 --- a/src/banner.rs +++ /dev/null @@ -1,100 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct Banner { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`Banner`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct BannerProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - // #[prop_or_default] - // pub onsignal: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for Banner { - type Message = Msg; - type Properties = BannerProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - html! { - - } - } -} diff --git a/src/barchart.rs b/src/barchart.rs deleted file mode 100644 index d3a9b22..0000000 --- a/src/barchart.rs +++ /dev/null @@ -1,191 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use animate::Canvas; -use charts::{BarChart as BarChartComponent, BarChartOptions, Chart}; -use dataflow::*; -use wasm_bindgen::prelude::*; -use wasm_bindgen::JsCast; -use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement}; -use yew::prelude::*; - -pub struct BarChart { - props: BarChartProps, - link: ComponentLink, - node_ref: NodeRef, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`BarChart`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct BarChartProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - #[prop_or_default] - pub onclick: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for BarChart { - type Message = Msg; - type Properties = BarChartProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - props, - node_ref: NodeRef::default(), - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - self.props.onclick.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - html! { - - } - } - - fn rendered(&mut self, first_render: bool) { - let canvas = self.node_ref.cast::().unwrap(); - let cr: CanvasRenderingContext2d = canvas - .get_context("2d") - .unwrap() - .unwrap() - .dyn_into() - .unwrap(); - - let stream = create_stream(); - - let mut options: BarChartOptions = Default::default(); - options.channel.labels = Some(Default::default()); - // options.xaxis.crosshair = Some(Default::default()); // enable crosshair - options.xaxis.labels.max_rotation = 90; - options.xaxis.labels.min_rotation = 0; - options.yaxis.min_value = Some(0); - options.yaxis.min_interval = Some(2.); - - let mut chart = BarChartComponent::new(options); - chart.set_stream(stream); - - chart.resize(800., 400.); - - let ctx = Canvas::new(&cr); // overhead - chart.draw(&ctx); - - // let element = self.node_ref.cast::().unwrap(); - // if self.props.checked { - // element.set_checked(self.props.checked); - // } - // if first_render { - // let callback = self.props.onchange.clone(); - // let target = self.node_ref.cast::().unwrap(); - // self.change_listener = Some(EventListener::new(&target, "change", move |_| { - // callback.emit(element.checked()); - // })); - // } - } -} - -fn create_stream() -> DataStream<'static, &'static str, i32> { - let metadata = vec![ - Channel { - name: "Series 1", - tag: 0, - visible: true, - }, - Channel { - name: "Series 2", - tag: 1, - visible: true, - }, - Channel { - name: "Series 3", - tag: 2, - visible: true, - }, - ]; - - // Zero stream tag is allways metric - let mut frames = vec![DataFrame { - metric: "Monday", - data: [(0, 1), (1, 3), (2, 5)].iter().cloned().collect(), - }]; - - frames.push(DataFrame { - metric: "Tuesday", - data: [(0, 3), (1, 4), (2, 6)].iter().cloned().collect(), - }); - - frames.push(DataFrame { - metric: "Wednesday", - data: [(0, 4), (1, 3), (2, 1)].iter().cloned().collect(), - }); - - // let skip one stream flow - frames.push(DataFrame { - metric: "Thursday", - data: [(1, 5), (2, 1)].iter().cloned().collect(), - }); - - frames.push(DataFrame { - metric: "Friday", - data: [(0, 3), (1, 4), (2, 2)].iter().cloned().collect(), - }); - - frames.push(DataFrame { - metric: "Saturday", - data: [(0, 5), (1, 10), (2, 4)].iter().cloned().collect(), - }); - - frames.push(DataFrame { - metric: "Sunday", - data: [(0, 4), (1, 12), (2, 8)].iter().cloned().collect(), - }); - - DataStream::new(metadata, frames) -} \ No newline at end of file diff --git a/src/button.rs b/src/button.rs deleted file mode 100644 index ed70dfa..0000000 --- a/src/button.rs +++ /dev/null @@ -1,88 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct Button { - props: ButtonProps, - link: ComponentLink, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`Button`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct ButtonProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - #[prop_or_default] - pub onclick: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for Button { - type Message = Msg; - type Properties = ButtonProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - props, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - self.props.onclick.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - html! { - - } - } -} diff --git a/src/card.rs b/src/card.rs deleted file mode 100644 index 77424b1..0000000 --- a/src/card.rs +++ /dev/null @@ -1,116 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -mod actions; -mod buttons; -mod media; -mod primary_action; - -pub use actions::*; -pub use buttons::*; -pub use media::*; -pub use primary_action::*; - -pub struct Card { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`Card`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct CardProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - // #[prop_or_default] - // pub onsignal: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for Card { - type Message = Msg; - type Properties = CardProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - html! { -
-
-
-
{ "Title" }
-
-
-
-
- - -
-
- - -
-
-
- } - } -} diff --git a/src/card/actions.rs b/src/card/actions.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/card/buttons.rs b/src/card/buttons.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/card/media.rs b/src/card/media.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/card/primary_action.rs b/src/card/primary_action.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/chapter_1.md b/src/chapter_1.md new file mode 100644 index 0000000..b743fda --- /dev/null +++ b/src/chapter_1.md @@ -0,0 +1 @@ +# Chapter 1 diff --git a/src/checkbox.rs b/src/checkbox.rs deleted file mode 100644 index 1d84d76..0000000 --- a/src/checkbox.rs +++ /dev/null @@ -1,108 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use super::to_option; -use gloo::events::EventListener; -use wasm_bindgen::prelude::*; -use web_sys::{Element, Node}; -use yew::prelude::*; - -/// The `checkbox` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/checkbox) -pub struct Checkbox { - props: CheckboxProps, - node_ref: NodeRef, - change_listener: Option, -} - -/// Props for [`Checkbox`] -/// -/// Documentation: -/// -/// - [Properties](https://github.com/material-components/material-components-web-components/tree/master/packages/checkbox#propertiesattributes) -/// - [Events](https://github.com/material-components/material-components-web-components/tree/master/packages/checkbox#events) -#[derive(Clone, PartialEq, Properties)] -pub struct CheckboxProps { - #[prop_or_default] - pub checked: bool, - #[prop_or_default] - pub indeterminate: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub value: String, - #[prop_or_default] - pub reduced_touch_target: bool, - /// Binds to `change` event on `checkbox` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onchange: Callback, -} - -impl Component for Checkbox { - type Message = (); - type Properties = CheckboxProps; - - fn create(props: Self::Properties, _link: ComponentLink) -> Self { - // Checkbox::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - change_listener: None, - } - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - // indeterminate?=to_option(self.props.indeterminate) - // disabled=self.props.disabled - // value=self.props.value - // reducedTouchTarget?=to_option(self.props.reduced_touch_target) - // ref=self.node_ref.clone() - - fn view(&self) -> Html { - - html! { -
- -
- - - -
-
-
-
- } - } - - fn rendered(&mut self, first_render: bool) { - // let element = self.node_ref.cast::().unwrap(); - // if self.props.checked { - // element.set_checked(self.props.checked); - // } - // if first_render { - // let callback = self.props.onchange.clone(); - // let target = self.node_ref.cast::().unwrap(); - // self.change_listener = Some(EventListener::new(&target, "change", move |_| { - // callback.emit(element.checked()); - // })); - // } - } -} diff --git a/src/chip.rs b/src/chip.rs deleted file mode 100644 index 7b19d73..0000000 --- a/src/chip.rs +++ /dev/null @@ -1,235 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::{event_into_details, to_option, WeakComponentLink}; -use gloo::events::EventListener; -use wasm_bindgen::prelude::*; -use web_sys::Node; -use yew::prelude::*; - -pub struct Chip { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`Chip`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Debug, Properties, Clone)] -pub struct ChipProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - // #[prop_or_default] - // pub onsignal: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for Chip { - type Message = Msg; - type Properties = ChipProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - html! { -
-
- - - { &self.label } - - -
- } - } -} - -// chips - - -pub struct Chips { - props: ChipsProps, - node_ref: NodeRef, - action_listener: Option, - selected_listener: Option, -} - -/// Props for [`Chips`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct ChipsProps { - #[prop_or_default] - pub activatable: bool, - #[prop_or_default] - pub root_tabbable: bool, - #[prop_or_default] - pub multi: bool, - #[prop_or_default] - pub wrap_focus: bool, - #[prop_or_default] - pub item_roles: Option, - #[prop_or_default] - pub inner_role: Option, - #[prop_or_default] - pub noninteractive: bool, - /// Binds to `action` event on `list` - // #[prop_or_default] - // pub onaction: Callback, - // /// Binds to `selected` event `list` - // #[prop_or_default] - // pub onselected: Callback, - /// [`WeakComponentLink`] for `List` which provides the following methods - /// - ```toggle(&self, index: usize, force: bool)``` - /// - ```get_focused_item_index(&self) -> usize``` - /// - ```focus_item_at_index(&self, index: usize)``` - /// - /// See [`WeakComponentLink`] documentation for more information - #[prop_or_default] - pub list_link: WeakComponentLink, - #[prop_or_default] - pub children: Children, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for Chips { - type Message = Msg; - type Properties = ChipsProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - props, - node_ref: NodeRef::default(), - action_listener: None, - selected_listener: None, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - html! { -
- { self.view_items() } -
- } - } -} - -impl Chips { - fn view_items(&self) -> Html { - html! {{ - for self.props.children.iter().enumerate().map(|(i, mut c)| { - c - }) - }} - } -} - -impl WeakComponentLink { - /// Binds to `toggle` method. - /// - /// See [here](https://github.com/material-components/material-components-web-components/tree/master/packages/list#methods) for details - pub fn toggle(&self, index: usize, force: bool) { - // let list = (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap(); - // list.toggle(index, force) - } - - /// Binds to `getFocusedItemIndex` method. - /// - /// See [here](https://github.com/material-components/material-components-web-components/tree/master/packages/list#methods) for details - pub fn get_focused_item_index(&self) -> usize { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .get_focused_item_index() - unimplemented!() - } - - /// Binds to `focusItemAtIndex` method. - /// - /// See [here](https://github.com/material-components/material-components-web-components/tree/master/packages/list#methods) for details - pub fn focus_item_at_index(&self, index: usize) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .focus_item_at_index(index) - } -} diff --git a/src/circular_progress.rs b/src/circular_progress.rs deleted file mode 100644 index dba9799..0000000 --- a/src/circular_progress.rs +++ /dev/null @@ -1,97 +0,0 @@ -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct CircularProgress { - link: ComponentLink, - // label: String, - // onsignal: Callback<()>, -} - -/// Props for [`CircularProgress`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/circular-progress#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct CircularProgressProps { - #[prop_or_default] - pub indeterminate: bool, - #[prop_or_default] - pub progress: f32, - #[prop_or_default] - pub density: u32, - #[prop_or_default] - pub closed: bool, -} - -// indeterminate?=to_option(props.indeterminate) -// progress=props.progress -// density=props.density -// closed?=to_option(props.closed) - -impl Component for CircularProgress { - type Message = (); - type Properties = CircularProgressProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - // label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - // match msg { - // Msg::Clicked => { - // // self.onsignal.emit(()); - // } - // } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - // self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // onclick=self.link.callback(|_| Msg::Clicked)> - // { &self.label } - // { props.children.clone() } - html! { -
-
- - - - -
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
- } - } -} - -// -// -// \ No newline at end of file diff --git a/src/circular_progress_four_color.rs b/src/circular_progress_four_color.rs deleted file mode 100644 index 298b0a8..0000000 --- a/src/circular_progress_four_color.rs +++ /dev/null @@ -1,92 +0,0 @@ -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct CircularProgressFourColor { - link: ComponentLink, - // label: String, - // onsignal: Callback<()>, -} - -/// Props for [`CircularProgressFourColor`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/circular-progress-four-color#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct CircularProgressFourColorProps { - #[prop_or_default] - pub indeterminate: bool, - #[prop_or_default] - pub progress: f32, - #[prop_or_default] - pub density: u32, - #[prop_or_default] - pub closed: bool, -} - -// indeterminate?=to_option(props.indeterminate) -// progress=props.progress -// density=props.density -// closed?=to_option(props.closed) - -impl Component for CircularProgressFourColor { - type Message = (); - type Properties = CircularProgressFourColorProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - // label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - // match msg { - // Msg::Clicked => { - // // self.onsignal.emit(()); - // } - // } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - // self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // onclick=self.link.callback(|_| Msg::Clicked)> - // { &self.label } - // { props.children.clone() } - html! { -
-
- - - - -
-
-
-
- - - -
-
- - - -
-
- - - -
-
-
-
- } - } -} diff --git a/src/datatable.rs b/src/datatable.rs deleted file mode 100644 index 16b3641..0000000 --- a/src/datatable.rs +++ /dev/null @@ -1,117 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct DataTable { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`DataTable`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct DataTableProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - // #[prop_or_default] - // pub onsignal: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for DataTable { - type Message = Msg; - type Properties = DataTableProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - html! { -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{ "Dessert" }{ "Carbs (g)" }{ "Protein (g)" }{ "Comments" }
{ "Frozen yogurt" }{ "24" }{ "4.0" }{ "Super tasty" }
{ "Ice cream sandwich" }{ "37" }{ "4.33333333333" }{ "I like ice cream more" }
{ "Eclair" }{ "24" }{ "6.0" }{ "New filing flavor" }
-
-
- } - } -} diff --git a/src/date_picker.rs b/src/date_picker.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/dialog.rs b/src/dialog.rs deleted file mode 100644 index 3d065dd..0000000 --- a/src/dialog.rs +++ /dev/null @@ -1,223 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -mod dialog_action; -pub use dialog_action::*; - -use super::{event_details_into, to_option, WeakComponentLink}; -use gloo::events::EventListener; -use wasm_bindgen::prelude::*; -use web_sys::{Element, Node}; -use yew::prelude::*; - -/// The `dialog` component. -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/dialog) -/// -/// ## Actions -/// -/// In order to pass actions, [`DialogAction`] component should be -/// used. -pub struct Dialog { - props: DialogProps, - node_ref: NodeRef, - opening_listener: Option, - opened_listener: Option, - closing_listener: Option, - closed_listener: Option, -} - -/// Props for [`Dialog`] -/// -/// Documentation: -/// -/// - [Properties](https://github.com/material-components/material-components-web-components/tree/master/packages/dialog#propertiesattributes) -/// - [Events](https://github.com/material-components/material-components-web-components/tree/master/packages/dialog#events) -#[derive(Clone, PartialEq, Properties)] -pub struct DialogProps { - #[prop_or_default] - pub open: bool, - #[prop_or_default] - pub hide_action: bool, - #[prop_or_default] - pub stacked: bool, - #[prop_or_default] - pub heading: Option, - #[prop_or_default] - pub scrim_click_action: Option, - #[prop_or_default] - pub escape_key_action: Option, - #[prop_or_default] - pub default_action: Option, - #[prop_or_default] - pub action_attribute: Option, - #[prop_or_default] - pub initial_focus_attribute: Option, - /// Binds to `opening` event on `dialog` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onopening: Callback<()>, - /// Binds to `opened` event on `dialog` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onopened: Callback<()>, - /// Binds to `closing` event on `dialog` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onclosing: Callback, - /// Binds to `closed` event on `dialog` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onclosed: Callback, - /// [`WeakComponentLink`] for `Dialog` which provides the following - /// methods: - /// - ```focus(&self)``` - /// - ```blur(&self)``` - /// - ```show(&self)``` - /// - ```close(&self)``` - /// - /// See [`WeakComponentLink`] documentation for more information - #[prop_or_default] - pub dialog_link: WeakComponentLink, - #[prop_or_default] - pub children: Children, -} - -impl Component for Dialog { - type Message = (); - type Properties = DialogProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - // props.dialog_link.borrow_mut().replace(link); - // Dialog::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - opening_listener: None, - opened_listener: None, - closing_listener: None, - closed_listener: None, - } - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - // open=self.props.open - // hideActions?=to_option(self.props.hide_action) - // stacked?=to_option(self.props.stacked) - // heading?=self.props.heading.as_ref() - // scrimClickAction?=self.props.scrim_click_action.as_ref() - // escapeKeyAction?=self.props.escape_key_action.as_ref() - // defaultAction?=self.props.default_action.as_ref() - // actionAttribute?=self.props.action_attribute.as_ref() - // initialFocusAttribute?=self.props.initial_focus_attribute.as_ref() - // ref=self.node_ref.clone()> - // { self.props.children.clone() } - - html! { -
-
-
-
{ "Discard draft?" }
-
- - -
-
-
-
-
- } - } - - fn rendered(&mut self, first_render: bool) { - // if first_render { - // let onopening = self.props.onopening.clone(); - // let onopened = self.props.onopened.clone(); - // let onclosing = self.props.onclosing.clone(); - // let onclosed = self.props.onclosed.clone(); - - // let element = self.node_ref.cast::().unwrap(); - - // self.opening_listener = Some(EventListener::new(&element, "opening", move |_| { - // onopening.emit(()) - // })); - - // self.opened_listener = Some(EventListener::new(&element, "opened", move |_| { - // onopened.emit(()) - // })); - - // self.closing_listener = Some(EventListener::new(&element, "closing", move |event| { - // onclosing.emit(action_from_event(event)) - // })); - - // self.closed_listener = Some(EventListener::new(&element, "closed", move |event| { - // onclosed.emit(action_from_event(event)) - // })); - // } - } -} - -impl WeakComponentLink { - pub fn focus(&self) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .focus() - } - - pub fn blur(&self) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .blur() - } - - pub fn show(&self) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .show() - } - - pub fn close(&self) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .close() - } -} - -// fn action_from_event(event: &Event) -> String { -// event_details_into::(event).action() -// } diff --git a/src/dialog/dialog_action.rs b/src/dialog/dialog_action.rs deleted file mode 100644 index d5c6934..0000000 --- a/src/dialog/dialog_action.rs +++ /dev/null @@ -1,80 +0,0 @@ -use yew::prelude::*; - -/// Dialog action type. -#[derive(Clone)] -pub enum ActionType { - /// Binds `to slot` of `primaryAction` - Primary, - /// Binds `to slot` of `secondaryAction` - Secondary, -} - -impl ToString for ActionType { - fn to_string(&self) -> String { - match self { - ActionType::Primary => "primaryAction", - ActionType::Secondary => "secondaryAction", - } - .to_string() - } -} - -/// Props for [`DialogAction`] -#[derive(Properties, Clone)] -pub struct ActionProps { - pub action_type: ActionType, - #[prop_or_default] - pub action: Option, - pub children: Children, -} - -/// Defines actions for [`Dialog`][crate::Dialog]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct DialogAction { - props: ActionProps, -} - -impl Component for DialogAction { - type Message = (); - type Properties = ActionProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self.props.children.iter().map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", self.props.action_type.to_string()); - // if let Some(action) = self.props.action.as_ref() { - // vtag.add_attribute("dialogAction", action.to_owned()); - // } - // Html::VTag(vtag) - // } - // _ => html! { - // - // { child } - // - // } - // } - // }).collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/drawer.rs b/src/drawer.rs deleted file mode 100644 index a07238b..0000000 --- a/src/drawer.rs +++ /dev/null @@ -1,338 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -mod drawer_app_content; -mod drawer_header; -mod drawer_subtitle; -mod drawer_title; - -pub use drawer_app_content::*; -pub use drawer_header::*; -pub use drawer_subtitle::*; -pub use drawer_title::*; - -use super::WeakComponentLink; -use gloo::{ - events::EventListener, - timers::callback::Timeout, -}; - -use wasm_bindgen::prelude::*; -use wasm_bindgen::JsCast; -use web_sys::{Element, Node}; -use yew::prelude::*; -use std::cell::RefCell; -use std::rc::Rc; - -/// The `drawer` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/drawer) -pub struct Drawer { - props: DrawerProps, - node_ref: NodeRef, - opened_listener: Option, - closed_listener: Option, - animation_frame: i32, - animation_timer: i32, -} - -pub enum DrawerMsg { - Open, - Close, - TransitionEnd, -} - -/// Props for [`Drawer`] -/// -/// Documentation: -/// -/// - [Properties](https://github.com/material-components/material-components-web-components/tree/master/packages/drawer#propertiesattributes) -/// - [Events](https://github.com/material-components/material-components-web-components/tree/master/packages/drawer#events) -#[derive(Clone, PartialEq, Properties)] -pub struct DrawerProps { - #[prop_or_default] - pub open: bool, - #[prop_or_default] - pub has_header: Option, - #[prop_or_default] - pub drawer_type: String, - /// Binds to `opened` event on `drawer` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onopened: Callback<()>, - /// Binds to `closed` event on `drawer` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onclosed: Callback<()>, - #[prop_or_default] - pub link: WeakComponentLink, - #[prop_or_default] - pub children: Children, -} - -impl Component for Drawer { - type Message = DrawerMsg; - type Properties = DrawerProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - props.link.borrow_mut().replace(link); - // Drawer::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - opened_listener: None, - closed_listener: None, - animation_frame: 0, - animation_timer: 0, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Self::Message::Open => { - self.props.open = true; - let el = self.node_ref.cast::().unwrap(); - let class_list = el.class_list(); - let _ = class_list.add_2("mdc-drawer--open", "mdc-drawer--animate"); - - // just a set timeout - let timeout = Timeout::new(5, move || { - let _ = class_list.add_1("mdc-drawer--opening"); - }); - - timeout.forget(); - - // // request animation frame - // let f = Rc::new(RefCell::new(None)); - // let g = f.clone(); - // // let g = f.borrow().as_ref().unwrap(); - // *g.borrow_mut() = Some(Closure::wrap(Box::new(move ||{ - // info!("OOOUCH"); - // let _ = f.borrow_mut().take(); - // let timeout = Timeout::new(0, move || { - // info!("GOT TIMEOUT"); - // }); - // timeout.forget(); - // }) as Box)); - // request_animation_frame(g.borrow().as_ref().unwrap()); - }, - Self::Message::Close => { - // self.onsignal.emit(()); - self.props.open = false; - let el = self.node_ref.cast::().unwrap(); - let class_list = el.class_list(); - let _ = class_list.add_1("mdc-drawer--closing"); - } - Self::Message::TransitionEnd => { - let el = self.node_ref.cast::().unwrap(); - let class_list = el.class_list(); - let _ = class_list.remove_3("mdc-drawer--animate", "mdc-drawer--opening", "mdc-drawer--closing"); - if !self.props.open { - let _ = class_list.remove_1("mdc-drawer--open"); - } - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - // hasHeader?=self.props.has_header - let link = self.props.link.borrow().clone().unwrap(); - html! { - <> - -
- - } - } - - fn rendered(&mut self, first_render: bool) { - // let element = self.node_ref.cast::().unwrap(); - // element.set_type(&JsValue::from(&self.props.drawer_type)); - // element.set_open(self.props.open); - - // if first_render { - // let onopen_callback = self.props.onopened.clone(); - // let onclose_callback = self.props.onclosed.clone(); - - // let element = self.node_ref.cast::().unwrap(); - - // self.opened_listener = Some(EventListener::new( - // &element, - // "MDCDrawer:opened", - // move |_| { - // onopen_callback.emit(()); - // }, - // )); - - // self.closed_listener = Some(EventListener::new( - // &element, - // "MDCDrawer:closed", - // move |_| { - // onclose_callback.emit(()); - // }, - // )); - // } - } -} - -impl Drawer { - fn classes(&self) -> String { - if self.props.open { - "mdc-drawer mdc-drawer--modal mdc-drawer--open".into() - } else { - "mdc-drawer mdc-drawer--modal".into() - } - } - - - // Big Unusable Magic - fn run_next_animation_frame(&self, callback: F) where F: FnOnce() { - info!("run_next_animation_frame"); - - // let _ = window().cancel_animation_frame(self.animation_frame); - let f = Rc::new(RefCell::new(None)); - let g = f.clone(); - // let g = f.borrow().as_ref().unwrap(); - *g.borrow_mut() = Some(Closure::wrap(Box::new(move ||{ - info!("OOOUCH"); - - // self.animation_frame = 0; - let _ = f.borrow_mut().take(); - }) as Box)); - request_animation_frame(g.borrow().as_ref().unwrap()); - } -} - -// move to utils -fn window() -> web_sys::Window { - web_sys::window().expect("no global `window` exists") -} - -fn request_animation_frame(f: &Closure) { - window() - .request_animation_frame(f.as_ref().unchecked_ref()) - .expect("should register `requestAnimationFrame` OK"); -} - -fn document() -> web_sys::Document { - window() - .document() - .expect("should have a document on window") -} - -fn body() -> web_sys::HtmlElement { - document().body().expect("document should have a body") -} - -impl WeakComponentLink { - /// A convenience method to for `drawer.open = !drawer.open` - pub fn flip_open_state(&self) { - // let node_ref = (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .clone(); - // let element = node_ref.cast::().unwrap(); - // let open = element.open(); - // element.set_open(!open); - } -} - -pub struct DrawerItem { - props: DrawerItemProps, - link: ComponentLink, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`DrawerItem`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Debug, Properties, Clone)] -pub struct DrawerItemProps { - pub label: String, - #[prop_or_default] - pub icon: String, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - // #[prop_or_default] - // pub onsignal: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for DrawerItem { - type Message = Msg; - type Properties = DrawerItemProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - props: props - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.props = props; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // - // mdc-list-item--selected - html! { - - - - { &self.props.label } - - } - } -} diff --git a/src/drawer/drawer_app_content.rs b/src/drawer/drawer_app_content.rs deleted file mode 100644 index 3a65d87..0000000 --- a/src/drawer/drawer_app_content.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "appContent"; - -/// Props for [`DrawerAppContent`] -#[derive(Properties, Clone)] -pub struct DrawerAppContentProps { - pub children: Children, -} - -/// Defines `appContent` for [`Drawer`][crate::Drawer]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct DrawerAppContent { - props: DrawerAppContentProps, -} - -impl Component for DrawerAppContent { - type Message = (); - type Properties = DrawerAppContentProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", "appContent"); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/drawer/drawer_header.rs b/src/drawer/drawer_header.rs deleted file mode 100644 index 57e3e16..0000000 --- a/src/drawer/drawer_header.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "header"; - -/// Props for [`DrawerHeader`] -#[derive(Properties, Clone)] -pub struct DrawerHeaderProps { - pub children: Children, -} - -/// Defines header for [`Drawer`][crate::Drawer]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct DrawerHeader { - props: DrawerHeaderProps, -} - -impl Component for DrawerHeader { - type Message = (); - type Properties = DrawerHeaderProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", SLOT); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/drawer/drawer_subtitle.rs b/src/drawer/drawer_subtitle.rs deleted file mode 100644 index 867bae9..0000000 --- a/src/drawer/drawer_subtitle.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "subtitle"; - -/// Props for [`DrawerSubtitle`] -#[derive(Properties, Clone)] -pub struct DrawerSubtitleProps { - pub children: Children, -} - -/// Defines sub title for [`Drawer`][crate::Drawer]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct DrawerSubtitle { - props: DrawerSubtitleProps, -} - -impl Component for DrawerSubtitle { - type Message = (); - type Properties = DrawerSubtitleProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", "subtitle"); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/drawer/drawer_title.rs b/src/drawer/drawer_title.rs deleted file mode 100644 index 706bf59..0000000 --- a/src/drawer/drawer_title.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "title"; - -/// Props for [`DrawerTitle`] -#[derive(Properties, Clone)] -pub struct DrawerTitleProps { - pub children: Children, -} - -/// Defines title for [`Drawer`][crate::Drawer]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct DrawerTitle { - props: DrawerTitleProps, -} - -impl Component for DrawerTitle { - type Message = (); - type Properties = DrawerTitleProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", "title"); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/fab.rs b/src/fab.rs deleted file mode 100644 index d0b3237..0000000 --- a/src/fab.rs +++ /dev/null @@ -1,82 +0,0 @@ -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct Fab { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`Fab`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/fab#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct FabProps { - #[prop_or_default] - pub icon: String, - #[prop_or_default] - pub label: String, - #[prop_or_default] - pub mini: bool, - #[prop_or_default] - pub reduced_touch_target: bool, - #[prop_or_default] - pub extended: bool, - #[prop_or_default] - pub show_icon_at_end: bool, - #[prop_or_default] - pub children: Children, -} - -// label=props.label -// icon=props.icon -// mini?=to_option(props.mini) -// reducedTouchTarget?=to_option(props.reduced_touch_target) -// extended?=to_option(props.extended) -// showIconAtEnd?=to_option(props.show_icon_at_end) - -impl Component for Fab { - type Message = Msg; - type Properties = FabProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // onclick=self.link.callback(|_| Msg::Clicked)> - // { &self.label } - // { props.children.clone() } - html! { - - } - } -} diff --git a/src/form_field.rs b/src/form_field.rs deleted file mode 100644 index 7e36196..0000000 --- a/src/form_field.rs +++ /dev/null @@ -1,72 +0,0 @@ -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct Formfield { - link: ComponentLink, - // label: String, - // onsignal: Callback<()>, -} - -/// Props for [`Formfield`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/formfield#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct FormfieldProps { - pub children: Children, - #[prop_or_default] - pub label: String, - #[prop_or_default] - pub align_end: bool, - #[prop_or_default] - pub space_between: bool, - #[prop_or_default] - pub nowrap: bool, -} - -// label=props.label -// alignEnd?=to_option(props.align_end) -// spaceBetween?=to_option(props.space_between) -// nowrap?=to_option(props.nowrap) -// >{ props.children.clone() } - -impl Component for Formfield { - type Message = (); - type Properties = FormfieldProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - // label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - // match msg { - // Msg::Clicked => { - // // self.onsignal.emit(()); - // } - // } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - // self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // onclick=self.link.callback(|_| Msg::Clicked)> - // { &self.label } - // { props.children.clone() } - html! { - - } - } -} diff --git a/src/gaugechart.rs b/src/gaugechart.rs deleted file mode 100644 index 24c1eb8..0000000 --- a/src/gaugechart.rs +++ /dev/null @@ -1,159 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use animate::Canvas; -use charts::{Chart, GaugeChart as GaugeChartComponent, GaugeChartOptions}; -use dataflow::*; -use wasm_bindgen::prelude::*; -use wasm_bindgen::JsCast; -use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement}; -use yew::prelude::*; - -pub struct GaugeChart { - props: GaugeChartProps, - link: ComponentLink, - node_ref: NodeRef, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`GaugeChart`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct GaugeChartProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - #[prop_or_default] - pub onclick: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for GaugeChart { - type Message = Msg; - type Properties = GaugeChartProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - props, - node_ref: NodeRef::default(), - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - self.props.onclick.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - html! { - - } - } - - fn rendered(&mut self, first_render: bool) { - let canvas = self.node_ref.cast::().unwrap(); - let cr: CanvasRenderingContext2d = canvas - .get_context("2d") - .unwrap() - .unwrap() - .dyn_into() - .unwrap(); - - let stream = create_stream(); - - let mut options: GaugeChartOptions = Default::default(); - options.labels = Some(Default::default()); - options.title.text = Some("Gauge Chart Demo"); - - let mut chart = GaugeChartComponent::new(options); - chart.set_stream(stream); - - chart.resize(800., 400.); - - let ctx = Canvas::new(&cr); // overhead - chart.draw(&ctx); - // let element = self.node_ref.cast::().unwrap(); - // if self.props.checked { - // element.set_checked(self.props.checked); - // } - // if first_render { - // let callback = self.props.onchange.clone(); - // let target = self.node_ref.cast::().unwrap(); - // self.change_listener = Some(EventListener::new(&target, "change", move |_| { - // callback.emit(element.checked()); - // })); - // } - } -} - -fn create_stream() -> DataStream<'static, &'static str, i32> { - let metadata = vec![ - Channel { - name: "Browser", - tag: 0, - visible: true, - }, - Channel { - name: "Share", - tag: 1, - visible: true, - }, - ]; - - let mut frames = vec![DataFrame { - metric: "Memory", - data: [(0, 25)].iter().cloned().collect(), - }]; - - frames.push(DataFrame { - metric: "CPU", - data: [(0, 75)].iter().cloned().collect(), - }); - - frames.push(DataFrame { - metric: "Disk", - data: [(0, 40)].iter().cloned().collect(), - }); - - DataStream::new(metadata, frames) -} diff --git a/src/icon.rs b/src/icon.rs deleted file mode 100644 index d1db33d..0000000 --- a/src/icon.rs +++ /dev/null @@ -1,57 +0,0 @@ -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct Icon { - link: ComponentLink, - // label: String, - // onsignal: Callback<()>, -} - -/// Props for [`Icon`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/icon#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct IconProps { - #[prop_or_default] - pub children: Children, -} - -impl Component for Icon { - type Message = (); - type Properties = IconProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - // label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - // match msg { - // Msg::Clicked => { - // // self.onsignal.emit(()); - // } - // } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - // self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - - // - - // { props.children.clone() } - html! { - { "favorite" } - } - } -} diff --git a/src/icon_button.rs b/src/icon_button.rs deleted file mode 100644 index 1364246..0000000 --- a/src/icon_button.rs +++ /dev/null @@ -1,75 +0,0 @@ -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct IconButton { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`IconButton`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/icon-button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct IconButtonProps { - #[prop_or_default] - pub label: String, - #[prop_or_default] - pub icon: String, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub children: Children, -} - -// label=props.label -// icon=props.icon -// disabled=props.disabled -// { props.children.clone() } - -impl Component for IconButton { - type Message = Msg; - type Properties = IconButtonProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // html! { - // - // } - html! { - - } - } -} \ No newline at end of file diff --git a/src/icon_button_toggle.rs b/src/icon_button_toggle.rs deleted file mode 100644 index 0dd1e7c..0000000 --- a/src/icon_button_toggle.rs +++ /dev/null @@ -1,105 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -mod off_icon; -mod on_icon; - -pub use off_icon::*; -pub use on_icon::*; - -use super::to_option; -use gloo::events::EventListener; -use wasm_bindgen::prelude::*; -use web_sys::Node; -use yew::prelude::*; - -/// The `icon-button-toggle` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/icon-button-toggle) -pub struct IconButtonToggle { - props: IconButtonToggleProps, - node_ref: NodeRef, - change_listener: Option, -} - -/// Props for [`IconButtonToggle`] -/// -/// Documentation: -/// -/// - [Properties](https://github.com/material-components/material-components-web-components/tree/master/packages/icon-button-toggle#propertiesattributes) -/// - [Events](https://github.com/material-components/material-components-web-components/tree/master/packages/icon-button-toggle#events) -#[derive(Clone, PartialEq, Properties)] -pub struct IconButtonToggleProps { - #[prop_or_default] - pub on: bool, - #[prop_or_default] - pub on_icon: String, - #[prop_or_default] - pub off_icon: String, - #[prop_or_default] - pub label: String, - #[prop_or_default] - pub disabled: bool, - /// Binds to `MDCIconButtonToggle:change`. - /// - /// Callback's parameter is the `isOn` value passed - /// - /// See events docs to learn more. - #[prop_or_default] - pub onchange: Callback, - #[prop_or_default] - pub children: Children, -} - -impl Component for IconButtonToggle { - type Message = (); - type Properties = IconButtonToggleProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - // IconButtonToggle::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - change_listener: None, - } - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - // on?=to_option(self.props.on) - // onIcon=self.props.on_icon - // offIcon=self.props.off_icon - // label=self.props.label - // disabled=self.props.disabled - // ref=self.node_ref.clone() - // > { self.props.children.clone() } - - unimplemented!() - } - - fn rendered(&mut self, first_render: bool) { - // if first_render { - // let element = self.node_ref.cast::().unwrap(); - - // let callback = self.props.onchange.clone(); - // self.change_listener = Some(EventListener::new( - // &element.clone(), - // "MDCIconButtonToggle:change", - // move |_| callback.emit(element.on()), - // )); - // } - unimplemented!() - } -} diff --git a/src/icon_button_toggle/off_icon.rs b/src/icon_button_toggle/off_icon.rs deleted file mode 100644 index 282e291..0000000 --- a/src/icon_button_toggle/off_icon.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "offIcon"; - -/// Props for [`OffIconButtonToggle`] -#[derive(Properties, Clone)] -pub struct OffIconButtonToggleProps { - pub children: Children, -} - -/// Defines header for [`IconButtonToggle`][crate::IconButtonToggle]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct OffIconButtonToggle { - props: OffIconButtonToggleProps, -} - -impl Component for OffIconButtonToggle { - type Message = (); - type Properties = OffIconButtonToggleProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", SLOT); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/icon_button_toggle/on_icon.rs b/src/icon_button_toggle/on_icon.rs deleted file mode 100644 index b192233..0000000 --- a/src/icon_button_toggle/on_icon.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "onIcon"; - -/// Props for [`OnIconButtonToggle`] -#[derive(Properties, Clone)] -pub struct OnIconButtonToggleProps { - pub children: Children, -} - -/// Defines header for [`IconButtonToggle`][crate::IconButtonToggle]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct OnIconButtonToggle { - props: OnIconButtonToggleProps, -} - -impl Component for OnIconButtonToggle { - type Message = (); - type Properties = OnIconButtonToggleProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", SLOT); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/image_list.rs b/src/image_list.rs deleted file mode 100644 index 2e72935..0000000 --- a/src/image_list.rs +++ /dev/null @@ -1,98 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -use super::to_option; -use wasm_bindgen::prelude::*; -use yew::prelude::*; - -pub struct ImageList { - link: ComponentLink, - label: String, - // onsignal: Callback<()>, -} - -pub enum Msg { - Clicked, -} - -/// Props for [`ImageList`] -/// -/// [Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/button#propertiesattributes) -#[derive(Clone, PartialEq, Properties)] -pub struct ImageListProps { - pub label: String, - #[prop_or_default] - pub icon: Option, - #[prop_or_default] - pub raised: bool, - #[prop_or_default] - pub unelevated: bool, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub dense: bool, - #[prop_or_default] - pub disabled: bool, - #[prop_or_default] - pub trailing_icon: bool, - // #[prop_or_default] - // pub onsignal: Callback<()>, -} - -// label=props.label -// icon?=props.icon.as_ref() -// raised?=to_option(props.raised) -// unelevated?=to_option(props.unelevated) -// outlined?=to_option(props.outlined) -// dense?=to_option(props.dense) -// trailingIcon?=to_option(props.trailing_icon) -// disabled=props.disabled - -impl Component for ImageList { - type Message = Msg; - type Properties = ImageListProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - Self { - link, - label: props.label, - // onsignal: props.onsignal, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - match msg { - Msg::Clicked => { - // self.onsignal.emit(()); - } - } - false - } - - fn change(&mut self, props: Self::Properties) -> ShouldRender { - self.label = props.label; - // self.onsignal = props.onsignal; - true - } - - fn view(&self) -> Html { - // html! { - // - // } - html! { -
    -
  • -
    - -
    -
    - { "Text label" } -
    -
  • -
- } - } -} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index bb65c76..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,308 +0,0 @@ -#![recursion_limit = "1024"] -#![allow(unused_variables)] -#![allow(dead_code)] -#![allow(unused_imports)] - -#![doc(html_root_url = "/docs")] - -//! A Material components library for [Yew](https://yew.rs). It wrpas around [Material Web Components](https://github.com/material-components/material-components-web-components) exposing Yew components. -//! -//! Example usage: -//! ```rust -//! use yew::html; -//! use yew_material::Button; -//! -//! html! { -//! - - - - } - } - - fn rendered(&mut self, first_render: bool) { - // let element = self.node_ref.cast::().unwrap(); - // element.set_open(self.props.open); - - // if first_render { - // let on_opening = self.props.onopening.clone(); - // self.opening_listener = Some(EventListener::new( - // &element, - // "MDCSnackbar:opening", - // move |_| { - // on_opening.emit(()); - // }, - // )); - - // let on_opened = self.props.onopened.clone(); - // self.opened_listener = Some(EventListener::new( - // &element, - // "MDCSnackbar:opened", - // move |_| { - // on_opened.emit(()); - // }, - // )); - - // let on_closing = self.props.onclosing.clone(); - // self.closing_listener = Some(EventListener::new( - // &element, - // "MDCSnackbar:closing", - // move |event| { - // on_closing.emit(event_into_details_reason(event)); - // }, - // )); - - // let on_closed = self.props.onclosed.clone(); - // self.closed_listener = Some(EventListener::new( - // &element, - // "MDCSnackbar:closed", - // move |event| { - // on_closed.emit(event_into_details_reason(event)); - // }, - // )); - // } - } -} - -impl WeakComponentLink { - pub fn show(&self) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .show() - unimplemented!() - } - - pub fn close(&self, reason: &str) { - // (*self.borrow().as_ref().unwrap().get_component().unwrap()) - // .node_ref - // .cast::() - // .unwrap() - // .close(&JsValue::from_str(reason)) - unimplemented!() - } -} - -fn event_into_details_reason(event: &Event) -> Option { - // let details: JsValue = event_into_details(event); - // if details.is_undefined() { - // None - // } else { - // Some(details.unchecked_into::().reason()) - // } - unimplemented!() -} diff --git a/src/switch.rs b/src/switch.rs deleted file mode 100644 index f7fcf76..0000000 --- a/src/switch.rs +++ /dev/null @@ -1,123 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use gloo::events::EventListener; -use wasm_bindgen::prelude::*; -use web_sys::Node; -use yew::prelude::*; - -/// The `switch` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/switch) -pub struct Switch { - props: SwitchProps, - link: ComponentLink, - change_listener: Option, -} - -pub enum Msg { - Clicked -} - -/// Props for [`Switch`] -/// -/// Documentation: -/// -/// - [Properties](https://github.com/material-components/material-components-web-components/tree/master/packages/switch#propertiesattributes) -/// - [Events](https://github.com/material-components/material-components-web-components/tree/master/packages/switch#events) -#[derive(Clone, PartialEq, Properties)] -pub struct SwitchProps { - #[prop_or_default] - pub checked: bool, - #[prop_or_default] - pub disabled: bool, - /// Binds to `change` event on `switch` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onchange: Callback, -} - -impl Component for Switch { - type Message = Msg; - type Properties = SwitchProps; - - fn create(props: Self::Properties, link: ComponentLink) -> Self { - // Switch::ensure_loaded(); - Self { - link, - props, - change_listener: None, - } - } - - fn update(&mut self, msg: Self::Message) -> ShouldRender { - // info!("Switch update!"); - match msg { - Msg::Clicked => { - if self.props.checked { - self.props.checked = false; - } else { - self.props.checked = true; - } - return true; - } - } - - // false - } - - fn change(&mut self, props: Self::Properties) -> bool { - if self.props != props { - self.props = props; - true - } else { - false - } - } - - fn view(&self) -> Html { - // disabled=self.props.disabled - // ref=self.node_ref.clone() - - html! { -
-
-
-
- -
-
- } - } - - fn rendered(&mut self, first_render: bool) { - // info!("Switch rendered!"); - // let element = self.node_ref.cast::().unwrap(); - // // element.set_checked(self.props.checked); - - // if first_render { - // let callback = self.props.onchange.clone(); - // self.change_listener = - // Some(EventListener::new(&element.clone(), "change", move |_| { - // callback.emit(element.checked()); - // })); - // } - } -} - -impl Switch { - fn classes(&self) -> String { - if self.props.checked { - "mdc-switch mdc-switch--checked".into() - } else { - "mdc-switch mdc-switch".into() - } - } -} - -// aria-checked=true -// /** Class used for a switch that is in the "checked" (on) position. */ -// CHECKED: 'mdc-switch--checked', -// /** Class used for a switch that is disabled. */ -// DISABLED: 'mdc-switch--disabled', \ No newline at end of file diff --git a/src/tabs/mod.rs b/src/tabs/mod.rs deleted file mode 100644 index 6e3891c..0000000 --- a/src/tabs/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -mod tab; -pub use tab::*; - -mod tab_bar; -pub use tab_bar::*; - -mod tab_icon; -pub use tab_icon::*; diff --git a/src/tabs/tab.rs b/src/tabs/tab.rs deleted file mode 100644 index 9eef336..0000000 --- a/src/tabs/tab.rs +++ /dev/null @@ -1,104 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use crate::{event_details_into, to_option}; -use gloo::events::EventListener; -use js_sys::Object; -use wasm_bindgen::prelude::*; -use web_sys::Element; -use yew::prelude::*; - -/// The `tab` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/tab) -pub struct Tab { - props: TabProps, - node_ref: NodeRef, - interacted_listener: Option, -} - -/// Props for `Tab` -/// -/// Documentation [properties](https://github.com/material-components/material-components-web-components/tree/master/packages/tab#propertiesattributes) -/// and [events](https://github.com/material-components/material-components-web-components/tree/master/packages/tab#events) -#[derive(Debug, Properties, Clone)] -pub struct TabProps { - #[prop_or_default] - pub label: String, - #[prop_or_default] - pub icon: String, - #[prop_or_default] - pub has_image_icon: bool, - #[prop_or_default] - pub indicator_icon: String, - #[prop_or_default] - pub is_fading_indicator: bool, - #[prop_or_default] - pub min_width: bool, - #[prop_or_default] - pub is_min_width_indicator: bool, - #[prop_or_default] - pub stacked: bool, - /// Binds to `MDCTab:interacted` event on `tab` - /// - /// See events docs to learn more. - #[prop_or_default] - pub oninteracted: Callback, - #[prop_or_default] - pub children: Children, -} - -impl Component for Tab { - type Message = (); - type Properties = TabProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - // Tab::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - interacted_listener: None, - } - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // label=self.props.label - // icon=self.props.icon - // hasImageIcon?=to_option(self.props.has_image_icon) - // indicatorIcon=self.props.indicator_icon - // isFadingIndicator?=to_option(self.props.is_fading_indicator) - // minWidth?=to_option(self.props.min_width) - // isMinWidthIndicator?=to_option(self.props.is_min_width_indicator) - // stacked?=to_option(self.props.stacked) - // ref=self.node_ref.clone() - // >{ self.props.children.clone() } - - unimplemented!() - } - - fn rendered(&mut self, first_render: bool) { - // if first_render { - // let element = self.node_ref.cast::().unwrap(); - - // let on_interacted = self.props.oninteracted.clone(); - // self.interacted_listener = Some(EventListener::new( - // &element, - // "MDCTab:interacted", - // move |event| { - // let detail = event_details_into::(event); - // on_interacted.emit(detail.tab_id()); - // }, - // )); - // } - } -} - diff --git a/src/tabs/tab_bar.rs b/src/tabs/tab_bar.rs deleted file mode 100644 index c0b3a1d..0000000 --- a/src/tabs/tab_bar.rs +++ /dev/null @@ -1,113 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use crate::event_details_into; -use gloo::events::EventListener; -use js_sys::Object; -use wasm_bindgen::prelude::*; -use web_sys::Element; -use yew::prelude::*; - - -/// The `tab-bar` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/tab-bar) -pub struct TabBar { - props: TabBarProps, - node_ref: NodeRef, - activated_listener: Option, -} - -/// Props for `TabBar`. -/// -/// Documentation [properties](https://github.com/material-components/material-components-web-components/tree/master/packages/tab-bar#propertiesattributes) -/// and [events](https://github.com/material-components/material-components-web-components/tree/master/packages/tab-bar#events) -#[derive(Debug, Properties, Clone)] -pub struct TabBarProps { - #[prop_or_default] - pub active_index: u32, - /// Binds to `MDCTabBar:activated` event on `tab` - /// - /// See events docs to learn more. - #[prop_or_default] - pub onactivated: Callback, - #[prop_or_default] - pub children: Children, -} - -impl Component for TabBar { - type Message = (); - type Properties = TabBarProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - // TabBar::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - activated_listener: None, - } - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // activeIndex=self.props.active_index - // ref=self.node_ref.clone() - // >{ self.props.children.clone() } - - html! { -
-
-
-
- - -
-
-
-
- } - } - - fn rendered(&mut self, first_render: bool) { - // if first_render { - // let element = self.node_ref.cast::().unwrap(); - - // let on_activated = self.props.onactivated.clone(); - // self.activated_listener = Some(EventListener::new( - // &element, - // "MDCTabBar:activated", - // move |event| { - // let detail = event_details_into::(event); - // on_activated.emit(detail.index()); - // }, - // )); - // } - } -} - diff --git a/src/tabs/tab_icon.rs b/src/tabs/tab_icon.rs deleted file mode 100644 index 2901dea..0000000 --- a/src/tabs/tab_icon.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use yew::prelude::*; - -const SLOT: &str = "icon"; - -/// Props for [`TabIcon`] -#[derive(Properties, Clone)] -pub struct TabIconProps { - pub children: Children, -} - -/// Defines title for [`Tab`][crate::Tab]. -/// -/// If the child passed is an element (a `VTag`), then it is modified to include -/// the appropriate attributes. Otherwise, the child is wrapped in a `span` -/// containing said attributes. -pub struct TabIcon { - props: TabIconProps, -} - -impl Component for TabIcon { - type Message = (); - type Properties = TabIconProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - Self { props } - } - - fn update(&mut self, _msg: Self::Message) -> bool { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // let children = self - // .props - // .children - // .iter() - // .map(|child| { - // match child { - // Html::VTag(mut vtag) => { - // vtag.add_attribute("slot", "title"); - // Html::VTag(vtag) - // } - // _ => { - // html! { - // - // { child } - // - // } - // } - // } - // }) - // .collect::(); - - // html! { - // { children } - // } - unimplemented!() - } -} diff --git a/src/text_inputs/mod.rs b/src/text_inputs/mod.rs deleted file mode 100644 index bc5a4be..0000000 --- a/src/text_inputs/mod.rs +++ /dev/null @@ -1,67 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -#[cfg(feature = "textfield")] -mod textfield; -#[cfg(feature = "textfield")] -pub use textfield::*; - -#[cfg(any(feature = "textfield", feature = "textarea"))] -pub(crate) mod validity_state; -#[cfg(any(feature = "textfield", feature = "textarea"))] -pub use validity_state::ValidityState; - -#[cfg(any(feature = "textfield", feature = "textarea"))] -pub(crate) mod text_field_type; -#[cfg(any(feature = "textfield", feature = "textarea"))] -pub use text_field_type::*; - -#[cfg(feature = "textarea")] -mod textarea; -#[cfg(feature = "textarea")] -pub use textarea::*; - -#[cfg(any(feature = "textfield", feature = "textarea"))] -pub use web_sys::ValidityState as NativeValidityState; - -use std::rc::Rc; - -use gloo::events::EventListener; -use wasm_bindgen::{JsCast, JsValue}; -use web_sys::{Element, Event, InputEvent}; -use yew::{Callback, InputData, NodeRef}; - -#[cfg(any(feature = "textfield", feature = "textarea"))] -pub(crate) type ValidityTransformFn = dyn Fn(String, NativeValidityState) -> ValidityState; - -#[cfg(any(feature = "textfield", feature = "textarea"))] -#[derive(Clone)] -/// Owned function for validity props -pub struct ValidityTransform(pub(crate) Rc); - -#[cfg(any(feature = "textfield", feature = "textarea"))] -impl ValidityTransform { - pub(crate) fn new ValidityState + 'static>( - func: F, - ) -> ValidityTransform { - ValidityTransform(Rc::new(func)) - } -} - -fn set_on_input_handler( - node_ref: &NodeRef, - callback: Callback, - convert: impl Fn((InputEvent, JsValue)) -> InputData + 'static, -) -> EventListener { - let element = node_ref.cast::().unwrap(); - EventListener::new(&element, "input", move |event: &Event| { - let js_value = JsValue::from(event); - - let input_event = js_value - .clone() - .dyn_into::() - .expect("could not convert to `InputEvent`"); - - callback.emit(convert((input_event, js_value))) - }) -} diff --git a/src/text_inputs/text_field_type.rs b/src/text_inputs/text_field_type.rs deleted file mode 100644 index 9031cfc..0000000 --- a/src/text_inputs/text_field_type.rs +++ /dev/null @@ -1,39 +0,0 @@ -/// The `TextFieldType` type -#[derive(Debug, Clone)] -pub enum TextFieldType { - Text, - Search, - Tel, - Url, - Email, - Password, - Date, - Month, - Week, - Time, - DatetimeLocal, - Number, - Color, -} - -impl ToString for TextFieldType { - fn to_string(&self) -> String { - use TextFieldType::*; - match self { - Text => "text", - Search => "search", - Tel => "tel", - Url => "url", - Email => "email", - Password => "password", - Date => "date", - Month => "month", - Week => "week", - Time => "time", - DatetimeLocal => "datetime-local", - Number => "number", - Color => "color", - } - .to_string() - } -} diff --git a/src/text_inputs/textarea.rs b/src/text_inputs/textarea.rs deleted file mode 100644 index 0fb090a..0000000 --- a/src/text_inputs/textarea.rs +++ /dev/null @@ -1,210 +0,0 @@ -#![allow(unused_variables)] -#![allow(dead_code)] - -use super::set_on_input_handler; -// use crate::text_inputs::validity_state::ValidityStateJS; -use crate::text_inputs::{TextFieldType, ValidityState, ValidityTransform}; -use crate::{to_option, to_option_string}; -use gloo::events::EventListener; -use wasm_bindgen::prelude::*; -use wasm_bindgen::JsCast; -use web_sys::Node; -pub use web_sys::ValidityState as NativeValidityState; -use yew::prelude::*; - -/// The `textarea` component -/// -/// [Documentation](https://github.com/material-components/material-components-web-components/tree/master/packages/textarea) -pub struct TextArea { - props: TextAreaProps, - node_ref: NodeRef, - // validity_transform_closure: - // Option ValidityStateJS>>, - input_listener: Option, -} - -/// Type for [`TextAreaProps::char_counter`]. -/// -/// Equivalent to `type TextAreaCharCounter = 'external'|'internal';` Typescript -/// type. -#[derive(Clone)] -pub enum TextAreaCharCounter { - Internal, - External, -} - -impl ToString for TextAreaCharCounter { - fn to_string(&self) -> String { - use TextAreaCharCounter::*; - match self { - Internal => "internal", - External => "external", - } - .to_string() - } -} - -/// Props for [`TextArea`] -/// -/// Documentation: -/// -/// - [Properties](https://github.com/material-components/material-components-web-components/tree/master/packages/checkbox#propertiesattributes) -#[derive(Properties, Clone)] -pub struct TextAreaProps { - #[prop_or_default] - pub rows: Option, - #[prop_or_default] - pub cols: Option, - #[prop_or_default] - pub value: String, - #[prop_or(TextFieldType::Text)] - pub field_type: TextFieldType, - #[prop_or_default] - pub label: String, - #[prop_or_default] - pub placeholder: String, - #[prop_or_default] - pub icon: String, - #[prop_or_default] - pub icon_trailing: String, - #[prop_or_default] - pub disabled: bool, - /// For boolean value `true`, `TextAreaCharCounter::External` is to be used. - /// Boolean value `false` results in character counter not being shown so - /// `None` should be used - #[prop_or_default] - pub char_counter: Option, - #[prop_or_default] - pub outlined: bool, - #[prop_or_default] - pub helper: String, - #[prop_or_default] - pub helper_persistent: bool, - #[prop_or_default] - pub required: bool, - #[prop_or_default] - pub max_length: String, - #[prop_or_default] - pub validation_message: String, - /// Type: `number | string` so I'll leave it as a string - #[prop_or_default] - pub min: String, - /// Type: `number | string` so I'll leave it as a string - #[prop_or_default] - pub max: String, - #[prop_or_default] - pub size: Option, // --| - #[prop_or_default] // | -- What you doing step size - pub step: Option, // --| - #[prop_or_default] - pub auto_validate: bool, - #[prop_or_default] - pub validity_transform: Option, - #[prop_or_default] - pub validate_on_initial_render: bool, - #[prop_or_default] - pub oninput: Callback, - #[prop_or_default] - pub name: String, -} - -impl Component for TextArea { - type Message = (); - type Properties = TextAreaProps; - - fn create(props: Self::Properties, _: ComponentLink) -> Self { - // TextArea::ensure_loaded(); - Self { - props, - node_ref: NodeRef::default(), - // validity_transform_closure: None, - input_listener: None, - } - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - false - } - - fn change(&mut self, props: Self::Properties) -> bool { - self.props = props; - true - } - - fn view(&self) -> Html { - // rows?=self.props.rows - // cols?=self.props.cols - // label?=to_option_string(&self.props.label) - // placeholder?=to_option_string(&self.props.placeholder) - // icon?=to_option_string(&self.props.icon) - // iconTrailing?=to_option_string(&self.props.icon_trailing) - // disabled=self.props.disabled - // charCounter?=self.props.char_counter.as_ref().map(|it| it.to_string()) - // outlined?=to_option(self.props.outlined) - // helper?=to_option_string(&self.props.helper) - // helperPersistent?=to_option(self.props.helper_persistent) - // required=self.props.required - // maxLength?=to_option_string(&self.props.max_length) - // validationMessage?=to_option_string(&self.props.validation_message) - // min?=to_option_string(&self.props.min) - // max?=to_option_string(&self.props.max) - // size?=self.props.size - // step?=self.props.step - // autoValidate?=to_option(self.props.auto_validate) - // validateOnInitialRender?=to_option(self.props.validate_on_initial_render) - // name?=to_option_string(&self.props.name) - // ref=self.node_ref.clone() - - html! { - - } - } - - fn rendered(&mut self, first_render: bool) { - // let element = self.node_ref.cast::