Skip to content

Commit

Permalink
feat: badge update dark mode (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt authored Oct 1, 2023
1 parent e6559d4 commit 9c09769
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
19 changes: 13 additions & 6 deletions src/components/icon-elements/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
"use client";
import React from "react";
import { tremorTwMerge } from "lib";

import { Sizes, getColorClassNames, makeClassName, mergeRefs, spacing } from "lib";
import { Color, Size } from "../../../lib";
import {
Sizes,
getColorClassNames,
makeClassName,
mergeRefs,
spacing,
Color,
Size,
tremorTwMerge,
} from "lib";
import { badgeProportions, iconSizes } from "./styles";
import { colorPalette } from "lib/theme";
import Tooltip, { useTooltip } from "components/util-elements/Tooltip/Tooltip";
Expand Down Expand Up @@ -33,8 +39,9 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>((props, ref) => {
"w-max flex-shrink-0 inline-flex justify-center items-center cursor-default rounded-tremor-full",
color
? tremorTwMerge(
getColorClassNames(color, colorPalette.lightBackground).bgColor,
getColorClassNames(color, colorPalette.darkText).textColor,
getColorClassNames(color, colorPalette.background).bgColor,
getColorClassNames(color, colorPalette.text).textColor,
"bg-opacity-20 dark:bg-opacity-25",
)
: tremorTwMerge(
// light
Expand Down
16 changes: 11 additions & 5 deletions src/components/icon-elements/BadgeDelta/BadgeDelta.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
"use client";
import React from "react";
import { tremorTwMerge } from "lib";

import { DeltaType, DeltaTypes, Size, makeClassName, spacing } from "../../../lib";
import { Sizes, mapInputsToDeltaType } from "lib";
import {
DeltaType,
DeltaTypes,
Size,
makeClassName,
spacing,
tremorTwMerge,
Sizes,
mapInputsToDeltaType,
} from "lib";
import {
badgeProportionsIconOnly,
badgeProportionsWithText,
Expand Down Expand Up @@ -40,7 +46,7 @@ const BadgeDelta = React.forwardRef<HTMLSpanElement, BadgeDeltaProps>((props, re
className={tremorTwMerge(
makeBadgeDeltaClassName("root"),
// common
"w-max flex-shrink-0 inline-flex justify-center items-center cursor-default rounded-tremor-full",
"w-max flex-shrink-0 inline-flex justify-center items-center cursor-default rounded-tremor-full bg-opacity-20 dark:bg-opacity-25",
colors[mappedDeltaType].bgColor,
colors[mappedDeltaType].textColor,
badgeProportions[size].paddingX,
Expand Down
20 changes: 10 additions & 10 deletions src/components/icon-elements/BadgeDelta/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,24 @@ export type ColorTypes = {

export const colors: { [key: string]: ColorTypes } = {
[DeltaTypes.Increase]: {
bgColor: getColorClassNames(BaseColors.Emerald, colorPalette.lightBackground).bgColor,
textColor: getColorClassNames(BaseColors.Emerald, colorPalette.darkText).textColor,
bgColor: getColorClassNames(BaseColors.Emerald, colorPalette.background).bgColor,
textColor: getColorClassNames(BaseColors.Emerald, colorPalette.text).textColor,
},
[DeltaTypes.ModerateIncrease]: {
bgColor: getColorClassNames(BaseColors.Emerald, colorPalette.lightBackground).bgColor,
textColor: getColorClassNames(BaseColors.Emerald, colorPalette.darkText).textColor,
bgColor: getColorClassNames(BaseColors.Emerald, colorPalette.background).bgColor,
textColor: getColorClassNames(BaseColors.Emerald, colorPalette.text).textColor,
},
[DeltaTypes.Decrease]: {
bgColor: getColorClassNames(BaseColors.Rose, colorPalette.lightBackground).bgColor,
textColor: getColorClassNames(BaseColors.Rose, colorPalette.darkText).textColor,
bgColor: getColorClassNames(BaseColors.Rose, colorPalette.background).bgColor,
textColor: getColorClassNames(BaseColors.Rose, colorPalette.text).textColor,
},
[DeltaTypes.ModerateDecrease]: {
bgColor: getColorClassNames(BaseColors.Rose, colorPalette.lightBackground).bgColor,
textColor: getColorClassNames(BaseColors.Rose, colorPalette.darkText).textColor,
bgColor: getColorClassNames(BaseColors.Rose, colorPalette.background).bgColor,
textColor: getColorClassNames(BaseColors.Rose, colorPalette.text).textColor,
},
[DeltaTypes.Unchanged]: {
bgColor: getColorClassNames(BaseColors.Orange, colorPalette.lightBackground).bgColor,
textColor: getColorClassNames(BaseColors.Orange, colorPalette.darkText).textColor,
bgColor: getColorClassNames(BaseColors.Orange, colorPalette.background).bgColor,
textColor: getColorClassNames(BaseColors.Orange, colorPalette.text).textColor,
},
};

Expand Down

0 comments on commit 9c09769

Please sign in to comment.