-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pablo Lopez
committed
May 14, 2024
1 parent
20a8fcc
commit 1c5d459
Showing
8 changed files
with
323 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './button/button.component'; | ||
export * from './status-chip/status-chip.component'; |
4 changes: 4 additions & 0 deletions
4
src/interface/src/styleguide/status-chip/status-chip.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<ng-container *ngIf="label; else defaultByStatus"> | ||
{{ label }} | ||
</ng-container> | ||
<ng-template #defaultByStatus>{{ defaultTextByStatus[status] }}</ng-template> |
31 changes: 31 additions & 0 deletions
31
src/interface/src/styleguide/status-chip/status-chip.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@import "mixins"; | ||
@import "colors"; | ||
|
||
:host { | ||
@include xs-label(); | ||
display: inline-flex; | ||
padding: 8px 12px; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 4px; | ||
|
||
&.in-progress { | ||
color: $color-main-blue; | ||
background-color: $color-soft-light-blue; | ||
} | ||
|
||
&.success { | ||
color: $color-brand-green; | ||
background-color: $color-brand-soft-green; | ||
} | ||
|
||
&.failed { | ||
color: $color-dark-red; | ||
background-color: $color-light-red | ||
} | ||
|
||
&.running { | ||
color: $color-dark-yellow; | ||
background-color: $color-brand-soft-yellow; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/interface/src/styleguide/status-chip/status-chip.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Component, HostBinding, Input } from '@angular/core'; | ||
import { NgIf, NgSwitch } from '@angular/common'; | ||
|
||
export type StatusChipStatus = 'inProgress' | 'success' | 'failed' | 'running'; | ||
|
||
/** | ||
* Status chip to display status inline. | ||
* Takes optional label or displays the status styled accordingly. | ||
*/ | ||
@Component({ | ||
selector: 'sg-status-chip', | ||
standalone: true, | ||
imports: [NgIf, NgSwitch], | ||
templateUrl: './status-chip.component.html', | ||
styleUrl: './status-chip.component.scss', | ||
}) | ||
export class StatusChipComponent { | ||
/** | ||
* The status | ||
*/ | ||
@Input() status: StatusChipStatus = 'inProgress'; | ||
/** | ||
* Optional label | ||
*/ | ||
@Input() label? = ''; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
readonly defaultTextByStatus: Record<StatusChipStatus, string> = { | ||
inProgress: 'In Progress', | ||
success: 'Success', | ||
failed: 'Failed', | ||
running: 'Running', | ||
}; | ||
|
||
@HostBinding('class.in-progress') | ||
get isInProgress() { | ||
return this.status === 'inProgress'; | ||
} | ||
|
||
@HostBinding('class.success') | ||
get isSuccess() { | ||
return this.status === 'success'; | ||
} | ||
|
||
@HostBinding('class.failed') | ||
get isFailed() { | ||
return this.status === 'failed'; | ||
} | ||
|
||
@HostBinding('class.running') | ||
get isRunning() { | ||
return this.status === 'running'; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/interface/src/styleguide/status-chip/status-chip.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { Meta, StoryObj } from '@storybook/angular'; | ||
import { argsToTemplate } from '@storybook/angular'; | ||
import { StatusChipComponent } from './status-chip.component'; | ||
|
||
const meta: Meta<StatusChipComponent> = { | ||
title: 'Components/Status Chip', | ||
component: StatusChipComponent, | ||
tags: ['autodocs'], | ||
render: (args) => ({ | ||
props: args, | ||
template: `<sg-status-chip ${argsToTemplate(args)}></sg-status-chip>`, | ||
}), | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<StatusChipComponent>; | ||
|
||
export const Default: Story = { | ||
args: {}, | ||
}; | ||
|
||
export const InProgress: Story = { | ||
args: { | ||
status: 'inProgress', | ||
}, | ||
}; | ||
export const Success: Story = { | ||
args: { | ||
status: 'success', | ||
}, | ||
}; | ||
export const Failed: Story = { | ||
args: { | ||
status: 'failed', | ||
}, | ||
}; | ||
export const Running: Story = { | ||
args: { | ||
status: 'running', | ||
}, | ||
}; | ||
|
||
export const AnyLabel: Story = { | ||
args: { | ||
status: 'success', | ||
label: 'done deal', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters