Skip to content

Commit

Permalink
refactor: use types
Browse files Browse the repository at this point in the history
  • Loading branch information
talkor committed Jan 26, 2025
1 parent 1a2ffc3 commit 1a61f57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/components/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SliderColor as SliderColorEnum } from "./SliderConstants";
import cx from "classnames";
import { withStaticProps } from "../../types";
import styles from "./Slider.module.scss";
import { SliderColor, SliderSize } from "./Slider.types";
import { SliderColor, SliderLabelColor, SliderLabelPosition, SliderSize } from "./Slider.types";

export type SliderProps = {
/**
Expand Down Expand Up @@ -79,11 +79,11 @@ export type SliderProps = {
/**
* Position of the `value` when `showValue` is true
*/
valueLabelPosition?: "top" | "bottom";
valueLabelPosition?: SliderLabelPosition;
/**
* Color of the `value` when `showValue` is true
*/
valueLabelColor?: "primary" | "secondary";
valueLabelColor?: SliderLabelColor;
/**
* Size small/medium/large of the component (Slider)
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/components/Slider/Slider.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { BASE_SIZES } from "../../constants";
import { DialogPosition } from "../Dialog";
import { TypographyColor } from "../Typography";

export type SliderColor = "primary" | "negative" | "positive";

export type SliderLabelColor = Extract<TypographyColor, "primary" | "secondary">;

export type SliderLabelPosition = Extract<DialogPosition, "top" | "bottom">;

export type SliderSize = (typeof BASE_SIZES)[keyof typeof BASE_SIZES];

export type InfixKind = "prefix" | "postfix";
6 changes: 3 additions & 3 deletions packages/core/src/components/Slider/SliderConstants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IconType } from "../Icon";
import { ReactElement } from "react";
import { SliderSize, SliderColor as SliderColorType } from "./Slider.types";
import { SliderSize, SliderColor as SliderColorType, SliderLabelPosition, SliderLabelColor } from "./Slider.types";

export const BEM_PREFIX = "monday";

Expand Down Expand Up @@ -47,8 +47,8 @@ export type SliderContextUI = {
size: SliderSize;
shapeTestId: (subElement: string) => string;
showValue: boolean;
valueLabelPosition: "top" | "bottom";
valueLabelColor: "primary" | "secondary";
valueLabelPosition: SliderLabelPosition;
valueLabelColor: SliderLabelColor;
};

export type SliderContextActions = {
Expand Down

0 comments on commit 1a61f57

Please sign in to comment.