Skip to content

Commit

Permalink
Finish basic components
Browse files Browse the repository at this point in the history
  • Loading branch information
vinimarcili committed Aug 28, 2023
1 parent 2715f0f commit 18e12bb
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/components/sq-tag/sq-tag.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div
class='tag-box background-{{ backgroundColor }} {{ color }}'
[ngClass]="{
'readonly': readonly,
'disabled': disabled,
}"
[ngStyle]="{
'color': getColor(),
'background-color': getBackgroundColor(),
}"
(click)="handleClick()"
>
<ng-content></ng-content>
</div>
Empty file.
Empty file.
47 changes: 47 additions & 0 deletions src/components/sq-tag/sq-tag.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'
import { ColorsHelper } from '../../helpers/colors.helper'
import { useMemo } from '../../helpers/memo.helper'

@Component({
selector: 'sq-tag',
templateUrl: './sq-tag.component.html',
styleUrls: ['./sq-tag.component.scss']
})
export class SqTagsComponent {
@Input() customClass = ''
@Input() rounded = false
@Input() color = ''
@Input() backgroundColor = ''
@Input() readonly = false
@Input() disabled = false

@Output() emitClick: EventEmitter<void> = new EventEmitter<void>()

constructor(public colorsHelper: ColorsHelper) {
}

validatePresetColors() {
return !!this.colorsHelper?.getCssVariableValue(this.color)
}

getColor = useMemo(() => {
if (this.validatePresetColors()) {
return ''
}
return this.color
})

getBackgroundColor = useMemo(() => {
if (this.validatePresetColors()) {
return ''
}
return this.backgroundColor
})

handleClick() {
if (this.readonly || this.disabled) {
return
}
this.emitClick.emit()
}
}
7 changes: 5 additions & 2 deletions src/main.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { SqOverlayComponent } from './components/sq-overlay/sq-overlay.component
import { SqModalComponent } from './components/sq-modal/sq-modal.component'
import { SqCollapseComponent } from './components/sq-accordion/sq-collapse/sq-collapse.component'
import { SqPaginationComponent } from './components/sq-pagination/sq-pagination.component'
import { SqTagsComponent } from './components/sq-tag/sq-tag.component'

@NgModule({
declarations: [
Expand All @@ -32,7 +33,8 @@ import { SqPaginationComponent } from './components/sq-pagination/sq-pagination.
SqOverlayComponent,
SqModalComponent,
SqCollapseComponent,
SqPaginationComponent
SqPaginationComponent,
SqTagsComponent
],
imports: [
CommonModule
Expand All @@ -52,7 +54,8 @@ import { SqPaginationComponent } from './components/sq-pagination/sq-pagination.
SqOverlayComponent,
SqModalComponent,
SqCollapseComponent,
SqPaginationComponent
SqPaginationComponent,
SqTagsComponent
]
})
export class SquidCSSModule { }
1 change: 1 addition & 0 deletions src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './components/sq-modal/sq-modal.component'
export * from './components/sq-accordion/sq-collapse/sq-collapse.component'
export * from './components/sq-accordion/sq-accordion.component'
export * from './components/sq-pagination/sq-pagination.component'
export * from './components/sq-tag/sq-tag.component'

export * from './directives/sq-tooltip/sq-tooltip.directive'

Expand Down

0 comments on commit 18e12bb

Please sign in to comment.