Skip to content

Commit

Permalink
feat(nft-launchpad): Add Collection Creation form front (#1477)
Browse files Browse the repository at this point in the history
Co-authored-by: n0izn0iz <n0izn0iz@users.noreply.github.com>
Co-authored-by: Yo HA <tronghieu.ha@gmail.com>
  • Loading branch information
3 people authored Feb 22, 2025
1 parent eaa00f6 commit c18215d
Show file tree
Hide file tree
Showing 46 changed files with 4,315 additions and 345 deletions.
3 changes: 3 additions & 0 deletions assets/icons/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"graphql-request": "^5",
"html-to-draftjs": "^1.5.0",
"immutable": "^4.0.0",
"keccak256": "^1.0.6",
"kubernetes-models": "^4.3.1",
"leaflet": "^1.9.4",
"leaflet.markercluster": "^1.5.3",
Expand Down
78 changes: 78 additions & 0 deletions packages/components/FilePreview/SelectedFilesPreview/ItemView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { FC } from "react";
import { TouchableOpacity, Image, StyleProp, ViewStyle } from "react-native";

import { BrandText } from "../../BrandText";
import { PrimaryBox } from "../../boxes/PrimaryBox";

import { neutral77, secondaryColor } from "@/utils/style/colors";
import { fontSemibold11, fontSemibold13 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";

export const itemSize = 120;
export const ItemView: FC<{
label: string;
subLabel?: string;
uri: string;
onPress: () => void;
style?: StyleProp<ViewStyle>;
}> = ({ label, subLabel, uri, onPress, style }) => {
return (
<TouchableOpacity
style={[
{
height: itemSize,
width: itemSize,
justifyContent: "flex-end",
alignItems: "center",
marginHorizontal: layout.spacing_x1,
},
style,
]}
onPress={onPress}
>
<PrimaryBox
style={{
height: itemSize,
width: itemSize,
}}
>
<Image
source={{ uri }}
style={{
height: itemSize - 2,
width: itemSize - 2,
borderRadius: 8,
}}
/>
</PrimaryBox>

<PrimaryBox
style={{
paddingHorizontal: layout.spacing_x1,
paddingVertical: layout.spacing_x0_5,
width: itemSize - 10,
bottom: -20,
alignItems: "center",
justifyContent: "center",
position: "absolute",
}}
>
<BrandText
style={[fontSemibold13, { color: secondaryColor }]}
numberOfLines={1}
>
{label}
</BrandText>
{subLabel && (
<BrandText
style={[fontSemibold11, { color: neutral77 }]}
numberOfLines={1}
ellipsizeMode="middle"
>
{subLabel}
</BrandText>
)}
</PrimaryBox>
</TouchableOpacity>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { FC } from "react";
import { View } from "react-native";

import { itemSize, ItemView } from "./ItemView";
import { BrandText } from "../../BrandText";
import { PrimaryBox } from "../../boxes/PrimaryBox";

import { DeleteButton } from "@/components/FilePreview/DeleteButton";
import { GridList } from "@/components/layout/GridList";
import { neutral33, neutral55 } from "@/utils/style/colors";
import { fontSemibold20 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";
import { LocalFileData } from "@/utils/types/files";

export const SelectedFilesPreview: FC<{
files: LocalFileData[];
onPressItem: (file: LocalFileData, itemIndex: number) => void;
onPressDeleteItem: (itemIndex: number) => void;
}> = ({ files, onPressItem, onPressDeleteItem }) => {
return (
<View
style={{
justifyContent: "flex-end",
height: "100%",
}}
>
{files.length ? (
<GridList<LocalFileData>
data={files}
keyExtractor={(item) => item.url}
renderItem={({ item, index }, elemWidth) => (
<View
style={{
height: itemSize + 6, // +6 to show DeleteButton
justifyContent: "flex-end",
}}
>
<DeleteButton
onPress={() => onPressDeleteItem(index)}
style={{ top: 0, right: 0 }}
/>
<ItemView
uri={URL.createObjectURL(item.file)}
label={`#${index + 1}`}
subLabel={item.file.name}
onPress={() => {
onPressItem(item, index);
}}
style={{ width: elemWidth }}
/>
</View>
)}
minElemWidth={itemSize}
gap={layout.spacing_x2_5}
noFixedHeight
/>
) : (
<PrimaryBox
style={{
height: 267,
width: "100%",
justifyContent: "center",
alignItems: "center",
borderColor: neutral33,
}}
>
<BrandText style={[fontSemibold20, { color: neutral55 }]}>
Selected files preview
</BrandText>
</PrimaryBox>
)}
</View>
);
};
127 changes: 127 additions & 0 deletions packages/components/NetworkSelector/NetworkSelectorWithLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { FC, useState } from "react";
import { StyleProp, View, ViewStyle } from "react-native";

import { NetworkSelectorMenu } from "./NetworkSelectorMenu";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
import { TertiaryBox } from "../boxes/TertiaryBox";
import { Label } from "../inputs/TextInputCustom";

import chevronDownSVG from "@/assets/icons/chevron-down.svg";
import chevronUpSVG from "@/assets/icons/chevron-up.svg";
import { NetworkIcon } from "@/components/NetworkIcon";
import { CustomPressable } from "@/components/buttons/CustomPressable";
import { SpacerRow } from "@/components/spacer";
import { useDropdowns } from "@/hooks/useDropdowns";
import { useSelectedNetworkInfo } from "@/hooks/useSelectedNetwork";
import { NetworkFeature, NetworkKind } from "@/networks";
import { neutral17, neutral77, secondaryColor } from "@/utils/style/colors";
import { fontSemibold14 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";

export const NetworkSelectorWithLabel: FC<{
label: string;
style?: StyleProp<ViewStyle>;
forceNetworkId?: string;
forceNetworkKind?: NetworkKind;
forceNetworkFeatures?: NetworkFeature[];
}> = ({
style,
forceNetworkId,
forceNetworkKind,
forceNetworkFeatures,
label,
}) => {
const [isDropdownOpen, setDropdownState, ref] = useDropdowns();
const [hovered, setHovered] = useState(false);
const selectedNetworkInfo = useSelectedNetworkInfo();

return (
<View
style={[
style,
{
width: "100%",
zIndex: 100,
},
]}
ref={ref}
>
<CustomPressable
onHoverIn={() => setHovered(true)}
onHoverOut={() => setHovered(false)}
onPress={() => setDropdownState(!isDropdownOpen)}
>
<Label style={{ marginBottom: layout.spacing_x1_5 }} hovered={hovered}>
{label}
</Label>

<TertiaryBox
style={[
{
width: "100%",
height: 40,
flexDirection: "row",
paddingHorizontal: 12,
backgroundColor: neutral17,
alignItems: "center",
},
hovered && { borderColor: secondaryColor },
]}
>
<View
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
flex: 1,
}}
>
<View
style={{
flexDirection: "row",
alignItems: "center",
}}
>
<NetworkIcon
networkId={selectedNetworkInfo?.id || ""}
size={16}
/>
<SpacerRow size={1} />

<BrandText
style={[
fontSemibold14,
{
marginRight: layout.spacing_x1,
color: selectedNetworkInfo ? secondaryColor : neutral77,
},
]}
>
{selectedNetworkInfo?.displayName}
</BrandText>
</View>

<SVG
source={isDropdownOpen ? chevronUpSVG : chevronDownSVG}
width={16}
height={16}
color={secondaryColor}
/>
</View>
</TertiaryBox>

{isDropdownOpen && (
<NetworkSelectorMenu
onSelect={() => {}}
optionsMenuwidth={416}
style={{ width: "100%", marginTop: layout.spacing_x0_75 }}
forceNetworkId={forceNetworkId}
forceNetworkKind={forceNetworkKind}
forceNetworkFeatures={forceNetworkFeatures}
/>
)}
</CustomPressable>
</View>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
useRef,
useState,
} from "react";
import { View } from "react-native";
import { StyleSheet, View } from "react-native";

import {
FileUploaderSmallHandle,
Expand Down Expand Up @@ -56,6 +56,8 @@ export const FileUploaderSmall = forwardRef<
const hiddenFileInputRef = useRef<HTMLInputElement>(null);
const [hovered, setHovered] = useState(false);
const [addedFiles, setAddedFiles] = useState<LocalFileData[]>([]);
const flatBoxStyle = StyleSheet.flatten(boxStyle);
const minHeight = flatBoxStyle.minHeight || 80;

useImperativeHandle(forwardRef, () => ({
resetFiles: () => {
Expand Down Expand Up @@ -163,41 +165,47 @@ export const FileUploaderSmall = forwardRef<
style={[
{
width: "100%",
minHeight: 80,
minHeight,
flex: 1,
paddingHorizontal: layout.spacing_x1_5,
alignItems: "center",
flexDirection: "row",
justifyContent: "center",
borderRadius: 12,
borderWidth: 1,
},
hovered && { borderColor: secondaryColor },
boxStyle,
]}
>
<View style={{ height: 32, width: 32 }}>
<SVGorImageIcon
icon={filesCount > 0 ? filesSVG : addSVG}
iconSize={32}
/>
</View>

<SpacerRow size={1} />
<BrandText
style={[fontSemibold14, { color: secondaryColor }]}
numberOfLines={1}
<View
style={{
alignItems: "center",
flexDirection: "row",
justifyContent: "center",
minHeight,
}}
>
{!multiple && filesCount && filesCount === addedFiles.length
? addedFiles[0].file.name
: !multiple && !filesCount
? "Select file"
: multiple && filesCount
? `${pluralize("file", filesCount, true)} selected`
: multiple && !filesCount
? "Select files"
: ""}
</BrandText>
<View style={{ height: 32, width: 32 }}>
<SVGorImageIcon
icon={filesCount > 0 ? filesSVG : addSVG}
iconSize={32}
/>
</View>

<SpacerRow size={1} />
<BrandText
style={[fontSemibold14, { color: secondaryColor }]}
numberOfLines={1}
>
{!multiple && filesCount && filesCount === addedFiles.length
? addedFiles[0].file.name
: !multiple && !filesCount
? "Select file"
: multiple && filesCount
? `${pluralize("file", filesCount, true)} selected`
: multiple && !filesCount
? "Select files"
: ""}
</BrandText>
</View>
</PrimaryBox>
)}

Expand Down
Loading

0 comments on commit c18215d

Please sign in to comment.