Skip to content

Commit

Permalink
Replace AlertStyle with Severity
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Oct 14, 2024
1 parent b19d24b commit b4f7ed5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 30 deletions.
11 changes: 3 additions & 8 deletions app/assets/interfaces/alerts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { Severity } from './severity'

export interface AlertInterface {
title?: string
description?: string
style?: AlertStyle | keyof typeof AlertStyle
style?: Severity | keyof typeof Severity
closeBtn?: boolean
hideIcon?: boolean
}

export enum AlertStyle {
Primary = 'Primary',
Success = 'Success',
Warning = 'Warning',
Danger = 'Danger'
}
5 changes: 3 additions & 2 deletions app/assets/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type AlertInterface, AlertStyle } from './alerts'
import type { AlertInterface } from './alerts'
import { Severity } from './severity'

export { type AlertInterface, AlertStyle }
export { type AlertInterface, Severity }
8 changes: 8 additions & 0 deletions app/assets/interfaces/severity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum Severity {
Primary = 'Primary',
Secondary = 'Secondary',
Success = 'Success',
Warning = 'Warning',
Danger = 'Danger',
Info = 'Info'
}
18 changes: 10 additions & 8 deletions app/assets/tests/interfaces/alerts.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest'
import { type AlertInterface, AlertStyle } from '../../interfaces'
import { type AlertInterface, Severity } from '../../interfaces'

describe('AlertInterface', () => {
test('should create an alert with title and description', () => {
Expand All @@ -14,10 +14,10 @@ describe('AlertInterface', () => {

test('should create an alert with style', () => {
const alert: AlertInterface = {
style: AlertStyle.Success
style: Severity.Success
}

expect(alert.style).toBe(AlertStyle.Success)
expect(alert.style).toBe(Severity.Success)
})

test('should create an alert with close button and hide icon', () => {
Expand All @@ -31,11 +31,13 @@ describe('AlertInterface', () => {
})
})

describe('AlertStyle', () => {
describe('Severity', () => {
test('should have the correct values', () => {
expect(AlertStyle.Primary).toBe('Primary')
expect(AlertStyle.Success).toBe('Success')
expect(AlertStyle.Warning).toBe('Warning')
expect(AlertStyle.Danger).toBe('Danger')
expect(Severity.Primary).toBe('Primary')
expect(Severity.Secondary).toBe('Secondary')
expect(Severity.Success).toBe('Success')
expect(Severity.Warning).toBe('Warning')
expect(Severity.Danger).toBe('Danger')
expect(Severity.Info).toBe('Info')
})
})
9 changes: 2 additions & 7 deletions dist/interfaces/alerts.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { Severity } from './severity';
export interface AlertInterface {
title?: string;
description?: string;
style?: AlertStyle | keyof typeof AlertStyle;
style?: Severity | keyof typeof Severity;
closeBtn?: boolean;
hideIcon?: boolean;
}
export declare enum AlertStyle {
Primary = "Primary",
Success = "Success",
Warning = "Warning",
Danger = "Danger"
}
5 changes: 3 additions & 2 deletions dist/interfaces/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { AlertInterface, AlertStyle } from './alerts';
export { type AlertInterface, AlertStyle };
import { AlertInterface } from './alerts';
import { Severity } from './severity';
export { type AlertInterface, Severity };
8 changes: 8 additions & 0 deletions dist/interfaces/severity.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export declare enum Severity {
Primary = "Primary",
Secondary = "Secondary",
Success = "Success",
Warning = "Warning",
Danger = "Danger",
Info = "Info"
}
2 changes: 1 addition & 1 deletion dist/types.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var a=(r=>(r.Primary="Primary",r.Success="Success",r.Warning="Warning",r.Danger="Danger",r))(a||{});exports.AlertStyle=a;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=(n=>(n.Primary="Primary",n.Secondary="Secondary",n.Success="Success",n.Warning="Warning",n.Danger="Danger",n.Info="Info",n))(r||{});exports.Severity=r;
4 changes: 2 additions & 2 deletions dist/types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var a = /* @__PURE__ */ ((r) => (r.Primary = "Primary", r.Success = "Success", r.Warning = "Warning", r.Danger = "Danger", r))(a || {});
var a = /* @__PURE__ */ ((n) => (n.Primary = "Primary", n.Secondary = "Secondary", n.Success = "Success", n.Warning = "Warning", n.Danger = "Danger", n.Info = "Info", n))(a || {});
export {
a as AlertStyle
a as Severity
};

0 comments on commit b4f7ed5

Please sign in to comment.