Skip to content

Commit

Permalink
Added more corrections from review
Browse files Browse the repository at this point in the history
  • Loading branch information
Mil4n0r committed Dec 13, 2024
1 parent f6e5b34 commit 0972270
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 33 deletions.
2 changes: 1 addition & 1 deletion apps/website/screens/theme-generator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const makeReadableSidenav = (token: string) =>
return i === 0 ? v.toUpperCase() : " " + v;
});

const isObject = (item: unknown) => item && typeof item === "object" && !Array.isArray(item);
const isObject = (item: unknown) => item != null && typeof item === "object" && !Array.isArray(item);

export const deepMerge = <T extends object>(target: T, ...sources: Partial<T>[]): T => {
if (!sources.length) return target;
Expand Down
3 changes: 1 addition & 2 deletions apps/website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"lib": ["dom", "dom.iterable", "esnext"],
"paths": {
"@/common/*": ["screens/common/*"]
},
"strict": true
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
Expand Down
4 changes: 1 addition & 3 deletions packages/lib/src/HalstackContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,4 @@ const HalstackProvider = ({ theme, advancedTheme, labels, children }: HalstackPr
);
};

export { HalstackProvider, HalstackLanguageContext };

export default HalstackContext;
export { HalstackContext as default, HalstackProvider, HalstackLanguageContext };
2 changes: 1 addition & 1 deletion packages/lib/src/accordion-group/AccordionGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Children, useCallback, useMemo, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import useTheme from "../useTheme";
import AccordionGroupAccordion from "./AccordionGroupAccordion";
Expand Down
4 changes: 1 addition & 3 deletions packages/lib/src/accordion-group/AccordionGroupContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { createContext } from "react";
import type { AccordionGroupAccordionContextProps } from "./types";

const AccordionGroupAccordionContext = createContext<AccordionGroupAccordionContextProps | null>(null);

export default AccordionGroupAccordionContext;
export default createContext<AccordionGroupAccordionContextProps | null>(null);
2 changes: 1 addition & 1 deletion packages/lib/src/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useId, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import useTheme from "../useTheme";
import AccordionPropsType from "./types";
Expand Down
8 changes: 3 additions & 5 deletions packages/lib/src/alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ const getIcon = (semantic: AlertPropsType["semantic"]) => {
}
};

const DxcAlert = ({
export default function DxcAlert({
closable = true,
message = [],
mode = "inline",
primaryAction,
secondaryAction,
semantic = "info",
title = "",
}: AlertPropsType) => {
}: AlertPropsType) {
const [messages, setMessages] = useState(Array.isArray(message) ? message : [message]);
const [currentIndex, setCurrentIndex] = useState(0);

Expand Down Expand Up @@ -245,6 +245,4 @@ const DxcAlert = ({
</ModalAlertWrapper>
</ThemeProvider>
);
};

export default DxcAlert;
}
2 changes: 1 addition & 1 deletion packages/lib/src/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled, { ThemeProvider } from "styled-components";
import { AdvancedTheme, spaces } from "../common/variables";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import useTheme from "../useTheme";
import type ButtonPropsType from "./types";
import DxcIcon from "../icon/Icon";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useRef, useId, forwardRef, KeyboardEvent } from "react";
import styled, { ThemeProvider } from "styled-components";
import { AdvancedTheme, spaces } from "../common/variables";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import useTheme from "../useTheme";
import useTranslatedLabels from "../useTranslatedLabels";
import CheckboxPropsType, { RefType } from "./types";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled, { ThemeProvider } from "styled-components";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import DxcIcon from "../icon/Icon";
import useTheme from "../useTheme";
Expand Down
4 changes: 1 addition & 3 deletions packages/lib/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ export type Margin = {
export type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
export type Side = keyof Margin;

const getMargin = (marginProp: Space | Margin | undefined, side: Side) =>
export const getMargin = (marginProp: Space | Margin | undefined, side: Side) =>
marginProp && typeof marginProp === "object"
? (marginProp[side] && spaces[marginProp[side]]) || "0px"
: marginProp && typeof marginProp === "string"
? spaces[marginProp]
: "0px";

export default getMargin;
2 changes: 1 addition & 1 deletion packages/lib/src/date-input/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import useTheme from "../useTheme";
import useTranslatedLabels from "../useTranslatedLabels";
import DateInputPropsType, { RefType } from "./types";
import DatePicker from "./DatePicker";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import DxcTextInput from "../text-input/TextInput";

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Popover from "@radix-ui/react-popover";
import { FocusEvent, KeyboardEvent, useCallback, useId, useLayoutEffect, useRef, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import DxcIcon from "../icon/Icon";
import useTheme from "../useTheme";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/resultset-table/ResultsetTable.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactNode, useEffect, useMemo, useRef, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import CoreTokens from "../common/coreTokens";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import DxcPaginator from "../paginator/Paginator";
import DxcTable, { DxcActionsCell } from "../table/Table";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Popover from "@radix-ui/react-popover";
import { ChangeEvent, FocusEvent, forwardRef, KeyboardEvent, MouseEvent, useCallback, useId, useMemo, useRef, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import { spaces } from "../common/variables";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import DxcIcon from "../icon/Icon";
import { Tooltip, TooltipWrapper } from "../tooltip/Tooltip";
import useTheme from "../useTheme";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeEvent, forwardRef, MouseEvent, useId, useMemo, useState } from "r
import styled, { ThemeProvider } from "styled-components";
import DxcTextInput from "../text-input/TextInput";
import { spaces } from "../common/variables";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import useTheme from "../useTheme";
import SliderPropsType, { RefType } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { forwardRef, KeyboardEvent, useId, useRef, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import { AdvancedTheme, spaces } from "../common/variables";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import useTheme from "../useTheme";
import useTranslatedLabels from "../useTranslatedLabels";
import SwitchPropsType, { RefType } from "./types";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled, { ThemeProvider } from "styled-components";
import { spaces, AdvancedTheme } from "../common/variables";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import DxcDropdown from "../dropdown/Dropdown";
import DxcFlex from "../flex/Flex";
import { DeepPartial, HalstackProvider } from "../HalstackContext";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import useTheme from "../useTheme";
import DxcIcon from "../icon/Icon";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/text-input/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "react";
import styled, { ThemeProvider } from "styled-components";
import DxcActionIcon from "../action-icon/ActionIcon";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import DxcFlex from "../flex/Flex";
import DxcIcon from "../icon/Icon";
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/textarea/Textarea.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeEvent, FocusEvent, forwardRef, useEffect, useId, useRef, useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import getMargin from "../common/utils";
import { getMargin } from "../common/utils";
import { spaces } from "../common/variables";
import useTheme from "../useTheme";
import useTranslatedLabels from "../useTranslatedLabels";
Expand Down
1 change: 0 additions & 1 deletion packages/typescript-config/react-library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"declaration": true,
"declarationMap": true,
"jsx": "react-jsx",
"strict": true,
"allowSyntheticDefaultImports": true
}
}

0 comments on commit 0972270

Please sign in to comment.