Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove lib style spacing (px and py) #891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { tremorTwMerge } from "lib";
import React from "react";
import { tremorTwMerge, ValueFormatter } from "lib";

import { ChartTooltipFrame, ChartTooltipRow } from "components/chart-elements/common/ChartTooltip";
import { spacing } from "lib";
import { ValueFormatter } from "../../../lib/inputTypes";

export interface DonutChartTooltipProps {
active: boolean | undefined;
Expand All @@ -16,7 +14,7 @@ export const DonutChartTooltip = ({ active, payload, valueFormatter }: DonutChar
const payloadRow = payload?.[0];
return (
<ChartTooltipFrame>
<div className={tremorTwMerge(spacing.twoXl.paddingX, spacing.sm.paddingY)}>
<div className={tremorTwMerge("px-4 py-2")}>
<ChartTooltipRow
value={valueFormatter(payloadRow.value)}
name={payloadRow.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { ScatterChartValueFormatter } from "components/chart-elements/ScatterCha
import {
BaseColors,
getColorClassNames,
spacing,
Color,
defaultValueFormatter,
tremorTwMerge,
colorPalette,
} from "lib";
import { colorPalette } from "lib/theme";

export const ChartTooltipFrame = ({ children }: { children: React.ReactNode }) => (
<div
Expand Down Expand Up @@ -87,13 +86,11 @@ const ScatterChartTooltip = ({
<div
className={tremorTwMerge(
// common
"flex items-center space-x-2 border-b",
"flex items-center space-x-2 border-b px-4 py-2",
// light
"border-tremor-border",
// dark
"dark:border-dark-tremor-border",
spacing.twoXl.paddingX,
spacing.sm.paddingY,
)}
>
<span
Expand Down Expand Up @@ -126,7 +123,7 @@ const ScatterChartTooltip = ({
</p>
</div>

<div className={tremorTwMerge(spacing.twoXl.paddingX, spacing.sm.paddingY, "space-y-1")}>
<div className={tremorTwMerge("px-4 py-2 space-y-1")}>
{payload.map(({ value, name }: { value: number; name: string }, idx: number) => {
const valueFormatterKey = Object.keys(axis).find((key) => axis[key] === name) ?? "";
const valueFormatterFn =
Expand Down
17 changes: 10 additions & 7 deletions src/components/chart-elements/common/ChartTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from "react";

import { BaseColors, getColorClassNames, spacing, tremorTwMerge, Color, ValueFormatter } from "lib";
import { colorPalette } from "lib/theme";
import {
BaseColors,
getColorClassNames,
tremorTwMerge,
Color,
ValueFormatter,
colorPalette,
} from "lib";

export const ChartTooltipFrame = ({ children }: { children: React.ReactNode }) => (
<div
Expand Down Expand Up @@ -89,11 +94,9 @@ const ChartTooltip = ({
<div
className={tremorTwMerge(
// light
"border-tremor-border border-b",
"border-tremor-border border-b px-4 py-2",
// dark
"dark:border-dark-tremor-border",
spacing.twoXl.paddingX,
spacing.sm.paddingY,
)}
>
<p
Expand All @@ -110,7 +113,7 @@ const ChartTooltip = ({
</p>
</div>

<div className={tremorTwMerge(spacing.twoXl.paddingX, spacing.sm.paddingY, "space-y-1")}>
<div className={tremorTwMerge("px-4 py-2 space-y-1")}>
{filteredPayload.map(({ value, name }: { value: number; name: string }, idx: number) => (
<ChartTooltipRow
key={`id-${idx}`}
Expand Down
9 changes: 3 additions & 6 deletions src/components/icon-elements/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import React from "react";
import Tooltip, { useTooltip } from "components/util-elements/Tooltip/Tooltip";
import {
Color,
Expand All @@ -7,11 +8,9 @@ import {
mergeRefs,
Size,
Sizes,
spacing,
tremorTwMerge,
colorPalette,
} from "lib";
import { colorPalette } from "lib/theme";
import React from "react";
import { badgeProportions, iconSizes } from "./styles";

const makeBadgeClassName = makeClassName("Badge");
Expand Down Expand Up @@ -62,9 +61,7 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>((props, ref) => {
<Icon
className={tremorTwMerge(
makeBadgeClassName("icon"),
"shrink-0",
spacing.twoXs.negativeMarginLeft,
spacing.xs.marginRight,
"shrink-0 -ml-1 mr-1.5",
iconSizes[size].height,
iconSizes[size].width,
)}
Expand Down
22 changes: 10 additions & 12 deletions src/components/icon-elements/Badge/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { spacing } from "lib/spacing";

export type BadgeProportionTypes = {
paddingX: string;
paddingY: string;
Expand All @@ -8,28 +6,28 @@ export type BadgeProportionTypes = {

export const badgeProportions: { [char: string]: BadgeProportionTypes } = {
xs: {
paddingX: spacing.sm.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-2",
paddingY: "py-0.5",
fontSize: "text-xs",
},
sm: {
paddingX: spacing.md.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-2.5",
paddingY: "py-0.5",
fontSize: "text-sm",
},
md: {
paddingX: spacing.lg.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-3",
paddingY: "py-0.5",
fontSize: "text-md",
},
lg: {
paddingX: spacing.xl.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-3.5",
paddingY: "py-0.5",
fontSize: "text-lg",
},
xl: {
paddingX: spacing.twoXl.paddingX,
paddingY: spacing.twoXs.paddingY,
paddingX: "px-4",
paddingY: "py-1",
fontSize: "text-xl",
},
};
Expand Down
7 changes: 2 additions & 5 deletions src/components/icon-elements/BadgeDelta/BadgeDelta.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import React from "react";
import Tooltip, { useTooltip } from "components/util-elements/Tooltip/Tooltip";
import {
DeltaType,
Expand All @@ -8,10 +9,8 @@ import {
mergeRefs,
Size,
Sizes,
spacing,
tremorTwMerge,
} from "lib";
import React from "react";
import {
badgeProportionsIconOnly,
badgeProportionsWithText,
Expand Down Expand Up @@ -67,9 +66,7 @@ const BadgeDelta = React.forwardRef<HTMLSpanElement, BadgeDeltaProps>((props, re
className={tremorTwMerge(
makeBadgeDeltaClassName("icon"),
"shrink-0",
children
? tremorTwMerge(spacing.twoXs.negativeMarginLeft, spacing.xs.marginRight)
: iconSizes[size].height,
children ? tremorTwMerge("-ml-1 mr-1.5") : iconSizes[size].height,
iconSizes[size].width,
)}
/>
Expand Down
43 changes: 21 additions & 22 deletions src/components/icon-elements/BadgeDelta/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseColors, DeltaTypes, getColorClassNames, spacing } from "lib";
import { BaseColors, DeltaTypes, getColorClassNames, colorPalette } from "lib";

import {
ArrowDownIcon,
Expand All @@ -7,7 +7,6 @@ import {
ArrowUpIcon,
ArrowUpRightIcon,
} from "assets";
import { colorPalette } from "lib/theme";

export type BadgeProportionTypes = {
paddingX: string;
Expand All @@ -19,28 +18,28 @@ export const badgeProportionsIconOnly: {
[char: string]: BadgeProportionTypes;
} = {
xs: {
paddingX: spacing.sm.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-2",
paddingY: "py-0.5",
fontSize: "text-xs",
},
sm: {
paddingX: spacing.md.paddingX,
paddingY: spacing.twoXs.paddingY,
paddingX: "px-2.5",
paddingY: "py-1",
fontSize: "text-sm",
},
md: {
paddingX: spacing.lg.paddingX,
paddingY: spacing.xs.paddingY,
paddingX: "px-3",
paddingY: "py-1.5",
fontSize: "text-md",
},
lg: {
paddingX: spacing.xl.paddingX,
paddingY: spacing.xs.paddingY,
paddingX: "px-3.5",
paddingY: "py-1.5",
fontSize: "text-lg",
},
xl: {
paddingX: spacing.xl.paddingX,
paddingY: spacing.xs.paddingY,
paddingX: "px-3.5",
paddingY: "py-1.5",
fontSize: "text-xl",
},
};
Expand All @@ -49,28 +48,28 @@ export const badgeProportionsWithText: {
[char: string]: BadgeProportionTypes;
} = {
xs: {
paddingX: spacing.sm.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-2",
paddingY: "py-0.5",
fontSize: "text-xs",
},
sm: {
paddingX: spacing.md.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-2.5",
paddingY: "py-0.5",
fontSize: "text-sm",
},
md: {
paddingX: spacing.lg.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-3",
paddingY: "py-0.5",
fontSize: "text-md",
},
lg: {
paddingX: spacing.xl.paddingX,
paddingY: spacing.threeXs.paddingY,
paddingX: "px-3.5",
paddingY: "py-0.5",
fontSize: "text-lg",
},
xl: {
paddingX: spacing.twoXl.paddingX,
paddingY: spacing.twoXs.paddingY,
paddingX: "px-4",
paddingY: "py-1",
fontSize: "text-xl",
},
};
Expand Down
25 changes: 11 additions & 14 deletions src/components/icon-elements/Icon/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { getColorClassNames, spacing, tremorTwMerge } from "lib";

import { colorPalette } from "lib/theme";
import { Color, IconVariant } from "../../../lib/inputTypes";
import { getColorClassNames, tremorTwMerge, colorPalette, Color, IconVariant } from "lib";

export type WrapperProportionTypes = {
paddingX: string;
Expand All @@ -10,24 +7,24 @@ export type WrapperProportionTypes = {

export const wrapperProportions: { [size: string]: WrapperProportionTypes } = {
xs: {
paddingX: spacing.xs.paddingX,
paddingY: spacing.xs.paddingY,
paddingX: "px-1.5",
paddingY: "py-1.5",
},
sm: {
paddingX: spacing.xs.paddingX,
paddingY: spacing.xs.paddingY,
paddingX: "px-1.5",
paddingY: "py-1.5",
},
md: {
paddingX: spacing.sm.paddingX,
paddingY: spacing.sm.paddingY,
paddingX: "px-2",
paddingY: "py-2",
},
lg: {
paddingX: spacing.sm.paddingX,
paddingY: spacing.sm.paddingY,
paddingX: "px-2",
paddingY: "py-2",
},
xl: {
paddingX: spacing.md.paddingX,
paddingY: spacing.md.paddingY,
paddingX: "px-2.5",
paddingY: "py-2.5",
},
};

Expand Down
11 changes: 5 additions & 6 deletions src/components/input-elements/BaseInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";
import React, { ReactNode, useCallback, useRef, useState } from "react";
import { ExclamationFilledIcon, EyeIcon, EyeOffIcon } from "assets";
import { getSelectButtonColors, hasValue } from "components/input-elements/selectUtils";
import { mergeRefs, spacing, tremorTwMerge } from "lib";
import React, { ReactNode, useCallback, useRef, useState } from "react";
import { mergeRefs, tremorTwMerge } from "lib";

export interface BaseInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
type?: "text" | "password" | "email" | "url" | "number";
Expand Down Expand Up @@ -117,15 +117,14 @@ const BaseInput = React.forwardRef<HTMLInputElement, BaseInputProps>((props, ref
className={tremorTwMerge(
makeInputClassName("input"),
// common
"w-full focus:outline-none focus:ring-0 border-none bg-transparent text-tremor-default rounded-tremor-default transition duration-100",
"w-full focus:outline-none focus:ring-0 border-none bg-transparent text-tremor-default rounded-tremor-default transition duration-100 py-2",
// light
"text-tremor-content-emphasis",
// dark
"dark:text-dark-tremor-content-emphasis",
"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",
Icon ? spacing.sm.paddingLeft : spacing.lg.paddingLeft,
error ? spacing.lg.paddingRight : spacing.twoXl.paddingRight,
spacing.sm.paddingY,
Icon ? "pl-2" : "pl-3",
error ? "pr-3" : "pr-4",
disabled
? "placeholder:text-tremor-content-subtle dark:placeholder:text-dark-tremor-content-subtle"
: "placeholder:text-tremor-content dark:placeholder:text-dark-tremor-content",
Expand Down
7 changes: 3 additions & 4 deletions src/components/input-elements/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use client";
import Tooltip, { useTooltip } from "components/util-elements/Tooltip/Tooltip";
import { tremorTwMerge } from "lib";
import React from "react";
import { Transition } from "react-transition-group";

import { HorizontalPositions, makeClassName, mergeRefs, Sizes, spacing } from "lib";
import { HorizontalPositions, makeClassName, mergeRefs, Sizes, tremorTwMerge } from "lib";

import { LoadingSpinner } from "assets";
import { ButtonVariant, Color, HorizontalPosition, Size } from "../../../lib";
Expand Down Expand Up @@ -34,8 +33,8 @@ export const ButtonIconOrSpinner = ({
const margin = !needMargin
? ""
: iconPosition === HorizontalPositions.Left
? tremorTwMerge(spacing.twoXs.negativeMarginLeft, spacing.xs.marginRight)
: tremorTwMerge(spacing.twoXs.negativeMarginRight, spacing.xs.marginLeft);
? tremorTwMerge("-ml-1", "mr-1.5")
: tremorTwMerge("-mr-1", "ml-1.5");

const defaultSpinnerSize = tremorTwMerge("w-0 h-0");
const spinnerSize: { [key: string]: any } = {
Expand Down
Loading
Loading