Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Button Toggle component #343

Closed
richard-to opened this issue Jun 3, 2024 · 9 comments · Fixed by #1014
Closed

Add Button Toggle component #343

richard-to opened this issue Jun 3, 2024 · 9 comments · Fixed by #1014
Assignees
Labels
feature request New feature / API

Comments

@richard-to
Copy link
Collaborator

https://material.angular.io/components/button-toggle/overview

@CelaniDe
Copy link

CelaniDe commented Jun 7, 2024

I noticed this feature request and I’m interested in working on it. I believe it would greatly benefit the project and I'm excited to contribute.

@richard-to
Copy link
Collaborator Author

richard-to commented Jun 7, 2024

Sure. Feel free to give it a try. This component I believe should be most similar to the radio button component. So it's a good starter task.

Some helpful documentation to start:


We also recently set up a .devcontainer config for Github Codespaces. So if you fork the repo, you should be able to get started right way by creating a Github Codespace. The free tier is a bit slow for installing everything.

You can also use .devcontainer with VSCode remote containers if you have Docker / Docker Compose installed.

Right now, we don't have any instructions for using these two approaches yet. And I would say it's "experimental" in that we haven't tested these environments out much yet.

But if you want to give help us test these dev environments out, that would be great too. Probably some kinks to work out with the dev flow.

@CelaniDe
Copy link

CelaniDe commented Jun 8, 2024

Thank you very much for your guidelines. I am working on it

@CelaniDe
Copy link

CelaniDe commented Jun 11, 2024

I have a question. I Read the documentation about building components with the scaffolding script. I did it but when i import the MatButtonToggleModule on the ButtonToggleComponent it shows on the web ui infinite loading. Could you please help me? thanks in advance

@Component({
  selector: 'mesop-button-toggle',
  templateUrl: 'button_toggle.ng.html',
  standalone: true,
  imports: [MatButtonToggleModule], //line that cause the bug
})

JavaScript Error: The directive '_MatButtonToggleGroup' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

@richard-to
Copy link
Collaborator Author

The issue sound familiar. My random guess is that you'll need to import the module.

Here's an example from table component. You'll see the first line we needed to import the MatTableModule. Maybe you need to do something similar. But maybe you already did that and didn't show that snippet.

import {MatTableModule} from '@angular/material/table';
import {Component, Input} from '@angular/core';
import {
  TableType,
  TableRow,
  TableClickEvent,
} from 'mesop/mesop/components/table/table_jspb_proto_pb/mesop/components/table/table_pb';
import {Channel} from '../../web/src/services/channel';
import {
  UserEvent,
  Key,
  Type,
} from 'mesop/mesop/protos/ui_jspb_proto_pb/mesop/protos/ui_pb';

@Component({
  selector: 'mesop-table',
  templateUrl: 'table.ng.html',
  standalone: true,
  imports: [MatTableModule],
})

Can you also post a link to your branch on your fork? In case that does not solve the problem, I can take a look at the code more closely.

@CelaniDe
Copy link

Thanks for your response. Yes i have import it. The following code is the whole .ts file

import {MatButtonToggleModule} from '@angular/material/button-toggle';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {
  Key,
  Type,
  UserEvent,
} from 'mesop/mesop/protos/ui_jspb_proto_pb/mesop/protos/ui_pb';
import {ButtonToggleType} from 'mesop/mesop/components/button_toggle/button_toggle_jspb_proto_pb/mesop/components/button_toggle/button_toggle_pb';
import {Channel} from '../../web/src/services/channel';

@Component({
  selector: 'mesop-button-toggle',
  templateUrl: 'button_toggle.ng.html',
  standalone: true,
  imports: [MatButtonToggleModule],
})
export class ButtonToggleComponent {
  @Input({required: true}) type!: Type;
  @Input() key!: Key;
  private _config!: ButtonToggleType;
  isChecked = false;

  constructor(private readonly channel: Channel) {}

  ngOnChanges() {
    this._config = ButtonToggleType.deserializeBinary(
      this.type.getValue() as unknown as Uint8Array,
    );
  }

  config(): ButtonToggleType {
    return this._config;
  }
}

My branch on my fork: feature/create-component-button_toggle

@richard-to
Copy link
Collaborator Author

Thanks. I'll take a look later.

@richard-to
Copy link
Collaborator Author

I took a look and haven't been able to figure out the reason why it's not able to import the MatButtonToggleModule. I'll keep looking when I get the chance.

@wwwillchen
Copy link
Collaborator

@CelaniDe I think it's because button toggle isn't listed in packages.bzl - you'll need to add it in two spots, similar to what @richard-to did in an earlier change for table (b59f6b9#diff-5ef0ea9ea291d74d4ad4ad321d0aea5488a66ea0560aff9eb210911b6809bbe2).

This is unfortunately due to the way we compile angular material components with Bazel and it's quite confusing.

@wwwillchen wwwillchen added the feature request New feature / API label Jun 19, 2024
@richard-to richard-to assigned richard-to and unassigned CelaniDe Sep 28, 2024
richard-to added a commit that referenced this issue Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature / API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants