Skip to content

Instantly share code, notes, and snippets.

View jcamilom's full-sized avatar

Camilo Muñoz jcamilom

  • Medellín, Colombia
View GitHub Profile
abstract class MultiCheckOption { } // (1)
@Component({
selector: 'simple-check-option',
providers: [
{ // (2)
provide: MultiCheckOption,
useExisting: SimpleCheckOptionComponent,
}
]
@ContentChildren(SimpleCheckOptionComponent)
options!: QueryList<SimpleCheckOptionComponent>;
@Component({
selector: 'user-check-option',
template: `
<label>
<input type="checkbox" [formControl]="control">
<div class="card">
<div class="avatar">
<img src="assets/images/{{ value.avatar }}">
<div class="span"></div>
</div>
private subscriptions = new Subscription();
private selectedValues: any[] = [];
ngAfterContentInit(): void {
this.options.forEach(option => {
this.subscriptions.add(
option.valueChanges$.subscribe(
(optionChecked) => {
if (optionChecked) {
this.add(option.value);
@Component({
selector: 'multi-check-field',
template: `<ng-content></ng-content>`
})
export class MultiCheckFieldComponent implements AfterContentInit {
@ContentChildren(SimpleCheckOptionComponent)
options!: QueryList<SimpleCheckOptionComponent>;
ngAfterContentInit(): void {
@Component({
selector: 'simple-check-option',
template: `
<label>
<input type="checkbox" [formControl]="control">
{{ label }}
</label>
`
})
export class SimpleCheckOptionComponent {
<multi-check-field>
<simple-check-option *ngFor="let option of options" [value]="option"
[label]="option.label">
</single-check-option>
</multi-check-field>
@jcamilom
jcamilom / side-menu.component.css
Created June 8, 2020 00:25
[Side Menu] Angular side menu with slide up/down animation #angular #animations
/* #F16257 is p0 */
/* #ef493e is p0 -5% luminosity */
/* #ed3326 is p0 -10% luminosity */
/* #F1A157 is s0 */
:host {
display: flex;
flex-direction: column;
}
@jcamilom
jcamilom / icongen.sh
Created June 26, 2018 02:26
[Create icons] How to create different sized icons for apps in Linux #linux #bash
#!/bin/bash
# This will create icons in their respective
# folders in "$HOME"/.local/share/icons/...
# Usage: icongen iconfile
# Check usage
if [[ $# -ne 2 ]]; then
echo "Usage: $0 icon_file new_icon_name"
@jcamilom
jcamilom / RemoveNonEmptyFolder.sh
Created May 3, 2018 20:36
[Remove non-empty folders in Linux] How to remove folders in Linux that contains other files and folders #linux
#!/bin/sh
# Remove folder that contains other files or directories
rm -r mydir
# Avoid getting the delete confirmation for each file
rm -rf mydir