Skip to content

Commit

Permalink
Refactor: update import statements to use absolute paths
Browse files Browse the repository at this point in the history
- Replace '@' alias with full package imports throughout the project
- Remove module-resolver plugin from Babel config
- Remove path aliases from tsconfig.json

This change ensures better compatibility when the package is consumed by external projects.
  • Loading branch information
Graeme Houston committed Aug 27, 2024
1 parent 91fc3bb commit 6c15d23
Show file tree
Hide file tree
Showing 28 changed files with 89 additions and 187 deletions.
14 changes: 1 addition & 13 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,5 @@ module.exports = {
"@babel/preset-react",
"@babel/preset-typescript",
],
plugins: [
"@babel/plugin-proposal-export-namespace-from",
"react-native-web",
[
"module-resolver",
{
root: ["./lib"],
alias: {
"@": "./lib",
},
},
],
],
plugins: ["@babel/plugin-proposal-export-namespace-from", "react-native-web"],
};
8 changes: 4 additions & 4 deletions lib/components/atoms/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useTheme } from "@/context/ThemeContext";
import { Variant } from "@/types/theme";
import { useResponsiveScale } from "@/utils/responsiveScaling";
import { createVariantSystem } from "@/utils/variant";
import React from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { Variant } from "../../../types/theme";
import { useResponsiveScale } from "../../../utils/responsiveScaling";
import { createVariantSystem } from "../../../utils/variant";

