Skip to content

Commit

Permalink
increase type specificity in WarningBox.tsx file
Browse files Browse the repository at this point in the history
  • Loading branch information
emilydrakesmith committed Oct 15, 2024
1 parent 6cc32cf commit 4fcdfc2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/RangeActionModal/WarningBox/WarningBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ import React from 'react';
import styles from './WarningBox.module.css'; // Import your styles here
import { IoWarningOutline } from 'react-icons/io5';

type dashedString = `--${string}`;
type cssVariable = `var(${dashedString})`;

// interface for obj with custom CSS properties and their values
interface ColorSetIF {
color: string;
background: string;
border: string;
color: cssVariable;
background: cssVariable;
border: `${number}px solid ${cssVariable}`;
}

// class constructor to make color set creation more readable
class ColorSet implements ColorSetIF {
public readonly color: string;
public readonly background: string;
public readonly border: string;
public readonly color: cssVariable;
public readonly background: cssVariable;
public readonly border: `1px solid ${cssVariable}`;
constructor(
col: string,
bck: string,
bor: string,
col: dashedString,
bck: dashedString,
bor: dashedString,
) {
this.color = `var(${col})`;
this.background = `var(${bck})`;
Expand Down

0 comments on commit 4fcdfc2

Please sign in to comment.