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

show checkbox later #4

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"src/assets"
],
"styles": [
"./node_modules/@sl-design-system/sanoma-learning/all.css",
"./node_modules/@sl-design-system/bingel-int/all.css",
"src/styles.css"
],
"scripts": []
Expand Down
3,737 changes: 3,361 additions & 376 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
"@oddbird/popover-polyfill": "^0.4.0",
"@open-wc/scoped-elements": "^3.0.5",
"@sl-design-system/angular": "^0.1.6",
"@sl-design-system/bingel-int": "^0.1.6",
"@sl-design-system/button": "^0.0.15",
"@sl-design-system/checkbox": "^0.0.25",
"@sl-design-system/checklist": "^0.0.1",
"@sl-design-system/form": "^0.0.11",
"@sl-design-system/icon": "^0.0.9",
"@sl-design-system/inline-message": "^0.2.5",
"@sl-design-system/radio-group": "^0.0.24",
"@sl-design-system/sanoma-learning": "^0.1.0",
"@sl-design-system/select": "^0.0.24",
Expand Down
30 changes: 20 additions & 10 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ <h1> Search result for {{query | json}}</h1>
<div class="skeleton" style="--w:40%; --m:3rem"></div>
</ng-container>
</div>
<slds-checkist>test</slds-checkist>
<sl-inline-message variant="success">
<span slot="title">title</span>
test
<span slot="details">details</span>
</sl-inline-message>
<sl-form [formGroup]="formGroup">
<sl-form-field label="Text field">
<sl-text-field formControlName="textField"></sl-text-field>
Expand Down Expand Up @@ -51,18 +57,22 @@ <h1> Search result for {{query | json}}</h1>
</sl-form-field>
</sl-form>

<sl-form #test [formGroup]="formGroupTest">
<h1>New form</h1>
<div *ngFor="let item of checkBoxValueList, let i = index">
{{i}}
{{formGroupTest.value | json}}
<sl-form-field>
<sl-checkbox formControlName="{{item}}">{{item}}</sl-checkbox>
</sl-form-field>
</div>
</sl-form>
<!-- <sl-form #test [formGroup]="formGroupTest">-->
<!-- <h1>New form</h1>-->
<!-- <div *ngFor="let item of checkBoxValueList, let i = index">-->
<!-- {{i}}-->
<!-- {{formGroupTest.value | json}}-->
<!-- <sl-form-field>-->
<!-- <sl-checkbox formControlName="{{item}}">{{item}}</sl-checkbox>-->
<!-- </sl-form-field>-->
<!-- </div>-->
<!-- <sl-form-field *ngIf="show">-->
<!-- <sl-checkbox formControlName="extra">extra</sl-checkbox>-->
<!-- </sl-form-field>-->
<!-- </sl-form>-->

<sl-button (click)="addFields()">add fields</sl-button>
<sl-button (click)="showAdditionalField()">show more</sl-button>

<pre>{{ formGroup.value | json }}</pre>

Expand Down
40 changes: 25 additions & 15 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import { FormsModule as CoreFormsModule } from '@sl-design-system/angular';
export class AppComponent implements OnInit, AfterViewInit {
query = '';
results = Array.from(Array(5)).map((_, i) => i );
show = false;

@ViewChild('test') contentRef: ElementRef;
// @ViewChild('test') contentRef: ElementRef;

search(searchForm:{query:string}) {
this.query = searchForm.query;
Expand Down Expand Up @@ -59,11 +60,15 @@ export class AppComponent implements OnInit, AfterViewInit {
// afterRender(() => {
// console.log('content height: ' + this.contentRef.nativeElement.scrollHeight);
// }, {phase: AfterRenderPhase.Read});
this.formGroupTest.addControl(
'extra',//option,
new FormControl(true)
)
}

ngAfterViewInit(): void {
const checkboxes = this.contentRef.nativeElement.querySelectorAll('sl-checkbox') as HTMLElement[];
console.log('this.checkBoxValueList after', this.checkBoxValueList, this.contentRef.nativeElement, 'test', checkboxes, this.formGroupTest);
// const checkboxes = this.contentRef.nativeElement.querySelectorAll('sl-checkbox') as HTMLElement[];
// console.log('this.checkBoxValueList after', this.checkBoxValueList, this.contentRef.nativeElement, 'test', checkboxes, this.formGroupTest);

// checkboxes.forEach((option, idx: number) => {
// console.log('option', option, this.checkBoxValueList[idx]);
Expand All @@ -86,17 +91,22 @@ export class AppComponent implements OnInit, AfterViewInit {
console.log('event', event);
}

showAdditionalField(): void {

this.show = true;
}

addFields(): void {
const checkboxes = this.contentRef.nativeElement.querySelectorAll('sl-checkbox') as Element[];
console.log('this.checkBoxValueList after', this.checkBoxValueList, this.contentRef.nativeElement, 'test', checkboxes);

checkboxes.forEach((option, idx: number) => {
console.log('option', option, this.checkBoxValueList[idx]);
this.formGroupTest.addControl(
this.checkBoxValueList[idx],//option,
new FormControl(true)
)
console.log('this.formGroupTest', this.formGroupTest);
// const checkboxes = this.contentRef.nativeElement.querySelectorAll('sl-checkbox') as Element[];
// console.log('this.checkBoxValueList after', this.checkBoxValueList, this.contentRef.nativeElement, 'test', checkboxes);

// checkboxes.forEach((option, idx: number) => {
// console.log('option', option, this.checkBoxValueList[idx]);
// this.formGroupTest.addControl(
// this.checkBoxValueList[idx],//option,
// new FormControl(true)
// )
// console.log('this.formGroupTest', this.formGroupTest);
// const control = this.formGroupTest.get(this.checkBoxValueList[idx]);
// if (control) {
// control.setValidators([Validators.required]); // Add your desired validators
Expand All @@ -105,14 +115,14 @@ export class AppComponent implements OnInit, AfterViewInit {
// checkboxes.forEach(option => {
// checkboxArray.push(new FormControl(false)); // Initialize with false
// });
});
// });

// checkboxes.forEach((option, idx: number) => {
// option.setC
// }

// this.ref.detectChanges();

console.log('this.checkBoxValueList after_2', this.checkBoxValueList, this.contentRef.nativeElement, 'test', checkboxes as HTMLElement[]);
// console.log('this.checkBoxValueList after_2', this.checkBoxValueList, this.contentRef.nativeElement, 'test', checkboxes as HTMLElement[]);
}
}
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import '@webcomponents/scoped-custom-element-registry/scoped-custom-element-regi
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
import { setup } from '@sl-design-system/sanoma-learning';
// import { setup } from '@sl-design-system/sanoma-learning';
import { setup } from '@sl-design-system/bingel-int';
// import '@sl-design-system/shared/index.js';
// import '@sl-design-system/shared/src/events.js';
import '@sl-design-system/button/register.js';
Expand All @@ -14,6 +15,8 @@ import '@sl-design-system/radio-group/register.js';
import '@sl-design-system/text-field/register.js';
import '@sl-design-system/textarea/register.js';
import '@sl-design-system/select/register.js';
import '@sl-design-system/inline-message/register.js';
// import '@sl-design-system/checklist';

bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));
Expand Down
Loading