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: first replace of legacies boxes #897

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion packages/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ViewStyle,
} from "react-native";

import { useDropdowns } from "../hooks/useDropdowns";
import { useDropdowns } from "@/hooks/useDropdowns";

interface DropdownProps {
children:
Expand Down
22 changes: 12 additions & 10 deletions packages/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import React from "react";
import { View, TouchableOpacity } from "react-native";

import { BrandText } from "./BrandText";
import { LegacyPrimaryBox } from "./boxes/LegacyPrimaryBox";
import { useDropdowns } from "../hooks/useDropdowns";
import { neutral33 } from "../utils/style/colors";
import { fontSemibold13 } from "../utils/style/fonts";
import { layout } from "../utils/style/layout";
import { PrimaryBox } from "./boxes/PrimaryBox";

import { useDropdowns } from "@/hooks/useDropdowns";
import { neutral33 } from "@/utils/style/colors";
import { fontSemibold13 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";

const DEFAULT_WIDTH = 164;

Expand Down Expand Up @@ -34,11 +35,12 @@ export const Menu: React.FC<MenuProps> = ({
</TouchableOpacity>
{isDropdownOpen && (
<View ref={dropdownRef} collapsable={false}>
<LegacyPrimaryBox
width={width}
style={{ position: "absolute", right: 0, bottom: -20 }}
mainContainerStyle={{
<PrimaryBox
style={{
position: "absolute",
right: 0,
bottom: -20,
width,
paddingHorizontal: layout.spacing_x1_5,
}}
>
Expand Down Expand Up @@ -66,7 +68,7 @@ export const Menu: React.FC<MenuProps> = ({
</BrandText>
</TouchableOpacity>
))}
</LegacyPrimaryBox>
</PrimaryBox>
</View>
)}
</View>
Expand Down
24 changes: 13 additions & 11 deletions packages/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import { StyleSheet, TouchableOpacity, View } from "react-native";

import { BrandText } from "./BrandText";
import { SVG } from "./SVG";
import { LegacySecondaryBox } from "./boxes/LegacySecondaryBox";
import { LegacyTertiaryBox } from "./boxes/LegacyTertiaryBox";
import { SecondaryBox } from "./boxes/SecondaryBox";
import { SpacerRow } from "./spacer";
import chevronDownSVG from "../../assets/icons/chevron-down.svg";
import chevronLeftDoubleSVG from "../../assets/icons/chevron-left-double.svg";
import chevronLeftSVG from "../../assets/icons/chevron-left.svg";
import chevronRightDoubleSVG from "../../assets/icons/chevron-right-double.svg";
import chevronRightSVG from "../../assets/icons/chevron-right.svg";
import chevronUpSVG from "../../assets/icons/chevron-up.svg";
import { useDropdowns } from "../hooks/useDropdowns";

import { useDropdowns } from "@/hooks/useDropdowns";
import {
neutral33,
neutral77,
neutralA3,
secondaryColor,
} from "../utils/style/colors";
import { fontSemibold13, fontSemibold14 } from "../utils/style/fonts";
import { layout } from "../utils/style/layout";
} from "@/utils/style/colors";
import { fontSemibold13, fontSemibold14 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";

interface PaginationProps {
currentPage: number;
Expand Down Expand Up @@ -114,11 +115,12 @@ export const Pagination = ({
</LegacyTertiaryBox>

{isDropdownOpen && (
<LegacySecondaryBox
noBrokenCorners
width={80}
style={{ position: "absolute", top: 46, right: 0 }}
mainContainerStyle={{
<SecondaryBox
style={{
position: "absolute",
top: 46,
right: 0,
width: 80,
paddingHorizontal: layout.spacing_x1_5,
paddingTop: layout.spacing_x1_5,
backgroundColor: neutral33,
Expand Down Expand Up @@ -147,7 +149,7 @@ export const Pagination = ({
</BrandText>
</TouchableOpacity>
))}
</LegacySecondaryBox>
</SecondaryBox>
)}
</View>
</View>
Expand Down
3 changes: 2 additions & 1 deletion packages/components/boxes/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ViewProps,
} from "react-native";

import { useTheme } from "../../hooks/useTheme";
import { useTheme } from "@/hooks/useTheme";

// Be very careful while editing this, try to refrain from adding new props

Expand Down Expand Up @@ -53,6 +53,7 @@ export type BoxStyle = Pick<
| "top"
| "bottom"
| "flex"
| "zIndex"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zIndex should be passed to the outer component IMO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep i agree

> & { borderRadius?: number; backgroundColor?: string; borderColor?: string };

export type GradientParams = Omit<LinearGradientProps, keyof ViewProps>;
Expand Down
126 changes: 0 additions & 126 deletions packages/components/boxes/LegacySecondaryBox.tsx

This file was deleted.

39 changes: 14 additions & 25 deletions packages/components/buttons/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import React from "react";
import { StyleProp, TouchableOpacity, ViewStyle } from "react-native";
import { StyleProp, TouchableOpacity } from "react-native";
import { SvgProps } from "react-native-svg";

import { SVG } from "../SVG";
import { BoxStyle } from "../boxes/Box";
import { SecondaryBox } from "../boxes/SecondaryBox";

import {
borderRadiusButton,
ButtonsSize,
heightButton,
} from "../../utils/style/buttons";
import { primaryColor } from "../../utils/style/colors";
import { SVG } from "../SVG";
import { LegacySecondaryBox } from "../boxes/LegacySecondaryBox";
} from "@/utils/style/buttons";
import { primaryColor } from "@/utils/style/colors";

export const IconButton: React.FC<{
width?: number;
size: ButtonsSize;
onPress?: (() => Promise<void>) | (() => void);
squaresBackgroundColor?: string;
style?: StyleProp<ViewStyle>;
style?: StyleProp<BoxStyle>;
iconSVG: React.FC<SvgProps>;
disabled?: boolean;
fullWidth?: boolean;
iconSize?: number;
iconColor?: string;
backgroundColor?: string;
borderColor?: string;
squaresBorderColor?: string;
noBrokenCorners?: boolean;
}> = ({
// If no width, the buttons will fit the content including paddingHorizontal 20
Expand All @@ -33,49 +34,37 @@ export const IconButton: React.FC<{
onPress,
style,
iconSVG,
disabled = false,
fullWidth = false,
iconSize = 16,
iconColor = "black",
backgroundColor = primaryColor,
borderColor,
squaresBorderColor,
noBrokenCorners,
}) => {
const boxProps = {
style,
disabled,
width,
fullWidth,
noBrokenCorners,
};

return (
<TouchableOpacity
onPress={onPress}
style={{ width: fullWidth ? "100%" : width }}
>
<LegacySecondaryBox
height={heightButton(size)}
mainContainerStyle={[
<SecondaryBox
style={[
style,
borderColor ? { borderWidth: 1, borderColor } : {},
{
height: heightButton(size),
flexDirection: "row",
borderRadius: borderRadiusButton(size),
backgroundColor,
paddingHorizontal: 20,
},
borderColor ? { borderWidth: 1, borderColor } : {},
]}
squaresBorderColor={squaresBorderColor}
{...boxProps}
>
<SVG
source={iconSVG}
width={iconSize}
height={iconSize}
color={iconColor}
/>
</LegacySecondaryBox>
</SecondaryBox>
</TouchableOpacity>
);
};
Loading
Loading