type ButtonProps = {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/components/atoms/LoadingIndicator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from "@/context/ThemeContext";
import React from "react";
import { ActivityIndicator, StyleSheet, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";

type LoadingIndicatorProps = {
// Define your props here
Expand Down
6 changes: 3 additions & 3 deletions lib/components/atoms/ProgressBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useTheme } from "@/context/ThemeContext";
import { Size, ThemeObject, Variant } from "@/types/theme";
import { createVariantSystem } from "@/utils/variant";
import React from "react";
import { StyleSheet, View, ViewStyle } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { Size, ThemeObject, Variant } from "../../../types/theme";
import { createVariantSystem } from "../../../utils/variant";

export type ProgressBarProps = {
percentage: number;
Expand Down
4 changes: 2 additions & 2 deletions lib/components/atoms/Text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useTheme } from "@/context/ThemeContext";
import { createResponsiveStyle } from "@/utils/responsiveHelper";
import React from "react";
import {
Text as RNText,
TextProps as RNTextProps,
StyleSheet,
TextStyle,
} from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { createResponsiveStyle } from "../../../utils/responsiveHelper";

type TextVariant =
| "eyebrow"
Expand Down
4 changes: 2 additions & 2 deletions lib/components/atoms/Tile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useSectionContext } from "@/components/organisms/Section";
import { useTheme } from "@/context/ThemeContext";
import Color from "color";
import React from "react";
import { StyleSheet, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { useSectionContext } from "../../organisms/Section";
import LoadingIndicator from "../LoadingIndicator";

type TileProps = {
Expand Down
23 changes: 12 additions & 11 deletions lib/components/atoms/TileContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import {
BadgeTile,
BannerTile,
ContentTile,
PointsTile,
RewardCategoryTile,
RewardTile,
TierTile,
} from "@/components/organisms";
import {
BadgeTileConfig,
BannerTileConfig,
Expand All @@ -17,8 +8,18 @@ import {
TierTileConfig,
Tile,
TileType,
} from "@/types/tile";
import { useResponsiveScale } from "@/utils/responsiveScaling";
} from "../../../types/tile";
import { useResponsiveScale } from "../../../utils/responsiveScaling";
import {
BadgeTile,
BannerTile,
ContentTile,
PointsTile,
RewardCategoryTile,
RewardTile,
TierTile,
} from "../../organisms";

import React from "react";
import { StyleSheet, View } from "react-native";

Expand Down
2 changes: 2 additions & 0 deletions lib/components/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Image from "./Image";
import LoadingIndicator from "./LoadingIndicator";
import ProgressBar from "./ProgressBar";
import Text from "./Text";
import Tile from "./Tile";
import TileContainer from "./TileContainer";

export {
Expand All @@ -13,5 +14,6 @@ export {
LoadingIndicator,
ProgressBar,
Text,
Tile,
TileContainer,
};
12 changes: 6 additions & 6 deletions lib/components/molecules/Carousel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import { Icon } from "@/components/atoms";
import { SectionHeader } from "@/components/molecules";
import { BannerTile } from "@/components/organisms/";
import { useTheme } from "@/context/ThemeContext";
import { Section } from "@/types/section";
import { BannerTileConfig, Tile, TileType } from "@/types/tile";
import React, { useRef, useState } from "react";
import {
NativeScrollEvent,
Expand All @@ -13,6 +7,12 @@ import {
TouchableOpacity,
View,
} from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { Section } from "../../../types/section";
import { BannerTileConfig, Tile, TileType } from "../../../types/tile";
import { Icon } from "../../atoms";
import { SectionHeader } from "../../molecules";
import { BannerTile } from "../../organisms";

type CarouselProps = {
section: Section;
Expand Down
8 changes: 4 additions & 4 deletions lib/components/molecules/Grid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TileContainer } from "@/components/atoms";
import { Section as SectionData } from "@/types/section";
import { Tile, TileHeight, TileType } from "@/types/tile";
import { useResponsiveScale } from "@/utils/responsiveScaling";
import React from "react";
import { StyleSheet, useWindowDimensions, View } from "react-native";
import { Section as SectionData } from "../../../types/section";
import { Tile, TileHeight, TileType } from "../../../types/tile";
import { useResponsiveScale } from "../../../utils/responsiveScaling";
import { TileContainer } from "../../atoms";
import SectionHeader from "../SectionHeader";

type GridProps = {
Expand Down
6 changes: 3 additions & 3 deletions lib/components/molecules/ProgressIndicator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Icon, ProgressBar } from "@/components/atoms";
import { useTheme } from "@/context/ThemeContext";
import { Size, Variant } from "@/types/theme";
import React from "react";
import { StyleSheet, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { Size, Variant } from "../../../types/theme";
import { Icon, ProgressBar } from "../../atoms";

export type ProgressIndicatorProps = {
currentPoints: number;
Expand Down
2 changes: 1 addition & 1 deletion lib/components/molecules/SectionHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Text } from "@/components/atoms";
import React from "react";
import { StyleSheet, View } from "react-native";
import { Text } from "../../atoms";

type SectionHeaderProps = {
title?: string;
Expand Down
4 changes: 2 additions & 2 deletions lib/components/molecules/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Carousel from "./Carousel";
import Grid from "./Grid";
import ProgressIndicator from "./ProgressIndicator";
import SectionHeader from "./SectionHeader";
export { Carousel, ProgressIndicator, SectionHeader , Grid};
import Grid from './Grid';
export { Carousel, Grid, ProgressIndicator, SectionHeader };
10 changes: 5 additions & 5 deletions lib/components/organisms/BadgeTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Icon, Text } from "@/components/atoms";
import Tile from "@/components/atoms/Tile";
import { useSectionContext } from "@/components/organisms/Section";
import { BadgeTileConfig } from "@/types/tile";
import { createResponsiveStyle } from "@/utils/responsiveHelper";
import { BadgeTileConfig } from "../../../types/tile";
import { createResponsiveStyle } from "../../../utils/responsiveHelper";
import { Icon, Text, Tile } from "../../atoms";
import { useSectionContext } from "../Section";

import React from "react";
import { Image, StyleSheet, View } from "react-native";

Expand Down
6 changes: 3 additions & 3 deletions lib/components/organisms/BannerTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, Text } from "@/components/atoms";
import { useTheme } from "@/context/ThemeContext";
import { BannerTileConfig } from "@/types/tile";
import React from "react";
import { Image, Linking, StyleSheet, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { BannerTileConfig } from "../../../types/tile";
import { Button, Text } from "../../atoms";

type BannerTileProps = {
configuration: BannerTileConfig;
Expand Down
10 changes: 5 additions & 5 deletions lib/components/organisms/ContentTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Text } from "@/components/atoms";
import Tile from "@/components/atoms/Tile";
import { useSectionContext } from "@/components/organisms/Section";
import { ContentTileConfig } from "@/types/tile";
import { createResponsiveStyle } from "@/utils/responsiveHelper";
import React from "react";
import { Image, StyleSheet, View } from "react-native";
import { ContentTileConfig } from "../../../types/tile";
import { createResponsiveStyle } from "../../../utils/responsiveHelper";
import { Text, Tile } from "../../atoms";

import { useSectionContext } from "../Section";
type ContentTileProps = {
configuration: ContentTileConfig;
};
Expand Down
7 changes: 3 additions & 4 deletions lib/components/organisms/PointsTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Text } from "@/components/atoms";
import Tile from "@/components/atoms/Tile";
import { useTheme } from "@/context/ThemeContext";
import { PointsTileConfig } from "@/types/tile";
import React from "react";
import { Image, StyleSheet, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { PointsTileConfig } from "../../../types/tile";
import { Text, Tile } from "../../atoms";
import { useSectionContext } from "../Section";

type PointsTileProps = {
Expand Down
5 changes: 2 additions & 3 deletions lib/components/organisms/RewardCategoryTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Tile from "@/components/atoms/Tile";
import { useTheme } from "@/context/ThemeContext";
import { RewardCategoryTileConfig } from "@/types/tile";
import React from "react";
import { Image, StyleSheet, Text, View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { RewardCategoryTileConfig } from "../../../types/tile";

type RewardCategoryTileProps = {
configuration: RewardCategoryTileConfig;
Expand Down
8 changes: 4 additions & 4 deletions lib/components/organisms/RewardTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { createContext, useContext } from "react";
import { RewardTileConfig } from "../../../types/tile";
import {
Button as ButtonAtom,
Image as ImageAtom,
Text,
} from "@/components/atoms";
import Tile from "@/components/atoms/Tile";
import { RewardTileConfig } from "@/types/tile";
import React, { createContext, useContext } from "react";
Tile,
} from "../../atoms";

type RewardTileContextType = {
configuration: RewardTileConfig;
Expand Down
11 changes: 6 additions & 5 deletions lib/components/organisms/Section/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Icon } from "@/components/atoms";
import { Carousel, Grid } from "@/components/molecules";
import { useSDK } from "@/context/SDKContext";
import { useTheme } from "@/context/ThemeContext";
import { Section as SectionData, SectionType } from "@/types/section";
import { useSDK } from "../../../context/SDKContext";
import { useTheme } from "../../../context/ThemeContext";
import { Section as SectionData, SectionType } from "../../../types/section";
import { Icon } from "../../atoms";
import { Carousel, Grid } from "../../molecules";

import React, { createContext, useContext, useEffect, useState } from "react";
import { StyleSheet, Text, View } from "react-native";

Expand Down
17 changes: 6 additions & 11 deletions lib/components/organisms/TierTile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
// @ts-nocheck
import { Text } from "@/components/atoms";
import Tile from "@/components/atoms/Tile";
import { ProgressIndicator } from "@/components/molecules";
import { useSectionContext } from "@/components/organisms/Section";
import { useTheme } from "@/context/ThemeContext";
import { TierTileConfig, TierTileType } from "@/types/tile";
import { useResponsiveScale } from "@/utils/responsiveScaling";
// TODO: Fix this file
import React from "react";
import { View } from "react-native";
import { useTheme } from "../../../context/ThemeContext";
import { TierTileConfig, TierTileType } from "../../../types/tile";
import { useResponsiveScale } from "../../../utils/responsiveScaling";
import { Text, Tile } from "../../atoms";
import { ProgressIndicator } from "../../molecules";

type TierTileProps = {
configuration: TierTileConfig;
};

const TierTile: React.FC<TierTileProps> = ({ configuration }) => {
const { ms, ps } = useResponsiveScale();
const { loading } = useSectionContext();
const { theme } = useTheme();

if (!configuration?.tier) return null;

const renderTierTileContent = () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/context/SDKContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Section } from "@/types/section";
import { Tile } from "@/types/tile";
import React, { createContext, ReactNode, useContext } from "react";
import { Section } from "../types/section";
import { Tile } from "../types/tile";

type SDKConfig = {
apiKey: string;
Expand Down
12 changes: 6 additions & 6 deletions lib/context/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { defaultTheme, sizes } from "@/utils/styling";
import {
getDerivedColor,
getDerivedColorPercentages,
getReadableTextColor,
} from "@/utils/themeHelpers";
import React, { createContext, useContext, useEffect, useState } from "react";
import {
BaseThemeObject,
ThemeContextType,
ThemeObject,
ThemeProviderProps,
} from "../types/theme";
import { defaultTheme } from "../utils/styling";
import {
getDerivedColor,
getDerivedColorPercentages,
getReadableTextColor,
} from "../utils/themeHelpers";

const ThemeContext = createContext<ThemeContextType | undefined>(undefined);

Expand Down
4 changes: 2 additions & 2 deletions lib/types/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sizes } from "@/utils/styling";
import { DerivedColors } from "@/utils/themeHelpers";
import { ReactNode } from "react";
import { sizes } from "../utils/styling";
import { DerivedColors } from "../utils/themeHelpers";

export type BaseThemeObject = {
accent: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/styling.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseThemeObject } from "@/types/theme";
import { BaseThemeObject } from "../types/theme";

export const sizes = {
borderRadius: 15,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@types/react-dom": "^18.2.7",
"@types/react-native": "^0.72.2",
"babel-loader": "^9.1.3",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-react-native-web": "^0.19.9",
"chromatic": "^11.7.1",
"concurrently": "^8.2.2",
Expand Down
6 changes: 1 addition & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-native",
"baseUrl": ".",
"paths": {
"@/*": ["lib/*"]
}
"jsx": "react-native"
},
"include": ["lib"]
}
Loading

0 comments on commit 6c15d23

Please sign in to comment.